chumsky icon indicating copy to clipboard operation
chumsky copied to clipboard

Added Non-Associative associativity for Pratt Parsers.

Open YunkaiZhang233 opened this issue 5 months ago • 0 comments

In current Pratt parsers, only associativity type of left and right are supported. However, according to the original designs of Pratt parsing, it should also support Non-Associative infix binary operators.

For example, consider operators == as a non-associative operator. We should be able to identify it as non-associative and therefore rejecting 1 == 2 == 3 as an expression with the numbers being atomic literals. Whilst the current design only allow == to be either left-associative or right-associative.

This PR added associativity non for infix binary operators, and changed the binding power calculation function slightly based on The Original Parsing Methodology and this article.

YunkaiZhang233 avatar Feb 06 '24 00:02 YunkaiZhang233