try to add some line numbers to ast -- helps with debugging
authorJacob Lifshay <programmerjake@gmail.com>
Thu, 28 Jul 2022 08:59:44 +0000 (01:59 -0700)
committerJacob Lifshay <programmerjake@gmail.com>
Thu, 28 Jul 2022 08:59:44 +0000 (01:59 -0700)
src/openpower/decoder/pseudo/parser.py

index 768825273f3ad3ded2266b308c899af6cee99f09..f78ef18aa7ef818944aa9ae6e05d75da0c7fb8b7 100644 (file)
@@ -350,7 +350,7 @@ class PowerParser:
 
     def p_funcdef(self, p):
         "funcdef : DEF NAME parameters COLON suite"
-        p[0] = ast.FunctionDef(p[2], p[3], p[5], ())
+        p[0] = ast.FunctionDef(p[2], p[3], p[5], (), lineno=p.lineno(2))
         # reset function parameters after suite is identified
         self.fnparm_vars = set()
 
@@ -762,9 +762,9 @@ class PowerParser:
             self.write_regs.add(name)  # and add to list to write
         if name in {'XLEN'}:
             attr = ast.Name("self", ast.Load())
-            p[0] = ast.Attribute(attr, name, ast.Load())
+            p[0] = ast.Attribute(attr, name, ast.Load(), lineno=p.lineno(1))
         else:
-            p[0] = ast.Name(id=name, ctx=ast.Load())
+            p[0] = ast.Name(id=name, ctx=ast.Load(), lineno=p.lineno(1))
 
     def p_atom_number(self, p):
         """atom : BINARY