-
Notifications
You must be signed in to change notification settings - Fork 4
No Operator Precedence for Multiplication and Division #8
Copy link
Copy link
Open
Description
Bug Report: No Operator Precedence for Multiplication and Division
Description
The lexer supports multiplication (*) and division (/) tokens, but the parser does not implement operator precedence.
All binary operators are currently parsed with the same precedence, causing expressions involving * and / to be parsed incorrectly.
Example Input
let x = 2 + 3 * 4;
Correct Interpretation
2 + (3 * 4)
Current Interpretation
(2 + 3) * 4
Current Behavior
- Lexer produces
TOKEN_STARandTOKEN_SLASH - Parser treats all operators equally
- Operator precedence rules are not applied
- Expression evaluation order is incorrect
Expected Behavior
*and/should have higher precedence than+and-- Expressions should follow standard arithmetic precedence
- Precedence should work correctly with parentheses
- Nested expressions should be parsed correctly
Suggested Direction
- Implement a precedence-aware expression parser
- Possible approaches:
- Recursive descent with
parse_term()/parse_factor() - Precedence climbing parser
- Recursive descent with
- Ensure compatibility with existing
+and-handling
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels