[master] 307d94f Make ',' a token when lexing the query expressions
Martin Blix Grydeland
martin at varnish-cache.org
Tue Oct 1 14:48:19 CEST 2013
commit 307d94faec14b92c9c8ef27a688899bb3feaaeed
Author: Martin Blix Grydeland <martin at varnish-software.com>
Date: Mon Sep 30 12:58:57 2013 +0200
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.
diff --git a/lib/libvarnishapi/generate.py b/lib/libvarnishapi/generate.py
index 1ef6d93..87bd044 100755
--- a/lib/libvarnishapi/generate.py
+++ b/lib/libvarnishapi/generate.py
@@ -63,7 +63,7 @@ tokens = {
"T_NOT": "not",
# Miscellaneous
- None: "<>~[]{}():",
+ None: "<>~[]{}():,",
# These have handwritten recognizers
"VAL": None,
diff --git a/lib/libvarnishapi/vxp.h b/lib/libvarnishapi/vxp.h
index 9a285b5..c0b979f 100644
--- a/lib/libvarnishapi/vxp.h
+++ b/lib/libvarnishapi/vxp.h
@@ -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
diff --git a/lib/libvarnishapi/vxp_parse.c b/lib/libvarnishapi/vxp_parse.c
index ec82b96..bdf64c5 100644
--- a/lib/libvarnishapi/vxp_parse.c
+++ b/lib/libvarnishapi/vxp_parse.c
@@ -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 */
More information about the varnish-commit
mailing list