qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH 6/9] qapi.py: Fix schema parser to check syntax


From: Markus Armbruster
Subject: Re: [Qemu-devel] [PATCH 6/9] qapi.py: Fix schema parser to check syntax systematically
Date: Fri, 26 Jul 2013 21:35:46 +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:
>> Fixes at least the following parser bugs:
>> 
>> * accepts any token in place of a colon
>> 
>> * treats comma as optional
>> 
>> * crashes when closing braces or brackets are missing
>> 
>> Signed-off-by: Markus Armbruster <address@hidden>
>> ---
>>  scripts/qapi.py                       | 40 
>> ++++++++++++++++++++++++++---------
>>  tests/qapi-schema/missing-colon.err   |  1 +
>>  tests/qapi-schema/missing-colon.exit  |  2 +-
>>  tests/qapi-schema/missing-colon.out   |  3 ---
>>  tests/qapi-schema/missing-comma.err   |  1 +
>>  tests/qapi-schema/missing-comma.exit  |  2 +-
>>  tests/qapi-schema/missing-comma.out   |  3 ---
>>  tests/qapi-schema/unclosed-object.err |  2 +-
>>  8 files changed, 35 insertions(+), 19 deletions(-)
>> 
>
>>  
>>      def get_values(self):
>>          expr = []
>> -        while self.tok != ']':
>> +        if self.tok == ']':
>> +            self.accept()
>> +            return expr
>> +        if not self.tok in [ '{', '[', "'" ]:
>> +            raise QAPISchemaError(self, 'Expected "{", "[", "]" or string')
>
> JSON allows primitives here, as in [ 1 ]; but I agree that for the
> purposes of our schema we will always be taking a string or complex
> object whenever we have a list.

The lexer doesn't recognize any atoms but strings.  If we change that,
the syntax error messages need to be reviewed (not just this one).

> Reviewed-by: Eric Blake <address@hidden>



reply via email to

[Prev in Thread] Current Thread [Next in Thread]