Method: Treetop::Compiler::ParsingRule#generate_method_definition

Defined in:
lib/treetop/compiler/node_classes/parsing_rule.rb

#generate_method_definition(builder) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/treetop/compiler/node_classes/parsing_rule.rb', line 17

def generate_method_definition(builder)
  builder.reset_addresses
  expression_address = builder.next_address
  result_var = "r#{expression_address}"
  
  builder.method_declaration(method_name) do
    builder.assign 'start_index', 'index'
    generate_cache_lookup(builder)
    builder.newline
    parsing_expression.compile(expression_address, builder)
    builder.newline
    generate_cache_storage(builder, result_var)
    builder.newline          
    builder << result_var
  end
end