add one to end subscript
authorLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Fri, 3 Apr 2020 16:25:06 +0000 (17:25 +0100)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Fri, 3 Apr 2020 16:25:06 +0000 (17:25 +0100)
src/soc/decoder/pseudo/parser.py

index 59da968de8f8cdb41adffff3feeaa911d36b4cbb..ffb8ec0fcdf1a5a48e2610adecb857230001b2f7 100644 (file)
@@ -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]]