help-bison
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Make empty rules return 0?


From: Adam Smalin
Subject: Make empty rules return 0?
Date: Sat, 1 Jun 2013 09:15:52 -0400

I wanted to experiment so I removed glr-parser and to my surprise maybeTest
blew up on me. I was expecting empty rules return  0 like it does for
glr-parser. Is there a reason why it doesn't? (It doesn't make sense as an
optimization)

program: maybeTest { printf("%d", $1); }
Test: '?' { $$=1; }
maybeTest: | Test

I can fix it like the below but I have a lot of rules that are optional.
I'm using bison 2.4.1 for windows. I may start doing builds on linux with
the latest (2.7?)
program: maybeTest { printf("%d", $1); }
Test: '?' { $$=1; }
maybeTest: {$$=0;}| Test


reply via email to

[Prev in Thread] Current Thread [Next in Thread]