add LSHIFT and RSHIFT operators to parser. reluctantly
authorLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Fri, 27 Oct 2023 14:46:12 +0000 (15:46 +0100)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Sun, 29 Oct 2023 08:54:37 +0000 (08:54 +0000)
src/openpower/decoder/pseudo/lexer.py
src/openpower/decoder/pseudo/parser.py

index b454b2ac61084d8e11318c873faab6aebefbe403..c42f8330e5fde38f82ef37c6cba1b0077c207a4c 100644 (file)
@@ -343,6 +343,8 @@ class PowerLexer:
         'GTU',
         'NE',
         'LE',
+        'LSHIFT',
+        'RSHIFT',
         'GE',
         'LT',
         'GT',
@@ -410,6 +412,8 @@ class PowerLexer:
     t_NE = r'!='
     t_LE = r'<='
     t_GE = r'>='
+    t_LSHIFT = r'<<'
+    t_RSHIFT = r'>>'
     t_LT = r'<'
     t_GT = r'>'
     t_PLUS = r'\+'
index 8e9132447ed8207875dc4058d4919ea14d207634..d0a2630acad98e5092fffd5ab771ef7460f1fefa 100644 (file)
@@ -87,6 +87,8 @@ binary_ops = {
     "|": ast.BitOr(),
     "+": ast.Add(),
     "-": ast.Sub(),
+    "<<": ast.LShift(),
+    ">>": ast.RShift(),
     "*": ast.Mult(),
     "/": ast.FloorDiv(),
     "%": ast.Mod(),
@@ -184,6 +186,7 @@ class PowerParser:
         ("left", "BITOR"),
         ("left", "BITXOR"),
         ("left", "BITAND"),
+        ("left", "LSHIFT", "RSHIFT"),
         ("left", "PLUS", "MINUS"),
         ("left", "MULT", "DIV", "MOD"),
         ("left", "INVERT"),
@@ -575,6 +578,8 @@ class PowerParser:
         """comparison : comparison PLUS comparison
                       | comparison MINUS comparison
                       | comparison MULT comparison
+                      | comparison LSHIFT comparison
+                      | comparison RSHIFT comparison
                       | comparison DIV comparison
                       | comparison MOD comparison
                       | comparison EQ comparison