/* A Bison parser, made from to_wfont.y by GNU Bison version 1.25 */ #define YYBISON 1 /* Identify Bison output. */ #define REAL 258 #define INTEGER 259 #define STRING 260 #define BOTTOM 261 #define CENTER 262 #define CLOSE 263 #define FONTNAME 264 #define PROPERTIES 265 #define NUM_CH 266 #define INDEX 267 #define L_SPACE 268 #define MAGIC 269 #define OPEN 270 #define RIGHT 271 #define R_SPACE 272 #define STROKE 273 #define TOP 274 #define VERTICES 275 #define BEARING 276 #define WIDTH 277 #line 1 "to_wfont.y" /* $XConsortium: to_wfont.y /main/9 1996/06/11 07:38:48 kaleb $ */ /* $XFree86: xc/fonts/PEX/to_wfont.y,v 3.6.2.3 1999/07/28 13:37:32 hohndel Exp $ */ /***************************************************************** Copyright (c) 1989,1990, 1991 X Consortium Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. Except as contained in this notice, the name of the X Consortium shall not be used in advertising or otherwise to promote the sale, use or other dealings in this Software without prior written authorization from the X Consortium. Copyright (c) 1989,1990, 1991 by Sun Microsystems, Inc. All Rights Reserved Permission to use, copy, modify, and distribute this software and its documentation for any purpose and without fee is hereby granted, provided that the above copyright notice appear in all copies and that both that copyright notice and this permission notice appear in supporting documentation, and that the names of Sun Microsystems, and the X Consortium, not be used in advertising or publicity pertaining to distribution of the software without specific, written prior permission. SUN MICROSYSTEMS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SUN MICROSYSTEMS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ******************************************************************/ #define YYMAXDEPTH 10000 #include #include #ifndef L_SET #define L_SET SEEK_SET #endif #include "wfont.h" #ifdef X_NOT_STDC_ENV FILE *fopen(); #endif typedef struct { float std_left, /* NCGA standard left spacing */ std_wide, /* character width */ std_rght; /* Right spacing */ } Standard; char fname[80]; Dispatch *Table; /* dispatch table */ Standard *sp_table; /* NCGA font spacings */ Path *strokes; /* strokes of each character */ Property *property; /* property list */ struct { int path, point, props; } count, expect; Path_subpath *current_path; Font_header head; /* font header */ int tableindex; /* which character */ int yyerrno; /* error number */ #line 93 "to_wfont.y" typedef union { int nil; /* void is reserved */ int ival; float dval; char *cval; } YYSTYPE; #include #ifndef __cplusplus #ifndef __STDC__ #define const #endif #endif #define YYFINAL 78 #define YYFLAG -32768 #define YYNTBASE 23 #define YYTRANSLATE(x) ((unsigned)(x) <= 277 ? yytranslate[x] : 58) static const char yytranslate[] = { 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22 }; #if YYDEBUG != 0 static const short yyprhs[] = { 0, 0, 6, 9, 13, 16, 19, 22, 25, 26, 28, 29, 34, 35, 38, 41, 42, 45, 48, 49, 53, 58, 61, 64, 65, 68, 71, 74, 75, 78, 79, 84, 85, 88, 90, 92, 94, 97, 98, 101, 102, 108, 111, 114, 117 }; static const short yyrhs[] = { 24, 28, 29, 34, 51, 0, 24, 34, 0, 25, 26, 27, 0, 9, 5, 0, 19, 3, 0, 6, 3, 0, 11, 4, 0, 0, 30, 0, 0, 10, 4, 31, 32, 0, 0, 33, 32, 0, 5, 5, 0, 0, 35, 34, 0, 36, 44, 0, 0, 39, 37, 38, 0, 40, 42, 43, 41, 0, 12, 4, 0, 18, 4, 0, 0, 20, 4, 0, 7, 3, 0, 16, 3, 0, 0, 45, 44, 0, 0, 48, 49, 46, 47, 0, 0, 50, 47, 0, 8, 0, 15, 0, 4, 0, 3, 3, 0, 0, 52, 51, 0, 0, 54, 53, 55, 56, 57, 0, 21, 4, 0, 13, 3, 0, 22, 3, 0, 17, 3, 0 }; #endif #if YYDEBUG != 0 static const short yyrline[] = { 0, 133, 133, 136, 139, 142, 144, 146, 148, 148, 150, 151, 153, 153, 155, 157, 158, 160, 163, 163, 165, 168, 170, 172, 172, 174, 176, 178, 178, 180, 181, 183, 183, 185, 185, 187, 189, 191, 192, 194, 194, 197, 199, 201, 203 }; #endif #if YYDEBUG != 0 || defined (YYERROR_VERBOSE) static const char * const yytname[] = { "$","error","$undefined.","REAL","INTEGER", "STRING","BOTTOM","CENTER","CLOSE","FONTNAME","PROPERTIES","NUM_CH","INDEX", "L_SPACE","MAGIC","OPEN","RIGHT","R_SPACE","STROKE","TOP","VERTICES","BEARING", "WIDTH","font","fontheader","fontname","top","bottom","num_ch","fontprops","properties", "@1","property_list","single_property","fontbody","glyph","glyph_header","@2", "sym_headinfo","index","nstroke","nvertice","center","right","strokes","path", "@3","points","closeflag","n_pts","coord","spacing","item","@4","counter","sp_left", "wide","sp_right", NULL }; #endif static const short yyr1[] = { 0, 23, 23, 24, 25, 26, 27, 28, 29, 29, 31, 30, 32, 32, 33, 34, 34, 35, 37, 36, 38, 39, 40, 41, 41, 42, 43, 44, 44, 46, 45, 47, 47, 48, 48, 49, 50, 51, 51, 53, 52, 54, 55, 56, 57 }; static const short yyr2[] = { 0, 5, 2, 3, 2, 2, 2, 2, 0, 1, 0, 4, 0, 2, 2, 0, 2, 2, 0, 3, 4, 2, 2, 0, 2, 2, 2, 0, 2, 0, 4, 0, 2, 1, 1, 1, 2, 0, 2, 0, 5, 2, 2, 2, 2 }; static const short yydefact[] = { 0, 0, 15, 0, 4, 0, 0, 8, 2, 15, 27, 18, 0, 0, 7, 21, 0, 15, 9, 16, 33, 34, 17, 27, 0, 0, 5, 0, 3, 10, 37, 28, 35, 29, 0, 19, 0, 6, 12, 0, 1, 37, 39, 31, 22, 0, 0, 0, 11, 12, 41, 38, 0, 0, 30, 31, 25, 0, 23, 14, 13, 0, 0, 36, 32, 26, 0, 20, 42, 0, 0, 24, 43, 0, 40, 44, 0, 0, 0 }; static const short yydefgoto[] = { 76, 2, 3, 13, 28, 7, 17, 18, 38, 48, 49, 8, 9, 10, 25, 35, 11, 36, 67, 46, 58, 22, 23, 43, 54, 24, 33, 55, 40, 41, 52, 42, 62, 70, 74 }; static const short yypact[] = { -4, 1, -8, -18,-32768, 3, 6, 2,-32768, -1, -6, -32768, 10, 8,-32768,-32768, 11, -1,-32768,-32768,-32768, -32768,-32768, -6, 12, 0,-32768, 14,-32768,-32768, -2, -32768,-32768,-32768, 16,-32768, 15,-32768, 18, 17,-32768, -2,-32768, 21,-32768, 22, 13, 23,-32768, 18,-32768, -32768, 19, 24,-32768, 21,-32768, 27, 20,-32768,-32768, 28, 4,-32768,-32768,-32768, 29,-32768,-32768, 31, 25, -32768,-32768, 32,-32768,-32768, 36, 37,-32768 }; static const short yypgoto[] = {-32768, -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, -11,-32768, -9,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, 26,-32768,-32768, -16,-32768,-32768,-32768, 5,-32768,-32768, -32768,-32768,-32768,-32768 }; #define YYLAST 49 static const short yytable[] = { 19, 12, 20, 5, 6, 1, 4, 14, 30, 21, 15, 6, 16, 26, 27, 29, 32, 37, 34, 39, 44, 50, 45, 47, 53, 56, 69, 63, 59, 57, 65, 68, 61, 71, 72, 75, 77, 78, 60, 64, 66, 0, 73, 0, 0, 0, 51, 0, 0, 31 }; static const short yycheck[] = { 9, 19, 8, 11, 12, 9, 5, 4, 17, 15, 4, 12, 10, 3, 6, 4, 4, 3, 18, 21, 4, 4, 7, 5, 3, 3, 22, 3, 5, 16, 3, 3, 13, 4, 3, 3, 0, 0, 49, 55, 20, -1, 17, -1, -1, -1, 41, -1, -1, 23 }; /* -*-C-*- Note some compilers choke on comments on `#line' lines. */ #line 3 "bison.simple" /* Skeleton output parser for bison, Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc. This program 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 2, 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, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* As a special exception, when this file is copied by Bison into a Bison output file, you may use that output file without restriction. This special exception was added by the Free Software Foundation in version 1.24 of Bison. */ #ifndef alloca #ifdef __GNUC__ #define alloca __builtin_alloca #else /* not GNU C. */ #if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi) #include #else /* not sparc */ #if defined (MSDOS) && !defined (__TURBOC__) #include #else /* not MSDOS, or __TURBOC__ */ #if defined(_AIX) #include #pragma alloca #else /* not MSDOS, __TURBOC__, or _AIX */ #ifdef __hpux #ifdef __cplusplus extern "C" { void *alloca (unsigned int); }; #else /* not __cplusplus */ void *alloca (); #endif /* not __cplusplus */ #endif /* __hpux */ #endif /* not _AIX */ #endif /* not MSDOS, or __TURBOC__ */ #endif /* not sparc. */ #endif /* not GNU C. */ #endif /* alloca not defined. */ /* This is the parser code that is written into each bison parser when the %semantic_parser declaration is not specified in the grammar. It was written by Richard Stallman by simplifying the hairy parser used when %semantic_parser is specified. */ /* Note: there must be only one dollar sign in this file. It is replaced by the list of actions, each action as one case of the switch. */ #define yyerrok (yyerrstatus = 0) #define yyclearin (yychar = YYEMPTY) #define YYEMPTY -2 #define YYEOF 0 #define YYACCEPT return(0) #define YYABORT return(1) #define YYERROR goto yyerrlab1 /* Like YYERROR except do call yyerror. This remains here temporarily to ease the transition to the new meaning of YYERROR, for GCC. Once GCC version 2 has supplanted version 1, this can go. */ #define YYFAIL goto yyerrlab #define YYRECOVERING() (!!yyerrstatus) #define YYBACKUP(token, value) \ do \ if (yychar == YYEMPTY && yylen == 1) \ { yychar = (token), yylval = (value); \ yychar1 = YYTRANSLATE (yychar); \ YYPOPSTACK; \ goto yybackup; \ } \ else \ { yyerror ("syntax error: cannot back up"); YYERROR; } \ while (0) #define YYTERROR 1 #define YYERRCODE 256 #ifndef YYPURE #define YYLEX yylex() #endif #ifdef YYPURE #ifdef YYLSP_NEEDED #ifdef YYLEX_PARAM #define YYLEX yylex(&yylval, &yylloc, YYLEX_PARAM) #else #define YYLEX yylex(&yylval, &yylloc) #endif #else /* not YYLSP_NEEDED */ #ifdef YYLEX_PARAM #define YYLEX yylex(&yylval, YYLEX_PARAM) #else #define YYLEX yylex(&yylval) #endif #endif /* not YYLSP_NEEDED */ #endif /* If nonreentrant, generate the variables here */ #ifndef YYPURE int yychar; /* the lookahead symbol */ YYSTYPE yylval; /* the semantic value of the */ /* lookahead symbol */ #ifdef YYLSP_NEEDED YYLTYPE yylloc; /* location data for the lookahead */ /* symbol */ #endif int yynerrs; /* number of parse errors so far */ #endif /* not YYPURE */ #if YYDEBUG != 0 int yydebug; /* nonzero means print parse trace */ /* Since this is uninitialized, it does not stop multiple parsers from coexisting. */ #endif /* YYINITDEPTH indicates the initial size of the parser's stacks */ #ifndef YYINITDEPTH #define YYINITDEPTH 200 #endif /* YYMAXDEPTH is the maximum size the stacks can grow to (effective only if the built-in stack extension method is used). */ #if YYMAXDEPTH == 0 #undef YYMAXDEPTH #endif #ifndef YYMAXDEPTH #define YYMAXDEPTH 10000 #endif /* Prevent warning if -Wstrict-prototypes. */ #ifdef __GNUC__ int yyparse (void); #endif #if __GNUC__ > 1 /* GNU C and GNU C++ define this. */ #define __yy_memcpy(TO,FROM,COUNT) __builtin_memcpy(TO,FROM,COUNT) #else /* not GNU C or C++ */ #ifndef __cplusplus /* This is the most reliable way to avoid incompatibilities in available built-in functions on various systems. */ static void __yy_memcpy (to, from, count) char *to; char *from; int count; { register char *f = from; register char *t = to; register int i = count; while (i-- > 0) *t++ = *f++; } #else /* __cplusplus */ /* This is the most reliable way to avoid incompatibilities in available built-in functions on various systems. */ static void __yy_memcpy (char *to, char *from, int count) { register char *f = from; register char *t = to; register int i = count; while (i-- > 0) *t++ = *f++; } #endif #endif #line 196 "bison.simple" /* The user can define YYPARSE_PARAM as the name of an argument to be passed into yyparse. The argument should have type void *. It should actually point to an object. Grammar actions can access the variable by casting it to the proper pointer type. */ #ifdef YYPARSE_PARAM #ifdef __cplusplus #define YYPARSE_PARAM_ARG void *YYPARSE_PARAM #define YYPARSE_PARAM_DECL #else /* not __cplusplus */ #define YYPARSE_PARAM_ARG YYPARSE_PARAM #define YYPARSE_PARAM_DECL void *YYPARSE_PARAM; #endif /* not __cplusplus */ #else /* not YYPARSE_PARAM */ #define YYPARSE_PARAM_ARG #define YYPARSE_PARAM_DECL #endif /* not YYPARSE_PARAM */ int yyparse(YYPARSE_PARAM_ARG) YYPARSE_PARAM_DECL { register int yystate; register int yyn; register short *yyssp; register YYSTYPE *yyvsp; int yyerrstatus; /* number of tokens to shift before error messages enabled */ int yychar1 = 0; /* lookahead token as an internal (translated) token number */ short yyssa[YYINITDEPTH]; /* the state stack */ YYSTYPE yyvsa[YYINITDEPTH]; /* the semantic value stack */ short *yyss = yyssa; /* refer to the stacks thru separate pointers */ YYSTYPE *yyvs = yyvsa; /* to allow yyoverflow to reallocate them elsewhere */ #ifdef YYLSP_NEEDED YYLTYPE yylsa[YYINITDEPTH]; /* the location stack */ YYLTYPE *yyls = yylsa; YYLTYPE *yylsp; #define YYPOPSTACK (yyvsp--, yyssp--, yylsp--) #else #define YYPOPSTACK (yyvsp--, yyssp--) #endif int yystacksize = YYINITDEPTH; #ifdef YYPURE int yychar; YYSTYPE yylval; int yynerrs; #ifdef YYLSP_NEEDED YYLTYPE yylloc; #endif #endif YYSTYPE yyval; /* the variable used to return */ /* semantic values from the action */ /* routines */ int yylen; #if YYDEBUG != 0 if (yydebug) fprintf(stderr, "Starting parse\n"); #endif yystate = 0; yyerrstatus = 0; yynerrs = 0; yychar = YYEMPTY; /* Cause a token to be read. */ /* Initialize stack pointers. Waste one element of value and location stack so that they stay on the same level as the state stack. The wasted elements are never initialized. */ yyssp = yyss - 1; yyvsp = yyvs; #ifdef YYLSP_NEEDED yylsp = yyls; #endif /* Push a new state, which is found in yystate . */ /* In all cases, when you get here, the value and location stacks have just been pushed. so pushing a state here evens the stacks. */ yynewstate: *++yyssp = yystate; if (yyssp >= yyss + yystacksize - 1) { /* Give user a chance to reallocate the stack */ /* Use copies of these so that the &'s don't force the real ones into memory. */ YYSTYPE *yyvs1 = yyvs; short *yyss1 = yyss; #ifdef YYLSP_NEEDED YYLTYPE *yyls1 = yyls; #endif /* Get the current used size of the three stacks, in elements. */ int size = yyssp - yyss + 1; #ifdef yyoverflow /* Each stack pointer address is followed by the size of the data in use in that stack, in bytes. */ #ifdef YYLSP_NEEDED /* This used to be a conditional around just the two extra args, but that might be undefined if yyoverflow is a macro. */ yyoverflow("parser stack overflow", &yyss1, size * sizeof (*yyssp), &yyvs1, size * sizeof (*yyvsp), &yyls1, size * sizeof (*yylsp), &yystacksize); #else yyoverflow("parser stack overflow", &yyss1, size * sizeof (*yyssp), &yyvs1, size * sizeof (*yyvsp), &yystacksize); #endif yyss = yyss1; yyvs = yyvs1; #ifdef YYLSP_NEEDED yyls = yyls1; #endif #else /* no yyoverflow */ /* Extend the stack our own way. */ if (yystacksize >= YYMAXDEPTH) { yyerror("parser stack overflow"); return 2; } yystacksize *= 2; if (yystacksize > YYMAXDEPTH) yystacksize = YYMAXDEPTH; yyss = (short *) alloca (yystacksize * sizeof (*yyssp)); __yy_memcpy ((char *)yyss, (char *)yyss1, size * sizeof (*yyssp)); yyvs = (YYSTYPE *) alloca (yystacksize * sizeof (*yyvsp)); __yy_memcpy ((char *)yyvs, (char *)yyvs1, size * sizeof (*yyvsp)); #ifdef YYLSP_NEEDED yyls = (YYLTYPE *) alloca (yystacksize * sizeof (*yylsp)); __yy_memcpy ((char *)yyls, (char *)yyls1, size * sizeof (*yylsp)); #endif #endif /* no yyoverflow */ yyssp = yyss + size - 1; yyvsp = yyvs + size - 1; #ifdef YYLSP_NEEDED yylsp = yyls + size - 1; #endif #if YYDEBUG != 0 if (yydebug) fprintf(stderr, "Stack size increased to %d\n", yystacksize); #endif if (yyssp >= yyss + yystacksize - 1) YYABORT; } #if YYDEBUG != 0 if (yydebug) fprintf(stderr, "Entering state %d\n", yystate); #endif goto yybackup; yybackup: /* Do appropriate processing given the current state. */ /* Read a lookahead token if we need one and don't already have one. */ /* yyresume: */ /* First try to decide what to do without reference to lookahead token. */ yyn = yypact[yystate]; if (yyn == YYFLAG) goto yydefault; /* Not known => get a lookahead token if don't already have one. */ /* yychar is either YYEMPTY or YYEOF or a valid token in external form. */ if (yychar == YYEMPTY) { #if YYDEBUG != 0 if (yydebug) fprintf(stderr, "Reading a token: "); #endif yychar = YYLEX; } /* Convert token to internal form (in yychar1) for indexing tables with */ if (yychar <= 0) /* This means end of input. */ { yychar1 = 0; yychar = YYEOF; /* Don't call YYLEX any more */ #if YYDEBUG != 0 if (yydebug) fprintf(stderr, "Now at end of input.\n"); #endif } else { yychar1 = YYTRANSLATE(yychar); #if YYDEBUG != 0 if (yydebug) { fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]); /* Give the individual parser a way to print the precise meaning of a token, for further debugging info. */ #ifdef YYPRINT YYPRINT (stderr, yychar, yylval); #endif fprintf (stderr, ")\n"); } #endif } yyn += yychar1; if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1) goto yydefault; yyn = yytable[yyn]; /* yyn is what to do for this token type in this state. Negative => reduce, -yyn is rule number. Positive => shift, yyn is new state. New state is final state => don't bother to shift, just return success. 0, or most negative number => error. */ if (yyn < 0) { if (yyn == YYFLAG) goto yyerrlab; yyn = -yyn; goto yyreduce; } else if (yyn == 0) goto yyerrlab; if (yyn == YYFINAL) YYACCEPT; /* Shift the lookahead token. */ #if YYDEBUG != 0 if (yydebug) fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]); #endif /* Discard the token being shifted unless it is eof. */ if (yychar != YYEOF) yychar = YYEMPTY; *++yyvsp = yylval; #ifdef YYLSP_NEEDED *++yylsp = yylloc; #endif /* count tokens shifted since error; after three, turn off error status. */ if (yyerrstatus) yyerrstatus--; yystate = yyn; goto yynewstate; /* Do the default action for the current state. */ yydefault: yyn = yydefact[yystate]; if (yyn == 0) goto yyerrlab; /* Do a reduction. yyn is the number of a rule to reduce with. */ yyreduce: yylen = yyr2[yyn]; if (yylen > 0) yyval = yyvsp[1-yylen]; /* implement default value of the action */ #if YYDEBUG != 0 if (yydebug) { int i; fprintf (stderr, "Reducing via rule %d (line %d), ", yyn, yyrline[yyn]); /* Print the symbols being reduced, and their result. */ for (i = yyprhs[yyn]; yyrhs[i] > 0; i++) fprintf (stderr, "%s ", yytname[yyrhs[i]]); fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]); } #endif switch (yyn) { case 1: #line 133 "to_wfont.y" { fini(); ; break;} case 2: #line 134 "to_wfont.y" { fini(); ; break;} case 3: #line 137 "to_wfont.y" { wf_header(yyvsp[-2].cval, yyvsp[-1].dval, yyvsp[0].dval); ; break;} case 4: #line 140 "to_wfont.y" { yyval.cval = yyvsp[0].cval; ; break;} case 5: #line 142 "to_wfont.y" { yyval.dval = yyvsp[0].dval;; break;} case 6: #line 144 "to_wfont.y" { yyval.dval = yyvsp[0].dval;; break;} case 7: #line 146 "to_wfont.y" { set_num_ch(yyvsp[0].ival);; break;} case 10: #line 150 "to_wfont.y" { init_properties (yyvsp[0].ival); ; break;} case 11: #line 151 "to_wfont.y" { check_num_props (); ; break;} case 14: #line 155 "to_wfont.y" { add_property(yyvsp[-1].cval, yyvsp[0].cval); ; break;} case 17: #line 161 "to_wfont.y" { check_nstroke(); ; break;} case 18: #line 163 "to_wfont.y" { tableindex = yyvsp[0].ival; ; break;} case 20: #line 166 "to_wfont.y" { glyph_header(yyvsp[-3].ival, yyvsp[-2].dval, yyvsp[-1].dval, yyvsp[0].ival); ; break;} case 21: #line 168 "to_wfont.y" { check_num_ch(); yyval.ival = yyvsp[0].ival; ; break;} case 22: #line 170 "to_wfont.y" { yyval.ival = yyvsp[0].ival; expect.path = yyvsp[0].ival; ; break;} case 23: #line 172 "to_wfont.y" {yyval.ival = 0;; break;} case 24: #line 172 "to_wfont.y" { yyval.ival = yyvsp[0].ival; ; break;} case 25: #line 174 "to_wfont.y" { yyval.dval = yyvsp[0].dval; ; break;} case 26: #line 176 "to_wfont.y" { yyval.dval = yyvsp[0].dval; ; break;} case 29: #line 180 "to_wfont.y" { init_path(yyvsp[-1].ival, yyvsp[0].ival); ; break;} case 30: #line 181 "to_wfont.y" { check_npts(); ; break;} case 33: #line 185 "to_wfont.y" { yyval.ival = yyvsp[0].nil == CLOSE; ; break;} case 34: #line 185 "to_wfont.y" { yyval.ival = yyvsp[0].nil == CLOSE; ; break;} case 35: #line 187 "to_wfont.y" { yyval.ival = yyvsp[0].ival; ; break;} case 36: #line 189 "to_wfont.y" { add_point(yyvsp[-1].dval, yyvsp[0].dval); ; break;} case 39: #line 194 "to_wfont.y" {tableindex = yyvsp[0].ival;; break;} case 40: #line 195 "to_wfont.y" { std_space(yyvsp[-2].dval, yyvsp[-1].dval, yyvsp[0].dval); ; break;} case 41: #line 197 "to_wfont.y" {yyval.ival = yyvsp[0].ival;; break;} case 42: #line 199 "to_wfont.y" {yyval.dval = yyvsp[0].dval;; break;} case 43: #line 201 "to_wfont.y" {yyval.dval = yyvsp[0].dval;; break;} case 44: #line 203 "to_wfont.y" {yyval.dval = yyvsp[0].dval;; break;} } /* the action file gets copied in in place of this dollarsign */ #line 498 "bison.simple" yyvsp -= yylen; yyssp -= yylen; #ifdef YYLSP_NEEDED yylsp -= yylen; #endif #if YYDEBUG != 0 if (yydebug) { short *ssp1 = yyss - 1; fprintf (stderr, "state stack now"); while (ssp1 != yyssp) fprintf (stderr, " %d", *++ssp1); fprintf (stderr, "\n"); } #endif *++yyvsp = yyval; #ifdef YYLSP_NEEDED yylsp++; if (yylen == 0) { yylsp->first_line = yylloc.first_line; yylsp->first_column = yylloc.first_column; yylsp->last_line = (yylsp-1)->last_line; yylsp->last_column = (yylsp-1)->last_column; yylsp->text = 0; } else { yylsp->last_line = (yylsp+yylen-1)->last_line; yylsp->last_column = (yylsp+yylen-1)->last_column; } #endif /* Now "shift" the result of the reduction. Determine what state that goes to, based on the state we popped back to and the rule number reduced by. */ yyn = yyr1[yyn]; yystate = yypgoto[yyn - YYNTBASE] + *yyssp; if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp) yystate = yytable[yystate]; else yystate = yydefgoto[yyn - YYNTBASE]; goto yynewstate; yyerrlab: /* here on detecting error */ if (! yyerrstatus) /* If not already recovering from an error, report this error. */ { ++yynerrs; #ifdef YYERROR_VERBOSE yyn = yypact[yystate]; if (yyn > YYFLAG && yyn < YYLAST) { int size = 0; char *msg; int x, count; count = 0; /* Start X at -yyn if nec to avoid negative indexes in yycheck. */ for (x = (yyn < 0 ? -yyn : 0); x < (sizeof(yytname) / sizeof(char *)); x++) if (yycheck[x + yyn] == x) size += strlen(yytname[x]) + 15, count++; msg = (char *) malloc(size + 15); if (msg != 0) { strcpy(msg, "parse error"); if (count < 5) { count = 0; for (x = (yyn < 0 ? -yyn : 0); x < (sizeof(yytname) / sizeof(char *)); x++) if (yycheck[x + yyn] == x) { strcat(msg, count == 0 ? ", expecting `" : " or `"); strcat(msg, yytname[x]); strcat(msg, "'"); count++; } } yyerror(msg); free(msg); } else yyerror ("parse error; also virtual memory exceeded"); } else #endif /* YYERROR_VERBOSE */ yyerror("parse error"); } goto yyerrlab1; yyerrlab1: /* here on error raised explicitly by an action */ if (yyerrstatus == 3) { /* if just tried and failed to reuse lookahead token after an error, discard it. */ /* return failure if at end of input */ if (yychar == YYEOF) YYABORT; #if YYDEBUG != 0 if (yydebug) fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]); #endif yychar = YYEMPTY; } /* Else will try to reuse lookahead token after shifting the error token. */ yyerrstatus = 3; /* Each real token shifted decrements this */ goto yyerrhandle; yyerrdefault: /* current state does not do anything special for the error token. */ #if 0 /* This is wrong; only states that explicitly want error tokens should shift them. */ yyn = yydefact[yystate]; /* If its default is to accept any token, ok. Otherwise pop it.*/ if (yyn) goto yydefault; #endif yyerrpop: /* pop the current state because it cannot handle the error token */ if (yyssp == yyss) YYABORT; yyvsp--; yystate = *--yyssp; #ifdef YYLSP_NEEDED yylsp--; #endif #if YYDEBUG != 0 if (yydebug) { short *ssp1 = yyss - 1; fprintf (stderr, "Error: state stack now"); while (ssp1 != yyssp) fprintf (stderr, " %d", *++ssp1); fprintf (stderr, "\n"); } #endif yyerrhandle: yyn = yypact[yystate]; if (yyn == YYFLAG) goto yyerrdefault; yyn += YYTERROR; if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR) goto yyerrdefault; yyn = yytable[yyn]; if (yyn < 0) { if (yyn == YYFLAG) goto yyerrpop; yyn = -yyn; goto yyreduce; } else if (yyn == 0) goto yyerrpop; if (yyn == YYFINAL) YYACCEPT; #if YYDEBUG != 0 if (yydebug) fprintf(stderr, "Shifting error token, "); #endif *++yyvsp = yylval; #ifdef YYLSP_NEEDED *++yylsp = yylloc; #endif yystate = yyn; goto yynewstate; } #line 205 "to_wfont.y" #define BYE(err) yyerrno = (err), yyerror() #define ERR_BASE 1000 #define OPEN_ERROR 1001 #define WRITE_ERROR 1002 #define WRONG_NAME 1003 #define NO_MEMORY 1004 #define EXCEED_PATH 1005 #define EXCEED_POINT 1006 #define PATH_MISMATCH 1007 #define POINT_MISMATCH 1008 #define PROP_MISMATCH 1009 #define EXCEED_PROPS 1010 char *prog; main(argc, argv) int argc; char *argv[]; { /* Usage : to_wfont [-o outfile] [infile] */ char *s; fname[0] = 0; tableindex = 0; head.num_ch = -1; prog = *argv; while (--argc > 0 && *++argv != NULL) { s = *argv; if (*s++ == '-') switch (*s) { case 'o': if (*++argv != NULL) { --argc; (void) strcpy(fname, *argv); } break; default: /* ignore other options */ ; } else { FILE *fp; /* standard input redirection */ fp = fopen(*argv, "r"); if (fp != NULL) { if (close(fileno(stdin)) < 0) { perror(prog); return; } if (dup(fileno(fp)) < 0) { perror(prog); return; } (void) fclose(fp); } } } #if defined(__QNX__) yyparse(); return; #else return (yyparse()); #endif } /* set number of characters */ set_num_ch(num_ch) int num_ch; { yyerrno = 0; head.num_ch = num_ch; if (num_ch > 0) { Table = (Dispatch *) malloc(num_ch * sizeof(Dispatch)); sp_table = (Standard *) malloc(num_ch * sizeof(Standard)); strokes = (Path *) malloc(num_ch * sizeof(Path)); } for (tableindex = 0; tableindex < num_ch; tableindex++) { Table[tableindex].center = 0.0; Table[tableindex].right = 0.0; Table[tableindex].offset = 0; sp_table[tableindex].std_left = 0.0; sp_table[tableindex].std_wide = 0.0; sp_table[tableindex].std_rght = 0.0; strokes[tableindex].n_subpaths = 0; strokes[tableindex].n_vertices = 0; strokes[tableindex].subpaths = NULL; } } /* initialize the property info in the header */ init_properties(num_props) int num_props; { if (num_props > 0) { head.properties = (Property *) malloc (num_props * sizeof (Property)); head.num_props = expect.props = num_props; } else { head.properties = NULL; head.num_props = expect.props = 0; } count.props = -1; property = head.properties; /* initialize the list pointer */ } check_num_props() { count.props++; if (count.props != expect.props) BYE (PROP_MISMATCH); } /* add individual property info into the buffer */ add_property(name, value) char *name, *value; { /* check if the property exceeds allocated space */ if (++count.props >= head.num_props) BYE(EXCEED_PROPS); /* copy the strings into the buffer */ (void) strcpy (property->propname, name); (void) strcpy (property->propvalue, value); /* increment the property pointer */ property++; } check_num_ch() { if (head.num_ch == -1) set_num_ch(128); } yyerror() { #if !defined(CSRG_BASED) && !defined(linux) && !defined(Lynx) && !defined(__GNU__) && !defined(__QNX__) extern int yylineno; #endif # define ERR_SIZE (sizeof(err_string) / sizeof(char *)) static char *err_string[] = { "Cannot open file", "Write fails", "Illegal font name", "Memory allocation failure", "Specified number of strokes exceeded", "Specified number of points exceeded", "Number of strokes do not match", "Number of points do not match", "Number of properties do not match", "Specified number of properties exceeded", 0}; char *str; yyerrno -= ERR_BASE; if (yyerrno > 0 && yyerrno < ERR_SIZE) str = err_string[yyerrno-1]; else str = "Syntax error"; #if !defined(CSRG_BASED) && !defined(linux) && !defined(Lynx) && !defined(__GNU__) && !defined(__QNX__) fprintf(stderr, "line %d: %s.\n", yylineno, str); #else fprintf(stderr, "%s.\n", str); #endif freeall(); (void) unlink(fname); exit(1); } /* create wfont header */ wf_header(name, top, bottom) char *name; float top, bottom; { if (name == NULL) BYE(WRONG_NAME); head.top = (float) top; head.bottom = (float) bottom; head.magic = WFONT_MAGIC_PEX; (void) strcpy(head.name, name); free(name); } /* create header for each glyph */ glyph_header(npath, center, right, npts) int npath, npts; float center, right; { { register Path *strk = strokes + tableindex; if (npath > 0) /* Don't allocate space unless the character has strokes associated with it. */ { strk->subpaths = (Path_subpath *) malloc(npath * sizeof (Path_subpath)); if (strk->subpaths == NULL) BYE(NO_MEMORY); strk->type = PATH_2DF; strk->n_subpaths = npath; strk->n_vertices = npts; } else { /* Just initialize the entry */ strk->subpaths = NULL; strk->type = PATH_2DF; strk->n_subpaths = 0; strk->n_vertices = 0; } } { register Dispatch *tbl = Table + tableindex; tbl->offset = 0; tbl->center = center; tbl->right = right; } count.path = -1; /* initialize path counter, not to * exceed n_subpath */ } /* create standard spacing info for each glyph */ std_space(l_bear, wide, r_bear) float l_bear, wide, r_bear; { register Standard *tbl = sp_table +tableindex; tbl->std_left = l_bear; tbl->std_wide = wide; tbl->std_rght = r_bear; } /* initialize each sub_path */ init_path(close, n) int close, n; { register Path_subpath *path; if (++count.path >= strokes[tableindex].n_subpaths) BYE(EXCEED_PATH); path = current_path = strokes[tableindex].subpaths + count.path; path->n_pts = n; path->closed = close; if (n > 0) path->pts.pt2df = (Path_point2df *) malloc(n * sizeof (Path_point2df)); if (path->pts.pt2df == NULL) BYE(NO_MEMORY); expect.point = path->n_pts; count.point = -1; /* initialize point counter, not to * exceed n_pts */ } /* accumulating points for each sub_path */ add_point(x, y) float x, y; { register Path_subpath *path; register Path_point2df *pt_ptr; path = current_path; if (++count.point >= path->n_pts) BYE(EXCEED_POINT); pt_ptr = path->pts.pt2df + count.point; pt_ptr->x = x; pt_ptr->y = y; } /* Path_type + n_subpaths + n_vertices */ #define STROKE_HEAD (sizeof (Path_type) + sizeof (int) + sizeof (int)) /* write out file, close everything, free everything */ fini() { static long zero = 0; /* pointers used to walk the arrays */ register Path_subpath *spath; register Dispatch *tbl_ptr; register Path *strptr; register Property *prop_ptr; FILE *fp; long offset; int npath; register int i, j, k; Standard *sp_ptr; Path_point2df *pt; if (fname[0] == 0) { /* default output file name */ (void) strcpy(fname, head.name); (void) strcat(fname, ".phont"); } if ((fp = fopen(fname, "w")) == NULL) BYE(OPEN_ERROR); # define BY_BYE(err) fclose(fp), BYE(err) /* adjust the characters for spacing, note max char width */ head.max_width = 0.0; for (i = 0, tbl_ptr = Table, strptr = strokes, sp_ptr = sp_table; i < head.num_ch; i++, tbl_ptr++, strptr++, sp_ptr++) { tbl_ptr->center += sp_ptr->std_left; tbl_ptr->right += sp_ptr->std_left + sp_ptr->std_rght; if (tbl_ptr->right > head.max_width) head.max_width = tbl_ptr->right; npath = strptr->n_subpaths; if (npath > 0 || tbl_ptr->center != 0.0 || tbl_ptr->right != 0.0) { for (j = 0, spath = strptr->subpaths; j < npath; j++, spath++) { for(k=0, pt = spath->pts.pt2df; kn_pts; k++, pt++) { pt->x += sp_ptr->std_left; } } } } /* write the header info */ if (fwrite(&head, sizeof (head), 1, fp) != 1) BY_BYE(WRITE_ERROR); (void) fseek(fp, START_PROPS, L_SET); /* write the property info, if any */ if (head.num_props > 0) { for (i=0, prop_ptr = head.properties; i < head.num_props; i++, prop_ptr++) { /* write the property name */ if (fwrite(prop_ptr->propname, 80, 1, fp) != 1) BY_BYE(WRITE_ERROR); /* write the property value */ if (fwrite(prop_ptr->propvalue, 80, 1, fp) != 1) BY_BYE(WRITE_ERROR); } } (void) fseek(fp, START_DISPATCH(head.num_props), L_SET); offset = START_PATH(head.num_ch, head.num_props); /* write the dispatch table */ for (i = 0, tbl_ptr = Table, strptr = strokes; i < head.num_ch; i++, tbl_ptr++, strptr++) { if (fwrite(&tbl_ptr->center, sizeof (float), 1, fp) != 1 || fwrite(&tbl_ptr->right, sizeof (float), 1, fp) != 1) BY_BYE(WRITE_ERROR); npath = strptr->n_subpaths; if (npath > 0 || tbl_ptr->center != 0.0 || tbl_ptr->right != 0.0) { if (fwrite(&offset, sizeof (offset), 1, fp) != 1) BY_BYE(WRITE_ERROR); offset += STROKE_HEAD + npath * 2 * sizeof (int); for (j = 0, spath = strptr->subpaths; j < npath; j++, spath++) offset += spath->n_pts * sizeof (Path_point2df); } else if (fwrite(&zero, sizeof (long), 1, fp) != 1) BY_BYE(WRITE_ERROR); } (void) fseek(fp, START_PATH(head.num_ch, head.num_props), L_SET); /* write the stroke table */ for (i = 0, tbl_ptr = Table, strptr = strokes; i < head.num_ch; i++, tbl_ptr++, strptr++) { if (strptr->n_subpaths > 0 || tbl_ptr->center != 0.0 || tbl_ptr->right != 0.0) { if (fwrite(strptr, STROKE_HEAD, 1, fp) != 1) BY_BYE(WRITE_ERROR); for (j = 0, spath = strptr->subpaths; j < strptr->n_subpaths; j++, spath++) { if (fwrite(&spath->n_pts, sizeof (spath->n_pts), 1, fp) != 1 || fwrite(&spath->closed, sizeof (spath->closed), 1, fp) != 1 || fwrite(spath->pts.pt2df, sizeof (Path_point2df), spath->n_pts, fp) != spath->n_pts) BY_BYE(WRITE_ERROR); } } } (void) fclose(fp); freeall(); # undef BY_BYE } freeall() { register Path *path; register Path_subpath *spath; register int i, j, n; path = strokes; for (i = 0; i < head.num_ch; i++, path++) { n = path->n_subpaths; if (n <= 0) continue; spath = path->subpaths; for (j = 0; j < n; j++, spath++) if (spath->pts.pt2df != NULL) free((char *) spath->pts.pt2df); if (path->subpaths != NULL) free((char *) path->subpaths); } if (Table) free(Table); if (sp_table) free(sp_table); if (strokes) free(strokes); if (head.properties != NULL) free((char *) head.properties); } check_nstroke() { count.path++; if (expect.path != count.path) BYE(PATH_MISMATCH); } check_npts() { count.point++; if (expect.point != count.point) BYE(POINT_MISMATCH); }