Class: Treetop::Compiler::SequenceElementAccessorModule
- Inherits:
-
Object
- Object
- Treetop::Compiler::SequenceElementAccessorModule
- Includes:
- InlineModuleMixin
- Defined in:
- lib/treetop/compiler/node_classes/sequence.rb
Instance Attribute Summary collapse
-
#sequence_elements ⇒ Object
readonly
Returns the value of attribute sequence_elements.
Attributes included from InlineModuleMixin
Instance Method Summary collapse
- #compile(index, builder, rule) ⇒ Object
-
#initialize(sequence_elements) ⇒ SequenceElementAccessorModule
constructor
A new instance of SequenceElementAccessorModule.
Constructor Details
#initialize(sequence_elements) ⇒ SequenceElementAccessorModule
Returns a new instance of SequenceElementAccessorModule.
49 50 51 |
# File 'lib/treetop/compiler/node_classes/sequence.rb', line 49 def initialize(sequence_elements) @sequence_elements = sequence_elements end |
Instance Attribute Details
#sequence_elements ⇒ Object (readonly)
Returns the value of attribute sequence_elements.
47 48 49 |
# File 'lib/treetop/compiler/node_classes/sequence.rb', line 47 def sequence_elements @sequence_elements end |
Instance Method Details
#compile(index, builder, rule) ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/treetop/compiler/node_classes/sequence.rb', line 53 def compile(index, builder, rule) super builder.module_declaration(module_name) do sequence_elements.each_with_index do |element, index| if element.label_name builder.method_declaration(element.label_name) do builder << "elements[#{index}]" end builder.newline unless index == sequence_elements.size - 1 end end end end |