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 = {
"T_NOT": "not",
# Miscellaneous
None: "<>~[]{}():",
None: "<>~[]{}():,",
# These have handwritten recognizers
"VAL": None,
......
......@@ -36,7 +36,7 @@
#include "vxp_tokens.h"
#define isword(c) (isalpha(c) || isdigit(c) || (c) == '_' || (c) == '-' || \
(c) == '.' || (c) == '*' || (c) == ',')
(c) == '.' || (c) == '*')
#define PF(t) (int)((t)->e - (t)->b), (t)->b
......
......@@ -57,33 +57,40 @@ vxp_expr_lhs(struct vxp *vxp, struct vex_lhs **plhs)
AN(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);
AN(*plhs);
(*plhs)->tags = vbit_init(SLT__MAX);
i = VSL_List2Tags(vxp->t->dec, -1, vsl_vbm_bitset, (*plhs)->tags);
if (i == -1) {
VSB_printf(vxp->sb, "Taglist matches zero tags ");
vxp_ErrWhere(vxp, vxp->t, -1);
return;
}
if (i == -2) {
VSB_printf(vxp->sb, "Taglist is ambiguous ");
vxp_ErrWhere(vxp, vxp->t, -1);
return;
}
if (i == -3) {
VSB_printf(vxp->sb, "Syntax error in taglist ");
vxp_ErrWhere(vxp, vxp->t, -1);
return;
while (1) {
/* The tags this expression applies to */
if (vxp->t->tok != VAL) {
VSB_printf(vxp->sb, "Expected VSL tag name got '%.*s' ",
PF(vxp->t));
vxp_ErrWhere(vxp, vxp->t, -1);
return;
}
i = VSL_Glob2Tags(vxp->t->dec, -1, vsl_vbm_bitset,
(*plhs)->tags);
if (i == -1) {
VSB_printf(vxp->sb, "Tag name matches zero tags ");
vxp_ErrWhere(vxp, vxp->t, -1);
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 == ':') {
/* 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