Bug in Racc?

Hi all,

The following was reported to Minero A. (Racc developer) a while ago;
he hasn’t replied so I assume he’s busy. Thus I’m putting it out to the
Ruby community, any ideas would be appreciated. Appologies for the
lengthy code segment, I wasn’t able to find what exactly was wrong -
the interaction appears very subtle!


I’m emailing you to report a potential bug in Racc. Again, I’m aware
that it is alpha s/w but I do like to help developers create stable
software :).

Do the following:
: j@moose:528:0$; wget
http://www.tippell.com/files/public/autocomplete_parser.y
: j@moose:529:0$; racc -o autocomplete_parser.rb autocomplete_parser.y
&& ruby1.9 autocomplete_parser.rb

You should get output along the lines:
10 shift/reduce conflicts
166 reduce/reduce conflicts
2 useless rules
005

Now uncomment line 16 and comment out lines 17-20. Repeat and you’ll
get the output:
10 shift/reduce conflicts
170 reduce/reduce conflicts
2 useless rules
/usr/local/lib/site_ruby/1.9/racc/parser.rb:350:in on_error': (Racc::ParseError) parse error on value "t4" (IDENT) from /usr/local/lib/site_ruby/1.9/racc/parser.rb:99:in do_parse’
from autocomplete_parser.y:121:in parse' from autocomplete_parser.rb:1246:in run’
from autocomplete_parser.rb:1248

A similar result can be seen on lines 35-39.

Next return to the original file and uncomment lines 67-79 and comment
lines 82-108. Run and you’ll get the same error message as before.

Note though that (again from the original), commenting out lines
133-134 provides the correct result:
10 shift/reduce conflicts
166 reduce/reduce conflicts
2 useless rules
012

I’m no yacc expert but the guys in the lab have confirmed that my code
looks correct - and racc compiles it fine. Moreover a parse error at
runtime rather than at compile time would lead me to believe that my
code is correct.

Unfortunately I’m also fairly new to Ruby and I don’t read Japanese -
which puts me at quite a poor position to write fixes.

Can you confirm that this is a bug in Racc?

Cheers,

Jon