diff --git a/lib/lrama/grammar/rule_builder.rb b/lib/lrama/grammar/rule_builder.rb index 4730cc39..c17a4048 100644 --- a/lib/lrama/grammar/rule_builder.rb +++ b/lib/lrama/grammar/rule_builder.rb @@ -102,7 +102,7 @@ def process_rhs(parameterizing_resolver) when Lrama::Lexer::Token::Ident @replaced_rhs << token when Lrama::Lexer::Token::InstantiateRule - if parameterizing_resolver.defined?(token.s_value) + if parameterizing_resolver.defined?(token.rule_name) parameterizing = parameterizing_resolver.build_rules(token, @rule_counter, @lhs_tag, line) @parameterizing_rules = @parameterizing_rules + parameterizing.map(&:rules).flatten @replaced_rhs = @replaced_rhs + parameterizing.map(&:token).flatten.uniq diff --git a/lib/lrama/lexer/token/instantiate_rule.rb b/lib/lrama/lexer/token/instantiate_rule.rb index 90f7c5ec..9b703dd9 100644 --- a/lib/lrama/lexer/token/instantiate_rule.rb +++ b/lib/lrama/lexer/token/instantiate_rule.rb @@ -8,6 +8,10 @@ def initialize(s_value:, alias_name: nil, location: nil, args: []) super s_value: s_value, alias_name: alias_name, location: location @args = args end + + def rule_name + s_value + end end end end diff --git a/sig/lrama/lexer/token/instantiate_rule.rbs b/sig/lrama/lexer/token/instantiate_rule.rbs index edad8508..3a017dbf 100644 --- a/sig/lrama/lexer/token/instantiate_rule.rbs +++ b/sig/lrama/lexer/token/instantiate_rule.rbs @@ -5,6 +5,7 @@ module Lrama attr_accessor args: Array[Lexer::Token] def initialize: (s_value: String, ?alias_name: String, ?location: Location, ?args: Array[Lexer::Token]) -> void + def rule_name: () -> String end end end