help-bison
[Top][All Lists]
Advanced

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

Lexical feedback and lookahead


From: Evan Lavelle
Subject: Lexical feedback and lookahead
Date: Tue, 19 Jul 2005 14:19:49 +0100
User-agent: Mozilla Thunderbird 1.0.2 (Windows/20050317)

I've got a problem where I need some communication back from Bison to Flex (in this case, I need Flex to return two different tokens for the same input, depending on context).

The procedure is something like:

1 - parser determines context and sets global flag for lexer

2 - lexer checks flag, reads a name, and returns a token depending on the flag

In general, this doesn't work because of Bison's lookahead - as often as not, the lexer has already returned a token before Bison has set the flag.

Is there a general solution to this problem? 'yyclearin' is no good; it just over-writes 'yychar'. YYBACKUP doesn't help, either, because you can't use it if there's already something in yychar. Ideally, I need to check if there's anything in yychar, and then push it back somehow.

Any ideas?

Thanks -

Evan





reply via email to

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