Class: Rattler::Compiler::ParserGenerator::RuleGenerator

Inherits:
Object
  • Object
show all
Includes:
Parsers
Defined in:
lib/rattler/compiler/parser_generator/rule_generator.rb

Instance Method Summary collapse

Constructor Details

#initialize(g) ⇒ RuleGenerator

Returns a new instance of RuleGenerator.



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

def initialize(g)
  @g = g
  @expr_generator = NestedExprGenerator.new(@g)
end

Instance Method Details

#generate(rule, opts = {}) ⇒ Object



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

def generate(rule, opts={})
  (@g << "# @private").newline
  @g.block "def match_#{rule.name} #:nodoc:" do
    @g << "apply :match_#{rule.name}!"
  end.newline.newline
  gen_match_method rule
end