Class: Antelope::Generator::Info
- Defined in:
- lib/antelope/generator/info.rb
Overview
Generates an output file, mainly for debugging. Included always as a generator for a grammar.
Constant Summary
Constants inherited from Base
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#generate ⇒ void
Actually performs the generation.
-
#initialize ⇒ Info
constructor
Defines singleton method for every mod that the grammar passed to the generator.
- #unused_symbols ⇒ Object
Methods inherited from Base
directive, directives, inherited, register_as, source_root, #template
Methods included from Base::Extra
Methods included from Base::Coerce
#coerce_directive_class, #coerce_directive_value, #coerce_nested_hash, #directives
Constructor Details
#initialize ⇒ Info
Defines singleton method for every mod that the grammar passed to the generator.
16 17 18 19 20 21 |
# File 'lib/antelope/generator/info.rb', line 16 def initialize(*) super mods.each do |k, v| define_singleton_method (k) { v } end end |
Instance Method Details
#generate ⇒ void
This method returns an undefined value.
Actually performs the generation. Uses the template in
output.erb, and generates the file <file>.output.
42 43 44 |
# File 'lib/antelope/generator/info.rb', line 42 def generate template "info", "#{file}.inf" end |
#unused_symbols ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/antelope/generator/info.rb', line 23 def unused_symbols @_unused_symbols ||= begin used = grammar.all_productions.map(&:items).flatten.uniq all = grammar.symbols.map do |s| if Symbol === s grammar.find_token(s) else s end end all - used - [grammar.find_token(:"$start")] end end |