Class: Rattler::Compiler::ParserGenerator::SemanticActionGenerator

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

Class Method Summary collapse

Instance Method Summary collapse

Methods included from SubGenerating

#gen_nested, #gen_top_level, #generate

Methods inherited from ExprGenerator

#gen_intermediate, #gen_intermediate_disallow, #initialize

Constructor Details

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

Class Method Details

.nested(*args) ⇒ Object



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

def SemanticActionGenerator.nested(*args)
  NestedSemanticActionGenerator.new(*args)
end

.top_level(*args) ⇒ Object



54
55
56
# File 'lib/rattler/compiler/parser_generator/semantic_action_generator.rb', line 54

def SemanticActionGenerator.top_level(*args)
  TopLevelSemanticActionGenerator.new(*args)
end

Instance Method Details

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



13
14
15
# File 'lib/rattler/compiler/parser_generator/semantic_action_generator.rb', line 13

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

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



9
10
11
# File 'lib/rattler/compiler/parser_generator/semantic_action_generator.rb', line 9

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

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



17
18
19
20
# File 'lib/rattler/compiler/parser_generator/semantic_action_generator.rb', line 17

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

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



30
31
32
# File 'lib/rattler/compiler/parser_generator/semantic_action_generator.rb', line 30

def gen_intermediate_assert(action, scope = ParserScope.empty)
  gen_nested action, :basic, scope
end

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



34
35
36
# File 'lib/rattler/compiler/parser_generator/semantic_action_generator.rb', line 34

def gen_intermediate_skip(action, scope = ParserScope.empty)
  gen_nested action, :basic, scope
end

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



26
27
28
# File 'lib/rattler/compiler/parser_generator/semantic_action_generator.rb', line 26

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

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



22
23
24
# File 'lib/rattler/compiler/parser_generator/semantic_action_generator.rb', line 22

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