|Parsing C with missing typedefs firstname.lastname@example.org (Bernt Kullbach) (1999-04-18)|
|Re: Parsing C with missing typedefs email@example.com (1999-04-19)|
|Re: Parsing C with missing typedefs firstname.lastname@example.org (1999-04-19)|
|From:||email@example.com (Dwight VandenBerghe)|
|Date:||19 Apr 1999 14:48:06 -0400|
On 18 Apr 1999 02:00:36 -0400, Bernt Kullbach
>does anyone know how I can parse C when typedefs are missing.
Sure. John's second suggestion is the way to go, but you need to do
it at full strength - in other words, trying to look ahead with simple
techniques won't work. Construct a second full parser from the ground
up just to do the lookahead. Have it available to call as a
subroutine when needed, then call it when your normal parsing fails.
Design its grammar to recognize every valid declaration that could
follow a typedef name (and don't forget to handle casts as well).
Make sure that it caches the lexical tokens that it eats from the
input stream, so that when it returns with a Yes or No (that tells you
whether the unknown identifier was a typedef name or not), you can go
back to parsing with your regular parser and it will retrieve the
already-seen tokens from the input cache. Mark any new typedef names
found in the symbol table as typedefs and make sure that they are
recognized as such from that point in the source onward, or this won't
work - it will only work to recognize one new typedef name at a time.
You'll make things easier on yourself if you use a modern parser
generator that supports re-entrant parsers.
Return to the
Search the comp.compilers archives again.