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 03:33:18 -0700 (PDT)

Thanks for the response.  I already am using an exclusive start condition to
pass the comment to Bison.  Could you explain what you mean?  I don't see
how this can solve the problem of ignoring a token if it doesn't fit into a
rule.

John P. Hartmann wrote:
> 
> That is probably much easier to handle by exclusive start conditions
> in the scanner.
> 
> On 23 July 2011 02:40, uclacasey <address@hidden> 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--tp32119417p32119417.html
>> Sent from the Gnu - Bison - Help mailing list archive at Nabble.com.
>>
>>
>> _______________________________________________
>> address@hidden https://lists.gnu.org/mailman/listinfo/help-bison
>>
> 
> _______________________________________________
> address@hidden https://lists.gnu.org/mailman/listinfo/help-bison
> 
> 

-- 
View this message in context: 
http://old.nabble.com/How-to-ignore-a-token-if-it-doesn%27t-fit-in-with-a-rule--tp32119417p32120789.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]