fix concat error
[soc.git] / src / soc / decoder / pseudo / parser.py
index e752aff8207666735ba223ab98d0b5a342c74945..02bb2cc1a645d3634aace922bda2da548df89eea 100644 (file)
@@ -80,10 +80,10 @@ def Assign(left, right):
 
 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])
@@ -113,13 +113,13 @@ unary_ops = {
     }
 
 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) ######
@@ -356,7 +356,7 @@ class PowerParser:
             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])
@@ -450,7 +450,12 @@ class PowerParser:
                      | 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]]