
14 Apr
2007
14 Apr
'07
11:52 p.m.
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