Class: Rattler::Compiler::ParserGenerator::NodeActionGenerator

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

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ExprGenerator

#gen_intermediate, #gen_intermediate_assert, #gen_intermediate_disallow, #gen_intermediate_skip, #initialize

Constructor Details

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

Class Method Details

.nested(*args) ⇒ Object



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

def NodeActionGenerator.nested(*args)
  NestedNodeActionGenerator.new(*args)
end

.top_level(*args) ⇒ Object



45
46
47
# File 'lib/rattler/compiler/parser_generator/node_action_generator.rb', line 45

def NodeActionGenerator.top_level(*args)
  TopLevelNodeActionGenerator.new(*args)
end

Instance Method Details

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



12
13
14
# File 'lib/rattler/compiler/parser_generator/node_action_generator.rb', line 12

def gen_assert(action, scope = ParserScope.empty)
  expr { @g.suffix(' && true') { gen_basic action, scope } }
end

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

:nodoc:



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

def gen_basic(action, scope = ParserScope.empty)
  @g << action.bindable_code.bind(scope)
end

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



16
17
18
19
# File 'lib/rattler/compiler/parser_generator/node_action_generator.rb', line 16

def gen_disallow(action, scope = ParserScope.empty)
  @g << '!'
  gen_basic action, scope
end

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



25
26
27
# File 'lib/rattler/compiler/parser_generator/node_action_generator.rb', line 25

def gen_skip(action, scope = ParserScope.empty)
  expr { @g.suffix('; true') { gen_basic action, scope } }
end

#gen_token(action, scope = ParserScope.empty) ⇒ Object



21
22
23
# File 'lib/rattler/compiler/parser_generator/node_action_generator.rb', line 21

def gen_token(action, scope = ParserScope.empty)
  @g.suffix('.to_s') { gen_basic action, scope }
end