lib/lrama/grammar/parameterizing_rule/rhs.rb in lrama-0.6.8 vs lib/lrama/grammar/parameterizing_rule/rhs.rb in lrama-0.6.9

- old
+ new

@@ -7,9 +7,31 @@ def initialize @symbols = [] @user_code = nil @precedence_sym = nil end + + def resolve_user_code(bindings) + return unless user_code + + var_to_arg = {} + symbols.each do |sym| + resolved_sym = bindings.resolve_symbol(sym) + if resolved_sym != sym + var_to_arg[sym.s_value] = resolved_sym.s_value + end + end + + var_to_arg.each do |var, arg| + user_code.references.each do |ref| + if ref.name == var + ref.name = arg + end + end + end + + return user_code + end end end end end