1
2 # line 2 "cpy.y"
3 /* @(#)cpy.y 1.6 18/06/17 2010-2018 J. Schilling */
4 #ifndef lint
5 static char y_sccsid[] =
6 "@(#)cpy.y 1.6 18/06/17 2010-2018 J. Schilling";
7 #endif
8 /*
9 * This implementation is based on the UNIX 32V release from 1978
10 * with permission from Caldera Inc.
11 *
12 * Copyright (c) 2010-2018 J. Schilling
13 * All rights reserved.
14 *
15 * Redistribution and use in source and binary forms, with or without
16 * modification, are permitted provided that the following conditions
17 * are met:
18 * 1. Redistributions of source code must retain the above copyright
19 * notice, this list of conditions and the following disclaimer.
20 * 2. Redistributions in binary form must reproduce the above copyright
21 * notice, this list of conditions and the following disclaimer in the
22 * documentation and/or other materials provided with the distribution.
23 * 3. Neither the name of the copyright holder nor the names of contributors
24 * may be used to endorse or promote products derived from this software
25 * without specific prior written permission.
26 *
27 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTOR(S) ``AS IS'' AND
28 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
29 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
30 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTOR(S) BE LIABLE
31 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
32 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
33 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
34 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
35 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
36 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
37 * SUCH DAMAGE.
38 */
39 /*
40 * Copyright(C) Caldera International Inc. 2001-2002. All rights reserved.
41 *
42 * Redistribution and use in source and binary forms, with or without
43 * modification, are permitted provided that the following conditions are
44 * met:
45 * 1. Redistributions of source code and documentation must retain the above
46 * copyright notice, this list of conditions and the following
47 * disclaimer.
48 *
49 * 2. Redistributions in binary form must reproduce the above copyright
50 * notice, this list of conditions and the following disclaimer in the
51 * documentation and/or other materials provided with the distribution.
52 *
53 * 3. All advertising materials mentioning features or use of this software
54 * must display the following acknowledgement: This product includes
55 * software developed or owned by Caldera International, Inc.
56 *
57 * 4. Neither the name of Caldera International, Inc. nor the names of other
58 * contributors may be used to endorse or promote products derived from
59 * this software without specific prior written permission.
60 *
61 * USE OF THE SOFTWARE PROVIDED FOR UNDER THIS LICENSE BY CALDERA
62 * INTERNATIONAL, INC. AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR
63 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
64 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
65 * DISCLAIMED. IN NO EVENT SHALL CALDERA INTERNATIONAL, INC. BE LIABLE FOR
66 * ANY DIRECT, INDIRECT INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
67 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
68 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
69 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
70 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
71 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
72 * POSSIBILITY OF SUCH DAMAGE.
73 */
74 #include <schily/mconfig.h>
75
76 #include "cpp.h"
77 #include <schily/limits.h>
78 # define number 257
79 # define stop 258
80 # define DEFINED 259
81 # define EQ 260
82 # define NE 261
83 # define LE 262
84 # define GE 263
85 # define LS 264
86 # define RS 265
87 # define ANDAND 266
88 # define OROR 267
89 # define UMINUS 268
90
91 #include <schily/inttypes.h>
92
93 #ifdef IS_SCHILY
94 #include <schily/stdlib.h>
95 #include <schily/string.h>
96 #define YYCONST const
97 #else
98 #ifdef __STDC__
99 #include <stdlib.h>
100 #include <string.h>
101 #define YYCONST const
102 #else
103 #include <malloc.h>
104 #include <memory.h>
105 #define YYCONST
106 #endif
107 #endif
108
109 #include <schily/values.h>
110
111 #if defined(__cplusplus) || defined(__STDC__)
112
113 #if defined(__cplusplus) && defined(__EXTERN_C__)
114 extern "C" {
115 #endif
116 #ifndef yyerror
117 #if defined(__cplusplus)
118 void yyerror(YYCONST char *);
119 #endif
120 #endif
121 #ifndef yylex
122 int yylex(void);
123 #endif
124 int yyparse(void);
125 #if defined(__cplusplus) && defined(__EXTERN_C__)
126 }
127 #endif
128
129 #endif
130
131 #define yyclearin yychar = -1
132 #define yyerrok yyerrflag = 0
133 extern int yychar;
134 extern int yyerrflag;
135 #ifndef YYSTYPE
136 #define YYSTYPE int
137 #endif
138 YYSTYPE yylval;
139 YYSTYPE yyval;
140 typedef int yytabelem;
141 #ifndef YYMAXDEPTH
142 #define YYMAXDEPTH 150
143 #endif
144 #if YYMAXDEPTH > 0
145 int yy_yys[YYMAXDEPTH], *yys = yy_yys;
146 YYSTYPE yy_yyv[YYMAXDEPTH], *yyv = yy_yyv;
147 #else /* user does initial allocation */
148 int *yys;
149 YYSTYPE *yyv;
150 #endif
151 static int yymaxdepth = YYMAXDEPTH;
152 # define YYERRCODE 256
153
154 # line 176 "cpy.y"
155
156 # include "yylex.c"
157 static YYCONST yytabelem yyexca[] ={
158 -1, 1,
159 0, -1,
160 -2, 0,
161 -1, 44,
162 262, 0,
163 263, 0,
164 60, 0,
165 62, 0,
166 -2, 9,
167 -1, 45,
168 262, 0,
169 263, 0,
170 60, 0,
171 62, 0,
172 -2, 10,
173 -1, 46,
174 262, 0,
175 263, 0,
176 60, 0,
177 62, 0,
178 -2, 11,
179 -1, 47,
180 262, 0,
181 263, 0,
182 60, 0,
183 62, 0,
184 -2, 12,
185 -1, 48,
186 260, 0,
187 261, 0,
188 -2, 13,
189 -1, 49,
190 260, 0,
191 261, 0,
192 -2, 14,
193 };
194 # define YYNPROD 30
195 # define YYLAST 363
196 static YYCONST yytabelem yyact[]={
197
198 13, 24, 35, 58, 13, 11, 14, 30, 15, 11,
199 12, 60, 13, 24, 12, 1, 57, 11, 14, 30,
200 15, 59, 12, 18, 13, 19, 29, 0, 0, 11,
201 14, 0, 15, 0, 12, 18, 3, 19, 29, 13,
202 24, 31, 32, 33, 11, 14, 30, 15, 0, 12,
203 13, 24, 0, 0, 0, 11, 14, 25, 15, 5,
204 12, 0, 18, 0, 19, 29, 7, 0, 0, 25,
205 0, 4, 0, 18, 0, 19, 29, 0, 13, 24,
206 0, 0, 0, 11, 14, 0, 15, 26, 12, 0,
207 0, 0, 13, 24, 0, 0, 25, 11, 14, 26,
208 15, 18, 12, 19, 13, 24, 0, 25, 0, 11,
209 14, 0, 15, 13, 12, 18, 0, 19, 11, 14,
210 0, 15, 0, 12, 0, 0, 26, 18, 0, 19,
211 0, 0, 0, 0, 13, 25, 18, 26, 19, 11,
212 14, 0, 15, 0, 12, 13, 0, 0, 0, 25,
213 11, 14, 6, 15, 0, 12, 0, 18, 0, 19,
214 0, 0, 0, 0, 0, 26, 0, 0, 0, 0,
215 0, 0, 2, 0, 0, 0, 0, 0, 0, 26,
216 34, 0, 0, 0, 37, 38, 39, 40, 41, 42,
217 43, 44, 45, 46, 47, 48, 49, 50, 51, 52,
218 53, 54, 55, 56, 0, 0, 0, 0, 0, 0,
219 0, 0, 0, 0, 0, 0, 0, 0, 0, 36,
220 0, 0, 0, 22, 23, 20, 21, 16, 17, 27,
221 28, 0, 61, 0, 0, 22, 23, 20, 21, 16,
222 17, 27, 28, 0, 0, 0, 0, 0, 0, 0,
223 0, 16, 17, 0, 0, 0, 0, 0, 0, 0,
224 10, 0, 22, 23, 20, 21, 16, 17, 27, 28,
225 0, 0, 0, 22, 23, 20, 21, 16, 17, 27,
226 28, 0, 0, 9, 0, 8, 0, 0, 0, 0,
227 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
228 0, 22, 23, 20, 21, 16, 17, 27, 0, 0,
229 0, 0, 0, 0, 0, 22, 23, 20, 21, 16,
230 17, 0, 0, 0, 0, 0, 0, 22, 23, 20,
231 21, 16, 17, 0, 0, 0, 22, 23, 20, 21,
232 16, 17, 0, 0, 0, 0, 0, 0, 0, 0,
233 0, 0, 0, 0, 0, 0, 0, 0, 0, 20,
234 21, 16, 17 };
235 static YYCONST yytabelem yypact[]={
236
237 26,-10000000, 2,-10000000, 26, 26, 26, 26, -38,-10000000,
238 -10000000, 26, 26, 26, 26, 26, 26, 26, 26, 26,
239 26, 26, 26, 26, 26, 26, 26, 26, 26, 26,
240 26,-10000000,-10000000,-10000000, -25, -254,-10000000,-10000000,-10000000,-10000000,
241 -33, -33, 108, 108, -13, -13, -13, -13, 97, 97,
242 76, 67, 67, 55, 41, -37, 13,-10000000, -30, 26,
243 -10000000, 13 };
244 static YYCONST yytabelem yypgo[]={
245
246 0, 15, 172, 36 };
247 static YYCONST yytabelem yyr1[]={
248
249 0, 1, 2, 2, 2, 2, 2, 2, 2, 2,
250 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
251 2, 2, 2, 3, 3, 3, 3, 3, 3, 3 };
252 static YYCONST yytabelem yyr2[]={
253
254 0, 5, 7, 7, 7, 7, 7, 7, 7, 7,
255 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
256 11, 7, 3, 5, 5, 5, 7, 9, 5, 3 };
257 static YYCONST yytabelem yychk[]={
258
259 -10000000, -1, -2, -3, 45, 33, 126, 40, 259, 257,
260 258, 42, 47, 37, 43, 45, 264, 265, 60, 62,
261 262, 263, 260, 261, 38, 94, 124, 266, 267, 63,
262 44, -3, -3, -3, -2, 40, 257, -2, -2, -2,
263 -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
264 -2, -2, -2, -2, -2, -2, -2, 41, 257, 58,
265 41, -2 };
266 static YYCONST yytabelem yydef[]={
267
268 0, -2, 0, 22, 0, 0, 0, 0, 0, 29,
269 1, 0, 0, 0, 0, 0, 0, 0, 0, 0,
270 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
271 0, 23, 24, 25, 0, 0, 28, 2, 3, 4,
272 5, 6, 7, 8, -2, -2, -2, -2, -2, -2,
273 15, 16, 17, 18, 19, 0, 21, 26, 0, 0,
274 27, 20 };
275 typedef struct
276 #ifdef __cplusplus
277 yytoktype
278 #endif
279 {
280 #ifdef __cplusplus
281 const
282 #endif
283 char *t_name; int t_val; } yytoktype;
284 #ifndef YYDEBUG
285 # define YYDEBUG 0 /* don't allow debugging */
286 #endif
287
288 #if YYDEBUG
289
290 yytoktype yytoks[] =
291 {
292 "number", 257,
293 "stop", 258,
294 "DEFINED", 259,
295 "EQ", 260,
296 "NE", 261,
297 "LE", 262,
298 "GE", 263,
299 "LS", 264,
300 "RS", 265,
301 "ANDAND", 266,
302 "OROR", 267,
303 ",", 44,
304 "=", 61,
305 "?", 63,
306 ":", 58,
307 "|", 124,
308 "^", 94,
309 "&", 38,
310 "<", 60,
311 ">", 62,
312 "+", 43,
313 "-", 45,
314 "*", 42,
315 "/", 47,
316 "%", 37,
317 "!", 33,
318 "~", 126,
319 "UMINUS", 268,
320 "(", 40,
321 ".", 46,
322 "-unknown-", -1 /* ends search */
323 };
324
325 #ifdef __cplusplus
326 const
327 #endif
328 char * yyreds[] =
329 {
330 "-no such reduction-",
331 "S : e stop",
332 "e : e '*' e",
333 "e : e '/' e",
334 "e : e '%' e",
335 "e : e '+' e",
336 "e : e '-' e",
337 "e : e LS e",
338 "e : e RS e",
339 "e : e '<' e",
340 "e : e '>' e",
341 "e : e LE e",
342 "e : e GE e",
343 "e : e EQ e",
344 "e : e NE e",
345 "e : e '&' e",
346 "e : e '^' e",
347 "e : e '|' e",
348 "e : e ANDAND e",
349 "e : e OROR e",
350 "e : e '?' e ':' e",
351 "e : e ',' e",
352 "e : term",
353 "term : '-' term",
354 "term : '!' term",
355 "term : '~' term",
356 "term : '(' e ')'",
357 "term : DEFINED '(' number ')'",
358 "term : DEFINED number",
359 "term : number",
360 };
361 #endif /* YYDEBUG */
362 # line 1 "/usr/share/lib/ccs/yaccpar"
363 /*
364 * CDDL HEADER START
365 *
366 * The contents of this file are subject to the terms of the
367 * Common Development and Distribution License, Version 1.0 only
368 * (the "License"). You may not use this file except in compliance
369 * with the License.
370 *
371 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
372 * or http://www.opensolaris.org/os/licensing.
373 * See the License for the specific language governing permissions
374 * and limitations under the License.
375 *
376 * When distributing Covered Code, include this CDDL HEADER in each
377 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
378 * If applicable, add the following below this CDDL HEADER, with the
379 * fields enclosed by brackets "[]" replaced with your own identifying
380 * information: Portions Copyright [yyyy] [name of copyright owner]
381 *
382 * CDDL HEADER END
383 */
384 /*
385 * Copyright 1993 Sun Microsystems, Inc. All rights reserved.
386 * Use is subject to license terms.
387 */
388
389 /* Copyright (c) 1988 AT&T */
390 /* All Rights Reserved */
391
392 #pragma ident "@(#)cpypre.c 1.4 19/08/29 SMI"
393
394 /*
395 ** Skeleton parser driver for yacc output
396 */
397
398 /*
399 ** yacc user known macros and defines
400 */
401 #define YYERROR goto yyerrlab
402 #define YYACCEPT return(0)
403 #define YYABORT return(1)
404 #define YYBACKUP( newtoken, newvalue )\
405 {\
406 if ( yychar >= 0 || ( yyr2[ yytmp ] >> 1 ) != 1 )\
407 {\
408 yyerror( "syntax error - cannot backup" );\
409 goto yyerrlab;\
410 }\
411 yychar = newtoken;\
412 yystate = *yyps;\
413 yylval = newvalue;\
414 goto yynewstate;\
415 }
416 #define YYRECOVERING() (!!yyerrflag)
417 #define YYNEW(type) malloc(sizeof(type) * yynewmax)
418 #define YYCOPY(to, from, type) \
419 (type *) memcpy(to, (char *) from, yymaxdepth * sizeof (type))
420 #define YYENLARGE( from, type) \
421 (type *) realloc((char *) from, yynewmax * sizeof(type))
422 #ifndef YYDEBUG
423 # define YYDEBUG 1 /* make debugging available */
424 #endif
425
426 /*
427 ** user known globals
428 */
429 int yydebug; /* set to 1 to get debugging */
430
431 /*
432 ** driver internal defines
433 */
434 #define YYFLAG (-10000000)
435
436 /*
437 ** global variables used by the parser
438 */
439 YYSTYPE *yypv; /* top of value stack */
440 int *yyps; /* top of state stack */
441
442 int yystate; /* current state */
443 int yytmp; /* extra var (lasts between blocks) */
444
445 int yynerrs; /* number of errors */
446 int yyerrflag; /* error recovery flag */
447 int yychar; /* current input token number */
448
449
450
451 #ifdef YYNMBCHARS
452 #define YYLEX() yycvtok(yylex())
453 /*
454 ** yycvtok - return a token if i is a wchar_t value that exceeds 255.
455 ** If i<255, i itself is the token. If i>255 but the neither
456 ** of the 30th or 31st bit is on, i is already a token.
457 */
458 #if defined(__STDC__) || defined(__cplusplus)
yycvtok(int i)459 int yycvtok(int i)
460 #else
461 int yycvtok(i) int i;
462 #endif
463 {
464 int first = 0;
465 int last = YYNMBCHARS - 1;
466 int mid;
467 wchar_t j;
468
469 if(i&0x60000000){/*Must convert to a token. */
470 if( yymbchars[last].character < i ){
471 return i;/*Giving up*/
472 }
473 while ((last>=first)&&(first>=0)) {/*Binary search loop*/
474 mid = (first+last)/2;
475 j = yymbchars[mid].character;
476 if( j==i ){/*Found*/
477 return yymbchars[mid].tvalue;
478 }else if( j<i ){
479 first = mid + 1;
480 }else{
481 last = mid -1;
482 }
483 }
484 /*No entry in the table.*/
485 return i;/* Giving up.*/
486 }else{/* i is already a token. */
487 return i;
488 }
489 }
490 #else/*!YYNMBCHARS*/
491 #define YYLEX() yylex()
492 #endif/*!YYNMBCHARS*/
493
494 /*
495 ** yyparse - return 0 if worked, 1 if syntax error not recovered from
496 */
497 #if defined(__STDC__) || defined(__cplusplus)
yyparse(void)498 int yyparse(void)
499 #else
500 int yyparse()
501 #endif
502 {
503 register YYSTYPE *yypvt = 0; /* top of value stack for $vars */
504
505 #if defined(__cplusplus) || defined(lint)
506 /*
507 hacks to please C++ and lint - goto's inside
508 switch should never be executed
509 */
510 static int __yaccpar_lint_hack__ = 0;
511 switch (__yaccpar_lint_hack__)
512 {
513 case 1: goto yyerrlab;
514 case 2: goto yynewstate;
515 }
516 #endif
517
518 /*
519 ** Initialize externals - yyparse may be called more than once
520 */
521 yypv = &yyv[-1];
522 yyps = &yys[-1];
523 yystate = 0;
524 yytmp = 0;
525 yynerrs = 0;
526 yyerrflag = 0;
527 yychar = -1;
528
529 #if YYMAXDEPTH <= 0
530 if (yymaxdepth <= 0)
531 {
532 if ((yymaxdepth = YYEXPAND(0)) <= 0)
533 {
534 yyerror("yacc initialization error");
535 YYABORT;
536 }
537 }
538 #endif
539
540 {
541 register YYSTYPE *yy_pv; /* top of value stack */
542 register int *yy_ps; /* top of state stack */
543 register int yy_state; /* current state */
544 register int yy_n; /* internal state number info */
545 goto yystack; /* moved from 6 lines above to here to please C++ */
546
547 /*
548 ** get globals into registers.
549 ** branch to here only if YYBACKUP was called.
550 */
551 yynewstate:
552 yy_pv = yypv;
553 yy_ps = yyps;
554 yy_state = yystate;
555 goto yy_newstate;
556
557 /*
558 ** get globals into registers.
559 ** either we just started, or we just finished a reduction
560 */
561 yystack:
562 yy_pv = yypv;
563 yy_ps = yyps;
564 yy_state = yystate;
565
566 /*
567 ** top of for (;;) loop while no reductions done
568 */
569 yy_stack:
570 /*
571 ** put a state and value onto the stacks
572 */
573 #if YYDEBUG
574 /*
575 ** if debugging, look up token value in list of value vs.
576 ** name pairs. 0 and negative (-1) are special values.
577 ** Note: linear search is used since time is not a real
578 ** consideration while debugging.
579 */
580 if ( yydebug )
581 {
582 register int yy_i;
583
584 printf( "State %d, token ", yy_state );
585 if ( yychar == 0 )
586 printf( "end-of-file\n" );
587 else if ( yychar < 0 )
588 printf( "-none-\n" );
589 else
590 {
591 for ( yy_i = 0; yytoks[yy_i].t_val >= 0;
592 yy_i++ )
593 {
594 if ( yytoks[yy_i].t_val == yychar )
595 break;
596 }
597 printf( "%s\n", yytoks[yy_i].t_name );
598 }
599 }
600 #endif /* YYDEBUG */
601 if ( ++yy_ps >= &yys[ yymaxdepth ] ) /* room on stack? */
602 {
603 /*
604 ** reallocate and recover. Note that pointers
605 ** have to be reset, or bad things will happen
606 */
607 long yyps_index = (yy_ps - yys);
608 long yypv_index = (yy_pv - yyv);
609 long yypvt_index = (yypvt - yyv);
610 int yynewmax;
611 #ifdef YYEXPAND
612 yynewmax = YYEXPAND(yymaxdepth);
613 #else
614 yynewmax = 2 * yymaxdepth; /* double table size */
615 if (yymaxdepth == YYMAXDEPTH) /* first time growth */
616 {
617 char *newyys = (char *)YYNEW(int);
618 char *newyyv = (char *)YYNEW(YYSTYPE);
619 if (newyys != 0 && newyyv != 0)
620 {
621 yys = YYCOPY(newyys, yys, int);
622 yyv = YYCOPY(newyyv, yyv, YYSTYPE);
623 }
624 else
625 yynewmax = 0; /* failed */
626 }
627 else /* not first time */
628 {
629 yys = YYENLARGE(yys, int);
630 yyv = YYENLARGE(yyv, YYSTYPE);
631 if (yys == 0 || yyv == 0)
632 yynewmax = 0; /* failed */
633 }
634 #endif
635 if (yynewmax <= yymaxdepth) /* tables not expanded */
636 {
637 yyerror( "yacc stack overflow" );
638 YYABORT;
639 }
640 yymaxdepth = yynewmax;
641
642 yy_ps = yys + yyps_index;
643 yy_pv = yyv + yypv_index;
644 yypvt = yyv + yypvt_index;
645 }
646 *yy_ps = yy_state;
647 *++yy_pv = yyval;
648
649 /*
650 ** we have a new state - find out what to do
651 */
652 yy_newstate:
653 if ( ( yy_n = yypact[ yy_state ] ) <= YYFLAG )
654 goto yydefault; /* simple state */
655 #if YYDEBUG
656 /*
657 ** if debugging, need to mark whether new token grabbed
658 */
659 yytmp = yychar < 0;
660 #endif
661 if ( ( yychar < 0 ) && ( ( yychar = YYLEX() ) < 0 ) )
662 yychar = 0; /* reached EOF */
663 #if YYDEBUG
664 if ( yydebug && yytmp )
665 {
666 register int yy_i;
667
668 printf( "Received token " );
669 if ( yychar == 0 )
670 printf( "end-of-file\n" );
671 else if ( yychar < 0 )
672 printf( "-none-\n" );
673 else
674 {
675 for ( yy_i = 0; yytoks[yy_i].t_val >= 0;
676 yy_i++ )
677 {
678 if ( yytoks[yy_i].t_val == yychar )
679 break;
680 }
681 printf( "%s\n", yytoks[yy_i].t_name );
682 }
683 }
684 #endif /* YYDEBUG */
685 if ( ( ( yy_n += yychar ) < 0 ) || ( yy_n >= YYLAST ) )
686 goto yydefault;
687 if ( yychk[ yy_n = yyact[ yy_n ] ] == yychar ) /*valid shift*/
688 {
689 yychar = -1;
690 yyval = yylval;
691 yy_state = yy_n;
692 if ( yyerrflag > 0 )
693 yyerrflag--;
694 goto yy_stack;
695 }
696
697 yydefault:
698 if ( ( yy_n = yydef[ yy_state ] ) == -2 )
699 {
700 #if YYDEBUG
701 yytmp = yychar < 0;
702 #endif
703 if ( ( yychar < 0 ) && ( ( yychar = YYLEX() ) < 0 ) )
704 yychar = 0; /* reached EOF */
705 #if YYDEBUG
706 if ( yydebug && yytmp )
707 {
708 register int yy_i;
709
710 printf( "Received token " );
711 if ( yychar == 0 )
712 printf( "end-of-file\n" );
713 else if ( yychar < 0 )
714 printf( "-none-\n" );
715 else
716 {
717 for ( yy_i = 0;
718 yytoks[yy_i].t_val >= 0;
719 yy_i++ )
720 {
721 if ( yytoks[yy_i].t_val
722 == yychar )
723 {
724 break;
725 }
726 }
727 printf( "%s\n", yytoks[yy_i].t_name );
728 }
729 }
730 #endif /* YYDEBUG */
731 /*
732 ** look through exception table
733 */
734 {
735 register YYCONST int *yyxi = yyexca;
736
737 while ( ( *yyxi != -1 ) ||
738 ( yyxi[1] != yy_state ) )
739 {
740 yyxi += 2;
741 }
742 while ( ( *(yyxi += 2) >= 0 ) &&
743 ( *yyxi != yychar ) )
744 ;
745 if ( ( yy_n = yyxi[1] ) < 0 )
746 YYACCEPT;
747 }
748 }
749
750 /*
751 ** check for syntax error
752 */
753 if ( yy_n == 0 ) /* have an error */
754 {
755 /* no worry about speed here! */
756 switch ( yyerrflag )
757 {
758 case 0: /* new error */
759 yyerror( "syntax error" );
760 goto skip_init;
761 yyerrlab:
762 /*
763 ** get globals into registers.
764 ** we have a user generated syntax type error
765 */
766 yy_pv = yypv;
767 yy_ps = yyps;
768 yy_state = yystate;
769 skip_init:
770 yynerrs++;
771 /* FALLTHRU */
772 case 1:
773 case 2: /* incompletely recovered error */
774 /* try again... */
775 yyerrflag = 3;
776 /*
777 ** find state where "error" is a legal
778 ** shift action
779 */
780 while ( yy_ps >= yys )
781 {
782 yy_n = yypact[ *yy_ps ] + YYERRCODE;
783 if ( yy_n >= 0 && yy_n < YYLAST &&
784 yychk[yyact[yy_n]] == YYERRCODE) {
785 /*
786 ** simulate shift of "error"
787 */
788 yy_state = yyact[ yy_n ];
789 goto yy_stack;
790 }
791 /*
792 ** current state has no shift on
793 ** "error", pop stack
794 */
795 #if YYDEBUG
796 # define _POP_ "Error recovery pops state %d, uncovers state %d\n"
797 if ( yydebug )
798 printf( _POP_, *yy_ps,
799 yy_ps[-1] );
800 # undef _POP_
801 #endif
802 yy_ps--;
803 yy_pv--;
804 }
805 /*
806 ** there is no state on stack with "error" as
807 ** a valid shift. give up.
808 */
809 YYABORT;
810 case 3: /* no shift yet; eat a token */
811 #if YYDEBUG
812 /*
813 ** if debugging, look up token in list of
814 ** pairs. 0 and negative shouldn't occur,
815 ** but since timing doesn't matter when
816 ** debugging, it doesn't hurt to leave the
817 ** tests here.
818 */
819 if ( yydebug )
820 {
821 register int yy_i;
822
823 printf( "Error recovery discards " );
824 if ( yychar == 0 )
825 printf( "token end-of-file\n" );
826 else if ( yychar < 0 )
827 printf( "token -none-\n" );
828 else
829 {
830 for ( yy_i = 0;
831 yytoks[yy_i].t_val >= 0;
832 yy_i++ )
833 {
834 if ( yytoks[yy_i].t_val
835 == yychar )
836 {
837 break;
838 }
839 }
840 printf( "token %s\n",
841 yytoks[yy_i].t_name );
842 }
843 }
844 #endif /* YYDEBUG */
845 if ( yychar == 0 ) /* reached EOF. quit */
846 YYABORT;
847 yychar = -1;
848 goto yy_newstate;
849 }
850 }/* end if ( yy_n == 0 ) */
851 /*
852 ** reduction by production yy_n
853 ** put stack tops, etc. so things right after switch
854 */
855 #if YYDEBUG
856 /*
857 ** if debugging, print the string that is the user's
858 ** specification of the reduction which is just about
859 ** to be done.
860 */
861 if ( yydebug )
862 printf( "Reduce by (%d) \"%s\"\n",
863 yy_n, yyreds[ yy_n ] );
864 #endif
865 yytmp = yy_n; /* value to switch over */
866 yypvt = yy_pv; /* $vars top of value stack */
867 /*
868 ** Look in goto table for next state
869 ** Sorry about using yy_state here as temporary
870 ** register variable, but why not, if it works...
871 ** If yyr2[ yy_n ] doesn't have the low order bit
872 ** set, then there is no action to be done for
873 ** this reduction. So, no saving & unsaving of
874 ** registers done. The only difference between the
875 ** code just after the if and the body of the if is
876 ** the goto yy_stack in the body. This way the test
877 ** can be made before the choice of what to do is needed.
878 */
879 {
880 /* length of production doubled with extra bit */
881 register int yy_len = yyr2[ yy_n ];
882
883 if ( !( yy_len & 01 ) )
884 {
885 yy_len >>= 1;
886 yyval = ( yy_pv -= yy_len )[1]; /* $$ = $1 */
887 yy_state = yypgo[ yy_n = yyr1[ yy_n ] ] +
888 *( yy_ps -= yy_len ) + 1;
889 if ( yy_state >= YYLAST ||
890 yychk[ yy_state =
891 yyact[ yy_state ] ] != -yy_n )
892 {
893 yy_state = yyact[ yypgo[ yy_n ] ];
894 }
895 goto yy_stack;
896 }
897 yy_len >>= 1;
898 yyval = ( yy_pv -= yy_len )[1]; /* $$ = $1 */
899 yy_state = yypgo[ yy_n = yyr1[ yy_n ] ] +
900 *( yy_ps -= yy_len ) + 1;
901 if ( yy_state >= YYLAST ||
902 yychk[ yy_state = yyact[ yy_state ] ] != -yy_n )
903 {
904 yy_state = yyact[ yypgo[ yy_n ] ];
905 }
906 }
907 /* save until reenter driver code */
908 yystate = yy_state;
909 yyps = yy_ps;
910 yypv = yy_pv;
911 }
912 /*
913 ** code supplied by user is placed in this switch
914 */
915 switch( yytmp )
916 {
917
918 case 1:
919 # line 96 "cpy.y"
920 {return(yypvt[-1]);} break;
921 case 2:
922 # line 100 "cpy.y"
923 {yyval = yypvt[-2] * yypvt[-0];} break;
924 case 3:
925 # line 102 "cpy.y"
926 {
927 if (yypvt[-0] == 0) {
928 yyerror("division by zero");
929 yyval = 0;
930 } else if (yypvt[-2] == INT_MIN && yypvt[-0] == -1) {
931 yyerror("division overflow");
932 yyval = INT_MIN;
933 } else {
934 yyval = yypvt[-2] / yypvt[-0];
935 }
936 } break;
937 case 4:
938 # line 114 "cpy.y"
939 {
940 if (yypvt[-0] == 0) {
941 yyerror("division by zero");
942 yyval = 0;
943 } else if (yypvt[-2] == INT_MIN && yypvt[-0] == -1) {
944 yyerror("division overflow");
945 yyval = INT_MIN;
946 } else {
947 yyval = yypvt[-2] % yypvt[-0];
948 }
949 } break;
950 case 5:
951 # line 126 "cpy.y"
952 {yyval = yypvt[-2] + yypvt[-0];} break;
953 case 6:
954 # line 128 "cpy.y"
955 {yyval = yypvt[-2] - yypvt[-0];} break;
956 case 7:
957 # line 130 "cpy.y"
958 {yyval = yypvt[-2] << yypvt[-0];} break;
959 case 8:
960 # line 132 "cpy.y"
961 {yyval = yypvt[-2] >> yypvt[-0];} break;
962 case 9:
963 # line 134 "cpy.y"
964 {yyval = yypvt[-2] < yypvt[-0];} break;
965 case 10:
966 # line 136 "cpy.y"
967 {yyval = yypvt[-2] > yypvt[-0];} break;
968 case 11:
969 # line 138 "cpy.y"
970 {yyval = yypvt[-2] <= yypvt[-0];} break;
971 case 12:
972 # line 140 "cpy.y"
973 {yyval = yypvt[-2] >= yypvt[-0];} break;
974 case 13:
975 # line 142 "cpy.y"
976 {yyval = yypvt[-2] == yypvt[-0];} break;
977 case 14:
978 # line 144 "cpy.y"
979 {yyval = yypvt[-2] != yypvt[-0];} break;
980 case 15:
981 # line 146 "cpy.y"
982 {yyval = yypvt[-2] & yypvt[-0];} break;
983 case 16:
984 # line 148 "cpy.y"
985 {yyval = yypvt[-2] ^ yypvt[-0];} break;
986 case 17:
987 # line 150 "cpy.y"
988 {yyval = yypvt[-2] | yypvt[-0];} break;
989 case 18:
990 # line 152 "cpy.y"
991 {yyval = yypvt[-2] && yypvt[-0];} break;
992 case 19:
993 # line 154 "cpy.y"
994 {yyval = yypvt[-2] || yypvt[-0];} break;
995 case 20:
996 # line 156 "cpy.y"
997 {yyval = yypvt[-4] ? yypvt[-2] : yypvt[-0];} break;
998 case 21:
999 # line 158 "cpy.y"
1000 {yyval = yypvt[-0];} break;
1001 case 22:
1002 # line 160 "cpy.y"
1003 {yyval = yypvt[-0];} break;
1004 case 23:
1005 # line 163 "cpy.y"
1006 {yyval = -yypvt[-0];} break;
1007 case 24:
1008 # line 165 "cpy.y"
1009 {yyval = !yypvt[-0];} break;
1010 case 25:
1011 # line 167 "cpy.y"
1012 {yyval = ~yypvt[-0];} break;
1013 case 26:
1014 # line 169 "cpy.y"
1015 {yyval = yypvt[-1];} break;
1016 case 27:
1017 # line 171 "cpy.y"
1018 {yyval = yypvt[-1];} break;
1019 case 28:
1020 # line 173 "cpy.y"
1021 {yyval = yypvt[-0];} break;
1022 case 29:
1023 # line 175 "cpy.y"
1024 {yyval = yypvt[-0];} break;
1025 # line 556 "/usr/share/lib/ccs/yaccpar"
1026 }
1027 goto yystack; /* reset registers in driver code */
1028 }
1029