diff options
author | Florian Westphal <fw@strlen.de> | 2021-06-02 20:38:46 +0200 |
---|---|---|
committer | Florian Westphal <fw@strlen.de> | 2021-06-02 23:46:11 +0200 |
commit | 5c2c6b09286048b39d51964391ef2aecfd247512 (patch) | |
tree | 03295d9dc27ec95a40a8ceb1012e69c356058732 /src | |
parent | 4359cb82833a6907f9ee9803be270db89ceaf758 (diff) |
json: catchall element support
Treat '*' as catchall element, not as a symbol.
Also add missing json test cases for wildcard set support.
Signed-off-by: Florian Westphal <fw@strlen.de>
Diffstat (limited to 'src')
-rw-r--r-- | src/expression.c | 1 | ||||
-rw-r--r-- | src/json.c | 5 | ||||
-rw-r--r-- | src/parser_json.c | 11 |
3 files changed, 7 insertions, 10 deletions
diff --git a/src/expression.c b/src/expression.c index c9133363..c6be0001 100644 --- a/src/expression.c +++ b/src/expression.c @@ -1341,6 +1341,7 @@ static const struct expr_ops set_elem_catchall_expr_ops = { .type = EXPR_SET_ELEM_CATCHALL, .name = "catch-all set element", .print = set_elem_catchall_expr_print, + .json = set_elem_catchall_expr_json, }; struct expr *set_elem_catchall_expr_alloc(const struct location *loc) @@ -889,6 +889,11 @@ static json_t *symbolic_constant_json(const struct symbol_table *tbl, return json_string(s->identifier); } +json_t *set_elem_catchall_expr_json(const struct expr *expr, struct output_ctx *octx) +{ + return json_string("*"); +} + static json_t *datatype_json(const struct expr *expr, struct output_ctx *octx) { const struct datatype *dtype = expr->dtype; diff --git a/src/parser_json.c b/src/parser_json.c index 2e791807..e6a0233a 100644 --- a/src/parser_json.c +++ b/src/parser_json.c @@ -315,15 +315,6 @@ static struct expr *json_parse_constant(struct json_ctx *ctx, const char *name) return NULL; } -static struct expr *wildcard_expr_alloc(void) -{ - struct expr *expr; - - expr = constant_expr_alloc(int_loc, &integer_type, - BYTEORDER_HOST_ENDIAN, 0, NULL); - return prefix_expr_alloc(int_loc, expr, 0); -} - /* this is a combination of symbol_expr, integer_expr, boolean_expr ... */ static struct expr *json_parse_immediate(struct json_ctx *ctx, json_t *root) { @@ -338,7 +329,7 @@ static struct expr *json_parse_immediate(struct json_ctx *ctx, json_t *root) symtype = SYMBOL_SET; str++; } else if (str[0] == '*' && str[1] == '\0') { - return wildcard_expr_alloc(); + return set_elem_catchall_expr_alloc(int_loc); } else if (is_keyword(str)) { return symbol_expr_alloc(int_loc, SYMBOL_VALUE, NULL, str); |