help-bison
[Top][All Lists]
Advanced

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

How to ignore a token if it doesn't fit in with a rule?


From: uclacasey
Subject: How to ignore a token if it doesn't fit in with a rule?
Date: Fri, 22 Jul 2011 17:40:57 -0700 (PDT)

I'm writing a program that handles comments as well as a few other things. If
a comment is in a specific place, then my program does something.

Flex passes a token upon finding a comment, and Bison then looks to see if
that token fits into a particular rule. If it does, then it takes an action
associated with that rule.

Here's the thing: the input I'm receiving might actually have comments in
the wrong places. In this case, I just want to ignore the comment rather
than flagging an error.

My question: 
How can I use a token if it fits into a rule, but ignore it if it doesn't?
Can I make a token "optional"?

(Note: The only way I can think of of doing this right now is scattering the
comment token in every possible place in every possible rule. There MUST be
a better solution than this. Maybe some rule involving the root?)
-- 
View this message in context: 
http://old.nabble.com/How-to-ignore-a-token-if-it-doesn%27t-fit-in-with-a-rule--tp32119417p32119417.html
Sent from the Gnu - Bison - Help mailing list archive at Nabble.com.




reply via email to

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