From 079bd1d6843aa9a89df9f2c3e2e4a42c56794b64 Mon Sep 17 00:00:00 2001 From: Thomas White Date: Wed, 13 Feb 2019 00:23:21 +0100 Subject: Handle frame options properly --- src/storycode.l | 10 +++++++++- src/storycode.y | 47 +++++++++++++++++++++++++++++++++++------------ 2 files changed, 44 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/storycode.l b/src/storycode.l index e470daa..a64fbec 100644 --- a/src/storycode.l +++ b/src/storycode.l @@ -45,13 +45,21 @@ PAD { return SC_PAD; } ALIGN { return SC_ALIGN; } FGCOL { return SC_FGCOL; } BGCOL { return SC_BGCOL; } +(?i:left) { return SC_LEFT; } +(?i:center) { return SC_CENTER; } +(?i:right) { return SC_RIGHT; } .*\n { sclval = strdup(yytext); sclval[yyleng-1] = '\0'; BEGIN(0); return SC_STRING; } -"[".*"]" { sclval = strdup(yytext); return SC_FRAMEOPTS; } +"[" { return SC_SQOPEN; } +"]" { return SC_SQCLOSE; } :[ ] { BEGIN(string); } :\n { sclval = strdup(""); return SC_STRING; } [{] { return SC_OPENBRACE; } [}] { return SC_CLOSEBRACE; } [.\n ] {} +[0-9\.]+ { /* FIXME: lval */ return SC_VALUE; } +[uf] { return SC_UNIT; } +[+] { return SC_PLUS; } +[x] { return SC_TIMES; } %% diff --git a/src/storycode.y b/src/storycode.y index 8146a6a..cbd952a 100644 --- a/src/storycode.y +++ b/src/storycode.y @@ -28,8 +28,7 @@ %define api.value.type {char *} %define api.token.prefix {SC_} -%token STYLES -%token SLIDE +%token STYLES SLIDE %token NARRATIVE %token PRESTITLE %token SLIDETITLE @@ -38,17 +37,15 @@ %token IMAGEFRAME %token BP -%token FRAMEOPTS +%token FONT TYPE PAD ALIGN FGCOL BGCOL -%token FONT -%token TYPE -%token PAD -%token ALIGN -%token FGCOL -%token BGCOL +%token LEFT CENTER RIGHT %token STRING %token OPENBRACE CLOSEBRACE +%token SQOPEN SQCLOSE +%token PLUS TIMES +%token UNIT VALUE %% @@ -115,18 +112,44 @@ textframe: multi_line_string: STRING { printf("string '%s'\n", $1); } | multi_line_string STRING { printf("more string '%s'\n", $2); } -| bulletpoint -| multi_line_string bulletpoint +| bulletpoint { printf("string *%s\n", $1); } +| multi_line_string bulletpoint { printf("more string *%s\n", $1); } ; +/* There can be any number of options */ frame_options: - FRAMEOPTS { printf("got some options: '%s'\n", $1); } + %empty +| frame_options frame_option +; + +/* Each option is enclosed in square brackets */ +frame_option: + SQOPEN frameopt SQCLOSE { printf("got an option: '%s'\n", $2); } +; + +frameopt: + geometry +| alignment +; + +geometry: + length TIMES length PLUS length PLUS length { $$ = "geom"; printf("Geometry\n"); } +; + +alignment: + LEFT +| CENTER +| RIGHT ; slidetitle: SLIDETITLE STRING { $$ = $2; } ; +length: + VALUE UNIT +; + /* ------ Stylesheet ------ */ -- cgit v1.2.3