[master] cc850c4 Don't assume symbols are a single token (2/many)
Poul-Henning Kamp
phk at FreeBSD.org
Wed Jan 31 10:50:10 UTC 2018
commit cc850c4c382f6159f09f225606c9b217f615bbd2
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Wed Jan 31 09:39:45 2018 +0000
Don't assume symbols are a single token (2/many)
diff --git a/lib/libvcc/vcc_action.c b/lib/libvcc/vcc_action.c
index 61d4264..e248fff 100644
--- a/lib/libvcc/vcc_action.c
+++ b/lib/libvcc/vcc_action.c
@@ -40,10 +40,10 @@
/*--------------------------------------------------------------------*/
static void v_matchproto_(sym_act_f)
-parse_call(struct vcc *tl, struct symbol *sym)
+vcc_act_call(struct vcc *tl, struct token *t, struct symbol *sym)
{
- vcc_NextToken(tl);
+ (void)t;
ExpectErr(tl, ID);
sym = VCC_SymbolGet(tl, SYM_SUB, SYMTAB_CREATE, XREF_REF);
AN(sym);
@@ -86,13 +86,12 @@ static const struct arith {
/*--------------------------------------------------------------------*/
static void v_matchproto_(sym_act_f)
-parse_set(struct vcc *tl, struct symbol *sym)
+vcc_act_set(struct vcc *tl, struct token *t, struct symbol *sym)
{
const struct arith *ap;
- const struct token *t;
vcc_type_t fmt;
- vcc_NextToken(tl);
+ (void)t;
ExpectErr(tl, ID);
t = tl->t;
sym = VCC_SymbolGet(tl, SYM_VAR, "Unknown variable", XREF_NONE);
@@ -142,12 +141,10 @@ parse_set(struct vcc *tl, struct symbol *sym)
/*--------------------------------------------------------------------*/
static void v_matchproto_(sym_act_f)
-parse_unset(struct vcc *tl, struct symbol *sym)
+vcc_act_unset(struct vcc *tl, struct token *t, struct symbol *sym)
{
- const struct token *t;
/* XXX: Wrong, should use VCC_Expr(HEADER) */
- vcc_NextToken(tl);
ExpectErr(tl, ID);
t = tl->t;
sym = VCC_SymbolGet(tl, SYM_VAR, "Unknown variable", XREF_NONE);
@@ -167,11 +164,11 @@ parse_unset(struct vcc *tl, struct symbol *sym)
/*--------------------------------------------------------------------*/
static void v_matchproto_(sym_act_f)
-parse_ban(struct vcc *tl, struct symbol *sym)
+vcc_act_ban(struct vcc *tl, struct token *t, struct symbol *sym)
{
+ (void)t;
(void)sym;
- vcc_NextToken(tl);
ExpectErr(tl, '(');
vcc_NextToken(tl);
@@ -190,11 +187,11 @@ parse_ban(struct vcc *tl, struct symbol *sym)
/*--------------------------------------------------------------------*/
static void v_matchproto_(sym_act_f)
-parse_hash_data(struct vcc *tl, struct symbol *sym)
+vcc_act_hash_data(struct vcc *tl, struct token *t, struct symbol *sym)
{
+ (void)t;
(void)sym;
- vcc_NextToken(tl);
SkipToken(tl, '(');
Fb(tl, 1, "VRT_hashdata(ctx,\n ");
@@ -208,7 +205,7 @@ parse_hash_data(struct vcc *tl, struct symbol *sym)
/*--------------------------------------------------------------------*/
static void
-parse_return_pass(struct vcc *tl)
+vcc_act_return_pass(struct vcc *tl)
{
ExpectErr(tl, '(');
@@ -224,7 +221,7 @@ parse_return_pass(struct vcc *tl)
/*--------------------------------------------------------------------*/
static void
-parse_return_synth(struct vcc *tl)
+vcc_act_return_synth(struct vcc *tl)
{
ExpectErr(tl, '(');
@@ -249,7 +246,7 @@ parse_return_synth(struct vcc *tl)
/*--------------------------------------------------------------------*/
static void
-parse_return_vcl(struct vcc *tl)
+vcc_act_return_vcl(struct vcc *tl)
{
struct symbol *sym;
struct inifin *p;
@@ -288,13 +285,13 @@ parse_return_vcl(struct vcc *tl)
/*--------------------------------------------------------------------*/
static void v_matchproto_(sym_act_f)
-parse_return(struct vcc *tl, struct symbol *sym)
+vcc_act_return(struct vcc *tl, struct token *t, struct symbol *sym)
{
unsigned hand;
const char *h;
+ (void)t;
(void)sym;
- vcc_NextToken(tl);
AN(tl->curproc);
if (tl->t->tok == ';' && tl->curproc->method == NULL) {
SkipToken(tl, ';');
@@ -323,11 +320,11 @@ parse_return(struct vcc *tl, struct symbol *sym)
vcc_NextToken(tl);
if (tl->t->tok == '(') {
if (hand == VCL_RET_SYNTH)
- parse_return_synth(tl);
+ vcc_act_return_synth(tl);
else if (hand == VCL_RET_VCL)
- parse_return_vcl(tl);
+ vcc_act_return_vcl(tl);
else if (hand == VCL_RET_PASS)
- parse_return_pass(tl);
+ vcc_act_return_pass(tl);
else {
VSB_printf(tl->sb, "Arguments not allowed.\n");
vcc_ErrWhere(tl, tl->t);
@@ -347,10 +344,10 @@ parse_return(struct vcc *tl, struct symbol *sym)
/*--------------------------------------------------------------------*/
static void v_matchproto_(sym_act_f)
-parse_synthetic(struct vcc *tl, struct symbol *sym)
+vcc_act_synthetic(struct vcc *tl, struct token *t, struct symbol *sym)
{
- vcc_NextToken(tl);
+ (void)t;
(void)sym;
ExpectErr(tl, '(');
ERRCHK(tl);
@@ -382,16 +379,16 @@ vcc_Action_Init(struct vcc *tl)
{
struct symbol *sym;
- ACT(ban, parse_ban, 0);
- ACT(call, parse_call, 0);
- ACT(hash_data, parse_hash_data,
+ ACT(ban, vcc_act_ban, 0);
+ ACT(call, vcc_act_call, 0);
+ ACT(hash_data, vcc_act_hash_data,
VCL_MET_HASH);
- ACT(if, vcc_ParseIf, 0);
- ACT(new, vcc_ParseNew,
+ ACT(if, vcc_Act_If, 0);
+ ACT(new, vcc_Act_New,
VCL_MET_INIT);
- ACT(return, parse_return, 0);
- ACT(set, parse_set, 0);
- ACT(synthetic, parse_synthetic,
+ ACT(return, vcc_act_return, 0);
+ ACT(set, vcc_act_set, 0);
+ ACT(synthetic, vcc_act_synthetic,
VCL_MET_SYNTH | VCL_MET_BACKEND_ERROR);
- ACT(unset, parse_unset, 0);
+ ACT(unset, vcc_act_unset, 0);
}
diff --git a/lib/libvcc/vcc_compile.h b/lib/libvcc/vcc_compile.h
index a572847..0bfed2a 100644
--- a/lib/libvcc/vcc_compile.h
+++ b/lib/libvcc/vcc_compile.h
@@ -108,7 +108,7 @@ typedef void sym_expr_t(struct vcc *tl, struct expr **,
struct token *, struct symbol *sym, vcc_type_t);
typedef void sym_wildcard_t(struct vcc *, struct symbol *, struct symbol *);
-typedef void sym_act_f(struct vcc *, struct symbol *);
+typedef void sym_act_f(struct vcc *, struct token *, struct symbol *);
struct symbol {
unsigned magic;
@@ -294,7 +294,7 @@ void vcc_Var_Init(struct vcc *);
/* vcc_parse.c */
void vcc_Parse(struct vcc *tl);
-sym_act_f vcc_ParseIf;
+sym_act_f vcc_Act_If;
/* vcc_utils.c */
const char *vcc_regexp(struct vcc *tl);
@@ -350,7 +350,7 @@ sym_wildcard_t vcc_Var_Wildcard;
/* vcc_vmod.c */
void vcc_ParseImport(struct vcc *tl);
-sym_act_f vcc_ParseNew;
+sym_act_f vcc_Act_New;
/* vcc_xref.c */
void vcc_AddRef(struct vcc *, struct symbol *);
diff --git a/lib/libvcc/vcc_expr.c b/lib/libvcc/vcc_expr.c
index 5cfc76c..f874d58 100644
--- a/lib/libvcc/vcc_expr.c
+++ b/lib/libvcc/vcc_expr.c
@@ -1264,22 +1264,19 @@ vcc_Expr(struct vcc *tl, vcc_type_t fmt)
*/
void v_matchproto_(sym_act_f)
-vcc_ParseCall(struct vcc *tl, struct symbol *sym)
+vcc_ParseCall(struct vcc *tl, struct token *t, struct symbol *sym)
{
struct expr *e;
- struct token *t1;
- t1 = tl->t;
e = NULL;
- vcc_NextToken(tl);
- vcc_Eval_SymFunc(tl, &e, t1, sym, VOID);
+ vcc_Eval_SymFunc(tl, &e, t, sym, VOID);
if (!tl->err) {
vcc_expr_fmt(tl->fb, tl->indent, e);
SkipToken(tl, ';');
VSB_cat(tl->fb, ";\n");
- } else if (t1 != tl->t) {
- vcc_ErrWhere2(tl, t1, tl->t);
+ } else if (t != tl->t) {
+ vcc_ErrWhere2(tl, t, tl->t);
}
vcc_delete_expr(e);
}
diff --git a/lib/libvcc/vcc_parse.c b/lib/libvcc/vcc_parse.c
index 133024c..a64e143 100644
--- a/lib/libvcc/vcc_parse.c
+++ b/lib/libvcc/vcc_parse.c
@@ -80,11 +80,11 @@ vcc_Conditional(struct vcc *tl)
*/
void v_matchproto_(sym_act_f)
-vcc_ParseIf(struct vcc *tl, struct symbol *sym)
+vcc_Act_If(struct vcc *tl, struct token *t, struct symbol *sym)
{
+ (void)t;
(void)sym;
- SkipToken(tl, ID);
Fb(tl, 1, "if ");
vcc_Conditional(tl);
ERRCHK(tl);
@@ -186,7 +186,8 @@ vcc_Compound(struct vcc *tl)
vcc_AddUses(tl, t, NULL,
sym->action_mask,
"Not a valid action");
- sym->action(tl, sym);
+ vcc_NextToken(tl);
+ sym->action(tl, t, sym);
break;
}
/* FALLTHROUGH */
diff --git a/lib/libvcc/vcc_vmod.c b/lib/libvcc/vcc_vmod.c
index 416ac1d..e0c0fdd 100644
--- a/lib/libvcc/vcc_vmod.c
+++ b/lib/libvcc/vcc_vmod.c
@@ -267,17 +267,15 @@ vcc_ParseImport(struct vcc *tl)
}
void v_matchproto_(sym_act_f)
-vcc_ParseNew(struct vcc *tl, struct symbol *sym)
+vcc_Act_New(struct vcc *tl, struct token *t, struct symbol *sym)
{
struct symbol *sy1, *sy2, *sy3;
struct inifin *ifp;
- struct token *t;
const char *p, *s_obj;
char buf1[128];
char buf2[128];
(void)sym;
- vcc_NextToken(tl);
ExpectErr(tl, ID);
vcc_ExpectVid(tl, "VCL object");
ERRCHK(tl);
More information about the varnish-commit
mailing list