Markus Armbruster 0f07a5d5f1 json: Nicer recovery from lexical errors
When the lexer chokes on an input character, it consumes the
character, emits a JSON error token, and enters its start state.  This
can lead to suboptimal error recovery.  For instance, input

    0123 ,

produces the tokens

    JSON_ERROR    01
    JSON_INTEGER  23
    JSON_COMMA    ,

Make the lexer skip characters after a lexical error until a
structural character ('[', ']', '{', '}', ':', ','), an ASCII control
character, or '\xFE', or '\xFF'.

Note that we must not skip ASCII control characters, '\xFE', '\xFF',
because those are documented to force the JSON parser into known-good
state, by docs/interop/qmp-spec.txt.

The lexer now produces

    JSON_ERROR    01
    JSON_COMMA    ,

Update qmp-test for the nicer error recovery: QMP now reports just one
error for input %p instead of two.  Also drop the newline after %p; it
was needed to tease out the second error.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-Id: <20180831075841.13363-5-armbru@redhat.com>
[Conflict with commit ebb4d82d888 resolved]
2018-09-24 18:08:07 +02:00
..
2018-02-22 15:44:07 -08:00
2017-09-22 10:46:25 +08:00
2018-03-21 15:13:40 +01:00
2018-08-16 09:50:54 +01:00
2017-03-01 11:51:28 +04:00
2017-03-01 11:51:05 +04:00
2018-08-16 09:50:54 +01:00
2017-03-01 11:51:05 +04:00
2018-08-31 09:53:10 +02:00
2018-08-31 09:53:10 +02:00
2018-08-31 16:28:33 +02:00
2018-08-31 16:28:33 +02:00
2018-02-08 09:22:03 +08:00
2017-09-05 22:34:40 +02:00
2018-08-31 09:53:10 +02:00
2018-08-23 18:46:25 +02:00
2018-08-23 18:46:25 +02:00
2017-12-20 22:01:24 +08:00