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

RE: Parser tools: How to make the lexer context sensitive?

I have now tried the flag approach using the following action.

    (specifier_qualifier_list)  (begin 
                                  (set! flag 'type_name)
                                  (let ([tmp (list 'type_name $1)])
                                    (set! flag 'not_type_name)

For (now) obvious reasons, it does not work.
The action is not evaluated until type_name is recognized;
thus the flag is not set until _after_ the lexer returns
the token (and thus wrongly returns  an IDENTIFIER
instead of a TYPE_NAME).

Is there somewhere else, I can set the flag?
How does one obtain information in the lexer from the parser?
How can one tell which terminal the parser is handling?

The yacc approach is to use yytext - is there an equivalent 
in the parser tools?

Any suggestions are welcome (Even the obvious ones; 
perhaps I missed something simple).

Jens Axel Søgaard