From 54b33a62d7d1dd5e70ee2d54a0bba51a59bac76f Mon Sep 17 00:00:00 2001 From: Thomas White Date: Thu, 3 Oct 2019 16:47:38 +0200 Subject: Get rid of spctx completely --- libstorycode/scparse_priv.h | 59 --------- libstorycode/storycode.c | 10 +- libstorycode/storycode.y | 312 +++++++++++++++++++++++++++----------------- 3 files changed, 199 insertions(+), 182 deletions(-) delete mode 100644 libstorycode/scparse_priv.h diff --git a/libstorycode/scparse_priv.h b/libstorycode/scparse_priv.h deleted file mode 100644 index 7e1e6db..0000000 --- a/libstorycode/scparse_priv.h +++ /dev/null @@ -1,59 +0,0 @@ -/* - * scparse_priv.h - * - * 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 . - * - */ - -#ifndef SCPARSE_PRIV_H -#define SCPARSE_PRIV_H - -#include "narrative.h" -#include "slide.h" - -enum style_mask -{ - STYMASK_GEOM = 1<<0, - STYMASK_FONT = 1<<1, - STYMASK_ALIGNMENT = 1<<2, - STYMASK_PADDING = 1<<3, - STYMASK_PARASPACE = 1<<4, - STYMASK_FGCOL = 1<<5, - STYMASK_BGCOL = 1<<6, -}; - -struct scpctx -{ - Narrative *n; - - /* Current style or frame options. - * These will be copied to a stylesheet entry or frame when the - * top-level rule is matched. */ - enum style_mask mask; - struct frame_geom geom; - char *font; - enum alignment alignment; - struct length padding[4]; - struct length paraspace[4]; - struct colour fgcol; - enum gradient bggrad; - struct colour bgcol; - struct colour bgcol2; -}; - -#endif /* SCPARSE_PRIV_H */ diff --git a/libstorycode/storycode.c b/libstorycode/storycode.c index 18e5270..139af67 100644 --- a/libstorycode/storycode.c +++ b/libstorycode/storycode.c @@ -37,7 +37,6 @@ #include "storycode_parse.h" #include "storycode_lex.h" -#include "scparse_priv.h" extern int scdebug; @@ -46,15 +45,16 @@ extern int scdebug; Narrative *storycode_parse_presentation(const char *sc) { YY_BUFFER_STATE b; - struct scpctx parse_ctx; + Narrative *n; b = sc_scan_string(sc); //scdebug = 1; - scparse(&parse_ctx); + n = narrative_new(); + scparse(n); sc_delete_buffer(b); - //narrative_debug(parse_ctx.n); + //narrative_debug(n); - return parse_ctx.n; + return n; } diff --git a/libstorycode/storycode.y b/libstorycode/storycode.y index a0d4757..c6ba2eb 100644 --- a/libstorycode/storycode.y +++ b/libstorycode/storycode.y @@ -31,7 +31,30 @@ #include "slide.h" #include "stylesheet.h" - #include "scparse_priv.h" + enum style_mask + { + STYMASK_GEOM = 1<<0, + STYMASK_FONT = 1<<1, + STYMASK_ALIGNMENT = 1<<2, + STYMASK_PADDING = 1<<3, + STYMASK_PARASPACE = 1<<4, + STYMASK_FGCOL = 1<<5, + STYMASK_BGCOL = 1<<6, + }; + + struct style + { + enum style_mask mask; + struct frame_geom geom; + char *font; + enum alignment alignment; + struct length padding[4]; + struct length paraspace[4]; + struct colour fgcol; + enum gradient bggrad; + struct colour bgcol; + struct colour bgcol2; + }; struct paragraph { struct text_run *runs; @@ -59,6 +82,8 @@ struct paragraph para; struct many_paragraphs many_paragraphs; + struct style style; + struct length len; struct length lenquad[4]; struct frame_geom geom; @@ -77,7 +102,7 @@ extern int sclex(); extern int scparse(); - void scerror(struct scpctx *ctx, const char *s); + void scerror(Narrative *n, const char *s); extern int lineno; %} @@ -105,11 +130,11 @@ %type narrative %type slide %type slide_parts -%type stylesheet %type slide_part -%type textframe -%type slide_prestitle -%type slidetitle +%type imageframe +%type slidetitle +%type textframe +%type slide_prestitle %type multi_line_string %type text_line %type slide_bulletpoint @@ -118,9 +143,22 @@ %type RUN_TEXT %type one_or_more_runs +%type stylesheet +%type