support binary literals with embedded _ (e.g. 0b10_01)
authorJacob Lifshay <programmerjake@gmail.com>
Fri, 19 May 2023 06:26:51 +0000 (23:26 -0700)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Fri, 2 Jun 2023 18:51:18 +0000 (19:51 +0100)
src/openpower/decoder/pseudo/lexer.py

index 6cf3020b55537b4f8095b28c4b86e49120d78d7a..d90105e4ec34f3d80f4071c141bcb3f2cf11a5cc 100644 (file)
@@ -368,8 +368,9 @@ class PowerLexer:
         return t
 
     def t_BINARY(self, t):
-        r"""0b[01]+"""
-        t.value = SelectableInt(int(t.value, 2), len(t.value)-2)
+        r"""0b[01_]+"""
+        val = t.value.replace("_", "")
+        t.value = SelectableInt(int(val, 2), len(val)-2)
         return t
 
     #t_NUMBER = r'\d+'