Is there a way to make a change-reduce parseq report for conflicts?

I play with the parsek and realized that I have an ambiguous grammar. Obviously, the error is on my part, but I'm kind of used to the yacc parser generators, letting me know that I'm stupid. Parsec just eats the characters in the order you parse it (yes, I know about try ).

Is there a way to get parsec to tell me when my grammar is not left? The programs that work for me are great.

Thanks!

(I know shift-reduce is related to another parser technology. I just want to describe ambiguous grammars.)

+8
haskell parsec
source share
1 answer

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.

+8
source share

All Articles