All of lore.kernel.org
 help / color / mirror / Atom feed
From: Markus Armbruster <armbru@redhat.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: Markus Armbruster <armbru@redhat.com>,
	qemu-devel <qemu-devel@nongnu.org>
Subject: Re: [PATCH 0/5] qobject: switch JSON parser to push
Date: Tue, 10 Feb 2026 16:52:13 +0100	[thread overview]
Message-ID: <87343861g2.fsf@pond.sub.org> (raw)
In-Reply-To: <CABgObfYrMS093t4GoxB8EgwYYT8wCb-MBozgC5ATq3BZdpheBA@mail.gmail.com> (Paolo Bonzini's message of "Tue, 10 Feb 2026 14:12:51 +0100")

Paolo Bonzini <pbonzini@redhat.com> writes:

> On Tue, Feb 10, 2026 at 2:06 PM Markus Armbruster <armbru@redhat.com> wrote:
>>
>> Paolo Bonzini <pbonzini@redhat.com> writes:
>> >                                                                     Still
>> > the difference in error reporting matters, because it gives feedback that
>> > is immediately useful, rather than possibly delayed forever.
>>
>> Reporting parse errors immediately is such a lovely quality of life
>> improvement.  May I have that without regressing error recovery?
>
> If it is a regression, of course.
>
> Especially the one for ^L, which needs a testcase.

I totally should've added one when I documented the technique back in
2018.

>                                                    Something like this
> should do:
>
> diff --git a/qobject/json-streamer.c b/qobject/json-streamer.c
> index f6380684897..287a345b49a 100644
> --- a/qobject/json-streamer.c
> +++ b/qobject/json-streamer.c
> @@ -35,17 +35,25 @@
>          parser->brace_count++;
>          break;
>      case JSON_RCURLY:
> -        if (parser->brace_count > 0) {
> -            parser->brace_count--;
> +        if (parser->brace_count <= 0) {
> +            goto end_error_recovery;
>          }
> +        parser->brace_count--;
>          break;
>      case JSON_LSQUARE:
>          parser->bracket_count++;
>          break;
>      case JSON_RSQUARE:
> -        if (parser->bracket_count > 0) {
> -            parser->bracket_count--;
> +        if (parser->bracket_count <= 0) {
> +            goto end_error_recovery;
>          }
> +        parser->bracket_count--;
> +        break;
> +    case JSON_ERROR:
> +    end_error_recovery:
> +        parser->brace_count = 0;
> +        parser->bracket_count = 0;
>          break;
>      default:
>          break;

Passes a quick smoke test!

Fine print: different errors can get reported, but that's probably a
slight improvement.



      reply	other threads:[~2026-02-10 15:54 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-07  8:48 [PATCH 0/5] qobject: switch JSON parser to push Paolo Bonzini
2026-01-07  8:48 ` [PATCH 1/5] json-parser: pass around lookahead token, constify Paolo Bonzini
2026-02-06 10:45   ` Markus Armbruster
2026-02-06 10:54     ` Paolo Bonzini
2026-01-07  8:48 ` [PATCH 2/5] json-parser: replace with a push parser Paolo Bonzini
2026-02-09  9:36   ` Markus Armbruster
2026-02-09 10:53     ` Paolo Bonzini
2026-02-12 13:12       ` Markus Armbruster
2026-02-16 16:41         ` Paolo Bonzini
2026-02-17  7:39           ` Markus Armbruster
2026-01-07  8:48 ` [PATCH 3/5] json-streamer: remove token queue Paolo Bonzini
2026-02-10  7:58   ` Markus Armbruster
2026-02-10  8:22     ` Paolo Bonzini
2026-02-11  7:13       ` Markus Armbruster
2026-01-07  8:48 ` [PATCH 4/5] json-streamer: do not heap-allocate JSONToken Paolo Bonzini
2026-02-10  8:30   ` Markus Armbruster
2026-01-07  8:48 ` [PATCH 5/5] json-parser: add location to JSON parsing errors Paolo Bonzini
2026-02-10  9:21   ` Markus Armbruster
2026-02-10  9:44     ` Paolo Bonzini
2026-02-11  7:18       ` Markus Armbruster
2026-01-21  5:57 ` [PATCH 0/5] qobject: switch JSON parser to push Paolo Bonzini
2026-01-30 13:00 ` Markus Armbruster
2026-01-30 13:36   ` Paolo Bonzini
2026-02-10 13:06     ` Markus Armbruster
2026-02-10 13:12       ` Paolo Bonzini
2026-02-10 15:52         ` Markus Armbruster [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87343861g2.fsf@pond.sub.org \
    --to=armbru@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.