Gabe Black has uploaded this change for review. ( https://gem5-review.googlesource.com/c/public/gem5/+/56337 )

Change subject: arch: Use the right lineno in the microcode assembler.
......................................................................

arch: Use the right lineno in the microcode assembler.

The one on the lexer token is just for our information, and doesn't
actually control anything. When adjusting the line number to account for
newlines, we need to set the lineno attribute on the lexer.

Change-Id: I0f4e0b02c1e717ff4b22df2e0fa8107216104265
---
M src/arch/ucasmlib/assembler.py
M src/arch/ucasmlib/block.py
2 files changed, 18 insertions(+), 5 deletions(-)



diff --git a/src/arch/ucasmlib/assembler.py b/src/arch/ucasmlib/assembler.py
index c5bf506..ab84ebb 100644
--- a/src/arch/ucasmlib/assembler.py
+++ b/src/arch/ucasmlib/assembler.py
@@ -114,8 +114,8 @@

     @lex.TOKEN(body_re)
     def t_asm_BODY(self, t):
+        t.lexer.lineno += t.value.count('\n')
         t.value = (t.lineno, t.value)
-        t.lineno += t.value[1].count('\n')
         return t


@@ -127,7 +127,7 @@
# Unless handled specially above, track newlines only for line counting.
     def t_ANY_NEWLINE(self, t):
         r'\n+'
-        t.lineno += t.value.count('\n')
+        t.lexer.lineno += t.value.count('\n')

     # Basic regular expressions to pick out simple tokens
     t_ANY_LPAREN = r'\('
diff --git a/src/arch/ucasmlib/block.py b/src/arch/ucasmlib/block.py
index c3e8b02..4bf3d38 100644
--- a/src/arch/ucasmlib/block.py
+++ b/src/arch/ucasmlib/block.py
@@ -127,7 +127,7 @@
     # statement statement terminator, ie a newline or semi colon.
     def t_params_PARAMS(self, t):
         r'([^\n;\\]|(\\.))+'
-        t.lineno += t.value.count('\n')
+        t.lexer.lineno += t.value.count('\n')
         unescapeParamsRE = re.compile(r'(\\[\n;\\])')
         def unescapeParams(mo):
             val = mo.group(0)
@@ -153,7 +153,7 @@
     # token is needed by the parser to detect the end of a statement.
     def t_INITIAL_NEWLINE(self, t):
         r'\n+'
-        t.lineno += t.value.count('\n')
+        t.lexer.lineno += t.value.count('\n')
         return t

     # A newline or semi colon when looking for params signals that the
@@ -161,7 +161,7 @@
     # assembly.
     def t_params_NEWLINE(self, t):
         r'\n+'
-        t.lineno += t.value.count('\n')
+        t.lexer.lineno += t.value.count('\n')
         t.lexer.pop_state()
         return t


--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/56337
To unsubscribe, or for help writing mail filters, visit https://gem5-review.googlesource.com/settings

Gerrit-Project: public/gem5
Gerrit-Branch: develop
Gerrit-Change-Id: I0f4e0b02c1e717ff4b22df2e0fa8107216104265
Gerrit-Change-Number: 56337
Gerrit-PatchSet: 1
Gerrit-Owner: Gabe Black <gabe.bl...@gmail.com>
Gerrit-MessageType: newchange
_______________________________________________
gem5-dev mailing list -- gem5-dev@gem5.org
To unsubscribe send an email to gem5-dev-le...@gem5.org
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s

Reply via email to