|Looking for LL(k) C grammar firstname.lastname@example.org (Italo Tasso) (2007-11-03)|
|Re: Looking for LL(k) C grammar Ruslan@Shevchenko.Kiev.UA (rssh) (2007-11-05)|
|Re: Looking for LL(k) C grammar email@example.com (George Neuner) (2007-11-05)|
|From:||George Neuner <firstname.lastname@example.org>|
|Date:||Mon, 05 Nov 2007 11:28:46 -0500|
On Sat, 3 Nov 2007 09:51:13 -0200, "Italo Tasso"
>I am trying to make a recursive descent parser for a simplified
>version of C. It doesn't have to be predictive, but it would be good
>to have no backup.
Recursive descent is predictive by nature.
You can't realistically avoid "backing up" in an RD parser if your
language is LL(k>1), but you can reduce the impact. Unreading a token
or two is very fast ... it's when you have to clean up partial parse
results and undo complex actions like tables updates that backtracking
becomes painful. The best remedy is to implement the parser in a GC'd
language (C and C++ have GC libraries) and code important data
structures in a functional style as much as possible so you can just
abandon the updates if necessary.
>I started with the grammar in the K&R book.
Which is incomplete.
C is fairly complex to parse. Depending on what your subset consists
of, you may be better off just locating an existing grammar written
for your parser tool and pruning the stuff you don't need.
Return to the
Search the comp.compilers archives again.