chumsky icon indicating copy to clipboard operation
chumsky copied to clipboard

Attempt At Non-Infix Pratt Parsing

Open lancylot2004 opened this issue 11 months ago • 3 comments

Along the same lines as #600.

Currently, the chumsky::pratt parser only supports binary infix operators with left or right associativity, but not non-infix ones. Other libraries and literature might term this as InfixN or non-associative. (Please correct me if I'm wrong~)

For example, comparison operators like > and == are typically non-associative, since expressions like 1 == 2 == 3 is invalid. (They cannot be chained.)

This PR adds a non option for associativity, and tries to follow the same article.

lancylot2004 avatar Feb 06 '25 16:02 lancylot2004

[!IMPORTANT] The PR for now breaks one of the postfix tests - I wanted to open it just in case someone who knows more than me would want to take a look!

lancylot2004 avatar Feb 06 '25 16:02 lancylot2004

Thanks for the PR, should be able to take a look at this soon.

zesterer avatar Feb 09 '25 18:02 zesterer

Do you have any idea why the current changes break the postfix test?

lancylot2004 avatar Feb 10 '25 11:02 lancylot2004