Skip to content

fix: Reorder binary operators to fix parser error#44

Open
exomo wants to merge 1 commit into
appsup-dart:masterfrom
exomo:fix/parse-binary-shift-operators
Open

fix: Reorder binary operators to fix parser error#44
exomo wants to merge 1 commit into
appsup-dart:masterfrom
exomo:fix/parse-binary-shift-operators

Conversation

@exomo

@exomo exomo commented Feb 14, 2026

Copy link
Copy Markdown

Fixes #34

Parsing binary operators evaluates them in an or ("|") expression. Since the parser evaluates them in order and returns the first matching pattern, shorter patterns that are a prefix of a longer pattern and come earlier in the order prevent the longer pattern from ever being parsed.

This was the case for the binary operators "<<" and ">>" making any expression that contains one of the shift operators invalid. (first < is parsed as the "<" operator, the second < can not be parsed in that position.

The fix is fairly simple. The operators are reordered in the definition of binaryOperations to make sure "<<" is evaluated before "<".

Add some additional test cases for binary operation expressions.

Parsing binary operators evaluates them in an or ("|") expression. Since
the parser evaluates them in order and returns the first matching
pattern, shorter patterns that are a prefix of a longer pattern and come
earlier in the order prevent the longer pattern from ever being parsed.

This was the case for the binary operators "<<" and ">>" making any
expression that contains one of the shift operators invalid.
(first < is parsed as the "<" operator, the second < can not be parsed
in that position.

The fix is fairly simple. The operators are reordered in the definition
of binaryOperations to make sure "<<" is evaluated before "<".

Add some additional test cases for binary operation expressions.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Parsing shift operations (<< and >>) fails

2 participants