Commit 307d94fa authored by Martin Blix Grydeland's avatar Martin Blix Grydeland

Make ',' a token when lexing the query expressions

Teach the parser how to read a comma separated list of tag globs,
rather than having the ',' character be recognised as valid for
barewords.
parent 80240d77
...@@ -63,7 +63,7 @@ tokens = { ...@@ -63,7 +63,7 @@ tokens = {
"T_NOT": "not", "T_NOT": "not",
# Miscellaneous # Miscellaneous
None: "<>~[]{}():", None: "<>~[]{}():,",
# These have handwritten recognizers # These have handwritten recognizers
"VAL": None, "VAL": None,
......
...@@ -36,7 +36,7 @@ ...@@ -36,7 +36,7 @@
#include "vxp_tokens.h" #include "vxp_tokens.h"
#define isword(c) (isalpha(c) || isdigit(c) || (c) == '_' || (c) == '-' || \ #define isword(c) (isalpha(c) || isdigit(c) || (c) == '_' || (c) == '-' || \
(c) == '.' || (c) == '*' || (c) == ',') (c) == '.' || (c) == '*')
#define PF(t) (int)((t)->e - (t)->b), (t)->b #define PF(t) (int)((t)->e - (t)->b), (t)->b
......
...@@ -57,33 +57,40 @@ vxp_expr_lhs(struct vxp *vxp, struct vex_lhs **plhs) ...@@ -57,33 +57,40 @@ vxp_expr_lhs(struct vxp *vxp, struct vex_lhs **plhs)
AN(plhs); AN(plhs);
AZ(*plhs); AZ(*plhs);
if (vxp->t->tok != VAL) {
VSB_printf(vxp->sb, "Expected VSL taglist got '%.*s' ",
PF(vxp->t));
vxp_ErrWhere(vxp, vxp->t, -1);
return;
}
ALLOC_OBJ(*plhs, VEX_LHS_MAGIC); ALLOC_OBJ(*plhs, VEX_LHS_MAGIC);
AN(*plhs); AN(*plhs);
(*plhs)->tags = vbit_init(SLT__MAX); (*plhs)->tags = vbit_init(SLT__MAX);
i = VSL_List2Tags(vxp->t->dec, -1, vsl_vbm_bitset, (*plhs)->tags); while (1) {
if (i == -1) { /* The tags this expression applies to */
VSB_printf(vxp->sb, "Taglist matches zero tags "); if (vxp->t->tok != VAL) {
vxp_ErrWhere(vxp, vxp->t, -1); VSB_printf(vxp->sb, "Expected VSL tag name got '%.*s' ",
return; PF(vxp->t));
} vxp_ErrWhere(vxp, vxp->t, -1);
if (i == -2) { return;
VSB_printf(vxp->sb, "Taglist is ambiguous "); }
vxp_ErrWhere(vxp, vxp->t, -1); i = VSL_Glob2Tags(vxp->t->dec, -1, vsl_vbm_bitset,
return; (*plhs)->tags);
} if (i == -1) {
if (i == -3) { VSB_printf(vxp->sb, "Tag name matches zero tags ");
VSB_printf(vxp->sb, "Syntax error in taglist "); vxp_ErrWhere(vxp, vxp->t, -1);
vxp_ErrWhere(vxp, vxp->t, -1); return;
return; }
if (i == -2) {
VSB_printf(vxp->sb, "Tag name is ambiguous ");
vxp_ErrWhere(vxp, vxp->t, -1);
return;
}
if (i == -3) {
VSB_printf(vxp->sb, "Syntax error in tag name ");
vxp_ErrWhere(vxp, vxp->t, -1);
return;
}
assert(i > 0);
vxp_NextToken(vxp);
if (vxp->t->tok != ',')
break;
vxp_NextToken(vxp);
} }
assert(i > 0);
vxp_NextToken(vxp);
if (vxp->t->tok == ':') { if (vxp->t->tok == ':') {
/* Record prefix */ /* Record prefix */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment