diff options
author | Thomas White <taw@physics.org> | 2019-02-13 00:23:21 +0100 |
---|---|---|
committer | Thomas White <taw@physics.org> | 2019-02-13 00:23:21 +0100 |
commit | 079bd1d6843aa9a89df9f2c3e2e4a42c56794b64 (patch) | |
tree | fbd682096666581231cbc0961188fd994c289407 /src | |
parent | c938a5d860462f83b2fbf61d65390e7bf9d7b6fb (diff) |
Handle frame options properly
Diffstat (limited to 'src')
-rw-r--r-- | src/storycode.l | 10 | ||||
-rw-r--r-- | src/storycode.y | 47 |
2 files changed, 44 insertions, 13 deletions
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; } <string>.*\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 ------ */ |