From dc10567baca441562631f8bd8037ecd1dc7f4919 Mon Sep 17 00:00:00 2001 From: Thomas Jensen Date: Tue, 30 Mar 1999 09:37:51 +0000 Subject: [PATCH] It drew a correct box for the first time! --- src/parser.y | 328 +++++++++++++++++++++++++++++---------------------- 1 file changed, 187 insertions(+), 141 deletions(-) diff --git a/src/parser.y b/src/parser.y index cbfaa90..ed4e8d6 100644 --- a/src/parser.y +++ b/src/parser.y @@ -4,7 +4,7 @@ * Date created: March 16, 1999 (Tuesday, 17:17h) * Author: Thomas Jensen * tsjensen@stud.informatik.uni-erlangen.de - * Version: $Id: parser.y,v 1.2 1999/03/19 17:57:20 tsjensen Exp tsjensen $ + * Version: $Id: parser.y,v 1.3 1999/03/24 17:29:12 tsjensen Exp tsjensen $ * Language: yacc (ANSI C) * Purpose: Yacc parser for boxes configuration files * Remarks: --- @@ -12,6 +12,10 @@ * Revision History: * * $Log: parser.y,v $ + * Revision 1.3 1999/03/24 17:29:12 tsjensen + * Added detection of empty shapes ("") which are now cleared (+warning) + * Changed rcs string to #ident directive + * * Revision 1.2 1999/03/19 17:57:20 tsjensen * ... still programming ... * @@ -28,7 +32,7 @@ #include #include "boxes.h" -#ident "$Id: parser.y,v 1.2 1999/03/19 17:57:20 tsjensen Exp tsjensen $"; +#ident "$Id: parser.y,v 1.3 1999/03/24 17:29:12 tsjensen Exp tsjensen $"; static int pflicht = 0; @@ -36,104 +40,107 @@ static int time_for_se_check = 0; -shape_t corner_ambiguity() +int check_sizes() /* - * Checks for ambiguity in corner specification using elastic and shape - * data. It must be clear which shape to use for each corner of the box. + * For the author's convenience, it is required that shapes on one side + * have equal width (vertical sides) and height (horizontal sides). * - * A corner specification is ambiguous if the distance between the corner - * and the nearest specified shape in horizontal and vertical direction is - * equal and both shapes have the same elasticity. - * - * RETURNS: ANZ_SHAPES no ambiguity - * a corner spec is ambiguous + * RETURNS: == 0 no problem detected + * != 0 on error (prints error message, too) * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ { - int hdist, vdist; /* distances to corners */ - shape_t hcand, vcand; /* candidate shapes */ - int c; + int i, j, k; - for (c=0; c 1) { if (perform_se_check() != 0) @@ -379,7 +412,13 @@ the_shapes: the_shapes SHAPE slist "height %d)\n", shape_name[$2], $3.width, $3.height); #endif - designs[design_idx].shape[$2] = $3; + if (isempty (designs[design_idx].shape+$2)) { + designs[design_idx].shape[$2] = $3; + } + else { + yyerror ("Duplicate specification for %s shape", shape_name[$2]); + YYABORT; + } } | SHAPE slist @@ -389,7 +428,13 @@ the_shapes: the_shapes SHAPE slist "height %d)\n", shape_name[$1], $2.width, $2.height); #endif - designs[design_idx].shape[$1] = $2; + if (isempty (designs[design_idx].shape + $1)) { + designs[design_idx].shape[$1] = $2; + } + else { + yyerror ("Duplicate specification for %s shape", shape_name[$1]); + YYABORT; + } } ; @@ -453,16 +498,17 @@ slist: '(' slist_entries ')' yyerror ("warning: minimum shape dimension is 1x1 - clearing."); - $$ = (sentry_t) { NULL, 0, 0, 0 }; + $$ = SENTRY_INITIALIZER; } else { $$ = $2; + /* memcpy (&($$), &($2), sizeof(sentry_t)); */ } } | '(' ')' { - $$ = (sentry_t) { NULL, 0, 0, 0 }; + $$ = SENTRY_INITIALIZER; } ; @@ -499,7 +545,7 @@ slist_entries: slist_entries ',' STRING | STRING { - sentry_t rval; + sentry_t rval = SENTRY_INITIALIZER; #ifdef DEBUG fprintf (stderr, "Initializing a shape entry with first line\n");