Skip to content

Commit 35de46b

Browse files
committed
Adjust the precedence
This adjusts the precedence rules to be more closely aligned to Python
1 parent 6119973 commit 35de46b

File tree

3 files changed

+292
-290
lines changed

3 files changed

+292
-290
lines changed

lib/rule_engine/parser/__init__.py

+6-4
Original file line numberDiff line numberDiff line change
@@ -144,20 +144,22 @@ class Parser(ParserBase):
144144
# reverse the order to lowest to highest for ply
145145
reversed((
146146
('nonassoc', 'LPAREN', 'RPAREN'),
147+
('nonassoc', 'LBRACKET', 'RBRACKET'),
147148
('left', 'ATTR', 'ATTR_SAFE'),
148-
('right', 'UMINUS'),
149149
('left', 'POW'),
150+
('right', 'UMINUS'),
150151
('left', 'MUL', 'TDIV', 'FDIV', 'MOD'),
151-
('left', 'BWLSH', 'BWRSH'),
152152
('left', 'ADD', 'SUB'),
153-
('nonassoc', 'EQ', 'NE', 'EQ_FZM', 'EQ_FZS', 'NE_FZM', 'NE_FZS', 'GE', 'GT', 'LE', 'LT', 'IN'), # Nonassociative operators
154-
('right', 'QMARK', 'COLON'),
153+
('left', 'BWLSH', 'BWRSH'),
155154
('left', 'BWAND'),
156155
('left', 'BWXOR'),
157156
('left', 'BWOR'),
157+
('nonassoc', 'EQ_FZM', 'EQ_FZS', 'NE_FZM', 'NE_FZS', 'GE', 'GT', 'LE', 'LT', 'IN'), # Nonassociative operators
158+
('nonassoc', 'EQ', 'NE'),
158159
('right', 'NOT'),
159160
('left', 'AND'),
160161
('left', 'OR'),
162+
('right', 'QMARK', 'COLON'),
161163
)
162164
))
163165

0 commit comments

Comments
 (0)