[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH 4/9] qapi.py: Decent syntax error reporting
From: |
Markus Armbruster |
Subject: |
Re: [Qemu-devel] [PATCH 4/9] qapi.py: Decent syntax error reporting |
Date: |
Fri, 26 Jul 2013 21:33:13 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.1 (gnu/linux) |
Eric Blake <address@hidden> writes:
> On 07/26/2013 06:39 AM, Markus Armbruster wrote:
>> Signed-off-by: Markus Armbruster <address@hidden>
>> ---
>> scripts/qapi.py | 29 +++++++++++++++++++++++++++--
>> tests/qapi-schema/test-qapi.py | 2 ++
>> tests/qapi-schema/unclosed-string.err | 2 +-
>> 3 files changed, 30 insertions(+), 3 deletions(-)
>
>>
>> +class QAPISchemaError(Exception):
>> + def __init__(self, schema, msg):
>> + self.fp = schema.fp
>> + self.msg = msg
>> + self.line = self.col = 1
>> + for ch in schema.src[0:schema.pos]:
>> + if ch == '\n':
>> + self.line += 1
>> + self.col = 1
>> + elif ch == '\t':
>> + self.col = (self.col + 7) % 8 + 1
>
> Do we even want to allow TABs in the schema files? Right now, they are
> tab-free; if you error out here instead of futzing with tab width, we
> could forcefully maintain that property.
I'm not volunteering for the TAB police, but if y'all want the parser to
reject TABs, I can do that.
>> + else:
>> + self.col += 1
>
> Does python support ++ as shorthand for += 1?
It doesn't, sadly.
> Reviewed-by: Eric Blake <address@hidden>
[Qemu-devel] [PATCH 5/9] qapi.py: Reject invalid characters in schema file, Markus Armbruster, 2013/07/26
[Qemu-devel] [PATCH 8/9] qapi.py: Rename expr_eval to expr in parse_schema(), Markus Armbruster, 2013/07/26
[Qemu-devel] [PATCH 9/9] qapi.py: Permit comments starting anywhere on the line, Markus Armbruster, 2013/07/26
[Qemu-devel] [PATCH 7/9] qapi.py: Fix diagnosing non-objects at a schema's top-level, Markus Armbruster, 2013/07/26