aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--data/demo.sc70
-rw-r--r--src/sc2_test.c17
-rw-r--r--src/storycode.l27
-rw-r--r--src/storycode.y126
4 files changed, 196 insertions, 44 deletions
diff --git a/data/demo.sc b/data/demo.sc
index 8e5cb62..6c91d5a 100644
--- a/data/demo.sc
+++ b/data/demo.sc
@@ -1,65 +1,73 @@
-STYLES:
- NARRATIVE:
- PRESTITLE:
+STYLES {
+ NARRATIVE {
+ PRESTITLE {
FONT: Cantarell Bold 16
- SLIDE:
- PRESTITLE:
+ }
+ }
+ 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:
+: 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:
+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.
+}
-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:
+: 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:
+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[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.
+: 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:
+: 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.
+: 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.
+: 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:
+: 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
+ 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.
+ :
+ BP: 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.
+ :
+ BP: Please report all bugs here:
+ : https://github.com/taw10/colloquium/issues
IMAGE[452.2ux431.0u+64.8+168.9]: alpha_warning.svg
+}
-That's enough to get you started. I hope you enjoy using Colloquium!
+: That's enough to get you started. I hope you enjoy using Colloquium!
diff --git a/src/sc2_test.c b/src/sc2_test.c
index 5db89c4..6f9977f 100644
--- a/src/sc2_test.c
+++ b/src/sc2_test.c
@@ -25,18 +25,33 @@
#include <stdlib.h>
#include <glib.h>
#include <glib/gstdio.h>
+#include <gio/gio.h>
#include "storycode.tab.h"
#include "storycode.h"
+extern int scdebug;
+
int main(int argc, char *argv[])
{
YY_BUFFER_STATE b;
+ GFile *file;
+ GBytes *bytes;
+ const char *text;
+ size_t len;
+
+ file = g_file_new_for_uri("resource:///uk/me/bitwiz/Colloquium/demo.sc");
+ bytes = g_file_load_bytes(file, NULL, NULL, NULL);
+ text = g_bytes_get_data(bytes, &len);
+ //scdebug = 1;
printf("Here goes...\n");
- b = sc_scan_string("PRESTITLE: Hi there\nPRESTITLE: Second title\nSTYLES:\nPRESTITLE: three");
+ b = sc_scan_string(text);
scparse();
sc_delete_buffer(b);
printf("Done.\n");
+
+ g_bytes_unref(bytes);
+
return 0;
}
diff --git a/src/storycode.l b/src/storycode.l
index 16a2375..e470daa 100644
--- a/src/storycode.l
+++ b/src/storycode.l
@@ -21,18 +21,37 @@
*/
%{
+ #define YYDEBUG 1
#include "storycode.tab.h"
%}
%option noyywrap nounput noinput
+%s string
%%
STYLES { return SC_STYLES; }
PRESTITLE { return SC_PRESTITLE; }
-: { return SC_COLON; }
-:[ ] { return SC_COLONSPACE; }
-[a-zA-Z0-9 ]+ { sclval = strdup(yytext); return SC_STRING; }
-[\n] { return SC_NEWLINE; }
+SLIDETITLE { return SC_SLIDETITLE; }
+NARRATIVE { return SC_NARRATIVE; }
+SLIDE { return SC_SLIDE; }
+BP { return SC_BP; }
+TYPE { return SC_TYPE; }
+TEXT { return SC_TEXTFRAME; }
+IMAGE { return SC_IMAGEFRAME; }
+FOOTER { return SC_FOOTER; }
+FONT { return SC_FONT; }
+PAD { return SC_PAD; }
+ALIGN { return SC_ALIGN; }
+FGCOL { return SC_FGCOL; }
+BGCOL { return SC_BGCOL; }
+<string>.*\n { sclval = strdup(yytext); sclval[yyleng-1] = '\0'; BEGIN(0); return SC_STRING; }
+"[".*"]" { sclval = strdup(yytext); return SC_FRAMEOPTS; }
+:[ ] { BEGIN(string); }
+:\n { sclval = strdup(""); return SC_STRING; }
+[{] { return SC_OPENBRACE; }
+[}] { return SC_CLOSEBRACE; }
+[.\n ] {}
+
%%
diff --git a/src/storycode.y b/src/storycode.y
index a5dd68a..ee802c6 100644
--- a/src/storycode.y
+++ b/src/storycode.y
@@ -28,31 +28,141 @@
%define api.value.type {char *}
%token SC_STYLES
+%token SC_SLIDE
+%token SC_NARRATIVE
%token SC_PRESTITLE
-%token SC_COLON
+%token SC_SLIDETITLE
+%token SC_FOOTER
+%token SC_TEXTFRAME
+%token SC_IMAGEFRAME
+%token SC_BP
+
+%token SC_FRAMEOPTS
+
+%token SC_FONT
+%token SC_TYPE
+%token SC_PAD
+%token SC_ALIGN
+%token SC_FGCOL
+%token SC_BGCOL
+
%token SC_STRING
%token SC_NEWLINE
-%token SC_COLONSPACE
+%token SC_OPENBRACE
+%token SC_CLOSEBRACE
%%
storycode:
%empty
- | scblock
- | scblock SC_NEWLINE storycode
+ | scblock storycode
;
scblock:
- stylesheet
- | prestitle
+ stylesheet { printf("That was the stylesheet\n"); }
+ | prestitle { printf("prestitle: '%s'\n", $1); }
+ | bulletpoint { printf("* '%s'\n", $1); }
+ | slide
+ | SC_STRING { printf("Text line '%s'\n", $1); }
;
stylesheet:
- SC_STYLES SC_COLON { printf("Stylesheet.\n"); }
+ SC_STYLES SC_OPENBRACE { printf("Here comes the stylesheet\n"); }
+ style_narrative { printf("Stylesheet - narrative\n"); }
+ style_slide { printf("Stylesheet - slide\n"); }
+ SC_CLOSEBRACE
;
+
+/* Can be in narrative or slide */
+
prestitle:
- SC_PRESTITLE SC_COLONSPACE SC_STRING { printf("Presentation title: '%s'\n", $3); }
+ SC_PRESTITLE SC_STRING { $$ = $2; }
+ ;
+
+bulletpoint:
+ SC_BP SC_STRING { $$ = $2; }
+ ;
+
+/* ------ Slide contents ------ */
+
+slide:
+ SC_SLIDE SC_OPENBRACE { printf("start of slide\n"); }
+ slide_parts
+ SC_CLOSEBRACE { printf("end of slide\n"); }
+ ;
+
+slide_parts:
+ %empty
+ | slide_part slide_parts
+ ;
+
+slide_part:
+ prestitle | imageframe | textframe | SC_FOOTER | slidetitle
+ ;
+
+imageframe:
+ SC_IMAGEFRAME frame_options SC_STRING
+ ;
+
+textframe:
+ SC_TEXTFRAME frame_options multi_line_string { printf("text frame '%s'\n", $1); }
+ ;
+
+multi_line_string:
+ SC_STRING
+ | SC_STRING multi_line_string
+ | bulletpoint
+ | bulletpoint multi_line_string
+ ;
+
+frame_options:
+ SC_FRAMEOPTS { printf("got some options: '%s'\n", $1); }
+ ;
+
+slidetitle:
+ SC_SLIDETITLE SC_STRING { $$ = $2; }
+ ;
+
+
+/* ------ Stylesheet ------ */
+
+style_narrative:
+ SC_NARRATIVE SC_OPENBRACE style_narrative_def SC_CLOSEBRACE { printf("narrative style\n"); }
+ ;
+
+style_narrative_def:
+ %empty
+ | style_prestitle style_narrative_def
+ | styledef style_narrative_def
+ ;
+
+style_slide:
+ SC_SLIDE SC_OPENBRACE style_slide_def SC_CLOSEBRACE { printf("slide style\n"); }
+ ;
+
+style_slide_def:
+ %empty
+ | style_prestitle style_slide_def
+ | styledef style_slide_def
+ ;
+
+style_prestitle:
+ SC_PRESTITLE SC_OPENBRACE styledefs SC_CLOSEBRACE { printf("prestitle style\n"); }
+ ;
+
+styledefs:
+ %empty
+ | styledef styledefs
+ ;
+
+styledef:
+ SC_FONT SC_STRING { printf("font def: '%s'\n", $2); }
+ | SC_TYPE SC_STRING { printf("type def: '%s'\n", $2); }
+ | SC_PAD SC_STRING { printf("pad def: '%s'\n", $2); }
+ | SC_FGCOL SC_STRING { printf("fgcol def: '%s'\n", $2); }
+ | SC_BGCOL SC_STRING { printf("bgcol def: '%s'\n", $2); }
+ | SC_ALIGN SC_STRING { printf("align def: '%s'\n", $2); }
;
%%