Skip to content

Commit

Permalink
Merge pull request #399 from ydah/fix-error-when-use-own-stack
Browse files Browse the repository at this point in the history
Fix an error for using parameterizing rules with own stack in semantic action
  • Loading branch information
yui-knk authored Apr 26, 2024
2 parents 3b1ade0 + 6e36867 commit 95ab3e9
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/lrama/grammar/rule_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ 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, lhs_tag: token.lhs_tag, skip_preprocess_references: true)
rule_builder = RuleBuilder.new(@rule_counter, @midrule_action_counter, lhs_tag: token.lhs_tag)
rule_builder.lhs = lhs_token
r.symbols.each { |sym| rule_builder.add_rhs(bindings.resolve_symbol(sym)) }
rule_builder.line = line
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ static int yyerror(YYLTYPE *loc, const char *str);
{
$$ = $1 + $2;
printf("(%d, %d)\n", $1, $2);
printf("(%d, %d)\n", $:1, $:2);
}
;

Expand Down
2 changes: 2 additions & 0 deletions spec/lrama/integration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,10 @@ def generate_object(grammar_file_path, c_path, obj_path, command_args: [])
it "prints messages corresponding to rules" do
expected = <<~STR
(2, 3)
(-2, -1)
pair even odd: 5
(1, 0)
(-2, -1)
pair odd even: 1
STR
test_parser("user_defined_parameterizing_rules", "2 3 ; 1 0", expected)
Expand Down

0 comments on commit 95ab3e9

Please sign in to comment.