mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-04 00:03:54 -06:00
qjson: Give each of the six structural chars its own token type
Simplifies things, because we always check for a specific one. Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-Id: <1448486613-17634-6-git-send-email-armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com>
This commit is contained in:
parent
b8d3b1da3c
commit
c54616608a
4 changed files with 42 additions and 47 deletions
|
@ -26,23 +26,21 @@ static void json_message_process_token(JSONLexer *lexer, QString *token, JSONTok
|
|||
JSONMessageParser *parser = container_of(lexer, JSONMessageParser, lexer);
|
||||
QDict *dict;
|
||||
|
||||
if (type == JSON_OPERATOR) {
|
||||
switch (qstring_get_str(token)[0]) {
|
||||
case '{':
|
||||
parser->brace_count++;
|
||||
break;
|
||||
case '}':
|
||||
parser->brace_count--;
|
||||
break;
|
||||
case '[':
|
||||
parser->bracket_count++;
|
||||
break;
|
||||
case ']':
|
||||
parser->bracket_count--;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
switch (type) {
|
||||
case JSON_LCURLY:
|
||||
parser->brace_count++;
|
||||
break;
|
||||
case JSON_RCURLY:
|
||||
parser->brace_count--;
|
||||
break;
|
||||
case JSON_LSQUARE:
|
||||
parser->bracket_count++;
|
||||
break;
|
||||
case JSON_RSQUARE:
|
||||
parser->bracket_count--;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
dict = qdict_new();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue