Class: Racc::ParserClassGenerator

Inherits:
Object
  • Object
show all
Defined in:
lib/racc/statetransitiontable.rb

Instance Method Summary collapse

Constructor Details

#initialize(states) ⇒ ParserClassGenerator

Returns a new instance of ParserClassGenerator.



268
269
270
271
# File 'lib/racc/statetransitiontable.rb', line 268

def initialize(states)
  @states = states
  @grammar = states.grammar
end

Instance Method Details

#generateObject



273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
# File 'lib/racc/statetransitiontable.rb', line 273

def generate
  table = @states.state_transition_table
  c = Class.new(::Racc::Parser)
  c.const_set :Racc_arg, [table.action_table,
                          table.action_check,
                          table.action_default,
                          table.action_pointer,
                          table.goto_table,
                          table.goto_check,
                          table.goto_default,
                          table.goto_pointer,
                          table.nt_base,
                          table.reduce_table,
                          table.token_value_table,
                          table.shift_n,
                          table.reduce_n,
                          false]
  c.const_set :Racc_token_to_s_table, table.token_to_s_table
  c.const_set :Racc_debug_parser, true
  define_actions c
  c
end