Skip to content

Commit

Permalink
Adjust the precedence
Browse files Browse the repository at this point in the history
This adjusts the precedence rules to be more closely aligned to Python
  • Loading branch information
zeroSteiner committed Jan 30, 2025
1 parent 6119973 commit 35de46b
Show file tree
Hide file tree
Showing 3 changed files with 292 additions and 290 deletions.
10 changes: 6 additions & 4 deletions lib/rule_engine/parser/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,20 +144,22 @@ class Parser(ParserBase):
# reverse the order to lowest to highest for ply
reversed((
('nonassoc', 'LPAREN', 'RPAREN'),
('nonassoc', 'LBRACKET', 'RBRACKET'),
('left', 'ATTR', 'ATTR_SAFE'),
('right', 'UMINUS'),
('left', 'POW'),
('right', 'UMINUS'),
('left', 'MUL', 'TDIV', 'FDIV', 'MOD'),
('left', 'BWLSH', 'BWRSH'),
('left', 'ADD', 'SUB'),
('nonassoc', 'EQ', 'NE', 'EQ_FZM', 'EQ_FZS', 'NE_FZM', 'NE_FZS', 'GE', 'GT', 'LE', 'LT', 'IN'), # Nonassociative operators
('right', 'QMARK', 'COLON'),
('left', 'BWLSH', 'BWRSH'),
('left', 'BWAND'),
('left', 'BWXOR'),
('left', 'BWOR'),
('nonassoc', 'EQ_FZM', 'EQ_FZS', 'NE_FZM', 'NE_FZS', 'GE', 'GT', 'LE', 'LT', 'IN'), # Nonassociative operators
('nonassoc', 'EQ', 'NE'),
('right', 'NOT'),
('left', 'AND'),
('left', 'OR'),
('right', 'QMARK', 'COLON'),
)
))

Expand Down
Loading

0 comments on commit 35de46b

Please sign in to comment.