From ecb068b20b4dfa457f40cc0b01ba82b41d935765 Mon Sep 17 00:00:00 2001 From: Luke Kenneth Casson Leighton Date: Fri, 27 Oct 2023 15:46:12 +0100 Subject: [PATCH] add LSHIFT and RSHIFT operators to parser. reluctantly --- src/openpower/decoder/pseudo/lexer.py | 4 ++++ src/openpower/decoder/pseudo/parser.py | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/src/openpower/decoder/pseudo/lexer.py b/src/openpower/decoder/pseudo/lexer.py index b454b2ac..c42f8330 100644 --- a/src/openpower/decoder/pseudo/lexer.py +++ b/src/openpower/decoder/pseudo/lexer.py @@ -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'\+' diff --git a/src/openpower/decoder/pseudo/parser.py b/src/openpower/decoder/pseudo/parser.py index 8e913244..d0a2630a 100644 --- a/src/openpower/decoder/pseudo/parser.py +++ b/src/openpower/decoder/pseudo/parser.py @@ -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 -- 2.30.2