]> err.no Git - varnish/commitdiff
Remove unused METHOD token.
authorphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Sun, 1 Apr 2007 15:33:56 +0000 (15:33 +0000)
committerphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Sun, 1 Apr 2007 15:33:56 +0000 (15:33 +0000)
Improve error handling for unterminated /* ... */ comments.

Add undocumented and unsupported facility for inline C source code
in VCL programs.  The syntax is "C{ getpid(); }C" and you are on
your own if you use this.

git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@1301 d4fa192b-c00b-0410-8231-f00ffab90ce4

varnish-cache/lib/libvcl/vcc_fixed_token.c
varnish-cache/lib/libvcl/vcc_gen_fixed_token.tcl
varnish-cache/lib/libvcl/vcc_parse.c
varnish-cache/lib/libvcl/vcc_token.c
varnish-cache/lib/libvcl/vcc_token_defs.h
varnish-cache/lib/libvcl/vcc_xref.c

index 864ddc9e7a05ff7f904323eb7bb2bba8de3d673b..69e8a7782129087990292080c9b5c2069efd4e05 100644 (file)
@@ -268,10 +268,10 @@ vcl_init_tnames(void)
        vcl_tnames['~'] = "'~'";
        vcl_tnames[';'] = "';'";
        vcl_tnames[CNUM] = "CNUM";
+       vcl_tnames[CSRC] = "CSRC";
        vcl_tnames[CSTR] = "CSTR";
        vcl_tnames[EOI] = "EOI";
        vcl_tnames[ID] = "ID";
-       vcl_tnames[METHOD] = "METHOD";
        vcl_tnames[T_ACL] = "acl";
        vcl_tnames[T_BACKEND] = "backend";
        vcl_tnames[T_CAND] = "&&";
index c4d32c7435c2ed68809e1efbae08fb3a1ad31d9c..4a8ba4df3802a2a57f7df2f135ffa4685d11d85b 100755 (executable)
@@ -97,7 +97,7 @@ set char {{}()*+-/%><=;!&.|~,}
 
 # Other token identifiers
 #
-set extras {ID VAR CNUM CSTR EOI METHOD}
+set extras {ID VAR CNUM CSTR EOI CSRC}
 
 #----------------------------------------------------------------------
 # Boilerplate warning for all generated files.
index 6b485b8eadb3186e32345a27f49e0372f0cfd22e..a6c46458d8226fe9a510c7191af6f6100850c419 100644 (file)
@@ -487,6 +487,12 @@ Compound(struct tokenlist *tl)
                        tl->indent -= INDENT;
                        Fb(tl, 1, "}\n");
                        return;
+               case CSRC:
+                       Fb(tl, 1, "%.*s\n",
+                           tl->t->e - (tl->t->b + 2),
+                           tl->t->b + 1);
+                       vcc_NextToken(tl);
+                       break;
                case EOI:
                        vsb_printf(tl->sb,
                            "End of input while in compound statement\n");
index 00ff0429888c03e84a90c83871d9ce7fcd3ae274..9e496724968791318036ca4bea7c1b5904be25a1 100644 (file)
@@ -49,6 +49,8 @@ vcc_ErrToken(struct tokenlist *tl, struct token *t)
 
        if (t->tok == EOI)
                vsb_printf(tl->sb, "end of input");
+       else if (t->tok == CSRC)
+               vsb_printf(tl->sb, "C{ ... }C");
        else
                vsb_printf(tl->sb, "'%.*s'", PF(t));
 }
@@ -71,8 +73,6 @@ vcc_ErrWhere(struct tokenlist *tl, struct token *t)
 
        lin = 1;
        pos = 0;
-       if (t->tok == METHOD)
-               return;
        sp = t->src;
        f = sp->name;
        b = sp->b;
@@ -315,14 +315,18 @@ vcc_Lexer(struct tokenlist *tl, struct source *sp)
 
                /* Skip C-style comments */
                if (*p == '/' && p[1] == '*') {
-                       p += 2;
-                       for (p += 2; p < sp->e; p++) {
-                               if (*p == '*' && p[1] == '/') {
-                                       p += 2;
+                       for (q += 2; q < sp->e; q++) {
+                               if (*q == '*' && q[1] == '/') {
+                                       p = q + 2;
                                        break;
                                }
                        }
-                       continue;
+                       if (q < sp->e)
+                               continue;
+                       vcc_AddToken(tl, EOI, p, p + 2);
+                       vsb_printf(tl->sb, "Unterminated /* ... */ comment, starting at\n");
+                       vcc_ErrWhere(tl, tl->t);
+                       return;
                }
 
                /* Skip C++-style comments */
@@ -332,6 +336,25 @@ vcc_Lexer(struct tokenlist *tl, struct source *sp)
                        continue;
                }
 
+               /* Recognize inline C-code */
+               if (*p == 'C' && p[1] == '{') {
+                       for (q = p + 2; q < sp->e; q++) {
+                               if (*q == '}' && q[1] == 'C') {
+                                       vcc_AddToken(tl, CSRC, p, q + 2);
+                                       p = q + 2;
+                                       break;
+                               }
+                       }
+                       if (q < sp->e)
+                               continue;
+                       vcc_AddToken(tl, EOI, p, p + 2);
+                       vsb_printf(tl->sb,
+                           "Unterminated inline C source, starting at\n");
+                       vcc_ErrWhere(tl, tl->t);
+                       return;
+               }
+       
+
                /* Match for the fixed tokens (see token.tcl) */
                u = vcl_fixed_token(p, &q);
                if (u != 0) {
index d5ebec7d9a9407319ddf1f2f4eabd55a7284be02..9a5d81eef78efaa697b87ada61a7b806382b2cc3 100644 (file)
@@ -34,4 +34,4 @@
 #define CNUM 152
 #define CSTR 153
 #define EOI 154
-#define METHOD 155
+#define CSRC 155
index b45d884d3e291e0b7f39d1724406297dd36652f6..68c8ec54b6a6670a9920ad8a0940e912c7cb4c1f 100644 (file)
@@ -149,11 +149,6 @@ vcc_CheckReferences(struct tokenlist *tl)
                nerr++;
 
                type = vcc_typename(tl, r);
-               if (r->defcnt == 0 && r->name->tok == METHOD) {
-                       vsb_printf(tl->sb,
-                           "No definition for method %.*s\n", PF(r->name));
-                       continue;
-               }
 
                if (r->defcnt == 0) {
                        vsb_printf(tl->sb,