105 |
105 |
['u'] = IN_DQ_UCODE0,
|
106 |
106 |
},
|
107 |
107 |
[IN_DQ_STRING] = {
|
108 |
|
[1 ... 0xFF] = IN_DQ_STRING,
|
|
108 |
[1 ... 0xBF] = IN_DQ_STRING,
|
|
109 |
[0xC2 ... 0xF4] = IN_DQ_STRING,
|
109 |
110 |
['\\'] = IN_DQ_STRING_ESCAPE,
|
110 |
111 |
['"'] = JSON_STRING,
|
111 |
112 |
},
|
... | ... | |
144 |
145 |
['u'] = IN_SQ_UCODE0,
|
145 |
146 |
},
|
146 |
147 |
[IN_SQ_STRING] = {
|
147 |
|
[1 ... 0xFF] = IN_SQ_STRING,
|
|
148 |
[1 ... 0xBF] = IN_SQ_STRING,
|
|
149 |
[0xC2 ... 0xF4] = IN_SQ_STRING,
|
148 |
150 |
['\\'] = IN_SQ_STRING_ESCAPE,
|
149 |
151 |
['\''] = JSON_STRING,
|
150 |
152 |
},
|
... | ... | |
305 |
307 |
new_state = IN_START;
|
306 |
308 |
break;
|
307 |
309 |
case IN_ERROR:
|
|
310 |
/* XXX: To avoid having previous bad input leaving the parser in an
|
|
311 |
* unresponsive state where we consume unpredictable amounts of
|
|
312 |
* subsequent "good" input, percolate this error state up to the
|
|
313 |
* tokenizer/parser by forcing a NULL object to be emitted, then
|
|
314 |
* reset state.
|
|
315 |
*
|
|
316 |
* Also note that this handling is required for reliable channel
|
|
317 |
* negotiation between QMP and the guest agent, since chr(0xFF)
|
|
318 |
* is placed at the beginning of certain events to ensure proper
|
|
319 |
* delivery when the channel is in an unknown state. chr(0xFF) is
|
|
320 |
* never a valid ASCII/UTF-8 sequence, so this should reliably
|
|
321 |
* induce an error/flush state.
|
|
322 |
*/
|
|
323 |
lexer->emit(lexer, lexer->token, JSON_ERROR, lexer->x, lexer->y);
|
308 |
324 |
QDECREF(lexer->token);
|
309 |
325 |
lexer->token = qstring_new();
|
310 |
326 |
new_state = IN_START;
|
311 |
|
return -EINVAL;
|
|
327 |
lexer->state = new_state;
|
|
328 |
return 0;
|
312 |
329 |
default:
|
313 |
330 |
break;
|
314 |
331 |
}
|
... | ... | |
346 |
363 |
|
347 |
364 |
int json_lexer_flush(JSONLexer *lexer)
|
348 |
365 |
{
|
349 |
|
return lexer->state == IN_START ? 0 : json_lexer_feed_char(lexer, 0);
|
|
366 |
return lexer->state == IN_START ? 0 : json_lexer_feed_char(lexer, 0, true);
|
350 |
367 |
}
|
351 |
368 |
|
352 |
369 |
void json_lexer_destroy(JSONLexer *lexer)
|