diff mbox series

[05/26] qapi/parser.py: start source info at line 0

Message ID 20200922223525.4085762-6-jsnow@redhat.com
State New
Headers show
Series qapi: static typing conversion, pt5 | expand

Commit Message

John Snow Sept. 22, 2020, 10:35 p.m. UTC
Before we have any actual line context, we still have a file context. We
can use this to report errors without mentioning a specific line.

Signed-off-by: John Snow <jsnow@redhat.com>
---
 scripts/qapi/parser.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/scripts/qapi/parser.py b/scripts/qapi/parser.py
index db4e9ae872..fc0b1516cc 100644
--- a/scripts/qapi/parser.py
+++ b/scripts/qapi/parser.py
@@ -55,7 +55,7 @@  def __init__(self, fname, previously_included=None, incl_info=None):
         self.pos = 0
         self.cursor = 0
         self.val = None
-        self.info = QAPISourceInfo(self._fname, 1, incl_info)
+        self.info = QAPISourceInfo(self._fname, parent=incl_info)
         self.line_pos = 0
 
         # Parser output:
@@ -78,6 +78,7 @@  def _parse(self):
         cur_doc = None
 
         # Prime the lexer:
+        self.info.line += 1
         if self.src == '' or self.src[-1] != '\n':
             self.src += '\n'
         self.accept()