aboutsummaryrefslogtreecommitdiff
path: root/libstorycode/storycode.l
diff options
context:
space:
mode:
authorThomas White <taw@bitwiz.me.uk>2019-02-24 17:56:21 +0100
committerThomas White <taw@bitwiz.me.uk>2019-02-24 17:56:21 +0100
commit7f09291dcbde21fb182a32482c3985470eda41d7 (patch)
tree5ed6e26c55e67a783c20e79f3a4ac00ddd59df06 /libstorycode/storycode.l
parent0cf09c110c9919efcbc3ff3b59cb83622b4ce1b2 (diff)
Stylesheet parser stuff
Diffstat (limited to 'libstorycode/storycode.l')
-rw-r--r--libstorycode/storycode.l56
1 files changed, 32 insertions, 24 deletions
diff --git a/libstorycode/storycode.l b/libstorycode/storycode.l
index 0406ee3..3a7704f 100644
--- a/libstorycode/storycode.l
+++ b/libstorycode/storycode.l
@@ -36,6 +36,13 @@
%option prefix="sc"
%option noyywrap nounput noinput
%s string
+%s geom
+%s font
+%s paraspace
+%s pad
+%s align
+%s col
+%s sqb
%%
@@ -45,38 +52,39 @@ SLIDETITLE { return SC_SLIDETITLE; }
NARRATIVE { return SC_NARRATIVE; }
SLIDE { return SC_SLIDE; }
BP { return SC_BP; }
-GEOMETRY { return SC_GEOMETRY; }
+GEOMETRY { BEGIN(geom); return SC_GEOMETRY; }
TEXT { return SC_TEXTFRAME; }
IMAGE { return SC_IMAGEFRAME; }
FOOTER { return SC_FOOTER; }
-FONT { return SC_FONT; }
-PAD { return SC_PAD; }
-PARASPACE { return SC_PARASPACE; }
-ALIGN { return SC_ALIGN; }
-FGCOL { return SC_FGCOL; }
-BGCOL { return SC_BGCOL; }
+FONT { BEGIN(font); return SC_FONT; }
+PAD { BEGIN(pad); return SC_PAD; }
+PARASPACE { BEGIN(paraspace); return SC_PARASPACE; }
+ALIGN { BEGIN(align); return SC_ALIGN; }
+FGCOL { BEGIN(col); return SC_FGCOL; }
+BGCOL { BEGIN(col); return SC_BGCOL; }
SIZE { return SC_SIZE; }
-(?i:left) { return SC_LEFT; }
-(?i:center) { return SC_CENTER; }
-(?i:right) { return SC_RIGHT; }
-<string>.*\n { sclval.str = strdup(yytext);
+<align,sqb>(?i:left) { return SC_LEFT; }
+<align,sqb>(?i:center) { return SC_CENTER; }
+<align,sqb>(?i:right) { return SC_RIGHT; }
+<string,font>.*\n { sclval.str = strdup(yytext);
sclval.str[yyleng-1] = '\0';
- BEGIN(0);
- lineno++;
- return SC_STRING; }
-"[" { return SC_SQOPEN; }
-"]" { return SC_SQCLOSE; }
-":" { return SC_COLON; }
-:[ ] { BEGIN(string); }
-:\n { sclval.str = strdup(""); lineno++; ;return SC_STRING; }
-[{] { return SC_OPENBRACE; }
-[}] { return SC_CLOSEBRACE; }
+ BEGIN(0);
+ lineno++;
+ return SC_STRING; }
+"[" { BEGIN(sqb); return SC_SQOPEN; }
+"]" { BEGIN(0); return SC_SQCLOSE; }
+<INITIAL>:[ ] { BEGIN(string); }
+:\n { sclval.str = strdup(""); lineno++; return SC_STRING; }
+[{] { return '{'; }
+[}] { return '}'; }
[. ] {}
-\n { lineno++; }
+\n { BEGIN(0); lineno++; }
[0-9\.]+ { sclval.val = atof(yytext); return SC_VALUE; }
[uf] { sclval.character = yytext[0]; return SC_UNIT; }
-[+] { return SC_PLUS; }
-[x] { return SC_TIMES; }
+[+] { return '+'; }
+[x] { return 'x'; }
+[,] { return ','; }
+<col>#[[:xdigit:]]{6} { sclval.str = strdup(yytext); return SC_HEXCOL; }
%%