X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;f=css-lex.c;h=129b1be740900c520fcd67657db9bd3887a46952;hb=refs%2Fheads%2Flua;hp=daad578e77236971be858d785f08c9f77151dc7c;hpb=8d7f30e7d13f2aaf12bcb381febeb548eabe708a;p=leo.git diff --git a/css-lex.c b/css-lex.c index daad578..129b1be 100644 --- 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 */ -#include +#include "leo.h" +#include "style.h" +#include "css.h" +#include "css-parse.h" + #include #include #include #include -#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 '}':