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

I set out to straighten out a number of hacks and inconsistencies in the

string spec we pass to the VCC, to make future VCL/VMOD/VCC work easier.

Instead I ended up rewriting the entire .VCC file compiler, which was
so much easier than the first time, because now I know what it should do.

There should be no incompatibilities, but as always: Please test and report.
parent 4fadbca2
......@@ -196,23 +196,22 @@ parse_new(struct vcc *tl)
/*lint -save -e448 */
/* Split the first three args */
p = sy2->args;
s_obj = p;
p += strlen(p) + 1;
s_init = p;
/*
* Check for the end marked (\0\0) followed by s(truct) to avoid
* matching an ENUM half-way through and generating illegal C code.
*/
while (p[0] != '\0' || p[1] != '\0' || p[2] != 's')
p++;
p += 2;
AZ(strncmp(p, "struct vmod_", 12));
s_struct = p;
p += strlen(p) + 1;
s_fini = p + strlen(p) + 1;
while (p[0] != '\0' || p[1] != '\0')
s_init = p;
while (p[0] != '\0' || p[1] != '\0' || p[2] != '\0')
p++;
p += 3;
s_fini = p;
while (p[0] != '\0' || p[1] != '\0' || p[2] != '\0')
p++;
p += 2;
p += 3;
Fh(tl, 0, "static %s *vo_%s;\n\n", s_struct, sy1->name);
......@@ -238,20 +237,9 @@ parse_new(struct vcc *tl)
sy3->args = p;
sy3->extra = TlDup(tl, buf1);
while (p[0] != '\0' || p[1] != '\0') {
if (!memcmp(p, "ENUM\0", 5)) {
/* XXX: Special case for ENUM that has
it's own \0\0 end marker. Not exactly
elegant, we should consider
alternatives here. Maybe runlength
encode the entire block? */
p += strlen(p) + 1;
while (p[0] != '\0' || p[1] != '\0')
p++;
}
while (p[0] != '\0' || p[1] != '\0' || p[2] != '\0')
p++;
}
p += 2;
p += 3;
}
sy1->def_e = tl->t;
/*lint -restore */
......
......@@ -662,20 +662,23 @@ vcc_func(struct vcc *tl, struct expr **e, const char *cfunc,
p += strlen(p) + 1;
continue;
}
if (fa->type == ENUM) {
fa->enum_bits = p;
while (*p != '\0')
if (*p == '\1') {
fa->enum_bits = ++p;
while (*p != '\1')
p += strlen(p) + 1;
p += strlen(p) + 1;
p++;
assert(*p == '\0');
p++;
}
if (*p == '\1') {
if (*p == '\2') {
fa->name = p + 1;
p = strchr(p, '\0') + 1;
if (*p == '\2') {
fa->val = p + 1;
p = strchr(p, '\0') + 1;
}
p += strlen(p) + 1;
}
if (*p == '\3') {
fa->val = p + 1;
p += strlen(p) + 1;
}
assert(*p == 0 || *p > ' ');
}
VTAILQ_FOREACH(fa, &head, list) {
......
......@@ -235,7 +235,8 @@ vcc_ParseImport(struct vcc *tl)
"\t\t VCL_EVENT_DISCARD);\n", p, PF(mod));
VSB_printf(ifp->event, "\t%s(ctx, &vmod_priv_%.*s, ev)",
p, PF(mod));
} else {
} else if (!strcmp(p, "$FUNC")) {
p += strlen(p) + 1;
sym = VCC_AddSymbolStr(tl, p, SYM_FUNC);
ERRCHK(tl);
AN(sym);
......@@ -245,6 +246,10 @@ vcc_ParseImport(struct vcc *tl)
p += strlen(p) + 1;
sym->args = p;
sym->fmt = VCC_arg_type(&p);
} else {
VSB_printf(tl->sb, "Internal spec error (%s)\n", p);
vcc_ErrWhere(tl, mod);
return;
}
}
......
This diff is collapsed.
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