Class: Rattler::Compiler::ParserGenerator::ApplyGenerator

Inherits:
ExprGenerator
  • Object
show all
Defined in:
lib/rattler/compiler/parser_generator/apply_generator.rb

Direct Known Subclasses

NestedApplyGenerator, TopLevelApplyGenerator

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ExprGenerator

#gen_intermediate, #gen_intermediate_assert, #gen_intermediate_disallow, #gen_token, #initialize

Constructor Details

This class inherits a constructor from Rattler::Compiler::ParserGenerator::ExprGenerator

Class Method Details

.nested(*args) ⇒ Object



53
54
55
# File 'lib/rattler/compiler/parser_generator/apply_generator.rb', line 53

def ApplyGenerator.nested(*args)
  NestedApplyGenerator.new(*args)
end

.top_level(*args) ⇒ Object



62
63
64
# File 'lib/rattler/compiler/parser_generator/apply_generator.rb', line 62

def ApplyGenerator.top_level(*args)
  TopLevelApplyGenerator.new(*args)
end

Instance Method Details

#gen_assert(apply, scope = ParserScope.empty) ⇒ Object



12
13
14
15
16
17
18
19
20
# File 'lib/rattler/compiler/parser_generator/apply_generator.rb', line 12

def gen_assert(apply, scope = ParserScope.empty)
  expr :block do
    lookahead do
      @g.surround("#{result_name} = (", ')') { gen_bare_skip apply }
      @g.newline
    end
    @g << result_name
  end
end

#gen_basic(apply, scope = ParserScope.empty) ⇒ Object

:nodoc:



8
9
10
# File 'lib/rattler/compiler/parser_generator/apply_generator.rb', line 8

def gen_basic(apply, scope = ParserScope.empty)
  @g << "match(:#{apply.rule_name})"
end

#gen_disallow(apply, scope = ParserScope.empty) ⇒ Object



22
23
24
25
26
27
28
29
30
# File 'lib/rattler/compiler/parser_generator/apply_generator.rb', line 22

def gen_disallow(apply, scope = ParserScope.empty)
  expr :block do
    lookahead do
      @g.surround("#{result_name} = !", '') { gen_basic apply }
      @g.newline
    end
    @g << result_name
  end
end

#gen_intermediate_skip(apply, scope = ParserScope.empty) ⇒ Object



36
37
38
# File 'lib/rattler/compiler/parser_generator/apply_generator.rb', line 36

def gen_intermediate_skip(apply, scope = ParserScope.empty)
  gen_basic apply
end

#gen_skip(apply, scope = ParserScope.empty) ⇒ Object



32
33
34
# File 'lib/rattler/compiler/parser_generator/apply_generator.rb', line 32

def gen_skip(apply, scope = ParserScope.empty)
  expr { gen_bare_skip apply }
end