diff options
-rw-r--r-- | data/demo.sc | 13 | ||||
-rw-r--r-- | meson.build | 27 | ||||
-rw-r--r-- | src/sc2_test.c | 32 | ||||
-rw-r--r-- | src/sc_lex.l | 38 | ||||
-rw-r--r-- | src/sc_parse.y | 91 |
5 files changed, 196 insertions, 5 deletions
diff --git a/data/demo.sc b/data/demo.sc index e6a60a7..734c179 100644 --- a/data/demo.sc +++ b/data/demo.sc @@ -1,9 +1,12 @@ -\fontsize[40]{\bold{}Hi there, welcome to \bold{Colloquium}!} +STYLES: + PRESTITLE: +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 \italic{narrative, not slides,} the centre of attention. Slides come when you need to illustrate something. This window is called the \oblique{narrative editor}. Your slides are embedded into the narrative text, like this:\slide{ -\prestitle{Welcome to Colloquium} - -\f[506.3ux520.3u+244.5+141.3]{\image[1fx1f+0+0,filename="colloquium.svg"]{}}\f[983.9ux75.4u+21.1+673.0]{\center{This is the presentation title slide, in case you hadn't noticed.}}} +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 + 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.}}} 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!} diff --git a/meson.build b/meson.build index 52b9243..a102fe4 100644 --- a/meson.build +++ b/meson.build @@ -27,6 +27,33 @@ gresources = gnome.compile_resources('colloquium-resources', 'data/colloquium.gresource.xml', source_dir: 'data', c_name: 'colloquium') +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', + 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], + command : [flex, '--outfile=@OUTPUT0@', + '--header-file=@OUTPUT1@', + '-P', 'sc', + '@INPUT@']) + +executable('sc2_test', + ['src/sc2_test.c', + sc_parse_c, + ], + gresources, + dependencies : [gtkdep]) + # Main program executable('colloquium', ['src/colloquium.c', diff --git a/src/sc2_test.c b/src/sc2_test.c new file mode 100644 index 0000000..c8f016a --- /dev/null +++ b/src/sc2_test.c @@ -0,0 +1,32 @@ +/* + * sc2_test.c + * + * Copyright © 2019 Thomas White <taw@bitwiz.org.uk> + * + * 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 <http://www.gnu.org/licenses/>. + * + */ + + +#include <string.h> +#include <stdlib.h> +#include <glib.h> +#include <glib/gstdio.h> + +int main(int argc, char *argv[]) +{ + return 0; +} diff --git a/src/sc_lex.l b/src/sc_lex.l new file mode 100644 index 0000000..a636588 --- /dev/null +++ b/src/sc_lex.l @@ -0,0 +1,38 @@ +/* + * sc_lex.l + * + * Copyright © 2019 Thomas White <taw@bitwiz.org.uk> + * + * 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 <http://www.gnu.org/licenses/>. + * + */ + +%{ + #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 new file mode 100644 index 0000000..cb881f6 --- /dev/null +++ b/src/sc_parse.y @@ -0,0 +1,91 @@ +/* + * sc2_parse.y + * + * Copyright © 2019 Thomas White <taw@bitwiz.org.uk> + * + * 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 <http://www.gnu.org/licenses/>. + * + */ + +%{ + // 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 + +%% + +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"); +} |