From ad5576a5c88dabc4f80b45c0ee9e06dbd34bc46a Mon Sep 17 00:00:00 2001 From: Thomas White Date: Thu, 7 Feb 2019 16:57:28 +0100 Subject: Skeleton parser --- data/demo.sc | 72 ++++++++++++++++++++++++++++++++------------- meson.build | 16 +++++----- src/sc2_test.c | 6 ++++ src/sc_lex.l | 38 ------------------------ src/sc_parse.y | 91 --------------------------------------------------------- src/storycode.l | 35 ++++++++++++++++++++++ src/storycode.y | 55 ++++++++++++++++++++++++++++++++++ 7 files changed, 155 insertions(+), 158 deletions(-) delete mode 100644 src/sc_lex.l delete mode 100644 src/sc_parse.y create mode 100644 src/storycode.l create mode 100644 src/storycode.y 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 #include +#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/sc_lex.l deleted file mode 100644 index a636588..0000000 --- a/src/sc_lex.l +++ /dev/null @@ -1,38 +0,0 @@ -/* - * sc_lex.l - * - * Copyright © 2019 Thomas White - * - * This file is part of Colloquium. - * - * Colloquium is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - */ - -%{ - #include "sc_parse.tab.h" - -%} -%% -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; -} -%% diff --git a/src/sc_parse.y b/src/sc_parse.y deleted file mode 100644 index cb881f6..0000000 --- a/src/sc_parse.y +++ /dev/null @@ -1,91 +0,0 @@ -/* - * sc2_parse.y - * - * Copyright © 2019 Thomas White - * - * This file is part of Colloquium. - * - * Colloquium is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - */ - -%{ - // 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 INT -%token FLOAT -%token 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 - ; - -%% - -void scerror(const char *s) { - printf("Error\n"); -} diff --git a/src/storycode.l b/src/storycode.l new file mode 100644 index 0000000..80d1a70 --- /dev/null +++ b/src/storycode.l @@ -0,0 +1,35 @@ +/* + * storycode.l + * + * Copyright © 2019 Thomas White + * + * This file is part of Colloquium. + * + * Colloquium is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + +%{ + #include "storycode.tab.h" +%} + +%option noyywrap nounput noinput + +%% + +STYLES { return SC_STYLES; } +PRESTITLE { return SC_PRESTITLE; } +[a-zA-Z0-9]+ { sclval = strdup(yytext); return SC_STRING; } + +%% diff --git a/src/storycode.y b/src/storycode.y new file mode 100644 index 0000000..25d7bc2 --- /dev/null +++ b/src/storycode.y @@ -0,0 +1,55 @@ +/* + * storycode.y + * + * Copyright © 2019 Thomas White + * + * This file is part of Colloquium. + * + * Colloquium is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + +%{ + extern int sclex(); + extern int scparse(); + void scerror(const char *s); +%} + +%define api.value.type {char *} +%token SC_STYLES +%token SC_PRESTITLE +%token SC_STRING + +%% + +storycode: + %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) { + printf("Error\n"); +} -- cgit v1.2.3