diff options
author | Emmanuele Bassi <ebassi@gnome.org> | 2009-09-22 15:34:18 +0100 |
---|---|---|
committer | Emmanuele Bassi <ebassi@gnome.org> | 2009-09-22 15:34:18 +0100 |
commit | bd604338b25884edbd86cf531505259948484323 (patch) | |
tree | b38225495c3c1c2ef1d2e99861cd78b9407b8df1 /json-glib/json-parser.c | |
parent | f99cf3d3d038eff786f85409f3d04736e2068e74 (diff) | |
download | json-glib-bd604338b25884edbd86cf531505259948484323.tar.gz |
[parser] Return the right expected token
When parsing a value embedded in a Json Object or Array we need to
return the right expected token so that the generated syntax error
will be correct.
Diffstat (limited to 'json-glib/json-parser.c')
-rw-r--r-- | json-glib/json-parser.c | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/json-glib/json-parser.c b/json-glib/json-parser.c index 35747d3..419f695 100644 --- a/json-glib/json-parser.c +++ b/json-glib/json-parser.c @@ -337,6 +337,7 @@ json_parse_value (JsonParser *parser, guint token, JsonNode **node) { + JsonNode *current_node = parser->priv->current_node; gboolean is_negative = FALSE; if (token == '-') @@ -383,8 +384,19 @@ json_parse_value (JsonParser *parser, break; default: - *node = NULL; - return G_TOKEN_RIGHT_BRACE; + { + JsonNodeType cur_type; + + *node = NULL; + + cur_type = json_node_get_node_type (current_node); + if (cur_type == JSON_NODE_ARRAY) + return G_TOKEN_RIGHT_BRACE; + else if (cur_type == JSON_NODE_OBJECT) + return G_TOKEN_RIGHT_CURLY; + else + return G_TOKEN_SYMBOL; + } } return G_TOKEN_NONE; |