help-bison
[Top][All Lists]
Advanced

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

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


From: uclacasey
Subject: Re: How to ignore a token if it doesn't fit in with a rule?
Date: Sat, 23 Jul 2011 11:17:25 -0700 (PDT)

Perhaps is there any way to get feedback from the parser?  For example, if it
is about to output a specific error message, I could intercept that error
message, revert, and pass a different token? 

p.s: if anything sounds outlandish, it's because I'm relatively new to this

uclacasey wrote:
> 
> 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--tp32119417p32122694.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]