qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH 33/56] json: Redesign the callback to consume JS


From: Eric Blake
Subject: Re: [Qemu-devel] [PATCH 33/56] json: Redesign the callback to consume JSON values
Date: Mon, 13 Aug 2018 10:30:35 -0500
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0

On 08/08/2018 07:03 AM, Markus Armbruster wrote:


Observations:

1. This is not the only way to use recursive descent.  If we replaced
    "get next token" by a coroutine yield, we could do without a
    streamer.

2. The lexer reports errors by passing a JSON_ERROR token to the
    streamer.  This communicates the offending input characters and
    their location, but no more.

In fact, the offending input wasn't completely available until earlier in the series :)


3. The streamer reports errors by passing a null token sequence to the
    callback.  The (already poor) lexical error information is thrown
    away.

4. Having the callback receive a token sequence duplicates the code to
    convert token sequence to abstract syntax tree in every callback.

5. Known bug: the streamer silently drops incomplete token sequences.

This commit rectifies 4. by lifting the call of the parser from the
callbacks into the streamer.  Later commits will address 3. and 5.

The lifting removes a bug from qjson.c's parse_json(): it passed a
pointer to a non-null Error * in certain cases, as demonstrated by
check-qjson.c.

json_parser_parse() is now unused.  It's a stupid wrapper around
json_parser_parse_err().  Drop it, and rename json_parser_parse_err()
to json_parser_parse().

Signed-off-by: Markus Armbruster <address@hidden>
---

Reviewed-by: Eric Blake <address@hidden>

--
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org



reply via email to

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