try again with adding XOR operator
authorLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Sat, 4 Apr 2020 20:19:40 +0000 (21:19 +0100)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Sat, 4 Apr 2020 20:19:40 +0000 (21:19 +0100)
src/soc/decoder/power_pseudo.py
src/soc/decoder/pseudo/lexer.py
src/soc/decoder/pseudo/parser.py
src/soc/decoder/pseudo/pywriter.py

index fc3f54103e67c8c782c8260611feb4fce53743ba..3bd52a3a6eac78dc476ea7066c766cfd27f0f5c9 100644 (file)
@@ -134,12 +134,17 @@ MEM(EA, 4) <- GPR(r)[32:63]
 #x <- x[0][32:63]
 """
 
+testdo = r"""
+for i = 0 to 7
+   print(i)
+"""
+code = testdo
 #code = testmul
 #code = testgetzero
 #code = testcat
 #code = testgpr
 #code = testmem
-code = testgprslice
+#code = testgprslice
 #code = testreg
 #code = cnttzd
 #code = cmpi
index ee06c3f154578d84bd20a524f38c1defece8b274..3638a7fe4c285b02ed4bb775c087c927fbbed099 100644 (file)
@@ -256,6 +256,7 @@ class PowerLexer:
         'APPEND',
         'BITOR',
         'BITAND',
+        'BITXOR',
         'RETURN',
         'WS',
         'NEWLINE',
@@ -308,6 +309,7 @@ class PowerLexer:
     t_APPEND = r'\|\|'
     t_BITOR = r'\|'
     t_BITAND = r'\&'
+    t_BITXOR = r'\&'
 
     # Ply nicely documented how to do this.
 
index 6abe1913a204d3bf7b6683e28fda08ae94fc4840..60a815c446be7e4a652d7566894fdf8403adb51c 100644 (file)
@@ -107,6 +107,7 @@ def make_eq_compare(arg):
 
 
 binary_ops = {
+    "^": ast.BitXor(),
     "&": ast.BitAnd(),
     "|": ast.BitOr(),
     "+": ast.Add(),
@@ -209,6 +210,7 @@ class PowerParser:
     precedence = (
         ("left", "EQ", "GT", "LT", "LE", "GE", "LTU", "GTU"),
         ("left", "BITOR"),
+        ("left", "BITXOR"),
         ("left", "BITAND"),
         ("left", "PLUS", "MINUS"),
         ("left", "MULT", "DIV", "MOD"),
@@ -439,6 +441,7 @@ class PowerParser:
                       | comparison LT comparison
                       | comparison GT comparison
                       | comparison BITOR comparison
+                      | comparison BITXOR comparison
                       | comparison BITAND comparison
                       | PLUS comparison
                       | comparison MINUS
index d26074cf31ff2d7299e1a87e153779132af4b528..2f5cd3a46f494394d3415dad7c780885402652a7 100644 (file)
@@ -80,8 +80,9 @@ class PyISAWriter(ISA):
 
 if __name__ == '__main__':
     isa = PyISAWriter()
-    isa.write_pysource('fixedstore')
+    isa.write_pysource('fixedlogical')
     exit(0)
+    isa.write_pysource('fixedstore')
     isa.write_pysource('fixedload')
     isa.write_pysource('comparefixed')
     isa.write_pysource('fixedarith')