aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2019-02-07 16:57:28 +0100
committerThomas White <taw@physics.org>2019-02-07 16:57:28 +0100
commitad5576a5c88dabc4f80b45c0ee9e06dbd34bc46a (patch)
treefb5e39f91e27c33b657dbeed89817f185691cfa5
parent249baac36e5d9b74a4bd435b665221652b267f81 (diff)
Skeleton parser
-rw-r--r--data/demo.sc72
-rw-r--r--meson.build16
-rw-r--r--src/sc2_test.c6
-rw-r--r--src/storycode.l (renamed from src/sc_lex.l)23
-rw-r--r--src/storycode.y (renamed from src/sc_parse.y)70
5 files changed, 92 insertions, 95 deletions
diff --git a/data/demo.sc b/data/demo.sc
index 734c179..8e5cb62 100644
--- a/data/demo.sc
+++ b/data/demo.sc
@@ -1,35 +1,65 @@
STYLES:
- PRESTITLE:
+ NARRATIVE:
+ PRESTITLE:
+ FONT: Cantarell Bold 16
+ SLIDE:
+ PRESTITLE:
+ TYPE: TEXT[1fx90u+0+0]
+ FONT: Cantarell Regular 64
+ PAD: 20,20,20,20
+ FGCOL: #eeeeee
+ ALIGN: center
+ BGCOL: rgba(0,0,0,0)
+
PRESTITLE: Hi there, welcome to Colloquium!
+
It looks like this is the first time you've used Colloquium. Keep reading to understand a little bit about how Colloquium works and how to use it.
+>
Colloquium works differently to other presentation programs. Colloquium makes /narrative, not slides,/ the centre of attention. Slides come when you need to illustrate something. This window is called the /narrative editor/. Your slides are embedded into the narrative text, like this:
+
SLIDE:
- PRES_TITLE: Welcome to Colloquium
+ PRESTITLE: Welcome to Colloquium
IMAGE[506.3ux520.3u+244.5+141.3]: colloquium.svg
- FRAME[983.9ux75.4u+21.1+673.0]: {\center{This is the presentation title slide, in case you hadn't noticed.}}}
+ TEXT[983.9ux75.4u+21.1+673.0][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.
-To edit a slide, simply double-click on it. Try it on this next slide:\slide{
-\slidetitle{Here is the slide title!}
-\footer{}
-\f[425.5ux85.0u+519.3+526.9]{Close this window when you've finished editing...}\f[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.}\f[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.}\f[0.0ux1.0u+809.1+430.0]{}}
+To edit a slide, simply double-click on it. Try it on this next 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.
+
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.
+
What is the narrative window for? Well, it's up to you! Here are some suggestions:
-\bp{}Use it just to help plan a smooth flow for your talk, reading it through to spot awkward transitions.
-\bp{}Write your talk word for word. Deliver your talk precisely as you planned it, no matter how nervous you get.
-\bp{}Write bullet-pointed notes to structure your talk.
-\bp{}Create a written version of your talk to print out and give to your audience as a handout.
-\bp{}Use it as a journal, adding slides whenever you have an illustration. You'll have a ready-made presentation on your activity, with no extra effort!
-Besides this, Colloquium has some features which will help you when you come to give your presentation. In the "Tools" menu, you'll find the presentation clock and the test card.
-Use the test card to make sure your computer is talking to the projector correctly. It shows you the resolution of the screen, where it thinks the edges are, and some colours. This helps you spot and fix all-too-common display problems early.
-Now, a short warning:\slide{\slidetitle{Alpha test software}\footer\f[391.8ux473.5u+567.8+143.7]{Colloquium is "alpha test" software.
+BP: Use it just to help plan a smooth flow for your talk, reading it through to spot awkward transitions.
+BP: Write your talk word for word. Deliver your talk precisely as you planned it, no matter how nervous you get.
+BP: Write bullet-pointed notes to structure your talk.
+BP: Create a written version of your talk to print out and give to your audience as a handout.
+BP: Use it as a journal, adding slides whenever you have an illustration. You'll have a ready-made presentation on your activity, with no extra effort!
-It will probably crash and lose your work a few times. Save and back up your work as frequently as possible.
+Besides this, Colloquium has some features which will help you when you come to give your presentation. In the "Tools" menu, you'll find the presentation clock and the test card.
-However, in years of use it has \bold{never} crashed on me in front of an audience. You will find most bugs in the editing features, not playback.
+Use the test card to make sure your computer is talking to the projector correctly. It shows you the resolution of the screen, where it thinks the edges are, and some colours. This helps you spot and fix all-too-common display problems early.
-Creating a backup slide deck in PDF format (File->Export slides as PDF) is nevertheless a wise safety measure.
+Now, a short warning:
+SLIDE:
+ SLIDETITLE: Alpha test software
+ FOOTER
+ TEXT[391.8ux473.5u+567.8+143.7]> 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.
+ >
+ > However, in years of use it has *never* crashed on me in front of an audience. You will find most bugs in the editing features, not playback.
+ >
+ > Creating a backup slide deck in PDF format (File->Export slides as PDF) is nevertheless a wise safety measure.
+ >
+ > Please report all bugs here:
+ > https://github.com/taw10/colloquium/issues
+ IMAGE[452.2ux431.0u+64.8+168.9]: alpha_warning.svg
-Please report all bugs here:
-https://github.com/taw10/colloquium/issues}\f[452.2ux431.0u+64.8+168.9]{\image[1fx1f+0+0,filename="alpha_warning.svg"]{}}\f[2.1ux10.3u+959.6+665.7]{}\f[0.0ux31.0u+957.5+654.3]{}}
That's enough to get you started. I hope you enjoy using Colloquium!
diff --git a/meson.build b/meson.build
index a102fe4..31d8b83 100644
--- a/meson.build
+++ b/meson.build
@@ -30,18 +30,18 @@ gresources = gnome.compile_resources('colloquium-resources',
flex = find_program('flex')
bison = find_program('bison')
-sc_parse_tab_ch = custom_target('sc_parse.tab.c',
- output : ['sc_parse.tab.c',
- 'sc_parse.tab.h'],
- input : 'src/sc_parse.y',
+storycode_tab_ch = custom_target('storycode.tab.c',
+ output : ['storycode.tab.c',
+ 'storycode.tab.h'],
+ input : 'src/storycode.y',
command : [bison, '--defines=@OUTPUT1@',
'-p', 'sc',
'--output=@OUTPUT0@',
'@INPUT@'])
-sc_parse_c = custom_target('sc_parse.c',
- output : ['sc_parse.c', 'sc_parse.h'],
- input : ['src/sc_lex.l', sc_parse_tab_ch],
+storycode_c = custom_target('storycode.c',
+ output : ['storycode.c', 'storycode.h'],
+ input : ['src/storycode.l', storycode_tab_ch],
command : [flex, '--outfile=@OUTPUT0@',
'--header-file=@OUTPUT1@',
'-P', 'sc',
@@ -49,7 +49,7 @@ sc_parse_c = custom_target('sc_parse.c',
executable('sc2_test',
['src/sc2_test.c',
- sc_parse_c,
+ storycode_c,
],
gresources,
dependencies : [gtkdep])
diff --git a/src/sc2_test.c b/src/sc2_test.c
index c8f016a..f626f26 100644
--- a/src/sc2_test.c
+++ b/src/sc2_test.c
@@ -26,7 +26,13 @@
#include <glib.h>
#include <glib/gstdio.h>
+#include "storycode.h"
+
int main(int argc, char *argv[])
{
+ printf("Here goes...\n");
+ sc_scan_string("PRESTITLE: Hello\n");
+ scparse();
+ printf("Done.\n");
return 0;
}
diff --git a/src/sc_lex.l b/src/storycode.l
index a636588..80d1a70 100644
--- a/src/sc_lex.l
+++ b/src/storycode.l
@@ -1,5 +1,5 @@
/*
- * sc_lex.l
+ * storycode.l
*
* Copyright © 2019 Thomas White <taw@bitwiz.org.uk>
*
@@ -21,18 +21,15 @@
*/
%{
- #include "sc_parse.tab.h"
-
+ #include "storycode.tab.h"
%}
+
+%option noyywrap nounput noinput
+
%%
-StoryCode { return STORYCODE; }
-type { return TYPE; }
-end { return END; }
-[ \t\n] ;
-[0-9]+\.[0-9]+ { sclval.fval = atof(yytext); return FLOAT; }
-[0-9]+ { sclval.ival = atoi(yytext); return INT; }
-[a-zA-Z0-9]+ {
- sclval.sval = strdup(yytext);
- return STRING;
-}
+
+STYLES { return SC_STYLES; }
+PRESTITLE { return SC_PRESTITLE; }
+[a-zA-Z0-9]+ { sclval = strdup(yytext); return SC_STRING; }
+
%%
diff --git a/src/sc_parse.y b/src/storycode.y
index cb881f6..25d7bc2 100644
--- a/src/sc_parse.y
+++ b/src/storycode.y
@@ -1,5 +1,5 @@
/*
- * sc2_parse.y
+ * storycode.y
*
* Copyright © 2019 Thomas White <taw@bitwiz.org.uk>
*
@@ -21,69 +21,33 @@
*/
%{
- // stuff from flex that bison needs to know about:
extern int sclex();
extern int scparse();
- extern FILE *scin;
-
void scerror(const char *s);
%}
-%union {
- int ival;
- float fval;
- char *sval;
-}
-
-%token STORYCODE TYPE
-%token END
-
-%token <ival> INT
-%token <fval> FLOAT
-%token <sval> STRING
+%define api.value.type {char *}
+%token SC_STYLES
+%token SC_PRESTITLE
+%token SC_STRING
%%
storycode:
- header template body_section footer {
- printf("End of storycode\n");
- }
- ;
-header:
- STORYCODE FLOAT {
- printf("Reading Storycode version $2\n");
- }
- ;
-template:
- typelines
- ;
-typelines:
- typelines typeline
- | typeline
- ;
-typeline:
- TYPE STRING {
- printf("type\n");
- free($2);
- }
- ;
-body_section:
- body_lines
- ;
-body_lines:
- body_lines body_line
- | body_line
- ;
-body_line:
- INT INT INT INT STRING {
- printf("type\n");
- free($5);
- }
- ;
-footer:
- END
+ %empty
+ | scblock '\n' storycode { printf("End of storycode\n"); }
;
+scblock:
+ stylesheet
+ | prestitle
+
+stylesheet:
+ SC_STYLES ':'
+
+prestitle:
+ SC_PRESTITLE ':' SC_STRING { printf("Presentation title: '%s'\n", $1); }
+
%%
void scerror(const char *s) {