Skip to content
Permalink
Browse files

Turn newline into the end of a VSL query

Instead of treating it as a mere whitespace separator. As a result the
lexer output looks like this:

    TOK_1, ..., TOK_N, EOI[, TOK_1, ..., TOK_N, EOI[...]]

At this point though, only the first series of tokens is considered, in
a single query mode that was already what we've had so far. It will also
be the parser's job to ignore consecutive EOI tokens for "empty" queries.
  • Loading branch information...
Dridi committed May 16, 2019
1 parent 5ce86e7 commit 406ec859a6275086166a8f4dd4ad0028a062f2ca
Showing with 11 additions and 2 deletions.
  1. +11 −2 lib/libvarnishapi/vxp_lexer.c
@@ -103,8 +103,8 @@ vxp_Lexer(struct vxp *vxp)

for (p = vxp->b; p < vxp->e; ) {

/* Skip any whitespace */
if (isspace(*p)) {
/* Skip any space or tab */
if (isblank(*p)) {
p++;
continue;
}
@@ -126,6 +126,8 @@ vxp_Lexer(struct vxp *vxp)
q++;
if (q == vxp->e)
break;
} else if (*q == '\n') {
break;
} else if (*q == quote) {
q++;
quote = '\0';
@@ -157,6 +159,13 @@ vxp_Lexer(struct vxp *vxp)
continue;
}

/* On to the next query */
if (*p == '\n') {
vxp_add_token(vxp, EOI, p, p + 1);
p++;
continue;
}

/* Error */
vxp_add_token(vxp, EOI, p, p + 1);
VSB_printf(vxp->sb, "Syntax error ");

0 comments on commit 406ec85

Please sign in to comment.
You can’t perform that action at this time.