[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 05/26] qapi/parser.py: start source info at line 0
From: |
John Snow |
Subject: |
[PATCH 05/26] qapi/parser.py: start source info at line 0 |
Date: |
Tue, 22 Sep 2020 18:35:04 -0400 |
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 --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()
--
2.26.2
- [PATCH 00/26] qapi: static typing conversion, pt5, John Snow, 2020/09/22
- [PATCH 03/26] qapi/parser.py: use 'with' statement for opening files, John Snow, 2020/09/22
- [PATCH 02/26] qapi/parser.py: group variable declarations in __init__, John Snow, 2020/09/22
- [PATCH 04/26] qapi/source.py: Add default arguments to QAPISourceInfo, John Snow, 2020/09/22
- [PATCH 01/26] qapi/parser.py: refactor parsing routine into method, John Snow, 2020/09/22
- [PATCH 05/26] qapi/parser.py: start source info at line 0,
John Snow <=
- [PATCH 07/26] qapi/parser.py: fully remove 'null' constant, John Snow, 2020/09/22
- [PATCH 08/26] qapi/parser.py: Assert lexer value is a string, John Snow, 2020/09/22
- [PATCH 06/26] qapi/parser.py: raise QAPIParseError during file opening, John Snow, 2020/09/22
- [PATCH 09/26] qapi/parser.py: assert get_expr returns object in outer loop, John Snow, 2020/09/22
- [PATCH 10/26] qapi/parser.py: assert object keys are strings, John Snow, 2020/09/22
- [PATCH 11/26] qapi/parser.py: Convert several methods to @classmethod, John Snow, 2020/09/22
- [PATCH 12/26] qapi/parser.py: add casts to pragma checks, John Snow, 2020/09/22
- [PATCH 13/26] qapi/parser.py: add type hint annotations, John Snow, 2020/09/22
- [PATCH 14/26] qapi/parser.py: add docstrings, John Snow, 2020/09/22
- [PATCH 15/26] qapi/parser.py: add ParsedExpression type, John Snow, 2020/09/22