]> mj.ucw.cz Git - leo.git/blobdiff - css-lex.c
TODO
[leo.git] / css-lex.c
index daad578e77236971be858d785f08c9f77151dc7c..129b1be740900c520fcd67657db9bd3887a46952 100644 (file)
--- a/css-lex.c
+++ b/css-lex.c
@@ -1,26 +1,25 @@
 /*
- *     Experimenta lMai Renderer -- MapCSS Lexer
+ *     Hic Est Leo -- MapCSS Lexer
  *
  *     (c) 2014--2015 Martin Mares <mj@ucw.cz>
  */
 
-#include <ucw/lib.h>
+#include "leo.h"
+#include "style.h"
+#include "css.h"
+#include "css-parse.h"
+
 #include <ucw/chartype.h>
 #include <ucw/fastbuf.h>
 #include <ucw/mempool.h>
 
 #include <fcntl.h>
 
-#include "leo.h"
-#include "style.h"
-#include "css.h"
-#include "css-parse.h"
-
 static struct fastbuf *fb;
 static struct fastbuf fbbuf;
 static int lino;
 
-void css_error(char *err, ...)
+void css_error(const char *err, ...)
 {
   va_list args;
   va_start(args, err);
@@ -50,7 +49,7 @@ int css_lex(void)
 {
   struct mempool *mp = css_this->pool;
   char *p;
-  int c, next, len, tok;
+  int c, next, len, tok, nesting;
 
   if (tok = css_this->pushed_token)
     {
@@ -199,6 +198,32 @@ int css_lex(void)
          css_lval.s = p;
          return RGB;
 
+       case '@':
+         if (next != '{')
+           return '@';
+         // Lua block
+         p = mp_start(mp, 1);
+         // FIXME p = mp_append_string(mp, p, "function () ");
+         nesting = 1;
+         bgetc(fb);
+         for (;;)
+           {
+             c = bgetc(fb);
+             if (c < 0)
+               css_error("Unterminated Lua block");
+             if (c == '{')
+               nesting++;
+             else if (c == '}')
+               {
+                 nesting--;
+                 if (!nesting)
+                   break;
+               }
+             p = mp_append_char(mp, p, c);
+           }
+         css_lval.s = mp_end_string(mp, p);
+         return LUA;
+
          // One-character operators
        case '{':
        case '}':