Class: Rattler::Compiler::ParserGenerator::SequenceGenerator
- Inherits:
-
ExprGenerator
- Object
- ExprGenerator
- Rattler::Compiler::ParserGenerator::SequenceGenerator
- Includes:
- SequenceGenerating
- Defined in:
- lib/rattler/compiler/parser_generator/sequence_generator.rb
Direct Known Subclasses
Class Method Summary collapse
Instance Method Summary collapse
Methods included from SequenceGenerating
#gen_assert, #gen_disallow, #gen_skip, #gen_token
Methods included from SubGenerating
#gen_nested, #gen_top_level, #generate
Methods inherited from ExprGenerator
#gen_intermediate, #gen_intermediate_assert, #gen_intermediate_disallow, #gen_intermediate_skip, #gen_token, #initialize
Constructor Details
This class inherits a constructor from Rattler::Compiler::ParserGenerator::ExprGenerator
Class Method Details
.nested(*args) ⇒ Object
44 45 46 |
# File 'lib/rattler/compiler/parser_generator/sequence_generator.rb', line 44 def SequenceGenerator.nested(*args) NestedSequenceGenerator.new(*args) end |
.top_level(*args) ⇒ Object
53 54 55 |
# File 'lib/rattler/compiler/parser_generator/sequence_generator.rb', line 53 def SequenceGenerator.top_level(*args) TopLevelSequenceGenerator.new(*args) end |
Instance Method Details
#gen_basic(sequence, scope = ParserScope.empty) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/rattler/compiler/parser_generator/sequence_generator.rb', line 9 def gen_basic(sequence, scope = ParserScope.empty) with_backtracking do gen_children_capturing(sequence, scope.nest) do |last_child, scope| if sequence.capture_count == 1 and last_child.capturing? gen_nested last_child, :basic, scope else @g.suffix(' &&') { scope = gen_capturing last_child, scope } @g.newline << result_expr(scope) end end end end |