qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH v3 for-2.5 09/12] qjson: Convert to parser to re


From: Markus Armbruster
Subject: Re: [Qemu-devel] [PATCH v3 for-2.5 09/12] qjson: Convert to parser to recursive descent
Date: Thu, 26 Nov 2015 09:37:37 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux)

Eric Blake <address@hidden> writes:

> On 11/25/2015 02:23 PM, Markus Armbruster wrote:
>> We backtrack in parse_value(), even though JSON is LL(1) and thus can
>> be parsed by straightforward recursive descent.  Do exactly that.
>> 
>> Based on an almost-correct patch from Paolo Bonzini.
>> 
>> Signed-off-by: Markus Armbruster <address@hidden>
>> ---
>>  qobject/json-parser.c | 165 
>> ++++++++++++++------------------------------------
>>  1 file changed, 47 insertions(+), 118 deletions(-)
>> 
>
>>  static QObject *parse_value(JSONParserContext *ctxt, va_list *ap)
>>  {
>> -    QObject *obj;
>> +    QObject *token;
>>  
>> -    obj = parse_object(ctxt, ap);
>> -    if (obj == NULL) {
>> -        obj = parse_array(ctxt, ap);
>> -    }
>> -    if (obj == NULL) {
>> -        obj = parse_escape(ctxt, ap);
>> -    }
>> -    if (obj == NULL) {
>> -        obj = parse_keyword(ctxt);
>> -    } 
>> -    if (obj == NULL) {
>> -        obj = parse_literal(ctxt);
>> +    token = parser_context_peek_token(ctxt);
>> +    if (token == NULL) {
>> +        parse_error(ctxt, NULL, "premature EOI");
>
> Should we spell that out as 'end of input'?
>
> But that's cosmetic, and doesn't affect correctness of the conversion.

Doesn't matter, because we generally throw away these error messages,
then make up a useless one *boggle*.  Once that's fixed, the
parse_error() could use some love.

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

Thanks!



reply via email to

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