aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorThomas White <taw@bitwiz.me.uk>2019-02-07 21:59:01 +0100
committerThomas White <taw@bitwiz.me.uk>2019-02-07 21:59:01 +0100
commit2453ffa05850d5c498dd900a4f66749e6d0c8989 (patch)
tree079b01ac42728304549366201bac790ede317a86 /src
parentad5576a5c88dabc4f80b45c0ee9e06dbd34bc46a (diff)
WIP
Diffstat (limited to 'src')
-rw-r--r--src/sc2_test.c6
-rw-r--r--src/storycode.l5
-rw-r--r--src/storycode.y13
3 files changed, 19 insertions, 5 deletions
diff --git a/src/sc2_test.c b/src/sc2_test.c
index f626f26..5db89c4 100644
--- a/src/sc2_test.c
+++ b/src/sc2_test.c
@@ -26,13 +26,17 @@
#include <glib.h>
#include <glib/gstdio.h>
+#include "storycode.tab.h"
#include "storycode.h"
int main(int argc, char *argv[])
{
+ YY_BUFFER_STATE b;
+
printf("Here goes...\n");
- sc_scan_string("PRESTITLE: Hello\n");
+ b = sc_scan_string("PRESTITLE: Hi there\nPRESTITLE: Second title\nSTYLES:\nPRESTITLE: three");
scparse();
+ sc_delete_buffer(b);
printf("Done.\n");
return 0;
}
diff --git a/src/storycode.l b/src/storycode.l
index 80d1a70..16a2375 100644
--- a/src/storycode.l
+++ b/src/storycode.l
@@ -30,6 +30,9 @@
STYLES { return SC_STYLES; }
PRESTITLE { return SC_PRESTITLE; }
-[a-zA-Z0-9]+ { sclval = strdup(yytext); return SC_STRING; }
+: { return SC_COLON; }
+:[ ] { return SC_COLONSPACE; }
+[a-zA-Z0-9 ]+ { sclval = strdup(yytext); return SC_STRING; }
+[\n] { return SC_NEWLINE; }
%%
diff --git a/src/storycode.y b/src/storycode.y
index 25d7bc2..a5dd68a 100644
--- a/src/storycode.y
+++ b/src/storycode.y
@@ -29,24 +29,31 @@
%define api.value.type {char *}
%token SC_STYLES
%token SC_PRESTITLE
+%token SC_COLON
%token SC_STRING
+%token SC_NEWLINE
+%token SC_COLONSPACE
%%
storycode:
%empty
- | scblock '\n' storycode { printf("End of storycode\n"); }
+ | scblock
+ | scblock SC_NEWLINE storycode
;
scblock:
stylesheet
| prestitle
+ ;
stylesheet:
- SC_STYLES ':'
+ SC_STYLES SC_COLON { printf("Stylesheet.\n"); }
+ ;
prestitle:
- SC_PRESTITLE ':' SC_STRING { printf("Presentation title: '%s'\n", $1); }
+ SC_PRESTITLE SC_COLONSPACE SC_STRING { printf("Presentation title: '%s'\n", $3); }
+ ;
%%