Propositions Parser using recursion

I wrote a parser for Elm types a while ago, so maybe it would help to read through that code:

I do not know the specifics of your assignment, but maybe there will be some techniques in there that are relevant!

Aside: If you have parentheses around each And, Or, Implies, and Equal, that makes things much easier! You can decide which proposition you are looking at when you see the infix operator. (If there are not always parentheses, but instead there is “operator associativity and precedence” that implicitly clarify the parens, I have found it works well to parse them into a flat list and then figure out the implicit parentheses in a second pass, independent from the parser code.) Not sure what is right for your case, but hopefully this gives some ideas!

1 Like