Class: Rattler::BackEnd::ParserGenerator::ApplyGenerator

Inherits:
ExprGenerator
  • Object
show all
Defined in:
lib/rattler/back_end/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

Methods included from Parsers

define

Constructor Details

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

Class Method Details

.nested(*args) ⇒ Object



67
68
69
# File 'lib/rattler/back_end/parser_generator/apply_generator.rb', line 67

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

.top_level(*args) ⇒ Object



76
77
78
# File 'lib/rattler/back_end/parser_generator/apply_generator.rb', line 76

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

Instance Method Details

#gen_assert(apply, scope = {}) ⇒ Object



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

def gen_assert(apply, scope={})
  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 = {}) ⇒ Object

:nodoc:



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

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

#gen_direct_action(apply, code, scope = {}) ⇒ Object



39
40
41
42
43
44
# File 'lib/rattler/back_end/parser_generator/apply_generator.rb', line 39

def gen_direct_action(apply, code, scope={})
  expr do
    gen_capture { gen_basic apply }
    @g << ' && (' << code.bind(scope, direct_action_args) << ')'
  end
end

#gen_disallow(apply, scope = {}) ⇒ Object



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

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

#gen_dispatch_action(apply, code, scope = {}) ⇒ Object



32
33
34
35
36
37
# File 'lib/rattler/back_end/parser_generator/apply_generator.rb', line 32

def gen_dispatch_action(apply, code, scope={})
  expr do
    gen_capture { gen_basic apply }
    @g << ' && ' << code.bind(scope, dispatch_action_args)
  end
end

#gen_intermediate_skip(apply, scope = {}) ⇒ Object



50
51
52
# File 'lib/rattler/back_end/parser_generator/apply_generator.rb', line 50

def gen_intermediate_skip(apply, scope={})
  gen_basic apply
end

#gen_skip(apply, scope = {}) ⇒ Object



46
47
48
# File 'lib/rattler/back_end/parser_generator/apply_generator.rb', line 46

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