From 8e0f6ea81295acbf72a14d8310fb3cd48ba01ba5 Mon Sep 17 00:00:00 2001 From: Jacob Lifshay Date: Wed, 3 May 2023 21:15:45 -0700 Subject: [PATCH] show actual mdwn source location in backtrace when parser raises SyntaxError --- src/openpower/decoder/power_pseudo.py | 8 +++--- .../decoder/pseudo/functionreader.py | 4 +-- src/openpower/decoder/pseudo/lexer.py | 13 +++++++++- src/openpower/decoder/pseudo/pagereader.py | 26 ++++++++++++++++--- src/openpower/decoder/pseudo/parser.py | 23 +++++++++++----- src/openpower/decoder/pseudo/pyfnwriter.py | 5 ++-- src/openpower/decoder/pseudo/pywriter.py | 6 +++-- 7 files changed, 65 insertions(+), 20 deletions(-) diff --git a/src/openpower/decoder/power_pseudo.py b/src/openpower/decoder/power_pseudo.py index f8d87dce..637826bc 100644 --- a/src/openpower/decoder/power_pseudo.py +++ b/src/openpower/decoder/power_pseudo.py @@ -258,21 +258,21 @@ def get_reg_hex(reg): return hex(reg.value) -def convert_to_pure_python(pcode, helper=False): +def convert_to_pure_python(pcode, helper=False, filename="string"): gsc = GardenSnakeCompiler(form=None, incl_carry=False, helper=helper) - tree = gsc.compile(pcode, mode="exec", filename="string") + tree = gsc.compile(pcode, mode="exec", filename=filename) tree = ast.fix_missing_locations(tree) return astor.to_source(tree) -def convert_to_python(pcode, form, incl_carry, helper=False): +def convert_to_python(pcode, form, incl_carry, helper=False, filename="string"): print("form", form) gsc = GardenSnakeCompiler(form=form, incl_carry=incl_carry, helper=helper) - tree = gsc.compile(pcode, mode="exec", filename="string") + tree = gsc.compile(pcode, mode="exec", filename=filename) tree = ast.fix_missing_locations(tree) regsused = {'read_regs': gsc.parser.read_regs, 'write_regs': gsc.parser.write_regs, diff --git a/src/openpower/decoder/pseudo/functionreader.py b/src/openpower/decoder/pseudo/functionreader.py index b87cf53e..4e065239 100644 --- a/src/openpower/decoder/pseudo/functionreader.py +++ b/src/openpower/decoder/pseudo/functionreader.py @@ -54,7 +54,7 @@ class ISAFunctions: # so please put ending of comments on one line: # # - if l.startswith('