Skip to content

Commit

Permalink
Fix a segmentation fault when run calc
Browse files Browse the repository at this point in the history
```
❯ exe/lrama -d sample/calc.y -o calc.c && gcc -Wall calc.c -o calc && ./calc
Enter the formula:
1
parse error: syntax error, unexpected NUM
[1]    52278 segmentation fault  ./calc
```
  • Loading branch information
ydah committed Apr 15, 2024
1 parent cc02b41 commit 41138d9
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions lib/lrama/grammar/rule_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,12 @@ def resolve_inline_rules(parameterizing_rule_resolver)
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, lhs_tag: lhs_tag, skip_preprocess_references: true)
rule_builder = RuleBuilder.new(@rule_counter, @midrule_action_counter, lhs_tag: lhs_tag)
resolve_inline_rhs(rule_builder, inline_rhs, i)
rule_builder.lhs = lhs
rule_builder.line = line
rule_builder.precedence_sym = precedence_sym
rule_builder.user_code = replace_inline_user_code(inline_rhs, i)
rule_builder.complete_input
rule_builder.setup_rules(parameterizing_rule_resolver)
resolved_builders << rule_builder
end
break
Expand Down

0 comments on commit 41138d9

Please sign in to comment.