From 98787a5e944f22af8786ca2dbcc3762bc0cbfd5d Mon Sep 17 00:00:00 2001 From: Jacob Lifshay Date: Thu, 11 May 2023 23:32:16 -0700 Subject: [PATCH] make lexer replace class with class_ since it's a python keyword --- src/openpower/decoder/pseudo/lexer.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/openpower/decoder/pseudo/lexer.py b/src/openpower/decoder/pseudo/lexer.py index 87147c81..6cf3020b 100644 --- a/src/openpower/decoder/pseudo/lexer.py +++ b/src/openpower/decoder/pseudo/lexer.py @@ -295,6 +295,9 @@ def filter(lexer, add_endmarker=True): lineno = token.lineno yield _new_token("ENDMARKER", lineno) + +KEYWORD_REPLACEMENTS = {'class': 'class_'} + ##### Lexer ###### @@ -428,6 +431,8 @@ class PowerLexer: def t_NAME(self, t): r'[a-zA-Z_][a-zA-Z0-9_]*' t.type = self.RESERVED.get(t.value, "NAME") + if t.value in KEYWORD_REPLACEMENTS: + t.value = KEYWORD_REPLACEMENTS[t.value] return t # Putting this before t_WS let it consume lines with only comments in -- 2.30.2