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

Introduce a "reserved" symboltype and wrangle an error message or two.

parent b072bb7e
......@@ -66,7 +66,7 @@ varnish v1 -cliok "vcl.discard vcl2"
varnish v1 -cliok "vcl.list"
varnish v1 -cliok "debug.vmod"
varnish v1 -errvcl {Symbol type (vmod) can not be used in expression.} {
varnish v1 -errvcl {Symbol 'std' type (vmod) can not be used in expression.} {
import std;
sub vcl_recv {
......
......@@ -20,7 +20,7 @@ varnish v1 -errvcl {Found: '0' at} { 0; }
# VCLs tokenstream.
# XXX: A better error message would be desirable
varnish v1 -errvcl {Symbol not found} " sub vcl_recv { { } { "
varnish v1 -errvcl {Symbol cannot be used here} " sub vcl_recv { { } { "
varnish v1 -errvcl {Comparison of different types: INT '!=' STRING} {
sub vcl_recv {
......@@ -31,7 +31,7 @@ varnish v1 -errvcl {Comparison of different types: INT '!=' STRING} {
}
}
varnish v1 -errvcl {Symbol type (sub) can not be used in expression.} {
varnish v1 -errvcl {Symbol 'vcl_recv' type (sub) can not be used in expression.} {
sub vcl_recv {
set req.http.foo = vcl_recv;
}
......@@ -307,6 +307,11 @@ varnish v1 -errvcl {'||' must be preceeded by BOOL, found REAL.} {
sub vcl_recv { if (std.random(0,1) || 0) { } }
}
varnish v1 -errvcl {Symbol 'acl' has wrong type (reserved):} {
import std;
sub vcl_recv { call acl; }
}
server s1 {
rxreq
txresp -hdr "bar: X"
......
......@@ -30,6 +30,7 @@
/*lint -save -e525 -e539 */
VCC_KIND(NONE, none)
VCC_KIND(RESERVED, reserved)
VCC_KIND(ACL, acl)
VCC_KIND(ACTION, action)
VCC_KIND(BACKEND, backend)
......
......@@ -46,11 +46,12 @@ vcc_act_call(struct vcc *tl, struct token *t, struct symbol *sym)
(void)t;
ExpectErr(tl, ID);
sym = VCC_SymbolGet(tl, SYM_SUB, SYMTAB_CREATE, XREF_REF);
AN(sym);
vcc_AddCall(tl, sym);
VCC_GlobalSymbol(sym, SUB, "VGC_function");
Fb(tl, 1, "%s(ctx);\n", sym->rname);
SkipToken(tl, ';');
if (sym != NULL) {
vcc_AddCall(tl, sym);
VCC_GlobalSymbol(sym, SUB, "VGC_function");
Fb(tl, 1, "%s(ctx);\n", sym->rname);
SkipToken(tl, ';');
}
}
/*--------------------------------------------------------------------*/
......
......@@ -713,9 +713,9 @@ vcc_expr4(struct vcc *tl, struct expr **e, vcc_type_t fmt)
return;
}
VSB_printf(tl->sb,
"Symbol type (%s) can not be used in expression.\n",
sym->kind->name);
vcc_ErrWhere(tl, tl->t);
"Symbol '%.*s' type (%s) can not be used in expression.\n",
PF(t), sym->kind->name);
vcc_ErrWhere(tl, t);
if (sym->def_b != NULL) {
VSB_printf(tl->sb, "That symbol was defined here:\n");
vcc_ErrWhere(tl, sym->def_b);
......
......@@ -434,5 +434,5 @@ vcc_Parse_Init(struct vcc *tl)
struct toplev *tp;
for (tp = toplev; tp->name != NULL; tp++)
AN(VCC_MkSym(tl, tp->name, SYM_NONE, tp->vcllo, tp->vclhi));
AN(VCC_MkSym(tl, tp->name, SYM_RESERVED, tp->vcllo, tp->vclhi));
}
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