On 6/15/26 10:11, Markus Armbruster wrote:
+         * Cause error recovery to end immediately.
+         * If not in error recovery, the parser will raise an error
+         * (due to JSON_ERROR or unexpected JSON_R{CURLY,SQUARE})

What do you mean by "due to JSON_ERROR"?

due to passing it to json_parser_feed().  Rewritten:

        /*
         * We goto here due to receiving either JSON_ERROR or a
         * JSON_R{CURLY,SQUARE}) that is known to be unbalanced.
         * If in error recovery, end it immediately.  If not in
         * error recovery, json_parser_feed() will raise an error
         * but error recovery won't be entered at all.
         */

We get here on unmatched } or ]: that's the gotos
you add above.

We also get here on end of non-empty input: that's when the if right
above doesn't return.

+         * but error recovery won't be entered at all.
+         */

This is the only comment on error recovery.  Would a comment giving a
brief overview on error recovery be useful?

It is added in the next commit. At this point there are still relics of the GQueue so it's kinda pointless.

Paolo

+        parser->brace_count = 0;
+        parser->bracket_count = 0;
          break;
      default:
          break;
@@ -83,9 +98,7 @@ void json_message_process_token(JSONLexer *lexer, GString 
*input,
g_queue_push_tail(&parser->tokens, token); - if ((parser->brace_count > 0 || parser->bracket_count > 0)
-        && parser->brace_count >= 0 && parser->bracket_count >= 0
-        && type != JSON_END_OF_INPUT) {
+    if (parser->brace_count > 0 || parser->bracket_count > 0) {
          return;
      }

We get here when

* no lexical error, and

* no limits exceeded, and

* the curlies and squares are balanced, either in fact or because
   we passed through end_error_recovery.

Good.

        /* Process all tokens in the queue */
        while (!g_queue_is_empty(&parser->tokens)) {





Reply via email to