/* * 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 . * */ %define api.token.prefix {SC_} %define api.pure full %locations %lex-param {yscan_t scanner} %parse-param {Narrative *n}; %parse-param {yyscan_t scanner}; %code requires { #include "narrative.h" #include "narrative_priv.h" #include "slide.h" #include "stylesheet.h" /* NB These structures look very similar to ones in stylesheet.c. * However, those structures are not exposed in the API, since there's no * need other than re-using them for a slightly different purpose here. */ enum parse_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 parse_style { enum parse_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 parse_paragraph { struct text_run *runs; int n_runs; int max_runs; }; struct parse_many_paragraphs { struct parse_paragraph *paras; int n_paras; int max_paras; }; typedef void *yyscan_t; } %union { Stylesheet *ss; Narrative *n; Slide *slide; SlideItem *slide_item; char *str; struct text_run run; struct parse_paragraph para; struct parse_many_paragraphs many_paragraphs; struct parse_style style; struct length len; struct length lenquad[4]; struct frame_geom geom; char character; double val; struct colour col; enum alignment align; enum gradient grad; } %{ #include #include #include extern int yylex(); void yyerror(YYLTYPE *locp, Narrative *n, yyscan_t scanner, const char *s); extern int lineno; %} %define parse.trace %token STYLES %token SLIDE %token EOP %token NARRATIVE %token PRESTITLE %token SLIDETITLE %token FOOTER %token TEXTFRAME %token IMAGEFRAME %token FILENAME %token BP %token SEG_START SEG_END %token FONT GEOMETRY PAD ALIGN FGCOL BGCOL PARASPACE %token VERT HORIZ %token LEFT CENTER RIGHT %token FONTNAME RUN_TEXT %token UNIT VALUE HEXCOL %token TEXT_START %type narrative %type slide %type slide_parts %type slide_part %type imageframe %type slidetitle %type textframe %type slide_prestitle %type multi_line_string %type text_line %type slide_bulletpoint %type text_line_with_start %type text_run %type RUN_TEXT %type one_or_more_runs %type stylesheet %type