From 22dc0fbdf002c7824941abc17a715a3e70ff37c1 Mon Sep 17 00:00:00 2001 From: Patrick Simianer Date: Tue, 24 Feb 2026 17:16:06 +0100 Subject: 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 --- prototype/grammar.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'prototype/grammar.rb') 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 -- cgit v1.2.3