aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2019-02-13 00:23:21 +0100
committerThomas White <taw@physics.org>2019-02-13 00:23:21 +0100
commit079bd1d6843aa9a89df9f2c3e2e4a42c56794b64 (patch)
treefbd682096666581231cbc0961188fd994c289407
parentc938a5d860462f83b2fbf61d65390e7bf9d7b6fb (diff)
Handle frame options properly
-rw-r--r--data/demo.sc16
-rw-r--r--src/storycode.l10
-rw-r--r--src/storycode.y47
3 files changed, 52 insertions, 21 deletions
diff --git a/data/demo.sc b/data/demo.sc
index 6c91d5a..70cb747 100644
--- a/data/demo.sc
+++ b/data/demo.sc
@@ -24,8 +24,8 @@ PRESTITLE: Hi there, welcome to Colloquium!
SLIDE {
PRESTITLE: Welcome to Colloquium
- IMAGE[506.3ux520.3u+244.5+141.3]: colloquium.svg
- TEXT[983.9ux75.4u+21.1+673.0][center]: This is the presentation title slide, in case you hadn't noticed.
+ IMAGE[506.3ux520.3u+244.5u+141.3u]: colloquium.svg
+ TEXT[983.9ux75.4u+21.1u+673.0u][center]: This is the presentation title slide, in case you hadn't noticed.
}
: As you can probably tell, the above slide happens to be the title page for the presentation.
@@ -34,10 +34,10 @@ SLIDE {
SLIDE {
SLIDETITLE: Here is the slide title!
FOOTER
- TEXT[425.5ux85.0u+519.3+526.9]: Close this window when you've finished editing...
- TEXT[383.5ux112.1u+62.0+139.6]: Editing slides works how you expect it to. Add a new text frame by holding shift and dragging from an empty area. Then simply type into the new frame.
- TEXT[442.3ux120.3u+321.6+341.8]: Shift-click and drag frames to move them.
- : Change their shape and size by shift-dragging the handles at the corners.
+ TEXT[425.5ux85.0u+519.3u+526.9u]: Close this window when you've finished editing...
+ TEXT[383.5ux112.1u+62.0u+139.6u]: Editing slides works how you expect it to. Add a new text frame by holding shift and dragging from an empty area. Then simply type into the new frame.
+ TEXT[442.3ux120.3u+321.6u+341.8u]: Shift-click and drag frames to move them.
+ : Change their shape and size by shift-dragging the handles at the corners.
}
: You can add a new slide from the "Insert" menu or using the toolbar at the top of the narrative window. Try it now: click to place the cursor at the end of this paragraph, then add a new slide.
@@ -57,7 +57,7 @@ BP: Use it as a journal, adding slides whenever you have an illustration. You'l
SLIDE {
SLIDETITLE: Alpha test software
FOOTER
- TEXT[391.8ux473.5u+567.8+143.7]: Colloquium is "alpha test" software.
+ TEXT[391.8ux473.5u+567.8u+143.7u]: Colloquium is "alpha test" software.
:
: It will probably crash and lose your work a few times. Save and back up your work as frequently as possible.
:
@@ -67,7 +67,7 @@ SLIDE {
:
BP: Please report all bugs here:
: https://github.com/taw10/colloquium/issues
- IMAGE[452.2ux431.0u+64.8+168.9]: alpha_warning.svg
+ IMAGE[452.2ux431.0u+64.8u+168.9u]: alpha_warning.svg
}
: That's enough to get you started. I hope you enjoy using Colloquium!
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 ------ */