aboutsummaryrefslogtreecommitdiff
path: root/libstorycode
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2019-10-03 22:07:52 +0200
committerThomas White <taw@physics.org>2019-10-05 17:03:43 +0200
commitc8eaf22e127acb629c1e3733eaf61749df91b9c9 (patch)
treeec03988505a17205e8a0ed9ad80df17b86493d7d /libstorycode
parent7db1f2b50c09365e6181bffbad7c043885a75e48 (diff)
Clean up stylesheet parser a bit
Diffstat (limited to 'libstorycode')
-rw-r--r--libstorycode/storycode.y53
1 files changed, 34 insertions, 19 deletions
diff --git a/libstorycode/storycode.y b/libstorycode/storycode.y
index 7de9fb0..fe14ed2 100644
--- a/libstorycode/storycode.y
+++ b/libstorycode/storycode.y
@@ -521,18 +521,43 @@ gradtype:
/* ------ Stylesheet ------ */
-stylesheet: { $<ss>$ = stylesheet_new(); }
- STYLES '{'
- NARRATIVE '{' style_narrative_def '}'
- SLIDE '{' style_slide_def '}'
- '}' { }
+stylesheet:
+ STYLES '{' stylesheet_blocks '}' { }
;
-style_narrative_def:
+stylesheet_blocks: { }
+ %empty
+| stylesheet_blocks stylesheet_block { }
+;
+
+stylesheet_block:
+ NARRATIVE '{' style_narrative_defs '}' { }
+| SLIDE '{' style_slide_defs '}' { }
+;
+
+style_narrative_defs:
%empty
-| style_narrative_def style_narrative_prestitle { set_stylesheet(n, &$2, "NARRATIVE.PRESTITLE"); }
-| style_narrative_def style_narrative_bp { set_stylesheet(n, &$2, "NARRATIVE.BP"); }
-| style_narrative_def styledefs { set_stylesheet(n, &$2, "NARRATIVE"); }
+| style_narrative_defs style_narrative_def { }
+;
+
+style_slide_defs:
+ %empty
+| style_slide_defs style_slide_def { }
+;
+
+style_narrative_def:
+ style_narrative_prestitle { set_stylesheet(n, &$1, "NARRATIVE.PRESTITLE"); }
+| style_narrative_bp { set_stylesheet(n, &$1, "NARRATIVE.BP"); }
+| styledef { set_stylesheet(n, &$1, "NARRATIVE"); }
+;
+
+style_slide_def:
+ background { set_stylesheet(n, &$1, "SLIDE"); }
+| slide_geom { set_stylesheet(n, &$1, "SLIDE"); }
+| style_slide_prestitle { set_stylesheet(n, &$1, "SLIDE.PRESTITLE"); }
+| style_slide_text { set_stylesheet(n, &$1, "SLIDE.TEXT"); }
+| style_slide_title { set_stylesheet(n, &$1, "SLIDE.SLIDETITLE"); }
+| style_slide_footer { set_stylesheet(n, &$1, "SLIDE.FOOTER"); }
;
style_narrative_prestitle:
@@ -543,16 +568,6 @@ style_narrative_bp:
BP '{' styledefs '}' { $$ = $3; }
;
-style_slide_def:
- %empty
-| style_slide_def background { set_stylesheet(n, &$2, "SLIDE"); }
-| style_slide_def slide_geom { set_stylesheet(n, &$2, "SLIDE"); }
-| style_slide_def style_slide_prestitle { set_stylesheet(n, &$2, "SLIDE.PRESTITLE"); }
-| style_slide_def style_slide_text { set_stylesheet(n, &$2, "SLIDE.TEXT"); }
-| style_slide_def style_slide_title { set_stylesheet(n, &$2, "SLIDE.SLIDETITLE"); }
-| style_slide_def style_slide_footer { set_stylesheet(n, &$2, "SLIDE.FOOTER"); }
-;
-
background:
BGCOL colour { copy_col(&$$.bgcol, $2);
$$.bggrad = GRAD_NONE;