diff options
| author | Patrick Simianer <patrick@lilt.com> | 2026-02-24 17:16:06 +0100 |
|---|---|---|
| committer | Patrick Simianer <patrick@lilt.com> | 2026-02-24 17:16:06 +0100 |
| commit | 22dc0fbdf002c7824941abc17a715a3e70ff37c1 (patch) | |
| tree | d5a58a69d34a046f1e1e753c73fac0fe4b377337 /prototype | |
| parent | e76951f21263eb7010a2898b9744364e989e90b8 (diff) | |
Emit binary glue rule only once
The [S] -> [S] [X] concatenation rule was duplicated for every non-S LHS
symbol. Move it out of the loop so it's added once.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Diffstat (limited to 'prototype')
| -rw-r--r-- | prototype/grammar.rb | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/prototype/grammar.rb b/prototype/grammar.rb index abccb15..4aebd95 100644 --- a/prototype/grammar.rb +++ b/prototype/grammar.rb @@ -120,9 +120,9 @@ class Grammar @rules.map { |r| r.lhs.symbol }.select { |s| s != 'S' }.uniq.each { |symbol| @rules << Rule.new(NT.new('S'), [NT.new(symbol, 0)], [NT.new(symbol, 0)], [0]) @start_nt << @rules.last - @rules << Rule.new(NT.new('S'), [NT.new('S', 0), NT.new('X', 1)], [NT.new('S', 0), NT.new('X', 1)], [0, 1]) - @start_nt << @rules.last } + @rules << Rule.new(NT.new('S'), [NT.new('S', 0), NT.new('X', 1)], [NT.new('S', 0), NT.new('X', 1)], [0, 1]) + @start_nt << @rules.last end def add_pass_through_rules a |
