Class Methods
::
lib/racc/statetransitiontable.rb
View on GitHub
# File tmp/rubies/ruby-3.0.5/lib/racc/statetransitiontable.rb, line 269
def initialize(states)
@states = states
@grammar = states.grammar
end
No documentation available
Instance Methods
lib/racc/statetransitiontable.rb
View on GitHub
# File tmp/rubies/ruby-3.0.5/lib/racc/statetransitiontable.rb, line 299
def define_actions(c)
c.module_eval "def _reduce_none(vals, vstack) vals[0] end"
@grammar.each do |rule|
if rule.action.empty?
c.funcall(:alias_method, "_reduce_#{rule.ident}", :_reduce_none)
else
c.funcall(:define_method, "_racc_action_#{rule.ident}", &rule.action.proc)
c.module_eval(<<-End, __FILE__, __LINE__ + 1)
def _reduce_#{rule.ident}(vals, vstack)
_racc_action_#{rule.ident}(*vals)
end
End
end
end
end
No documentation available
#
lib/racc/statetransitiontable.rb
View on GitHub
# File tmp/rubies/ruby-3.0.5/lib/racc/statetransitiontable.rb, line 274
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
No documentation available