From: Jacob Lifshay Date: Fri, 12 May 2023 06:32:16 +0000 (-0700) Subject: make lexer replace class with class_ since it's a python keyword X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=f6fbc46dd0a4cc4dcee7c20b7d898d11b7634fa4;p=openpower-isa.git make lexer replace class with class_ since it's a python keyword --- 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