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

Improve VCC error messages.

Fixes: 	#2696
parent 13d519c6
......@@ -83,7 +83,7 @@ varnish v1 -errvcl {Unknown token '<<' when looking for STRING} {
sub vcl_recv { ban (<<); }
}
varnish v1 -errvcl {Expected an action, 'if', '{' or '}'} {
varnish v1 -errvcl {Symbol not found} {
backend b { .host = "127.0.0.1"; }
sub vcl_recv { ban_hash (if); }
}
......@@ -93,7 +93,7 @@ varnish v1 -vcl {
sub vcl_recv { ban ("req.url ~ foo"); }
}
varnish v1 -errvcl {Expected an action, 'if', '{' or '}'} {
varnish v1 -errvcl "Symbol not found" {
backend b { .host = "127.0.0.1"; }
sub vcl_recv { kluf ; }
}
......
......@@ -20,7 +20,7 @@ varnish v1 -errvcl {Found: '0' at} { 0; }
# VCLs tokenstream.
# XXX: A better error message would be desirable
varnish v1 -errvcl {Expected an action, 'if', } " sub vcl_recv { { } { "
varnish v1 -errvcl {Symbol not found} " sub vcl_recv { { } { "
varnish v1 -errvcl {Comparison of different types: INT '!=' STRING} {
sub vcl_recv {
......
......@@ -12,13 +12,13 @@ varnish v1 -errvcl {Variable is read only.} {
sub vcl_recv { call foo ; }
}
varnish v1 -errvcl "Expected an action, 'if', '{' or '}'" {
varnish v1 -errvcl "Symbol not found" {
backend b { .host = "127.0.0.1"; }
sub vcl_recv { discard; }
}
varnish v1 -errvcl "Expected an action, 'if', '{' or '}'" {
varnish v1 -errvcl "Symbol not found" {
backend b { .host = "127.0.0.1"; }
sub foo { discard; }
......
......@@ -160,7 +160,7 @@ vcc_Compound(struct vcc *tl)
vcc_NextToken(tl);
tl->indent -= INDENT;
Fb(tl, 1, "}\n");
return;
break;
case CSRC:
if (tl->allow_inline_c) {
Fb(tl, 1, "%.*s\n",
......@@ -177,25 +177,31 @@ vcc_Compound(struct vcc *tl)
VSB_printf(tl->sb,
"End of input while in compound statement\n");
tl->err = 1;
return;
break;
case ID:
sym = VCC_SymbolGet(tl, SYM_NONE, SYMTAB_NOERR,
XREF_NONE);
if (sym != NULL && sym->action != NULL) {
if (sym == NULL) {
VSB_printf(tl->sb, "Symbol not found.\n");
vcc_ErrWhere(tl, tl->t);
} else if (sym->action == NULL) {
VSB_printf(tl->sb,
"Symbol cannot be used here.\n");
vcc_ErrWhere(tl, tl->t);
} else {
if (sym->action_mask != 0)
vcc_AddUses(tl, t, NULL,
sym->action_mask,
"Not a valid action");
sym->action(tl, t, sym);
break;
}
/* FALLTHROUGH */
break;
default:
/* We deliberately do not mention inline C */
VSB_printf(tl->sb,
"Expected an action, 'if', '{' or '}'\n");
vcc_ErrWhere(tl, tl->t);
return;
break;
}
Fb(tl, 1, "if (*ctx->handling) return;\n");
}
......
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