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=98787a5e944f22af8786ca2dbcc3762bc0cbfd5d;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