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

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

At Wed, 27 Mar 2002 02:30:46 +0100, Jens_Axel_Søgaard wrote:
>    [(@ (L) (* (: (L) (D))))  (if <parsing a type_name?>
>                                  (token-TYPENAME (get-lexeme))
>                                  (token-IDENTIFIER (get-lexeme)))]
> What shall I write in place of <parsing a type_name?> ?

If I remember correctly, the standard solution is to have a table of
`typedef'ed names. When the parser encounters a typedef, it puts the
type name into the table. So the test above would be "is (get-lexeme)
in the table?".

(I'm not immediately sure how to handle typedefs that aren't at the top
level. I think I probably ignored that possibility in my parser long

At Wed, 27 Mar 2002 13:21:02 -0700 (MST), Scott Owens wrote:
> Currently there is no way for the lexer to get useful information about
> the state of the parser.

To be clear, I'm not arguing with Scott's claim above, but I'm saying
that the information to send from the parser to the lexer is not really
something about the current state of ther parser, but about a history
of typedefs previously seen by the parser.