2 /* A Bison parser, made from reclass.y
3 by GNU Bison version 1.25
6 #define YYBISON 1 /* Identify Bison output. */
20 int curval,startval,endval,loop_var;
22 int interactive_parser=0;
40 #define YYTRANSLATE(x) ((unsigned)(x) <= 258 ? yytranslate[x] : 18)
42 static const char yytranslate[] = { 0,
43 2, 2, 2, 2, 2, 2, 2, 2, 2, 8,
44 2, 2, 9, 2, 2, 2, 2, 2, 2, 2,
45 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
46 2, 2, 2, 2, 2, 2, 2, 2, 2, 5,
47 7, 2, 2, 2, 2, 2, 2, 2, 2, 2,
48 2, 2, 2, 2, 2, 2, 2, 6, 2, 2,
49 4, 2, 2, 2, 2, 2, 2, 2, 2, 2,
50 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
51 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
52 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
53 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
54 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
55 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
56 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
57 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
58 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
59 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
60 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
61 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
62 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
63 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
64 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
65 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
66 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
67 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
68 2, 2, 2, 2, 2, 1, 2, 3
72 static const short yyprhs[] = { 0,
73 0, 2, 6, 7, 10, 12, 14, 17, 24, 26,
74 29, 31, 34, 36, 40, 42
77 static const short yyrhs[] = { 11,
78 0, 10, 13, 11, 0, 0, 12, 14, 0, 17,
79 0, 1, 0, 16, 4, 0, 5, 16, 6, 16,
80 7, 4, 0, 8, 0, 9, 8, 0, 15, 0,
81 14, 15, 0, 16, 0, 16, 6, 16, 0, 3,
82 0, 16, 6, 16, 4, 16, 6, 16, 0
88 static const short yyrline[] = { 0,
89 17, 19, 22, 23, 24, 25, 31, 32, 34, 35,
90 36, 37, 38, 46, 54, 59
95 #if YYDEBUG != 0 || defined (YYERROR_VERBOSE)
97 static const char * const yytname[] = { "$","error","$undefined.","NUMBER",
98 "'='","'('","':'","')'","'\\n'","'\\r'","list","statement","dest","eol","range",
99 "subrange","value","map_statement", NULL
103 static const short yyr1[] = { 0,
104 10, 10, 11, 11, 11, 11, 12, 12, 13, 13,
105 14, 14, 15, 15, 16, 17
108 static const short yyr2[] = { 0,
109 1, 3, 0, 2, 1, 1, 2, 6, 1, 2,
113 static const short yydefact[] = { 0,
114 6, 15, 0, 0, 1, 0, 0, 5, 0, 9,
115 0, 0, 4, 11, 13, 7, 0, 0, 10, 2,
116 12, 0, 0, 0, 14, 0, 0, 0, 8, 0,
120 static const short yydefgoto[] = { 4,
121 5, 6, 12, 13, 14, 7, 8
124 static const short yypact[] = { 4,
125 -32768,-32768, -2, 8,-32768, -2, 14,-32768, -4,-32768,
126 3, 4, -2,-32768, 0,-32768, -2, -2,-32768,-32768,
127 -32768, -2, 17, 15,-32768, -2, 20, 19,-32768, -2,
131 static const short yypgoto[] = {-32768,
132 16,-32768,-32768,-32768, 18, -3,-32768
139 static const short yytable[] = { 9,
140 2, 18, 15, -3, 1, 22, 2, 32, 3, 15,
141 19, -3, -3, 23, 24, 10, 11, 16, 25, 17,
142 26, 27, 28, 29, 30, 33, 31, 20, 0, 0,
146 static const short yycheck[] = { 3,
147 3, 6, 6, 0, 1, 6, 3, 0, 5, 13,
148 8, 8, 9, 17, 18, 8, 9, 4, 22, 6,
149 4, 7, 26, 4, 6, 0, 30, 12, -1, -1,
152 /* -*-C-*- Note some compilers choke on comments on `#line' lines. */
153 #line 3 "/usr/lib/bison.simple"
155 /* Skeleton output parser for bison,
156 Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc.
158 This program is free software; you can redistribute it and/or modify
159 it under the terms of the GNU General Public License as published by
160 the Free Software Foundation; either version 2, or (at your option)
163 This program is distributed in the hope that it will be useful,
164 but WITHOUT ANY WARRANTY; without even the implied warranty of
165 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
166 GNU General Public License for more details.
168 You should have received a copy of the GNU General Public License
169 along with this program; if not, write to the Free Software
170 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
172 /* As a special exception, when this file is copied by Bison into a
173 Bison output file, you may use that output file without restriction.
174 This special exception was added by the Free Software Foundation
175 in version 1.24 of Bison. */
179 #define alloca __builtin_alloca
180 #else /* not GNU C. */
181 #if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi)
183 #else /* not sparc */
184 #if defined (MSDOS) && !defined (__TURBOC__)
186 #else /* not MSDOS, or __TURBOC__ */
190 #else /* not MSDOS, __TURBOC__, or _AIX */
194 void *alloca (unsigned int);
196 #else /* not __cplusplus */
198 #endif /* not __cplusplus */
200 #endif /* not _AIX */
201 #endif /* not MSDOS, or __TURBOC__ */
202 #endif /* not sparc. */
203 #endif /* not GNU C. */
204 #endif /* alloca not defined. */
206 /* This is the parser code that is written into each bison parser
207 when the %semantic_parser declaration is not specified in the grammar.
208 It was written by Richard Stallman by simplifying the hairy parser
209 used when %semantic_parser is specified. */
211 /* Note: there must be only one dollar sign in this file.
212 It is replaced by the list of actions, each action
213 as one case of the switch. */
215 #define yyerrok (yyerrstatus = 0)
216 #define yyclearin (yychar = YYEMPTY)
219 #define YYACCEPT return(0)
220 #define YYABORT return(1)
221 #define YYERROR goto yyerrlab1
222 /* Like YYERROR except do call yyerror.
223 This remains here temporarily to ease the
224 transition to the new meaning of YYERROR, for GCC.
225 Once GCC version 2 has supplanted version 1, this can go. */
226 #define YYFAIL goto yyerrlab
227 #define YYRECOVERING() (!!yyerrstatus)
228 #define YYBACKUP(token, value) \
230 if (yychar == YYEMPTY && yylen == 1) \
231 { yychar = (token), yylval = (value); \
232 yychar1 = YYTRANSLATE (yychar); \
237 { yyerror ("syntax error: cannot back up"); YYERROR; } \
241 #define YYERRCODE 256
244 #define YYLEX yylex()
250 #define YYLEX yylex(&yylval, &yylloc, YYLEX_PARAM)
252 #define YYLEX yylex(&yylval, &yylloc)
254 #else /* not YYLSP_NEEDED */
256 #define YYLEX yylex(&yylval, YYLEX_PARAM)
258 #define YYLEX yylex(&yylval)
260 #endif /* not YYLSP_NEEDED */
263 /* If nonreentrant, generate the variables here */
267 int yychar; /* the lookahead symbol */
268 YYSTYPE yylval; /* the semantic value of the */
269 /* lookahead symbol */
272 YYLTYPE yylloc; /* location data for the lookahead */
276 int yynerrs; /* number of parse errors so far */
277 #endif /* not YYPURE */
280 int yydebug; /* nonzero means print parse trace */
281 /* Since this is uninitialized, it does not stop multiple parsers
285 /* YYINITDEPTH indicates the initial size of the parser's stacks */
288 #define YYINITDEPTH 200
291 /* YYMAXDEPTH is the maximum size the stacks can grow to
292 (effective only if the built-in stack extension method is used). */
299 #define YYMAXDEPTH 10000
302 /* Prevent warning if -Wstrict-prototypes. */
307 #if __GNUC__ > 1 /* GNU C and GNU C++ define this. */
308 #define __yy_memcpy(TO,FROM,COUNT) __builtin_memcpy(TO,FROM,COUNT)
309 #else /* not GNU C or C++ */
312 /* This is the most reliable way to avoid incompatibilities
313 in available built-in functions on various systems. */
315 __yy_memcpy (to, from, count)
320 register char *f = from;
321 register char *t = to;
322 register int i = count;
328 #else /* __cplusplus */
330 /* This is the most reliable way to avoid incompatibilities
331 in available built-in functions on various systems. */
333 __yy_memcpy (char *to, char *from, int count)
335 register char *f = from;
336 register char *t = to;
337 register int i = count;
346 #line 196 "/usr/lib/bison.simple"
348 /* The user can define YYPARSE_PARAM as the name of an argument to be passed
349 into yyparse. The argument should have type void *.
350 It should actually point to an object.
351 Grammar actions can access the variable by casting it
352 to the proper pointer type. */
356 #define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
357 #define YYPARSE_PARAM_DECL
358 #else /* not __cplusplus */
359 #define YYPARSE_PARAM_ARG YYPARSE_PARAM
360 #define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
361 #endif /* not __cplusplus */
362 #else /* not YYPARSE_PARAM */
363 #define YYPARSE_PARAM_ARG
364 #define YYPARSE_PARAM_DECL
365 #endif /* not YYPARSE_PARAM */
368 yyparse(YYPARSE_PARAM_ARG)
371 register int yystate;
373 register short *yyssp;
374 register YYSTYPE *yyvsp;
375 int yyerrstatus; /* number of tokens to shift before error messages enabled */
376 int yychar1 = 0; /* lookahead token as an internal (translated) token number */
378 short yyssa[YYINITDEPTH]; /* the state stack */
379 YYSTYPE yyvsa[YYINITDEPTH]; /* the semantic value stack */
381 short *yyss = yyssa; /* refer to the stacks thru separate pointers */
382 YYSTYPE *yyvs = yyvsa; /* to allow yyoverflow to reallocate them elsewhere */
385 YYLTYPE yylsa[YYINITDEPTH]; /* the location stack */
386 YYLTYPE *yyls = yylsa;
389 #define YYPOPSTACK (yyvsp--, yyssp--, yylsp--)
391 #define YYPOPSTACK (yyvsp--, yyssp--)
394 int yystacksize = YYINITDEPTH;
405 YYSTYPE yyval; /* the variable used to return */
406 /* semantic values from the action */
413 fprintf(stderr, "Starting parse\n");
419 yychar = YYEMPTY; /* Cause a token to be read. */
421 /* Initialize stack pointers.
422 Waste one element of value and location stack
423 so that they stay on the same level as the state stack.
424 The wasted elements are never initialized. */
432 /* Push a new state, which is found in yystate . */
433 /* In all cases, when you get here, the value and location stacks
434 have just been pushed. so pushing a state here evens the stacks. */
439 if (yyssp >= yyss + yystacksize - 1)
441 /* Give user a chance to reallocate the stack */
442 /* Use copies of these so that the &'s don't force the real ones into memory. */
443 YYSTYPE *yyvs1 = yyvs;
446 YYLTYPE *yyls1 = yyls;
449 /* Get the current used size of the three stacks, in elements. */
450 int size = yyssp - yyss + 1;
453 /* Each stack pointer address is followed by the size of
454 the data in use in that stack, in bytes. */
456 /* This used to be a conditional around just the two extra args,
457 but that might be undefined if yyoverflow is a macro. */
458 yyoverflow("parser stack overflow",
459 &yyss1, size * sizeof (*yyssp),
460 &yyvs1, size * sizeof (*yyvsp),
461 &yyls1, size * sizeof (*yylsp),
464 yyoverflow("parser stack overflow",
465 &yyss1, size * sizeof (*yyssp),
466 &yyvs1, size * sizeof (*yyvsp),
470 yyss = yyss1; yyvs = yyvs1;
474 #else /* no yyoverflow */
475 /* Extend the stack our own way. */
476 if (yystacksize >= YYMAXDEPTH)
478 yyerror("parser stack overflow");
482 if (yystacksize > YYMAXDEPTH)
483 yystacksize = YYMAXDEPTH;
484 yyss = (short *) alloca (yystacksize * sizeof (*yyssp));
485 __yy_memcpy ((char *)yyss, (char *)yyss1, size * sizeof (*yyssp));
486 yyvs = (YYSTYPE *) alloca (yystacksize * sizeof (*yyvsp));
487 __yy_memcpy ((char *)yyvs, (char *)yyvs1, size * sizeof (*yyvsp));
489 yyls = (YYLTYPE *) alloca (yystacksize * sizeof (*yylsp));
490 __yy_memcpy ((char *)yyls, (char *)yyls1, size * sizeof (*yylsp));
492 #endif /* no yyoverflow */
494 yyssp = yyss + size - 1;
495 yyvsp = yyvs + size - 1;
497 yylsp = yyls + size - 1;
502 fprintf(stderr, "Stack size increased to %d\n", yystacksize);
505 if (yyssp >= yyss + yystacksize - 1)
511 fprintf(stderr, "Entering state %d\n", yystate);
517 /* Do appropriate processing given the current state. */
518 /* Read a lookahead token if we need one and don't already have one. */
521 /* First try to decide what to do without reference to lookahead token. */
523 yyn = yypact[yystate];
527 /* Not known => get a lookahead token if don't already have one. */
529 /* yychar is either YYEMPTY or YYEOF
530 or a valid token in external form. */
532 if (yychar == YYEMPTY)
536 fprintf(stderr, "Reading a token: ");
541 /* Convert token to internal form (in yychar1) for indexing tables with */
543 if (yychar <= 0) /* This means end of input. */
546 yychar = YYEOF; /* Don't call YYLEX any more */
550 fprintf(stderr, "Now at end of input.\n");
555 yychar1 = YYTRANSLATE(yychar);
560 fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]);
561 /* Give the individual parser a way to print the precise meaning
562 of a token, for further debugging info. */
564 YYPRINT (stderr, yychar, yylval);
566 fprintf (stderr, ")\n");
572 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
577 /* yyn is what to do for this token type in this state.
578 Negative => reduce, -yyn is rule number.
579 Positive => shift, yyn is new state.
580 New state is final state => don't bother to shift,
582 0, or most negative number => error. */
597 /* Shift the lookahead token. */
601 fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
604 /* Discard the token being shifted unless it is eof. */
613 /* count tokens shifted since error; after three, turn off error status. */
614 if (yyerrstatus) yyerrstatus--;
619 /* Do the default action for the current state. */
622 yyn = yydefact[yystate];
626 /* Do a reduction. yyn is the number of a rule to reduce with. */
630 yyval = yyvsp[1-yylen]; /* implement default value of the action */
637 fprintf (stderr, "Reducing via rule %d (line %d), ",
640 /* Print the symbols being reduced, and their result. */
641 for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
642 fprintf (stderr, "%s ", yytname[yyrhs[i]]);
643 fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
652 { if (interactive_parser)
660 { curval=yyvsp[-1]; ;
664 { curval=-1; startval=yyvsp[-4] ; endval = yyvsp[-2];
670 if (curval>=0) table[yyvsp[0]]=curval;
671 else {table[yyvsp[0]]=loop_var++;
679 { int i; for(i=yyvsp[-2];i<=yyvsp[0];i++)
680 if (curval>=0) table[i]=curval;
681 else {table[i]=loop_var++;
690 { yyerror("Class value out of range\n");
698 int i,start,stop,startv,stopv;
699 if (yyvsp[-2]>yyvsp[0]) {start=yyvsp[0];startv=yyvsp[-4];stop=yyvsp[-2];stopv=yyvsp[-6];}
700 else {start=yyvsp[-2];startv=yyvsp[-6];stop=yyvsp[0];stopv=yyvsp[-4];}
701 for (i=start;i<=stop;i++)
702 table[i]=(i-start)*(stopv-startv)/(start-stop)+startv;
706 /* the action file gets copied in in place of this dollarsign */
707 #line 498 "/usr/lib/bison.simple"
718 short *ssp1 = yyss - 1;
719 fprintf (stderr, "state stack now");
720 while (ssp1 != yyssp)
721 fprintf (stderr, " %d", *++ssp1);
722 fprintf (stderr, "\n");
732 yylsp->first_line = yylloc.first_line;
733 yylsp->first_column = yylloc.first_column;
734 yylsp->last_line = (yylsp-1)->last_line;
735 yylsp->last_column = (yylsp-1)->last_column;
740 yylsp->last_line = (yylsp+yylen-1)->last_line;
741 yylsp->last_column = (yylsp+yylen-1)->last_column;
745 /* Now "shift" the result of the reduction.
746 Determine what state that goes to,
747 based on the state we popped back to
748 and the rule number reduced by. */
752 yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
753 if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
754 yystate = yytable[yystate];
756 yystate = yydefgoto[yyn - YYNTBASE];
760 yyerrlab: /* here on detecting error */
763 /* If not already recovering from an error, report this error. */
767 #ifdef YYERROR_VERBOSE
768 yyn = yypact[yystate];
770 if (yyn > YYFLAG && yyn < YYLAST)
777 /* Start X at -yyn if nec to avoid negative indexes in yycheck. */
778 for (x = (yyn < 0 ? -yyn : 0);
779 x < (sizeof(yytname) / sizeof(char *)); x++)
780 if (yycheck[x + yyn] == x)
781 size += strlen(yytname[x]) + 15, count++;
782 msg = (char *) malloc(size + 15);
785 strcpy(msg, "parse error");
790 for (x = (yyn < 0 ? -yyn : 0);
791 x < (sizeof(yytname) / sizeof(char *)); x++)
792 if (yycheck[x + yyn] == x)
794 strcat(msg, count == 0 ? ", expecting `" : " or `");
795 strcat(msg, yytname[x]);
804 yyerror ("parse error; also virtual memory exceeded");
807 #endif /* YYERROR_VERBOSE */
808 yyerror("parse error");
812 yyerrlab1: /* here on error raised explicitly by an action */
814 if (yyerrstatus == 3)
816 /* if just tried and failed to reuse lookahead token after an error, discard it. */
818 /* return failure if at end of input */
824 fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
830 /* Else will try to reuse lookahead token
831 after shifting the error token. */
833 yyerrstatus = 3; /* Each real token shifted decrements this */
837 yyerrdefault: /* current state does not do anything special for the error token. */
840 /* This is wrong; only states that explicitly want error tokens
841 should shift them. */
842 yyn = yydefact[yystate]; /* If its default is to accept any token, ok. Otherwise pop it.*/
843 if (yyn) goto yydefault;
846 yyerrpop: /* pop the current state because it cannot handle the error token */
848 if (yyssp == yyss) YYABORT;
858 short *ssp1 = yyss - 1;
859 fprintf (stderr, "Error: state stack now");
860 while (ssp1 != yyssp)
861 fprintf (stderr, " %d", *++ssp1);
862 fprintf (stderr, "\n");
868 yyn = yypact[yystate];
873 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
892 fprintf(stderr, "Shifting error token, ");
907 { int c,numb=0,isnumb=0;
908 static char unget_buf=0;
909 while ((c=unget_buf?unget_buf:(*my_getc)())!=EOF)
922 case '9': {isnumb=1; numb=numb*10+c-'0'; break;}
924 case '\t': {if (isnumb) { yylval=numb; return NUMBER; } break;}
925 default: if (isnumb) { yylval=numb; unget_buf=c; return NUMBER;}
933 { fprintf(stderr,"%s\n",s);
936 RECLASS make_reclass_table(EPP *infile,int (*recl_getc)())
937 { int size=epp_table_size(infile);
939 return parse_statements(size,create_reclass_table(size),recl_getc);
941 RECLASS parse_statements(int size,RECLASS src,int (*recl_getc)())
944 if (size>65535)size=65535;
946 if (yyparse()) { free(table);return NULL;}
949 RECLASS create_reclass_table(size)
952 if (size<=0) return NULL;
953 else if (size>65535) size=65535;
954 table=malloc((size+1)*sizeof(short int));
955 for(i=0;i<=size;i++) table[i]=i;
958 RECLASS wrapped_reclass(EPP *infile,int white)
961 maxclass=epp_table_size(infile);
962 table=malloc(maxclass*sizeof(short int));
964 for(i=1;i<=maxclass;i++) table[i]=(i-1)%(white-1)+1;
965 table[infile->offsite]=white;