Skip to content

Commit c4fa3e4

Browse files
committed
Correction for arithmetical operations, They now have their dedicated information function instead of the standard one to avoid the issue of arithmetical operations appearing as alternatives inside a bigger one
1 parent 07e3405 commit c4fa3e4

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

library/info.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -333,24 +333,30 @@ def get_comparison_middle(root):
333333

334334

335335
# Extract Left Middle and Right from arithmetical operations
336+
337+
def get_arithmetic(root):
338+
if not match_node(root,ast.BinOp) or match_parent(root,ast.BinOp):
339+
return None
340+
return root
341+
336342
def get_arithmetic_left(root):
337-
if not match_node(root,ast.BinOp):
343+
if not match_node(root,ast.BinOp) or match_parent(root,ast.BinOp):
338344
return None
339345
items = get_sub_index(root,None)
340346
if len(items)>=1:
341347
return items[0]
342348
return None
343349

344350
def get_arithmetic_right(root):
345-
if not match_node(root,ast.BinOp):
351+
if not match_node(root,ast.BinOp) or match_parent(root,ast.BinOp):
346352
return None
347353
items = get_sub_index(root,None)
348354
if len(items)>=2:
349355
return items[-1]
350356
return None
351357

352358
def get_arithmetic_middle(root):
353-
if not match_node(root,ast.BinOp):
359+
if not match_node(root,ast.BinOp) or match_parent(root,ast.BinOp):
354360
return None
355361
items = get_sub_index(root,None)
356362
if len(items)==3:

queries/big_roi.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ def standard(x):
119119

120120
"attribute":((ast.Attribute),(),standard),
121121
"comparison":((ast.Compare),(),standard),
122-
"arithmetic":((ast.BinOp),(),standard),
122+
"arithmetic":((ast.BinOp),(),get_arithmetic),
123123
"boolean":((ast.BoolOp),(),standard),
124124

125125
"container":((ast.Compare),(),get_container_check),

0 commit comments

Comments
 (0)