Skip to content

Commit

Permalink
Merge pull request ruby#381 from ydah/fix-user-defined-action
Browse files Browse the repository at this point in the history
Fix an issue in a user-defined parameterizing rule where the caller cannot access `$$` in the rule
  • Loading branch information
yui-knk authored Feb 28, 2024
2 parents d41440e + 4bc6930 commit 85b2fe2
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 75 deletions.
4 changes: 2 additions & 2 deletions lib/lrama/grammar/rule_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,12 @@ def process_rhs(parameterizing_rule_resolver)
@replaced_rhs << lhs_token
parameterizing_rule_resolver.created_lhs_list << lhs_token
parameterizing_rule.rhs_list.each do |r|
rule_builder = RuleBuilder.new(@rule_counter, @midrule_action_counter, i, lhs_tag: token.lhs_tag, skip_preprocess_references: true)
rule_builder = RuleBuilder.new(@rule_counter, @midrule_action_counter, lhs_tag: token.lhs_tag, skip_preprocess_references: true)
rule_builder.lhs = lhs_token
r.symbols.each { |sym| rule_builder.add_rhs(bindings.resolve_symbol(sym)) }
rule_builder.line = line
rule_builder.user_code = r.user_code
rule_builder.precedence_sym = r.precedence_sym
rule_builder.user_code = r.user_code
rule_builder.complete_input
rule_builder.setup_rules(parameterizing_rule_resolver)
@rule_builders_for_parameterizing_rules << rule_builder
Expand Down
2 changes: 1 addition & 1 deletion spec/lrama/integration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def generate_object(grammar_file_path, c_path, obj_path, command_args: [])
it "prints messages corresponding to rules" do
expected = <<~STR
(2, 3)
pair even odd: 2
pair even odd: 5
(1, 0)
pair odd even: 1
STR
Expand Down
Loading

0 comments on commit 85b2fe2

Please sign in to comment.