1
2 /* A Bison parser, made from printdefy.y
3 by GNU Bison version 1.25
4 */
5
6 #define YYBISON 1 /* Identify Bison output. */
7
8 #define tINT 258
9 #define tDOUBLE 259
10 #define tSTRING 260
11 #define tCLASS 261
12 #define tBEGIN 262
13 #define tEND 263
14 #define ASSIGN 264
15 #define PRINTER 265
16 #define NAME 266
17 #define DRIVER 267
18 #define COLOR 268
19 #define NOCOLOR 269
20 #define MODEL 270
21 #define LANGUAGE 271
22 #define BRIGHTNESS 272
23 #define GAMMA 273
24 #define CONTRAST 274
25 #define CYAN 275
26 #define MAGENTA 276
27 #define YELLOW 277
28 #define SATURATION 278
29 #define DENSITY 279
30 #define ENDPRINTER 280
31 #define VALUE 281
32
33 #line 23 "printdefy.y"
34
35
36 #include <string.h>
37 #include <stdio.h>
38 #include <stdlib.h>
39 #include "printdef.h"
40
41 extern int mylineno;
42 stp_printer_t thePrinter;
43 char *quotestrip(const char *i);
44 char *endstrip(const char *i);
45
46 extern int yylex(void);
47 void initialize_the_printer(const char *name, const char *driver);
48 void output_the_printer(void);
49 static int yyerror(const char *s);
50
51 const char *printfuncs[] =
52 {
53 "canon",
54 "escp2",
55 "pcl",
56 "ps",
57 "lexmark"
58 };
59
60 const size_t nprintfuncs = sizeof(printfuncs) / sizeof(const char *);
61
62 void
initialize_the_printer(const char * name,const char * driver)63 initialize_the_printer(const char *name, const char *driver)
64 {
65 strncpy(thePrinter.printvars.output_to, name, 63);
66 strncpy(thePrinter.printvars.driver, driver, 63);
67 thePrinter.printvars.top = -1;
68 thePrinter.model = -1;
69 thePrinter.printvars.brightness = 1.0;
70 thePrinter.printvars.gamma = 1.0;
71 thePrinter.printvars.contrast = 1.0;
72 thePrinter.printvars.cyan = 1.0;
73 thePrinter.printvars.magenta = 1.0;
74 thePrinter.printvars.yellow = 1.0;
75 thePrinter.printvars.saturation = 1.0;
76 thePrinter.printvars.density = 1.0;
77 }
78
79 void
output_the_printer(void)80 output_the_printer(void)
81 {
82 printf(" {\n");
83 printf(" %s,\n", thePrinter.printvars.output_to);
84 printf(" %s,\n", thePrinter.printvars.driver);
85 printf(" %d,\n", thePrinter.model);
86 printf(" &stp_%s_printfuncs,\n", printfuncs[thePrinter.printvars.top]);
87 printf(" {\n");
88 printf(" \"\",\n"); /* output_to */
89 printf(" %s,\n", thePrinter.printvars.driver); /* driver */
90 printf(" \"\",\n"); /* ppd_file */
91 printf(" \"\",\n"); /* resolution */
92 printf(" \"\",\n"); /* media_size */
93 printf(" \"\",\n"); /* media_type */
94 printf(" \"\",\n"); /* media_source */
95 printf(" \"\",\n"); /* ink_type */
96 printf(" \"\",\n"); /* dither_algorithm */
97 printf(" %d,\n", thePrinter.printvars.output_type);
98 printf(" %.3f,\n", thePrinter.printvars.brightness);
99 printf(" 1.0,\n"); /* scaling */
100 printf(" -1,\n"); /* orientation */
101 printf(" 0,\n"); /* top */
102 printf(" 0,\n"); /* left */
103 printf(" %.3f,\n", thePrinter.printvars.gamma);
104 printf(" %.3f,\n", thePrinter.printvars.contrast);
105 printf(" %.3f,\n", thePrinter.printvars.cyan);
106 printf(" %.3f,\n", thePrinter.printvars.magenta);
107 printf(" %.3f,\n", thePrinter.printvars.yellow);
108 printf(" %.3f,\n", thePrinter.printvars.saturation);
109 printf(" %.3f,\n", thePrinter.printvars.density);
110 printf(" }\n");
111 printf(" },\n");
112 }
113
114 extern int mylineno;
115 extern char* yytext;
116
yyerror(const char * s)117 static int yyerror( const char *s )
118 {
119 fprintf(stderr,"stdin:%d: %s before '%s'\n",mylineno,s,yytext);
120 return 0;
121 }
122
123 #include <stdio.h>
124
125 #ifndef __cplusplus
126 #ifndef __STDC__
127 #define const
128 #endif
129 #endif
130
131
132
133 #define YYFINAL 98
134 #define YYFLAG -32768
135 #define YYNTBASE 27
136
137 #define YYTRANSLATE(x) ((unsigned)(x) <= 281 ? yytranslate[x] : 48)
138
139 static const char yytranslate[] = { 0,
140 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
141 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
142 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
143 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
144 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
145 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
146 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
147 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
148 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
149 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
150 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
151 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
152 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
153 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
154 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
155 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
156 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
157 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
158 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
159 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
160 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
161 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
162 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
163 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
164 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
165 2, 2, 2, 2, 2, 1, 2, 3, 4, 5,
166 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
167 16, 17, 18, 19, 20, 21, 22, 23, 24, 25,
168 26
169 };
170
171 #if YYDEBUG != 0
172 static const short yyprhs[] = { 0,
173 0, 10, 20, 24, 28, 32, 39, 46, 53, 60,
174 67, 74, 81, 88, 95, 102, 103, 105, 107, 109,
175 111, 113, 115, 117, 119, 121, 123, 125, 127, 129,
176 131, 134, 136, 140, 143, 146
177 };
178
179 static const short yyrhs[] = { 7,
180 10, 11, 9, 5, 12, 9, 5, 8, 0, 7,
181 10, 12, 9, 5, 11, 9, 5, 8, 0, 7,
182 25, 8, 0, 7, 13, 8, 0, 7, 14, 8,
183 0, 7, 15, 26, 9, 3, 8, 0, 7, 16,
184 26, 9, 6, 8, 0, 7, 17, 26, 9, 4,
185 8, 0, 7, 18, 26, 9, 4, 8, 0, 7,
186 19, 26, 9, 4, 8, 0, 7, 20, 26, 9,
187 4, 8, 0, 7, 21, 26, 9, 4, 8, 0,
188 7, 22, 26, 9, 4, 8, 0, 7, 23, 26,
189 9, 4, 8, 0, 7, 24, 26, 9, 4, 8,
190 0, 0, 27, 0, 28, 0, 30, 0, 31, 0,
191 32, 0, 33, 0, 34, 0, 35, 0, 36, 0,
192 37, 0, 38, 0, 39, 0, 40, 0, 41, 0,
193 45, 44, 0, 44, 0, 43, 45, 29, 0, 43,
194 29, 0, 47, 46, 0, 42, 0
195 };
196
197 #endif
198
199 #if YYDEBUG != 0
200 static const short yyrline[] = { 0,
201 125, 128, 131, 134, 137, 140, 143, 156, 159, 162,
202 165, 168, 171, 174, 177, 181, 184, 184, 187, 187,
203 187, 187, 187, 187, 187, 188, 188, 188, 188, 188,
204 191, 191, 194, 194, 197, 197
205 };
206 #endif
207
208
209 #if YYDEBUG != 0 || defined (YYERROR_VERBOSE)
210
211 static const char * const yytname[] = { "$","error","$undefined.","tINT","tDOUBLE",
212 "tSTRING","tCLASS","tBEGIN","tEND","ASSIGN","PRINTER","NAME","DRIVER","COLOR",
213 "NOCOLOR","MODEL","LANGUAGE","BRIGHTNESS","GAMMA","CONTRAST","CYAN","MAGENTA",
214 "YELLOW","SATURATION","DENSITY","ENDPRINTER","VALUE","printerstart","printerstartalt",
215 "printerend","color","nocolor","model","language","brightness","gamma","contrast",
216 "cyan","magenta","yellow","saturation","density","Empty","pstart","parg","pargs",
217 "Printer","Printers", NULL
218 };
219 #endif
220
221 static const short yyr1[] = { 0,
222 27, 28, 29, 30, 31, 32, 33, 34, 35, 36,
223 37, 38, 39, 40, 41, 42, 43, 43, 44, 44,
224 44, 44, 44, 44, 44, 44, 44, 44, 44, 44,
225 45, 45, 46, 46, 47, 47
226 };
227
228 static const short yyr2[] = { 0,
229 9, 9, 3, 3, 3, 6, 6, 6, 6, 6,
230 6, 6, 6, 6, 6, 0, 1, 1, 1, 1,
231 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
232 2, 1, 3, 2, 2, 1
233 };
234
235 static const short yydefact[] = { 16,
236 36, 0, 0, 17, 18, 0, 35, 0, 0, 34,
237 19, 20, 21, 22, 23, 24, 25, 26, 27, 28,
238 29, 30, 32, 0, 0, 0, 0, 0, 0, 0,
239 0, 0, 0, 0, 0, 0, 0, 0, 0, 33,
240 31, 0, 0, 4, 5, 0, 0, 0, 0, 0,
241 0, 0, 0, 0, 0, 3, 0, 0, 0, 0,
242 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
243 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
244 0, 0, 6, 7, 8, 9, 10, 11, 12, 13,
245 14, 15, 0, 0, 1, 2, 0, 0
246 };
247
248 static const short yydefgoto[] = { 4,
249 5, 10, 11, 12, 13, 14, 15, 16, 17, 18,
250 19, 20, 21, 22, 1, 6, 23, 24, 7, 2
251 };
252
253 static const short yypact[] = {-32768,
254 -32768, 13, 6,-32768,-32768, 10,-32768, 3, -13,-32768,
255 -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
256 -32768,-32768,-32768, 10, 9, 12, 11, 14, -3, -2,
257 -1, 0, 1, 2, 4, 5, 7, 8, 21,-32768,
258 -32768, 27, 30,-32768,-32768, 28, 29, 31, 32, 33,
259 34, 35, 36, 37, 38,-32768, 24, 39, 45, 43,
260 47, 48, 49, 50, 51, 52, 53, 54, 55, 56,
261 58, 59, 60, 61, 62, 63, 64, 65, 66, 67,
262 57, 71,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
263 -32768,-32768, 69, 70,-32768,-32768, 79,-32768
264 };
265
266 static const short yypgoto[] = {-32768,
267 -32768, 15,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
268 -32768,-32768,-32768,-32768,-32768,-32768, 68,-32768,-32768,-32768
269 };
270
271
272 #define YYLAST 92
273
274
275 static const short yytable[] = { 27,
276 28, 29, 30, 31, 32, 33, 34, 35, 36, 37,
277 38, 39, 97, 25, 26, 8, 9, 42, 44, 3,
278 43, 45, 46, 47, 48, 49, 50, 51, 56, 52,
279 53, 57, 54, 55, 58, 69, 59, 60, 40, 61,
280 62, 63, 64, 65, 66, 67, 68, 71, 72, 70,
281 73, 74, 75, 76, 77, 78, 79, 80, 0, 0,
282 0, 93, 0, 81, 82, 83, 84, 85, 86, 87,
283 88, 89, 90, 91, 92, 94, 95, 96, 98, 0,
284 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
285 0, 41
286 };
287
288 static const short yycheck[] = { 13,
289 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
290 24, 25, 0, 11, 12, 10, 7, 9, 8, 7,
291 9, 8, 26, 26, 26, 26, 26, 26, 8, 26,
292 26, 5, 26, 26, 5, 12, 9, 9, 24, 9,
293 9, 9, 9, 9, 9, 9, 9, 3, 6, 11,
294 4, 4, 4, 4, 4, 4, 4, 4, -1, -1,
295 -1, 5, -1, 9, 9, 8, 8, 8, 8, 8,
296 8, 8, 8, 8, 8, 5, 8, 8, 0, -1,
297 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
298 -1, 24
299 };
300 /* -*-C-*- Note some compilers choke on comments on `#line' lines. */
301 #line 3 "/usr/share/bison.simple"
302
303 /* Skeleton output parser for bison,
304 Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc.
305
306 This program is free software; you can redistribute it and/or modify
307 it under the terms of the GNU General Public License as published by
308 the Free Software Foundation; either version 2, or (at your option)
309 any later version.
310
311 This program is distributed in the hope that it will be useful,
312 but WITHOUT ANY WARRANTY; without even the implied warranty of
313 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
314 GNU General Public License for more details.
315
316 You should have received a copy of the GNU General Public License
317 along with this program; if not, write to the Free Software
318 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
319
320 /* As a special exception, when this file is copied by Bison into a
321 Bison output file, you may use that output file without restriction.
322 This special exception was added by the Free Software Foundation
323 in version 1.24 of Bison. */
324
325 #ifndef alloca
326 #ifdef __GNUC__
327 #define alloca __builtin_alloca
328 #else /* not GNU C. */
329 #if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi)
330 #include <alloca.h>
331 #else /* not sparc */
332 #if defined (MSDOS) && !defined (__TURBOC__)
333 #include <malloc.h>
334 #else /* not MSDOS, or __TURBOC__ */
335 #if defined(_AIX)
336 #include <malloc.h>
337 #pragma alloca
338 #else /* not MSDOS, __TURBOC__, or _AIX */
339 #ifdef __hpux
340 #ifdef __cplusplus
341 extern "C" {
342 void *alloca (unsigned int);
343 };
344 #else /* not __cplusplus */
345 void *alloca ();
346 #endif /* not __cplusplus */
347 #endif /* __hpux */
348 #endif /* not _AIX */
349 #endif /* not MSDOS, or __TURBOC__ */
350 #endif /* not sparc. */
351 #endif /* not GNU C. */
352 #endif /* alloca not defined. */
353
354 /* This is the parser code that is written into each bison parser
355 when the %semantic_parser declaration is not specified in the grammar.
356 It was written by Richard Stallman by simplifying the hairy parser
357 used when %semantic_parser is specified. */
358
359 /* Note: there must be only one dollar sign in this file.
360 It is replaced by the list of actions, each action
361 as one case of the switch. */
362
363 #define yyerrok (yyerrstatus = 0)
364 #define yyclearin (yychar = YYEMPTY)
365 #define YYEMPTY -2
366 #define YYEOF 0
367 #define YYACCEPT return(0)
368 #define YYABORT return(1)
369 #define YYERROR goto yyerrlab1
370 /* Like YYERROR except do call yyerror.
371 This remains here temporarily to ease the
372 transition to the new meaning of YYERROR, for GCC.
373 Once GCC version 2 has supplanted version 1, this can go. */
374 #define YYFAIL goto yyerrlab
375 #define YYRECOVERING() (!!yyerrstatus)
376 #define YYBACKUP(token, value) \
377 do \
378 if (yychar == YYEMPTY && yylen == 1) \
379 { yychar = (token), yylval = (value); \
380 yychar1 = YYTRANSLATE (yychar); \
381 YYPOPSTACK; \
382 goto yybackup; \
383 } \
384 else \
385 { yyerror ("syntax error: cannot back up"); YYERROR; } \
386 while (0)
387
388 #define YYTERROR 1
389 #define YYERRCODE 256
390
391 #ifndef YYPURE
392 #define YYLEX yylex()
393 #endif
394
395 #ifdef YYPURE
396 #ifdef YYLSP_NEEDED
397 #ifdef YYLEX_PARAM
398 #define YYLEX yylex(&yylval, &yylloc, YYLEX_PARAM)
399 #else
400 #define YYLEX yylex(&yylval, &yylloc)
401 #endif
402 #else /* not YYLSP_NEEDED */
403 #ifdef YYLEX_PARAM
404 #define YYLEX yylex(&yylval, YYLEX_PARAM)
405 #else
406 #define YYLEX yylex(&yylval)
407 #endif
408 #endif /* not YYLSP_NEEDED */
409 #endif
410
411 /* If nonreentrant, generate the variables here */
412
413 #ifndef YYPURE
414
415 int yychar; /* the lookahead symbol */
416 YYSTYPE yylval; /* the semantic value of the */
417 /* lookahead symbol */
418
419 #ifdef YYLSP_NEEDED
420 YYLTYPE yylloc; /* location data for the lookahead */
421 /* symbol */
422 #endif
423
424 int yynerrs; /* number of parse errors so far */
425 #endif /* not YYPURE */
426
427 #if YYDEBUG != 0
428 int yydebug; /* nonzero means print parse trace */
429 /* Since this is uninitialized, it does not stop multiple parsers
430 from coexisting. */
431 #endif
432
433 /* YYINITDEPTH indicates the initial size of the parser's stacks */
434
435 #ifndef YYINITDEPTH
436 #define YYINITDEPTH 200
437 #endif
438
439 /* YYMAXDEPTH is the maximum size the stacks can grow to
440 (effective only if the built-in stack extension method is used). */
441
442 #if YYMAXDEPTH == 0
443 #undef YYMAXDEPTH
444 #endif
445
446 #ifndef YYMAXDEPTH
447 #define YYMAXDEPTH 10000
448 #endif
449
450 #ifndef YYPARSE_RETURN_TYPE
451 #define YYPARSE_RETURN_TYPE int
452 #endif
453
454 /* Prevent warning if -Wstrict-prototypes. */
455 #ifdef __GNUC__
456 YYPARSE_RETURN_TYPE yyparse (void);
457 #endif
458
459 #if __GNUC__ > 1 /* GNU C and GNU C++ define this. */
460 #define __yy_memcpy(TO,FROM,COUNT) __builtin_memcpy(TO,FROM,COUNT)
461 #else /* not GNU C or C++ */
462 #ifndef __cplusplus
463
464 /* This is the most reliable way to avoid incompatibilities
465 in available built-in functions on various systems. */
466 static void
__yy_memcpy(to,from,count)467 __yy_memcpy (to, from, count)
468 char *to;
469 char *from;
470 int count;
471 {
472 register char *f = from;
473 register char *t = to;
474 register int i = count;
475
476 while (i-- > 0)
477 *t++ = *f++;
478 }
479
480 #else /* __cplusplus */
481
482 /* This is the most reliable way to avoid incompatibilities
483 in available built-in functions on various systems. */
484 static void
__yy_memcpy(char * to,char * from,int count)485 __yy_memcpy (char *to, char *from, int count)
486 {
487 register char *f = from;
488 register char *t = to;
489 register int i = count;
490
491 while (i-- > 0)
492 *t++ = *f++;
493 }
494
495 #endif
496 #endif
497
498 #line 196 "/usr/share/bison.simple"
499
500 /* The user can define YYPARSE_PARAM as the name of an argument to be passed
501 into yyparse. The argument should have type void *.
502 It should actually point to an object.
503 Grammar actions can access the variable by casting it
504 to the proper pointer type. */
505
506 #ifdef YYPARSE_PARAM
507 #ifdef __cplusplus
508 #define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
509 #define YYPARSE_PARAM_DECL
510 #else /* not __cplusplus */
511 #define YYPARSE_PARAM_ARG YYPARSE_PARAM
512 #define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
513 #endif /* not __cplusplus */
514 #else /* not YYPARSE_PARAM */
515 #define YYPARSE_PARAM_ARG
516 #define YYPARSE_PARAM_DECL
517 #endif /* not YYPARSE_PARAM */
518
519 YYPARSE_RETURN_TYPE
yyparse(YYPARSE_PARAM_ARG)520 yyparse(YYPARSE_PARAM_ARG)
521 YYPARSE_PARAM_DECL
522 {
523 register int yystate;
524 register int yyn;
525 register short *yyssp;
526 register YYSTYPE *yyvsp;
527 int yyerrstatus; /* number of tokens to shift before error messages enabled */
528 int yychar1 = 0; /* lookahead token as an internal (translated) token number */
529
530 short yyssa[YYINITDEPTH]; /* the state stack */
531 YYSTYPE yyvsa[YYINITDEPTH]; /* the semantic value stack */
532
533 short *yyss = yyssa; /* refer to the stacks thru separate pointers */
534 YYSTYPE *yyvs = yyvsa; /* to allow yyoverflow to reallocate them elsewhere */
535
536 #ifdef YYLSP_NEEDED
537 YYLTYPE yylsa[YYINITDEPTH]; /* the location stack */
538 YYLTYPE *yyls = yylsa;
539 YYLTYPE *yylsp;
540
541 #define YYPOPSTACK (yyvsp--, yyssp--, yylsp--)
542 #else
543 #define YYPOPSTACK (yyvsp--, yyssp--)
544 #endif
545
546 int yystacksize = YYINITDEPTH;
547
548 #ifdef YYPURE
549 int yychar;
550 YYSTYPE yylval;
551 int yynerrs;
552 #ifdef YYLSP_NEEDED
553 YYLTYPE yylloc;
554 #endif
555 #endif
556
557 YYSTYPE yyval; /* the variable used to return */
558 /* semantic values from the action */
559 /* routines */
560
561 int yylen;
562
563 #if YYDEBUG != 0
564 if (yydebug)
565 fprintf(stderr, "Starting parse\n");
566 #endif
567
568 yystate = 0;
569 yyerrstatus = 0;
570 yynerrs = 0;
571 yychar = YYEMPTY; /* Cause a token to be read. */
572
573 /* Initialize stack pointers.
574 Waste one element of value and location stack
575 so that they stay on the same level as the state stack.
576 The wasted elements are never initialized. */
577
578 yyssp = yyss - 1;
579 yyvsp = yyvs;
580 #ifdef YYLSP_NEEDED
581 yylsp = yyls;
582 #endif
583
584 /* Push a new state, which is found in yystate . */
585 /* In all cases, when you get here, the value and location stacks
586 have just been pushed. so pushing a state here evens the stacks. */
587 yynewstate:
588
589 *++yyssp = yystate;
590
591 if (yyssp >= yyss + yystacksize - 1)
592 {
593 /* Give user a chance to reallocate the stack */
594 /* Use copies of these so that the &'s don't force the real ones into memory. */
595 YYSTYPE *yyvs1 = yyvs;
596 short *yyss1 = yyss;
597 #ifdef YYLSP_NEEDED
598 YYLTYPE *yyls1 = yyls;
599 #endif
600
601 /* Get the current used size of the three stacks, in elements. */
602 int size = yyssp - yyss + 1;
603
604 #ifdef yyoverflow
605 /* Each stack pointer address is followed by the size of
606 the data in use in that stack, in bytes. */
607 #ifdef YYLSP_NEEDED
608 /* This used to be a conditional around just the two extra args,
609 but that might be undefined if yyoverflow is a macro. */
610 yyoverflow("parser stack overflow",
611 &yyss1, size * sizeof (*yyssp),
612 &yyvs1, size * sizeof (*yyvsp),
613 &yyls1, size * sizeof (*yylsp),
614 &yystacksize);
615 #else
616 yyoverflow("parser stack overflow",
617 &yyss1, size * sizeof (*yyssp),
618 &yyvs1, size * sizeof (*yyvsp),
619 &yystacksize);
620 #endif
621
622 yyss = yyss1; yyvs = yyvs1;
623 #ifdef YYLSP_NEEDED
624 yyls = yyls1;
625 #endif
626 #else /* no yyoverflow */
627 /* Extend the stack our own way. */
628 if (yystacksize >= YYMAXDEPTH)
629 {
630 yyerror("parser stack overflow");
631 return 2;
632 }
633 yystacksize *= 2;
634 if (yystacksize > YYMAXDEPTH)
635 yystacksize = YYMAXDEPTH;
636 yyss = (short *) alloca (yystacksize * sizeof (*yyssp));
637 __yy_memcpy ((char *)yyss, (char *)yyss1, size * sizeof (*yyssp));
638 yyvs = (YYSTYPE *) alloca (yystacksize * sizeof (*yyvsp));
639 __yy_memcpy ((char *)yyvs, (char *)yyvs1, size * sizeof (*yyvsp));
640 #ifdef YYLSP_NEEDED
641 yyls = (YYLTYPE *) alloca (yystacksize * sizeof (*yylsp));
642 __yy_memcpy ((char *)yyls, (char *)yyls1, size * sizeof (*yylsp));
643 #endif
644 #endif /* no yyoverflow */
645
646 yyssp = yyss + size - 1;
647 yyvsp = yyvs + size - 1;
648 #ifdef YYLSP_NEEDED
649 yylsp = yyls + size - 1;
650 #endif
651
652 #if YYDEBUG != 0
653 if (yydebug)
654 fprintf(stderr, "Stack size increased to %d\n", yystacksize);
655 #endif
656
657 if (yyssp >= yyss + yystacksize - 1)
658 YYABORT;
659 }
660
661 #if YYDEBUG != 0
662 if (yydebug)
663 fprintf(stderr, "Entering state %d\n", yystate);
664 #endif
665
666 goto yybackup;
667 yybackup:
668
669 /* Do appropriate processing given the current state. */
670 /* Read a lookahead token if we need one and don't already have one. */
671 /* yyresume: */
672
673 /* First try to decide what to do without reference to lookahead token. */
674
675 yyn = yypact[yystate];
676 if (yyn == YYFLAG)
677 goto yydefault;
678
679 /* Not known => get a lookahead token if don't already have one. */
680
681 /* yychar is either YYEMPTY or YYEOF
682 or a valid token in external form. */
683
684 if (yychar == YYEMPTY)
685 {
686 #if YYDEBUG != 0
687 if (yydebug)
688 fprintf(stderr, "Reading a token: ");
689 #endif
690 yychar = YYLEX;
691 }
692
693 /* Convert token to internal form (in yychar1) for indexing tables with */
694
695 if (yychar <= 0) /* This means end of input. */
696 {
697 yychar1 = 0;
698 yychar = YYEOF; /* Don't call YYLEX any more */
699
700 #if YYDEBUG != 0
701 if (yydebug)
702 fprintf(stderr, "Now at end of input.\n");
703 #endif
704 }
705 else
706 {
707 yychar1 = YYTRANSLATE(yychar);
708
709 #if YYDEBUG != 0
710 if (yydebug)
711 {
712 fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]);
713 /* Give the individual parser a way to print the precise meaning
714 of a token, for further debugging info. */
715 #ifdef YYPRINT
716 YYPRINT (stderr, yychar, yylval);
717 #endif
718 fprintf (stderr, ")\n");
719 }
720 #endif
721 }
722
723 yyn += yychar1;
724 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
725 goto yydefault;
726
727 yyn = yytable[yyn];
728
729 /* yyn is what to do for this token type in this state.
730 Negative => reduce, -yyn is rule number.
731 Positive => shift, yyn is new state.
732 New state is final state => don't bother to shift,
733 just return success.
734 0, or most negative number => error. */
735
736 if (yyn < 0)
737 {
738 if (yyn == YYFLAG)
739 goto yyerrlab;
740 yyn = -yyn;
741 goto yyreduce;
742 }
743 else if (yyn == 0)
744 goto yyerrlab;
745
746 if (yyn == YYFINAL)
747 YYACCEPT;
748
749 /* Shift the lookahead token. */
750
751 #if YYDEBUG != 0
752 if (yydebug)
753 fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
754 #endif
755
756 /* Discard the token being shifted unless it is eof. */
757 if (yychar != YYEOF)
758 yychar = YYEMPTY;
759
760 *++yyvsp = yylval;
761 #ifdef YYLSP_NEEDED
762 *++yylsp = yylloc;
763 #endif
764
765 /* count tokens shifted since error; after three, turn off error status. */
766 if (yyerrstatus) yyerrstatus--;
767
768 yystate = yyn;
769 goto yynewstate;
770
771 /* Do the default action for the current state. */
772 yydefault:
773
774 yyn = yydefact[yystate];
775 if (yyn == 0)
776 goto yyerrlab;
777
778 /* Do a reduction. yyn is the number of a rule to reduce with. */
779 yyreduce:
780 yylen = yyr2[yyn];
781 if (yylen > 0)
782 yyval = yyvsp[1-yylen]; /* implement default value of the action */
783
784 #if YYDEBUG != 0
785 if (yydebug)
786 {
787 int i;
788
789 fprintf (stderr, "Reducing via rule %d (line %d), ",
790 yyn, yyrline[yyn]);
791
792 /* Print the symbols being reduced, and their result. */
793 for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
794 fprintf (stderr, "%s ", yytname[yyrhs[i]]);
795 fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
796 }
797 #endif
798
799
800 switch (yyn) {
801
802 case 1:
803 #line 126 "printdefy.y"
804 { initialize_the_printer(yyvsp[-4].sval, yyvsp[-1].sval); ;
805 break;}
806 case 2:
807 #line 129 "printdefy.y"
808 { initialize_the_printer(yyvsp[-1].sval, yyvsp[-4].sval); ;
809 break;}
810 case 3:
811 #line 132 "printdefy.y"
812 { output_the_printer(); ;
813 break;}
814 case 4:
815 #line 135 "printdefy.y"
816 { thePrinter.printvars.output_type = OUTPUT_COLOR; ;
817 break;}
818 case 5:
819 #line 138 "printdefy.y"
820 { thePrinter.printvars.output_type = OUTPUT_GRAY; ;
821 break;}
822 case 6:
823 #line 141 "printdefy.y"
824 { thePrinter.model = yyvsp[-1].ival; ;
825 break;}
826 case 7:
827 #line 144 "printdefy.y"
828 {
829 int i;
830 for (i = 0; i < nprintfuncs; i++)
831 {
832 if (!strcmp(yyvsp[-1].sval, printfuncs[i]))
833 {
834 thePrinter.printvars.top = i;
835 break;
836 }
837 }
838 ;
839 break;}
840 case 8:
841 #line 157 "printdefy.y"
842 { thePrinter.printvars.brightness = yyvsp[-1].dval; ;
843 break;}
844 case 9:
845 #line 160 "printdefy.y"
846 { thePrinter.printvars.gamma = yyvsp[-1].dval; ;
847 break;}
848 case 10:
849 #line 163 "printdefy.y"
850 { thePrinter.printvars.contrast = yyvsp[-1].dval; ;
851 break;}
852 case 11:
853 #line 166 "printdefy.y"
854 { thePrinter.printvars.cyan = yyvsp[-1].dval; ;
855 break;}
856 case 12:
857 #line 169 "printdefy.y"
858 { thePrinter.printvars.magenta = yyvsp[-1].dval; ;
859 break;}
860 case 13:
861 #line 172 "printdefy.y"
862 { thePrinter.printvars.yellow = yyvsp[-1].dval; ;
863 break;}
864 case 14:
865 #line 175 "printdefy.y"
866 { thePrinter.printvars.saturation = yyvsp[-1].dval; ;
867 break;}
868 case 15:
869 #line 178 "printdefy.y"
870 { thePrinter.printvars.density = yyvsp[-1].dval; ;
871 break;}
872 }
873 /* the action file gets copied in in place of this dollarsign */
874 #line 498 "/usr/share/bison.simple"
875
876 yyvsp -= yylen;
877 yyssp -= yylen;
878 #ifdef YYLSP_NEEDED
879 yylsp -= yylen;
880 #endif
881
882 #if YYDEBUG != 0
883 if (yydebug)
884 {
885 short *ssp1 = yyss - 1;
886 fprintf (stderr, "state stack now");
887 while (ssp1 != yyssp)
888 fprintf (stderr, " %d", *++ssp1);
889 fprintf (stderr, "\n");
890 }
891 #endif
892
893 *++yyvsp = yyval;
894
895 #ifdef YYLSP_NEEDED
896 yylsp++;
897 if (yylen == 0)
898 {
899 yylsp->first_line = yylloc.first_line;
900 yylsp->first_column = yylloc.first_column;
901 yylsp->last_line = (yylsp-1)->last_line;
902 yylsp->last_column = (yylsp-1)->last_column;
903 yylsp->text = 0;
904 }
905 else
906 {
907 yylsp->last_line = (yylsp+yylen-1)->last_line;
908 yylsp->last_column = (yylsp+yylen-1)->last_column;
909 }
910 #endif
911
912 /* Now "shift" the result of the reduction.
913 Determine what state that goes to,
914 based on the state we popped back to
915 and the rule number reduced by. */
916
917 yyn = yyr1[yyn];
918
919 yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
920 if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
921 yystate = yytable[yystate];
922 else
923 yystate = yydefgoto[yyn - YYNTBASE];
924
925 goto yynewstate;
926
927 yyerrlab: /* here on detecting error */
928
929 if (! yyerrstatus)
930 /* If not already recovering from an error, report this error. */
931 {
932 ++yynerrs;
933
934 #ifdef YYERROR_VERBOSE
935 yyn = yypact[yystate];
936
937 if (yyn > YYFLAG && yyn < YYLAST)
938 {
939 int size = 0;
940 char *msg;
941 int x, count;
942
943 count = 0;
944 /* Start X at -yyn if nec to avoid negative indexes in yycheck. */
945 for (x = (yyn < 0 ? -yyn : 0);
946 x < (sizeof(yytname) / sizeof(char *)); x++)
947 if (yycheck[x + yyn] == x)
948 size += strlen(yytname[x]) + 15, count++;
949 msg = (char *) malloc(size + 15);
950 if (msg != 0)
951 {
952 strcpy(msg, "parse error");
953
954 if (count < 5)
955 {
956 count = 0;
957 for (x = (yyn < 0 ? -yyn : 0);
958 x < (sizeof(yytname) / sizeof(char *)); x++)
959 if (yycheck[x + yyn] == x)
960 {
961 strcat(msg, count == 0 ? ", expecting `" : " or `");
962 strcat(msg, yytname[x]);
963 strcat(msg, "'");
964 count++;
965 }
966 }
967 yyerror(msg);
968 free(msg);
969 }
970 else
971 yyerror ("parse error; also virtual memory exceeded");
972 }
973 else
974 #endif /* YYERROR_VERBOSE */
975 yyerror("parse error");
976 }
977
978 goto yyerrlab1;
979 yyerrlab1: /* here on error raised explicitly by an action */
980
981 if (yyerrstatus == 3)
982 {
983 /* if just tried and failed to reuse lookahead token after an error, discard it. */
984
985 /* return failure if at end of input */
986 if (yychar == YYEOF)
987 YYABORT;
988
989 #if YYDEBUG != 0
990 if (yydebug)
991 fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
992 #endif
993
994 yychar = YYEMPTY;
995 }
996
997 /* Else will try to reuse lookahead token
998 after shifting the error token. */
999
1000 yyerrstatus = 3; /* Each real token shifted decrements this */
1001
1002 goto yyerrhandle;
1003
1004 yyerrdefault: /* current state does not do anything special for the error token. */
1005
1006 #if 0
1007 /* This is wrong; only states that explicitly want error tokens
1008 should shift them. */
1009 yyn = yydefact[yystate]; /* If its default is to accept any token, ok. Otherwise pop it.*/
1010 if (yyn) goto yydefault;
1011 #endif
1012
1013 yyerrpop: /* pop the current state because it cannot handle the error token */
1014
1015 if (yyssp == yyss) YYABORT;
1016 yyvsp--;
1017 yystate = *--yyssp;
1018 #ifdef YYLSP_NEEDED
1019 yylsp--;
1020 #endif
1021
1022 #if YYDEBUG != 0
1023 if (yydebug)
1024 {
1025 short *ssp1 = yyss - 1;
1026 fprintf (stderr, "Error: state stack now");
1027 while (ssp1 != yyssp)
1028 fprintf (stderr, " %d", *++ssp1);
1029 fprintf (stderr, "\n");
1030 }
1031 #endif
1032
1033 yyerrhandle:
1034
1035 yyn = yypact[yystate];
1036 if (yyn == YYFLAG)
1037 goto yyerrdefault;
1038
1039 yyn += YYTERROR;
1040 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
1041 goto yyerrdefault;
1042
1043 yyn = yytable[yyn];
1044 if (yyn < 0)
1045 {
1046 if (yyn == YYFLAG)
1047 goto yyerrpop;
1048 yyn = -yyn;
1049 goto yyreduce;
1050 }
1051 else if (yyn == 0)
1052 goto yyerrpop;
1053
1054 if (yyn == YYFINAL)
1055 YYACCEPT;
1056
1057 #if YYDEBUG != 0
1058 if (yydebug)
1059 fprintf(stderr, "Shifting error token, ");
1060 #endif
1061
1062 *++yyvsp = yylval;
1063 #ifdef YYLSP_NEEDED
1064 *++yylsp = yylloc;
1065 #endif
1066
1067 yystate = yyn;
1068 goto yynewstate;
1069 }
1070 #line 200 "printdefy.y"
1071
1072
1073 int
main(int argc,char ** argv)1074 main(int argc, char **argv)
1075 {
1076 int retval;
1077 int i;
1078 printf("/* This file is automatically generated. See printers.xml.\n");
1079 printf(" DO NOT EDIT! */\n\n");
1080 for (i = 0; i < nprintfuncs; i++)
1081 printf("const extern stp_printfuncs_t stp_%s_printfuncs;\n",
1082 printfuncs[i]);
1083 printf("\nstatic const stp_internal_printer_t printers[] =\n");
1084 printf("{\n");
1085 retval = yyparse();
1086 printf("};\n");
1087 printf("static const int printer_count = sizeof(printers) / sizeof(stp_internal_printer_t);\n");
1088 return retval;
1089 }
1090