diff options
author | Thomas White <taw@bitwiz.me.uk> | 2019-02-25 20:15:27 +0100 |
---|---|---|
committer | Thomas White <taw@bitwiz.me.uk> | 2019-02-25 20:15:27 +0100 |
commit | 0a146090aa9dc02f5568e9c314e11ab69b40d225 (patch) | |
tree | e49f002604cfd9ea080e12530b087bd7fbd2188d /libstorycode | |
parent | e20292a1db872d9cf31a2b7cbcfdb4e1dd40b987 (diff) |
Reorganise grammar a little bit
Diffstat (limited to 'libstorycode')
-rw-r--r-- | libstorycode/storycode.y | 65 |
1 files changed, 39 insertions, 26 deletions
diff --git a/libstorycode/storycode.y b/libstorycode/storycode.y index 4199a4c..724a779 100644 --- a/libstorycode/storycode.y +++ b/libstorycode/storycode.y @@ -79,10 +79,12 @@ %type <n> narrative %type <s> slide %type <ss> stylesheet -%type <str> prestitle +%type <str> narrative_prestitle +%type <str> slide_prestitle %type <str> STRING %type <str> imageframe -%type <str> bulletpoint +%type <str> slide_bulletpoint +%type <str> narrative_bulletpoint %type <str> frameopt %type <geom> geometry %type <lenquad> lenquad @@ -168,36 +170,38 @@ void set_style(struct scpctx *ctx, enum style_element element) %% +/* The only thing a "presentation" really needs is narrative */ presentation: stylesheet narrative { presentation_add_stylesheet(ctx->p, ctx->ss); presentation_add_narrative(ctx->p, ctx->n); } | narrative { presentation_add_narrative(ctx->p, ctx->n); } ; + +/* ------ Narrative ------ */ + narrative: narrative_el { } | narrative narrative_el { } ; narrative_el: - prestitle { narrative_add_prestitle(ctx->n, $1); } -| bulletpoint { narrative_add_bp(ctx->n, $1); } -| slide { narrative_add_slide(ctx->n, $1); } -| STRING { narrative_add_text(ctx->n, $1); } + narrative_prestitle { narrative_add_prestitle(ctx->n, $1); } +| narrative_bulletpoint { narrative_add_bp(ctx->n, $1); } +| slide { narrative_add_slide(ctx->n, $1); } +| STRING { narrative_add_text(ctx->n, $1); } ; -/* Can be in narrative or slide */ - -prestitle: +narrative_prestitle: PRESTITLE STRING { $$ = $2; } ; -bulletpoint: +narrative_bulletpoint: BP STRING { $$ = $2; } ; -/* ------ Slide contents ------ */ +/* -------- Slide -------- */ slide: SLIDE '{' slide_parts '}' { presentation_add_slide(ctx->p, ctx->s); @@ -212,13 +216,17 @@ slide_parts: ; slide_part: - prestitle { slide_add_prestitle(ctx->s, $1); str_reset(ctx); } -| imageframe { slide_add_image(ctx->s, $1, ctx->geom); - str_reset(ctx); } -| textframe { slide_add_text(ctx->s, ctx->str, ctx->n_str, ctx->geom); - str_reset(ctx); } -| FOOTER { slide_add_footer(ctx->s); } -| slidetitle { slide_add_slidetitle(ctx->s, $1); str_reset(ctx); } + slide_prestitle { slide_add_prestitle(ctx->s, $1); str_reset(ctx); } +| imageframe { slide_add_image(ctx->s, $1, ctx->geom); + str_reset(ctx); } +| textframe { slide_add_text(ctx->s, ctx->str, ctx->n_str, ctx->geom); + str_reset(ctx); } +| FOOTER { slide_add_footer(ctx->s); } +| slidetitle { slide_add_slidetitle(ctx->s, $1); str_reset(ctx); } +; + +slide_prestitle: + PRESTITLE STRING { $$ = $2; } ; imageframe: @@ -231,10 +239,18 @@ textframe: ; multi_line_string: - STRING { add_str(ctx, $1); } -| multi_line_string STRING { add_str(ctx, $2); } -| bulletpoint { add_str(ctx, $1); } -| multi_line_string bulletpoint { add_str(ctx, $2); } + STRING { add_str(ctx, $1); } +| multi_line_string STRING { add_str(ctx, $2); } +| slide_bulletpoint { add_str(ctx, $1); } +| multi_line_string slide_bulletpoint { add_str(ctx, $2); } +; + +slide_bulletpoint: + BP STRING { $$ = $2; } +; + +slidetitle: + SLIDETITLE STRING { $$ = $2; } ; /* There can be any number of options */ @@ -253,6 +269,7 @@ frameopt: | alignment { ctx->alignment = $1; } ; +/* Primitives for describing styles (used in frame options and stylesheets) */ geometry: length 'x' length '+' length '+' length { $$.w = $1; $$.h = $3; $$.x = $5; $$.y = $7; } @@ -279,10 +296,6 @@ alignment: | RIGHT { $$ = ALIGN_RIGHT; } ; -slidetitle: - SLIDETITLE STRING { $$ = $2; } -; - length: VALUE UNIT { $$.len = $VALUE; if ( $UNIT == 'u' ) $$.unit = LENGTH_UNIT; |