
On Sun, Apr 15, 2007 at 07:42:02AM +0100, Lennart Augustsson wrote:
But the qualifiers aren't arbitrary names, are they?
Yes they are. I don't have knowledge of typedefs used :) Nice try though, I toyed with that idea for a long while. Ultimately I decided that it would complicate the lexer too much to add knowledge of C's keywords. Then I thought of the typedef problem.
On Apr 15, 2007, at 04:52 , Stefan O'Rear wrote:
I'm writing a code generator for C, and I'm trying to parse a C-like input language using LL(1) (parsec specifically). The syntax of declarators is giving me trouble: (simplified)
declaration = qualifiers >> (declarator `sepBy1` char ',') qualifiers = many1 name declarator = name
now if we have "<name> <name>", they are both parsed by the greedy many1 in qualifiers! I can make this work with some ugly rearranging:
declaration = fdeclarator >> many (char ',' >> declarator) fdeclarator = name >> many1 name declarator = name
is there a more elegant way?
Stefan