def make_le_compare(arg):
(left, right) = arg
- return ast.Compare(left, [ast.Le()], [right])
+ return ast.Compare(left, [ast.LtE()], [right])
def make_ge_compare(arg):
(left, right) = arg
- return ast.Compare(left, [ast.Ge()], [right])
+ return ast.Compare(left, [ast.GtE()], [right])
def make_lt_compare(arg):
(left, right) = arg
return ast.Compare(left, [ast.Lt()], [right])
}
def check_concat(node): # checks if the comparison is already a concat
- print (node)
+ print ("check concat", node)
if not isinstance(node, ast.Call):
return [node]
- print (node.func.id)
+ print ("func", node.func.id)
if node.func.id != 'concat':
return [node]
- return node[1]
+ return node.args
########## Parser (tokens -> AST) ######
elif p[2] == '||':
l = check_concat(p[1]) + check_concat(p[3])
p[0] = ast.Call(ast.Name("concat"), l, [])
- elif p[2] in ['<', '>', '=']:
+ elif p[2] in ['<', '>', '=', '<=', '>=']:
p[0] = binary_ops[p[2]]((p[1],p[3]))
else:
p[0] = ast.BinOp(p[1], binary_ops[p[2]], p[3])
| test
"""
if len(p) == 4:
- p[0] = [p[1], p[3]]
+ # add one to end
+ if isinstance(p[3], ast.Constant):
+ end = ast.Constant(p[3].value+1)
+ else:
+ end = ast.BinOp(p[3], ast.Add(), ast.Constant(1))
+ p[0] = [p[1], end]
else:
p[0] = [p[1]]