Commit f7e0dc2d authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Add a SkipToken() macro which does a ExpectErr() + vcc_NextToken().



git-svn-id: http://www.varnish-cache.org/svn/trunk/varnish-cache@4649 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent c60b4f81
......@@ -309,10 +309,8 @@ vcc_acl_entry(struct tokenlist *tl)
vcc_NextToken(tl);
}
if (ae->para) {
ExpectErr(tl, ')');
vcc_NextToken(tl);
}
if (ae->para)
SkipToken(tl, ')');
if (!vcc_acl_try_netnotation(tl, ae)) {
ERRCHK(tl);
......@@ -504,17 +502,14 @@ vcc_Acl(struct tokenlist *tl)
vcc_AddDef(tl, an, R_ACL);
bprintf(acln, "%.*s", PF(an));
ExpectErr(tl, '{');
vcc_NextToken(tl);
SkipToken(tl, '{');
while (tl->t->tok != '}') {
vcc_acl_entry(tl);
ERRCHK(tl);
ExpectErr(tl, ';');
vcc_NextToken(tl);
SkipToken(tl, ';');
}
ExpectErr(tl, '}');
vcc_NextToken(tl);
SkipToken(tl, '}');
vcc_acl_emit(tl, acln, 0);
}
......@@ -232,8 +232,7 @@ parse_set(struct tokenlist *tl)
Fb(tl, 0, ");\n");
break;
case HASH:
ExpectErr(tl, T_INCR);
vcc_NextToken(tl);
SkipToken(tl, T_INCR);
if (!vcc_StringVal(tl)) {
ERRCHK(tl);
vcc_ExpectedStringval(tl);
......
......@@ -259,8 +259,7 @@ vcc_ParseProbe(struct tokenlist *tl)
"?initial",
NULL);
ExpectErr(tl, '{');
vcc_NextToken(tl);
SkipToken(tl, '{');
window = 0;
threshold = 0;
......@@ -334,8 +333,7 @@ vcc_ParseProbe(struct tokenlist *tl)
return;
}
ExpectErr(tl, ';');
vcc_NextToken(tl);
SkipToken(tl, ';');
}
if (t_threshold != NULL || t_window != NULL) {
......@@ -376,8 +374,7 @@ vcc_ParseProbe(struct tokenlist *tl)
if (status > 0)
Fb(tl, 0, "\t\t.exp_status = %u,\n", status);
Fb(tl, 0, "\t},\n");
ExpectErr(tl, '}');
vcc_NextToken(tl);
SkipToken(tl, '}');
}
/*--------------------------------------------------------------------
......@@ -415,8 +412,7 @@ vcc_ParseHostDef(struct tokenlist *tl, int serial, const char *vgcname)
NULL);
t_first = tl->t;
ExpectErr(tl, '{');
vcc_NextToken(tl);
SkipToken(tl, '{');
vsb = vsb_newauto();
AN(vsb);
......@@ -451,49 +447,42 @@ vcc_ParseHostDef(struct tokenlist *tl, int serial, const char *vgcname)
assert(tl->t->dec != NULL);
t_host = tl->t;
vcc_NextToken(tl);
ExpectErr(tl, ';');
vcc_NextToken(tl);
SkipToken(tl, ';');
} else if (vcc_IdIs(t_field, "port")) {
ExpectErr(tl, CSTR);
assert(tl->t->dec != NULL);
t_port = tl->t;
vcc_NextToken(tl);
ExpectErr(tl, ';');
vcc_NextToken(tl);
SkipToken(tl, ';');
} else if (vcc_IdIs(t_field, "host_header")) {
ExpectErr(tl, CSTR);
assert(tl->t->dec != NULL);
t_hosthdr = tl->t;
vcc_NextToken(tl);
ExpectErr(tl, ';');
vcc_NextToken(tl);
SkipToken(tl, ';');
} else if (vcc_IdIs(t_field, "connect_timeout")) {
Fb(tl, 0, "\t.connect_timeout = ");
vcc_TimeVal(tl);
ERRCHK(tl);
Fb(tl, 0, ",\n");
ExpectErr(tl, ';');
vcc_NextToken(tl);
SkipToken(tl, ';');
} else if (vcc_IdIs(t_field, "first_byte_timeout")) {
Fb(tl, 0, "\t.first_byte_timeout = ");
vcc_TimeVal(tl);
ERRCHK(tl);
Fb(tl, 0, ",\n");
ExpectErr(tl, ';');
vcc_NextToken(tl);
SkipToken(tl, ';');
} else if (vcc_IdIs(t_field, "between_bytes_timeout")) {
Fb(tl, 0, "\t.between_bytes_timeout = ");
vcc_TimeVal(tl);
ERRCHK(tl);
Fb(tl, 0, ",\n");
ExpectErr(tl, ';');
vcc_NextToken(tl);
SkipToken(tl, ';');
} else if (vcc_IdIs(t_field, "max_connections")) {
u = vcc_UintVal(tl);
vcc_NextToken(tl);
ERRCHK(tl);
ExpectErr(tl, ';');
vcc_NextToken(tl);
SkipToken(tl, ';');
Fb(tl, 0, "\t.max_connections = %u,\n", u);
} else if (vcc_IdIs(t_field, "saintmode_threshold")) {
u = vcc_UintVal(tl);
......@@ -510,8 +499,7 @@ vcc_ParseHostDef(struct tokenlist *tl, int serial, const char *vgcname)
vcc_NextToken(tl);
ERRCHK(tl);
saint = u;
ExpectErr(tl, ';');
vcc_NextToken(tl);
SkipToken(tl, ';');
} else if (vcc_IdIs(t_field, "probe")) {
vcc_ParseProbe(tl);
ERRCHK(tl);
......@@ -616,8 +604,7 @@ vcc_ParseBackendHost(struct tokenlist *tl, int serial, char **nm)
}
vcc_AddRef(tl, h->name, R_BACKEND);
vcc_NextToken(tl);
ExpectErr(tl, ';');
vcc_NextToken(tl);
SkipToken(tl, ';');
*nm = h->vgcname;
} else if (tl->t->tok == '{') {
t = tl->t;
......@@ -721,13 +708,10 @@ vcc_ParseDirector(struct tokenlist *tl)
vcc_ErrWhere(tl, tl->t_policy);
return;
}
ExpectErr(tl, '{');
vcc_NextToken(tl);
SkipToken(tl, '{');
dl->func(tl);
if (!tl->err) {
ExpectErr(tl, '}');
vcc_NextToken(tl);
}
if (!tl->err)
SkipToken(tl, '}');
Fi(tl, 0,
"\tVRT_init_dir(cli, VCL_conf.director, \"%.*s\",\n",
PF(tl->t_policy));
......
......@@ -98,14 +98,12 @@ vcc_IsField(struct tokenlist *tl, struct token **t, struct fld_spec *fs)
{
struct token *t_field;
ExpectErr(tl, '.');
vcc_NextToken(tl);
SkipToken(tl, '.');
ExpectErr(tl, ID);
t_field = tl->t;
*t = t_field;
vcc_NextToken(tl);
ExpectErr(tl, '=');
vcc_NextToken(tl);
SkipToken(tl, '=');
for (; fs->name != NULL; fs++) {
if (!vcc_IdIs(t_field, fs->name + 1))
......
......@@ -242,4 +242,7 @@ int vcc_CheckUses(struct tokenlist *tl);
#define ERRCHK(tl) do { if ((tl)->err) return; } while (0)
#define ErrInternal(tl) vcc__ErrInternal(tl, __func__, __LINE__)
#define Expect(a, b) vcc__Expect(a, b, __LINE__)
#define ExpectErr(a, b) do { vcc__Expect(a, b, __LINE__); ERRCHK(a);} while (0)
#define ExpectErr(a, b) \
do { vcc__Expect(a, b, __LINE__); ERRCHK(a);} while (0)
#define SkipToken(a, b) \
do { vcc__Expect(a, b, __LINE__); ERRCHK(a); vcc_NextToken(a); } while (0)
......@@ -70,8 +70,7 @@ vcc_ParseRandomDirector(struct tokenlist *tl)
retries = vcc_UintVal(tl);
ERRCHK(tl);
vcc_NextToken(tl);
ExpectErr(tl, ';');
vcc_NextToken(tl);
SkipToken(tl, ';');
} else {
ErrInternal(tl);
}
......@@ -88,8 +87,7 @@ vcc_ParseRandomDirector(struct tokenlist *tl)
t_be = tl->t;
vcc_ResetFldSpec(mfs);
ExpectErr(tl, '{');
vcc_NextToken(tl);
SkipToken(tl, '{');
Fc(tl, 0, "\t{");
while (tl->t->tok != '}') { /* Member fields */
......@@ -116,8 +114,7 @@ vcc_ParseRandomDirector(struct tokenlist *tl)
}
Fc(tl, 0, "%s .weight = %u", first, u);
vcc_NextToken(tl);
ExpectErr(tl, ';');
vcc_NextToken(tl);
SkipToken(tl, ';');
} else {
ErrInternal(tl);
}
......
......@@ -67,8 +67,7 @@ vcc_ParseRoundRobinDirector(struct tokenlist *tl)
t_be = tl->t;
vcc_ResetFldSpec(fs);
ExpectErr(tl, '{');
vcc_NextToken(tl);
SkipToken(tl, '{');
Fc(tl, 0, "\t{");
while (tl->t->tok != '}') { /* Member fields */
......
......@@ -344,8 +344,7 @@ Cond_2(struct tokenlist *tl)
if (tl->t->tok == '(') {
vcc_NextToken(tl);
Cond_0(tl);
ExpectErr(tl, ')');
vcc_NextToken(tl);
SkipToken(tl, ')');
} else if (tl->t->tok == VAR) {
vp = vcc_FindVar(tl, tl->t, vcc_vars);
ERRCHK(tl);
......@@ -412,14 +411,12 @@ static void
Conditional(struct tokenlist *tl)
{
ExpectErr(tl, '(');
vcc_NextToken(tl);
SkipToken(tl, '(');
Fb(tl, 1, "(\n");
L(tl, Cond_0(tl));
ERRCHK(tl);
Fb(tl, 1, ")\n");
ExpectErr(tl, ')');
vcc_NextToken(tl);
SkipToken(tl, ')');
}
/*--------------------------------------------------------------------*/
......@@ -428,9 +425,8 @@ static void
IfStmt(struct tokenlist *tl)
{
ExpectErr(tl, T_IF);
SkipToken(tl, T_IF);
Fb(tl, 1, "if \n");
vcc_NextToken(tl);
L(tl, Conditional(tl));
ERRCHK(tl);
L(tl, Compound(tl));
......@@ -469,11 +465,10 @@ Compound(struct tokenlist *tl)
{
int i;
ExpectErr(tl, '{');
SkipToken(tl, '{');
Fb(tl, 1, "{\n");
tl->indent += INDENT;
C(tl, ";");
vcc_NextToken(tl);
while (1) {
ERRCHK(tl);
switch (tl->t->tok) {
......@@ -503,8 +498,7 @@ Compound(struct tokenlist *tl)
i = vcc_ParseAction(tl);
ERRCHK(tl);
if (i) {
ExpectErr(tl, ';');
vcc_NextToken(tl);
SkipToken(tl, ';');
break;
}
/* FALLTHROUGH */
......
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