Eric Blake <[email protected]> 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 <[email protected]> >> --- >> 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 <[email protected]> Thanks!
