lib/lrama/grammar/rule_builder.rb in lrama-0.6.11 vs lib/lrama/grammar/rule_builder.rb in lrama-0.7.0

- old
+ new

@@ -71,11 +71,11 @@ rhs.each_with_index do |token, i| if (inline_rule = @parameterizing_rule_resolver.find_inline(token)) inline_rule.rhs_list.each do |inline_rhs| rule_builder = RuleBuilder.new(@rule_counter, @midrule_action_counter, @parameterizing_rule_resolver, lhs_tag: lhs_tag) if token.is_a?(Lexer::Token::InstantiateRule) - resolve_inline_rhs(rule_builder, inline_rhs, i, Binding.new(inline_rule, token.args)) + resolve_inline_rhs(rule_builder, inline_rhs, i, Binding.new(inline_rule.parameters, token.args)) else resolve_inline_rhs(rule_builder, inline_rhs, i) end rule_builder.lhs = lhs rule_builder.line = line @@ -133,12 +133,12 @@ @replaced_rhs << token when Lrama::Lexer::Token::InstantiateRule parameterizing_rule = @parameterizing_rule_resolver.find_rule(token) raise "Unexpected token. #{token}" unless parameterizing_rule - bindings = Binding.new(parameterizing_rule, token.args) - lhs_s_value = lhs_s_value(token, bindings) + bindings = Binding.new(parameterizing_rule.parameters, token.args) + lhs_s_value = bindings.concatenated_args_str(token) if (created_lhs = @parameterizing_rule_resolver.created_lhs(lhs_s_value)) @replaced_rhs << created_lhs else lhs_token = Lrama::Lexer::Token::Ident.new(s_value: lhs_s_value, location: token.location) @replaced_rhs << lhs_token @@ -170,21 +170,9 @@ @rule_builders_for_derived_rules << rule_builder else raise "Unexpected token. #{token}" end end - end - - def lhs_s_value(token, bindings) - s_values = token.args.map do |arg| - resolved = bindings.resolve_symbol(arg) - if resolved.is_a?(Lexer::Token::InstantiateRule) - [resolved.s_value, resolved.args.map(&:s_value)] - else - resolved.s_value - end - end - "#{token.rule_name}_#{s_values.join('_')}" end def resolve_inline_rhs(rule_builder, inline_rhs, index, bindings = nil) rhs.each_with_index do |token, i| if index == i