From: Luke Kenneth Casson Leighton Date: Fri, 27 Oct 2023 14:46:12 +0000 (+0100) Subject: add LSHIFT and RSHIFT operators to parser. reluctantly X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=f3f8aff4aefa36e0af4c9afe2d6e5913d2e78328;p=openpower-isa.git add LSHIFT and RSHIFT operators to parser. reluctantly --- 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