I am not an expert at Parsec, so I will most likely be fixed, but I do not think that this is possible for the simple reason that Parsec does not know anything about your grammar.
Or in another way, while your grammar may be ambiguous, your Parsec parser is not, and the program has no way to determine that some other parsek combinator layout that produces different output for equivalent input, the representation of the unspecified grammar is also valid .
Since you have grammar, you can use happy and alex , which will give you much more lexx / yacc experience.
An interesting project might be adapting BNFC to create AST parser combinators to represent grammar, but I suspect this would be a non-trivial task.
John l
source share