parser.c revision 1.1 1 1.1 christos #if HAVE_NBTOOL_CONFIG_H
2 1.1 christos #include "nbtool_config.h"
3 1.1 christos #endif
4 1.1 christos #include <stdlib.h>
5 1.1 christos #ifndef lint
6 1.1 christos #if 0
7 1.1 christos static char yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93";
8 1.1 christos #else
9 1.1 christos #if defined(__NetBSD__) && defined(__IDSTRING)
10 1.1 christos __IDSTRING(yyrcsid, "NetBSD: skeleton.c,v 1.29 2008/07/18 14:25:37 drochner Exp ");
11 1.1 christos #endif /* __NetBSD__ && __IDSTRING */
12 1.1 christos #endif /* 0 */
13 1.1 christos #endif /* lint */
14 1.1 christos #define YYBYACC 1
15 1.1 christos #define YYMAJOR 1
16 1.1 christos #define YYMINOR 9
17 1.1 christos #define YYLEX yylex()
18 1.1 christos #define YYEMPTY -1
19 1.1 christos #define yyclearin (yychar=(YYEMPTY))
20 1.1 christos #define yyerrok (yyerrflag=0)
21 1.1 christos #define YYRECOVERING (yyerrflag!=0)
22 1.1 christos #define YYPREFIX "yy"
23 1.1 christos #line 2 "/usr/src/tools/m4/../../usr.bin/m4/parser.y"
24 1.1 christos /* NetBSD: parser.y,v 1.2 2009/10/26 21:11:28 christos Exp */
25 1.1 christos /* $OpenBSD: parser.y,v 1.6 2008/08/21 21:00:14 espie Exp $ */
26 1.1 christos /*
27 1.1 christos * Copyright (c) 2004 Marc Espie <espie (at) cvs.openbsd.org>
28 1.1 christos *
29 1.1 christos * Permission to use, copy, modify, and distribute this software for any
30 1.1 christos * purpose with or without fee is hereby granted, provided that the above
31 1.1 christos * copyright notice and this permission notice appear in all copies.
32 1.1 christos *
33 1.1 christos * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
34 1.1 christos * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
35 1.1 christos * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
36 1.1 christos * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
37 1.1 christos * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
38 1.1 christos * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
39 1.1 christos * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
40 1.1 christos */
41 1.1 christos #if HAVE_NBTOOL_CONFIG_H
42 1.1 christos #include "nbtool_config.h"
43 1.1 christos #endif
44 1.1 christos __RCSID("NetBSD: parser.y,v 1.2 2009/10/26 21:11:28 christos Exp ");
45 1.1 christos #include <stdint.h>
46 1.1 christos #define YYSTYPE int32_t
47 1.1 christos extern int32_t end_result;
48 1.1 christos extern int yylex(void);
49 1.1 christos extern int yyerror(const char *);
50 1.1 christos #line 48 "parser.c"
51 1.1 christos #define NUMBER 257
52 1.1 christos #define ERROR 258
53 1.1 christos #define LOR 259
54 1.1 christos #define LAND 260
55 1.1 christos #define EQ 261
56 1.1 christos #define NE 262
57 1.1 christos #define LE 263
58 1.1 christos #define GE 264
59 1.1 christos #define LSHIFT 265
60 1.1 christos #define RSHIFT 266
61 1.1 christos #define UMINUS 267
62 1.1 christos #define UPLUS 268
63 1.1 christos #define YYERRCODE 256
64 1.1 christos const short yylhs[] = { -1,
65 1.1 christos 0, 1, 1, 1, 1, 1, 1, 1, 1, 1,
66 1.1 christos 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
67 1.1 christos 1, 1, 1, 1, 1,
68 1.1 christos };
69 1.1 christos const short yylen[] = { 2,
70 1.1 christos 1, 3, 3, 3, 3, 3, 3, 3, 3, 3,
71 1.1 christos 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
72 1.1 christos 2, 2, 2, 2, 1,
73 1.1 christos };
74 1.1 christos const short yydefred[] = { 0,
75 1.1 christos 25, 0, 0, 0, 0, 0, 0, 0, 22, 21,
76 1.1 christos 23, 24, 0, 0, 0, 0, 0, 0, 0, 0,
77 1.1 christos 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
78 1.1 christos 0, 20, 0, 0, 0, 0, 0, 0, 0, 0,
79 1.1 christos 0, 0, 0, 0, 0, 0, 0, 4, 5, 6,
80 1.1 christos };
81 1.1 christos const short yydgoto[] = { 7,
82 1.1 christos 8,
83 1.1 christos };
84 1.1 christos const short yysindex[] = { -13,
85 1.1 christos 0, -13, -13, -13, -13, -13, 0, 190, 0, 0,
86 1.1 christos 0, 0, 114, -13, -13, -13, -13, -13, -13, -13,
87 1.1 christos -13, -13, -13, -13, -13, -13, -13, -13, -13, -13,
88 1.1 christos -13, 0, 321, 347, 159, 397, 354, -24, -24, -35,
89 1.1 christos -35, -35, -35, 136, 136, -31, -31, 0, 0, 0,
90 1.1 christos };
91 1.1 christos const short yyrindex[] = { 0,
92 1.1 christos 0, 0, 0, 0, 0, 0, 0, 3, 0, 0,
93 1.1 christos 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
94 1.1 christos 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
95 1.1 christos 0, 0, 65, 56, 51, 48, 74, 60, 66, 34,
96 1.1 christos 40, 76, 83, 17, 26, 1, 9, 0, 0, 0,
97 1.1 christos };
98 1.1 christos const short yygindex[] = { 0,
99 1.1 christos 458,
100 1.1 christos };
101 1.1 christos #define YYTABLESIZE 663
102 1.1 christos const short yytable[] = { 0,
103 1.1 christos 2, 31, 1, 0, 0, 31, 29, 27, 3, 28,
104 1.1 christos 29, 30, 31, 0, 0, 30, 7, 29, 27, 4,
105 1.1 christos 28, 0, 30, 0, 0, 8, 6, 0, 0, 2,
106 1.1 christos 0, 3, 0, 9, 0, 21, 0, 23, 2, 11,
107 1.1 christos 0, 2, 0, 2, 0, 2, 3, 16, 0, 3,
108 1.1 christos 17, 3, 0, 3, 7, 18, 0, 7, 0, 13,
109 1.1 christos 2, 0, 2, 8, 19, 14, 8, 0, 3, 0,
110 1.1 christos 3, 9, 0, 15, 9, 10, 7, 11, 7, 0,
111 1.1 christos 11, 0, 12, 0, 0, 8, 0, 8, 16, 0,
112 1.1 christos 0, 17, 0, 9, 2, 9, 18, 13, 0, 11,
113 1.1 christos 13, 11, 3, 14, 0, 19, 14, 0, 0, 0,
114 1.1 christos 7, 15, 5, 10, 15, 0, 10, 0, 0, 8,
115 1.1 christos 12, 0, 0, 12, 2, 0, 0, 9, 0, 0,
116 1.1 christos 0, 0, 3, 11, 0, 10, 0, 10, 0, 0,
117 1.1 christos 7, 16, 12, 0, 12, 0, 0, 0, 0, 8,
118 1.1 christos 31, 18, 0, 13, 32, 29, 27, 9, 28, 14,
119 1.1 christos 30, 0, 0, 11, 0, 0, 0, 15, 0, 10,
120 1.1 christos 0, 16, 31, 21, 17, 23, 12, 29, 27, 0,
121 1.1 christos 28, 0, 30, 13, 0, 0, 0, 0, 0, 14,
122 1.1 christos 0, 0, 0, 0, 0, 31, 18, 15, 0, 10,
123 1.1 christos 29, 27, 0, 28, 0, 30, 12, 17, 0, 0,
124 1.1 christos 0, 0, 0, 0, 0, 0, 0, 0, 21, 0,
125 1.1 christos 23, 0, 0, 0, 0, 0, 31, 18, 0, 25,
126 1.1 christos 26, 29, 27, 0, 28, 0, 30, 16, 22, 24,
127 1.1 christos 25, 26, 0, 1, 0, 0, 0, 0, 0, 21,
128 1.1 christos 0, 23, 17, 0, 0, 0, 0, 0, 0, 2,
129 1.1 christos 2, 2, 2, 2, 2, 2, 2, 3, 3, 3,
130 1.1 christos 3, 3, 3, 3, 3, 7, 7, 7, 7, 7,
131 1.1 christos 7, 7, 7, 17, 8, 8, 8, 8, 8, 8,
132 1.1 christos 8, 8, 9, 9, 9, 9, 9, 9, 11, 11,
133 1.1 christos 11, 11, 11, 11, 0, 0, 16, 16, 0, 17,
134 1.1 christos 17, 0, 0, 16, 18, 18, 0, 0, 13, 13,
135 1.1 christos 13, 13, 0, 19, 14, 14, 14, 14, 0, 0,
136 1.1 christos 0, 0, 15, 15, 10, 10, 10, 10, 10, 10,
137 1.1 christos 0, 12, 12, 12, 12, 12, 12, 0, 0, 0,
138 1.1 christos 0, 0, 0, 0, 0, 0, 0, 31, 18, 0,
139 1.1 christos 0, 0, 29, 27, 0, 28, 0, 30, 0, 0,
140 1.1 christos 0, 0, 14, 15, 19, 20, 22, 24, 25, 26,
141 1.1 christos 21, 0, 23, 31, 18, 0, 0, 0, 29, 27,
142 1.1 christos 31, 28, 0, 30, 0, 29, 27, 0, 28, 0,
143 1.1 christos 30, 0, 0, 0, 0, 0, 21, 0, 23, 0,
144 1.1 christos 0, 0, 0, 21, 17, 23, 0, 0, 0, 19,
145 1.1 christos 20, 22, 24, 25, 26, 0, 0, 0, 0, 0,
146 1.1 christos 0, 0, 0, 31, 18, 0, 0, 0, 29, 27,
147 1.1 christos 17, 28, 0, 30, 16, 0, 0, 0, 14, 15,
148 1.1 christos 19, 20, 22, 24, 25, 26, 21, 0, 23, 9,
149 1.1 christos 10, 11, 12, 13, 0, 0, 0, 0, 0, 0,
150 1.1 christos 16, 33, 34, 35, 36, 37, 38, 39, 40, 41,
151 1.1 christos 42, 43, 44, 45, 46, 47, 48, 49, 50, 0,
152 1.1 christos 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
153 1.1 christos 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
154 1.1 christos 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
155 1.1 christos 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
156 1.1 christos 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
157 1.1 christos 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
158 1.1 christos 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
159 1.1 christos 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
160 1.1 christos 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
161 1.1 christos 15, 19, 20, 22, 24, 25, 26, 0, 0, 0,
162 1.1 christos 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
163 1.1 christos 0, 0, 0, 0, 0, 0, 0, 19, 20, 22,
164 1.1 christos 24, 25, 26, 0, 19, 20, 22, 24, 25, 26,
165 1.1 christos 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
166 1.1 christos 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
167 1.1 christos 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
168 1.1 christos 0, 0, 0, 0, 0, 0, 0, 19, 20, 22,
169 1.1 christos 24, 25, 26,
170 1.1 christos };
171 1.1 christos const short yycheck[] = { -1,
172 1.1 christos 0, 37, 0, -1, -1, 37, 42, 43, 0, 45,
173 1.1 christos 42, 47, 37, -1, -1, 47, 0, 42, 43, 33,
174 1.1 christos 45, -1, 47, -1, -1, 0, 40, -1, -1, 43,
175 1.1 christos -1, 45, -1, 0, -1, 60, -1, 62, 38, 0,
176 1.1 christos -1, 41, -1, 43, -1, 45, 38, 0, -1, 41,
177 1.1 christos 0, 43, -1, 45, 38, 0, -1, 41, -1, 0,
178 1.1 christos 60, -1, 62, 38, 0, 0, 41, -1, 60, -1,
179 1.1 christos 62, 38, -1, 0, 41, 0, 60, 38, 62, -1,
180 1.1 christos 41, -1, 0, -1, -1, 60, -1, 62, 41, -1,
181 1.1 christos -1, 41, -1, 60, 94, 62, 41, 38, -1, 60,
182 1.1 christos 41, 62, 94, 38, -1, 41, 41, -1, -1, -1,
183 1.1 christos 94, 38, 126, 38, 41, -1, 41, -1, -1, 94,
184 1.1 christos 38, -1, -1, 41, 124, -1, -1, 94, -1, -1,
185 1.1 christos -1, -1, 124, 94, -1, 60, -1, 62, -1, -1,
186 1.1 christos 124, 94, 60, -1, 62, -1, -1, -1, -1, 124,
187 1.1 christos 37, 38, -1, 94, 41, 42, 43, 124, 45, 94,
188 1.1 christos 47, -1, -1, 124, -1, -1, -1, 94, -1, 94,
189 1.1 christos -1, 124, 37, 60, 124, 62, 94, 42, 43, -1,
190 1.1 christos 45, -1, 47, 124, -1, -1, -1, -1, -1, 124,
191 1.1 christos -1, -1, -1, -1, -1, 37, 38, 124, -1, 124,
192 1.1 christos 42, 43, -1, 45, -1, 47, 124, 94, -1, -1,
193 1.1 christos -1, -1, -1, -1, -1, -1, -1, -1, 60, -1,
194 1.1 christos 62, -1, -1, -1, -1, -1, 37, 38, -1, 265,
195 1.1 christos 266, 42, 43, -1, 45, -1, 47, 124, 263, 264,
196 1.1 christos 265, 266, -1, 257, -1, -1, -1, -1, -1, 60,
197 1.1 christos -1, 62, 94, -1, -1, -1, -1, -1, -1, 259,
198 1.1 christos 260, 261, 262, 263, 264, 265, 266, 259, 260, 261,
199 1.1 christos 262, 263, 264, 265, 266, 259, 260, 261, 262, 263,
200 1.1 christos 264, 265, 266, 94, 259, 260, 261, 262, 263, 264,
201 1.1 christos 265, 266, 259, 260, 261, 262, 263, 264, 259, 260,
202 1.1 christos 261, 262, 263, 264, -1, -1, 259, 260, -1, 259,
203 1.1 christos 260, -1, -1, 124, 259, 260, -1, -1, 259, 260,
204 1.1 christos 261, 262, -1, 259, 259, 260, 261, 262, -1, -1,
205 1.1 christos -1, -1, 259, 260, 259, 260, 261, 262, 263, 264,
206 1.1 christos -1, 259, 260, 261, 262, 263, 264, -1, -1, -1,
207 1.1 christos -1, -1, -1, -1, -1, -1, -1, 37, 38, -1,
208 1.1 christos -1, -1, 42, 43, -1, 45, -1, 47, -1, -1,
209 1.1 christos -1, -1, 259, 260, 261, 262, 263, 264, 265, 266,
210 1.1 christos 60, -1, 62, 37, 38, -1, -1, -1, 42, 43,
211 1.1 christos 37, 45, -1, 47, -1, 42, 43, -1, 45, -1,
212 1.1 christos 47, -1, -1, -1, -1, -1, 60, -1, 62, -1,
213 1.1 christos -1, -1, -1, 60, 94, 62, -1, -1, -1, 261,
214 1.1 christos 262, 263, 264, 265, 266, -1, -1, -1, -1, -1,
215 1.1 christos -1, -1, -1, 37, 38, -1, -1, -1, 42, 43,
216 1.1 christos 94, 45, -1, 47, 124, -1, -1, -1, 259, 260,
217 1.1 christos 261, 262, 263, 264, 265, 266, 60, -1, 62, 2,
218 1.1 christos 3, 4, 5, 6, -1, -1, -1, -1, -1, -1,
219 1.1 christos 124, 14, 15, 16, 17, 18, 19, 20, 21, 22,
220 1.1 christos 23, 24, 25, 26, 27, 28, 29, 30, 31, -1,
221 1.1 christos -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
222 1.1 christos -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
223 1.1 christos -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
224 1.1 christos -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
225 1.1 christos -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
226 1.1 christos -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
227 1.1 christos -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
228 1.1 christos -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
229 1.1 christos -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
230 1.1 christos 260, 261, 262, 263, 264, 265, 266, -1, -1, -1,
231 1.1 christos -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
232 1.1 christos -1, -1, -1, -1, -1, -1, -1, 261, 262, 263,
233 1.1 christos 264, 265, 266, -1, 261, 262, 263, 264, 265, 266,
234 1.1 christos -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
235 1.1 christos -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
236 1.1 christos -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
237 1.1 christos -1, -1, -1, -1, -1, -1, -1, 261, 262, 263,
238 1.1 christos 264, 265, 266,
239 1.1 christos };
240 1.1 christos #define YYFINAL 7
241 1.1 christos #ifndef YYDEBUG
242 1.1 christos #define YYDEBUG 0
243 1.1 christos #endif
244 1.1 christos #define YYMAXTOKEN 268
245 1.1 christos #if YYDEBUG
246 1.1 christos const char * const yyname[] = {
247 1.1 christos "end-of-file",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
248 1.1 christos "'!'",0,0,0,"'%'","'&'",0,"'('","')'","'*'","'+'",0,"'-'",0,"'/'",0,0,0,0,0,0,0,
249 1.1 christos 0,0,0,0,0,"'<'",0,"'>'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
250 1.1 christos 0,0,0,"'^'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"'|'",0,
251 1.1 christos "'~'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
252 1.1 christos 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
253 1.1 christos 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
254 1.1 christos 0,0,0,0,0,0,0,0,0,0,0,0,0,"NUMBER","ERROR","LOR","LAND","EQ","NE","LE","GE",
255 1.1 christos "LSHIFT","RSHIFT","UMINUS","UPLUS",
256 1.1 christos };
257 1.1 christos const char * const yyrule[] = {
258 1.1 christos "$accept : top",
259 1.1 christos "top : expr",
260 1.1 christos "expr : expr '+' expr",
261 1.1 christos "expr : expr '-' expr",
262 1.1 christos "expr : expr '*' expr",
263 1.1 christos "expr : expr '/' expr",
264 1.1 christos "expr : expr '%' expr",
265 1.1 christos "expr : expr LSHIFT expr",
266 1.1 christos "expr : expr RSHIFT expr",
267 1.1 christos "expr : expr '<' expr",
268 1.1 christos "expr : expr '>' expr",
269 1.1 christos "expr : expr LE expr",
270 1.1 christos "expr : expr GE expr",
271 1.1 christos "expr : expr EQ expr",
272 1.1 christos "expr : expr NE expr",
273 1.1 christos "expr : expr '&' expr",
274 1.1 christos "expr : expr '^' expr",
275 1.1 christos "expr : expr '|' expr",
276 1.1 christos "expr : expr LAND expr",
277 1.1 christos "expr : expr LOR expr",
278 1.1 christos "expr : '(' expr ')'",
279 1.1 christos "expr : '-' expr",
280 1.1 christos "expr : '+' expr",
281 1.1 christos "expr : '!' expr",
282 1.1 christos "expr : '~' expr",
283 1.1 christos "expr : NUMBER",
284 1.1 christos };
285 1.1 christos #endif
286 1.1 christos #ifndef YYSTYPE
287 1.1 christos typedef int YYSTYPE;
288 1.1 christos #endif
289 1.1 christos #ifdef YYSTACKSIZE
290 1.1 christos #undef YYMAXDEPTH
291 1.1 christos #define YYMAXDEPTH YYSTACKSIZE
292 1.1 christos #else
293 1.1 christos #ifdef YYMAXDEPTH
294 1.1 christos #define YYSTACKSIZE YYMAXDEPTH
295 1.1 christos #else
296 1.1 christos #define YYSTACKSIZE 10000
297 1.1 christos #define YYMAXDEPTH 10000
298 1.1 christos #endif
299 1.1 christos #endif
300 1.1 christos #define YYINITSTACKSIZE 200
301 1.1 christos int yydebug;
302 1.1 christos int yynerrs;
303 1.1 christos int yyerrflag;
304 1.1 christos int yychar;
305 1.1 christos short *yyssp;
306 1.1 christos YYSTYPE *yyvsp;
307 1.1 christos YYSTYPE yyval;
308 1.1 christos static YYSTYPE yyvalzero;
309 1.1 christos YYSTYPE yylval;
310 1.1 christos short *yyss;
311 1.1 christos short *yysslim;
312 1.1 christos YYSTYPE *yyvs;
313 1.1 christos int yystacksize;
314 1.1 christos int yyparse(void);
315 1.1 christos #line 85 "/usr/src/tools/m4/../../usr.bin/m4/parser.y"
316 1.1 christos
317 1.1 christos #line 315 "parser.c"
318 1.1 christos /* allocate initial stack or double stack size, up to YYMAXDEPTH */
319 1.1 christos static int yygrowstack(void);
320 1.1 christos static int yygrowstack(void)
321 1.1 christos {
322 1.1 christos int newsize, i;
323 1.1 christos short *newss;
324 1.1 christos YYSTYPE *newvs;
325 1.1 christos
326 1.1 christos if ((newsize = yystacksize) == 0)
327 1.1 christos newsize = YYINITSTACKSIZE;
328 1.1 christos else if (newsize >= YYMAXDEPTH)
329 1.1 christos return -1;
330 1.1 christos else if ((newsize *= 2) > YYMAXDEPTH)
331 1.1 christos newsize = YYMAXDEPTH;
332 1.1 christos i = yyssp - yyss;
333 1.1 christos if ((newss = (short *)realloc(yyss, newsize * sizeof *newss)) == NULL)
334 1.1 christos return -1;
335 1.1 christos yyss = newss;
336 1.1 christos yyssp = newss + i;
337 1.1 christos if ((newvs = (YYSTYPE *)realloc(yyvs, newsize * sizeof *newvs)) == NULL)
338 1.1 christos return -1;
339 1.1 christos yyvs = newvs;
340 1.1 christos yyvsp = newvs + i;
341 1.1 christos yystacksize = newsize;
342 1.1 christos yysslim = yyss + newsize - 1;
343 1.1 christos return 0;
344 1.1 christos }
345 1.1 christos
346 1.1 christos #define YYABORT goto yyabort
347 1.1 christos #define YYREJECT goto yyabort
348 1.1 christos #define YYACCEPT goto yyaccept
349 1.1 christos #define YYERROR goto yyerrlab
350 1.1 christos int
351 1.1 christos yyparse(void)
352 1.1 christos {
353 1.1 christos int yym, yyn, yystate;
354 1.1 christos #if YYDEBUG
355 1.1 christos const char *yys;
356 1.1 christos
357 1.1 christos if ((yys = getenv("YYDEBUG")) != NULL)
358 1.1 christos {
359 1.1 christos yyn = *yys;
360 1.1 christos if (yyn >= '0' && yyn <= '9')
361 1.1 christos yydebug = yyn - '0';
362 1.1 christos }
363 1.1 christos #endif
364 1.1 christos
365 1.1 christos yynerrs = 0;
366 1.1 christos yyerrflag = 0;
367 1.1 christos yychar = (-1);
368 1.1 christos
369 1.1 christos if (yyss == NULL && yygrowstack()) goto yyoverflow;
370 1.1 christos yyssp = yyss;
371 1.1 christos yyvsp = yyvs;
372 1.1 christos *yyssp = yystate = 0;
373 1.1 christos
374 1.1 christos yyloop:
375 1.1 christos if ((yyn = yydefred[yystate]) != 0) goto yyreduce;
376 1.1 christos if (yychar < 0)
377 1.1 christos {
378 1.1 christos if ((yychar = yylex()) < 0) yychar = 0;
379 1.1 christos #if YYDEBUG
380 1.1 christos if (yydebug)
381 1.1 christos {
382 1.1 christos yys = 0;
383 1.1 christos if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
384 1.1 christos if (!yys) yys = "illegal-symbol";
385 1.1 christos printf("%sdebug: state %d, reading %d (%s)\n",
386 1.1 christos YYPREFIX, yystate, yychar, yys);
387 1.1 christos }
388 1.1 christos #endif
389 1.1 christos }
390 1.1 christos if ((yyn = yysindex[yystate]) && (yyn += yychar) >= 0 &&
391 1.1 christos yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
392 1.1 christos {
393 1.1 christos #if YYDEBUG
394 1.1 christos if (yydebug)
395 1.1 christos printf("%sdebug: state %d, shifting to state %d\n",
396 1.1 christos YYPREFIX, yystate, yytable[yyn]);
397 1.1 christos #endif
398 1.1 christos if (yyssp >= yysslim && yygrowstack())
399 1.1 christos {
400 1.1 christos goto yyoverflow;
401 1.1 christos }
402 1.1 christos *++yyssp = yystate = yytable[yyn];
403 1.1 christos *++yyvsp = yylval;
404 1.1 christos yychar = (-1);
405 1.1 christos if (yyerrflag > 0) --yyerrflag;
406 1.1 christos goto yyloop;
407 1.1 christos }
408 1.1 christos if ((yyn = yyrindex[yystate]) && (yyn += yychar) >= 0 &&
409 1.1 christos yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
410 1.1 christos {
411 1.1 christos yyn = yytable[yyn];
412 1.1 christos goto yyreduce;
413 1.1 christos }
414 1.1 christos if (yyerrflag) goto yyinrecovery;
415 1.1 christos goto yynewerror;
416 1.1 christos yynewerror:
417 1.1 christos yyerror("syntax error");
418 1.1 christos goto yyerrlab;
419 1.1 christos yyerrlab:
420 1.1 christos ++yynerrs;
421 1.1 christos yyinrecovery:
422 1.1 christos if (yyerrflag < 3)
423 1.1 christos {
424 1.1 christos yyerrflag = 3;
425 1.1 christos for (;;)
426 1.1 christos {
427 1.1 christos if ((yyn = yysindex[*yyssp]) && (yyn += YYERRCODE) >= 0 &&
428 1.1 christos yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE)
429 1.1 christos {
430 1.1 christos #if YYDEBUG
431 1.1 christos if (yydebug)
432 1.1 christos printf("%sdebug: state %d, error recovery shifting\
433 1.1 christos to state %d\n", YYPREFIX, *yyssp, yytable[yyn]);
434 1.1 christos #endif
435 1.1 christos if (yyssp >= yysslim && yygrowstack())
436 1.1 christos {
437 1.1 christos goto yyoverflow;
438 1.1 christos }
439 1.1 christos *++yyssp = yystate = yytable[yyn];
440 1.1 christos *++yyvsp = yylval;
441 1.1 christos goto yyloop;
442 1.1 christos }
443 1.1 christos else
444 1.1 christos {
445 1.1 christos #if YYDEBUG
446 1.1 christos if (yydebug)
447 1.1 christos printf("%sdebug: error recovery discarding state %d\n",
448 1.1 christos YYPREFIX, *yyssp);
449 1.1 christos #endif
450 1.1 christos if (yyssp <= yyss) goto yyabort;
451 1.1 christos --yyssp;
452 1.1 christos --yyvsp;
453 1.1 christos }
454 1.1 christos }
455 1.1 christos }
456 1.1 christos else
457 1.1 christos {
458 1.1 christos if (yychar == 0) goto yyabort;
459 1.1 christos #if YYDEBUG
460 1.1 christos if (yydebug)
461 1.1 christos {
462 1.1 christos yys = 0;
463 1.1 christos if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
464 1.1 christos if (!yys) yys = "illegal-symbol";
465 1.1 christos printf("%sdebug: state %d, error recovery discards token %d (%s)\n",
466 1.1 christos YYPREFIX, yystate, yychar, yys);
467 1.1 christos }
468 1.1 christos #endif
469 1.1 christos yychar = (-1);
470 1.1 christos goto yyloop;
471 1.1 christos }
472 1.1 christos yyreduce:
473 1.1 christos #if YYDEBUG
474 1.1 christos if (yydebug)
475 1.1 christos printf("%sdebug: state %d, reducing by rule %d (%s)\n",
476 1.1 christos YYPREFIX, yystate, yyn, yyrule[yyn]);
477 1.1 christos #endif
478 1.1 christos yym = yylen[yyn];
479 1.1 christos if (yym)
480 1.1 christos yyval = yyvsp[1-yym];
481 1.1 christos else
482 1.1 christos yyval = yyvalzero;
483 1.1 christos switch (yyn)
484 1.1 christos {
485 1.1 christos case 1:
486 1.1 christos #line 45 "/usr/src/tools/m4/../../usr.bin/m4/parser.y"
487 1.1 christos { end_result = yyvsp[0]; }
488 1.1 christos break;
489 1.1 christos case 2:
490 1.1 christos #line 47 "/usr/src/tools/m4/../../usr.bin/m4/parser.y"
491 1.1 christos { yyval = yyvsp[-2] + yyvsp[0]; }
492 1.1 christos break;
493 1.1 christos case 3:
494 1.1 christos #line 48 "/usr/src/tools/m4/../../usr.bin/m4/parser.y"
495 1.1 christos { yyval = yyvsp[-2] - yyvsp[0]; }
496 1.1 christos break;
497 1.1 christos case 4:
498 1.1 christos #line 49 "/usr/src/tools/m4/../../usr.bin/m4/parser.y"
499 1.1 christos { yyval = yyvsp[-2] * yyvsp[0]; }
500 1.1 christos break;
501 1.1 christos case 5:
502 1.1 christos #line 50 "/usr/src/tools/m4/../../usr.bin/m4/parser.y"
503 1.1 christos {
504 1.1 christos if (yyvsp[0] == 0) {
505 1.1 christos yyerror("division by zero");
506 1.1 christos exit(1);
507 1.1 christos }
508 1.1 christos yyval = yyvsp[-2] / yyvsp[0];
509 1.1 christos }
510 1.1 christos break;
511 1.1 christos case 6:
512 1.1 christos #line 57 "/usr/src/tools/m4/../../usr.bin/m4/parser.y"
513 1.1 christos {
514 1.1 christos if (yyvsp[0] == 0) {
515 1.1 christos yyerror("modulo zero");
516 1.1 christos exit(1);
517 1.1 christos }
518 1.1 christos yyval = yyvsp[-2] % yyvsp[0];
519 1.1 christos }
520 1.1 christos break;
521 1.1 christos case 7:
522 1.1 christos #line 64 "/usr/src/tools/m4/../../usr.bin/m4/parser.y"
523 1.1 christos { yyval = yyvsp[-2] << yyvsp[0]; }
524 1.1 christos break;
525 1.1 christos case 8:
526 1.1 christos #line 65 "/usr/src/tools/m4/../../usr.bin/m4/parser.y"
527 1.1 christos { yyval = yyvsp[-2] >> yyvsp[0]; }
528 1.1 christos break;
529 1.1 christos case 9:
530 1.1 christos #line 66 "/usr/src/tools/m4/../../usr.bin/m4/parser.y"
531 1.1 christos { yyval = yyvsp[-2] < yyvsp[0]; }
532 1.1 christos break;
533 1.1 christos case 10:
534 1.1 christos #line 67 "/usr/src/tools/m4/../../usr.bin/m4/parser.y"
535 1.1 christos { yyval = yyvsp[-2] > yyvsp[0]; }
536 1.1 christos break;
537 1.1 christos case 11:
538 1.1 christos #line 68 "/usr/src/tools/m4/../../usr.bin/m4/parser.y"
539 1.1 christos { yyval = yyvsp[-2] <= yyvsp[0]; }
540 1.1 christos break;
541 1.1 christos case 12:
542 1.1 christos #line 69 "/usr/src/tools/m4/../../usr.bin/m4/parser.y"
543 1.1 christos { yyval = yyvsp[-2] >= yyvsp[0]; }
544 1.1 christos break;
545 1.1 christos case 13:
546 1.1 christos #line 70 "/usr/src/tools/m4/../../usr.bin/m4/parser.y"
547 1.1 christos { yyval = yyvsp[-2] == yyvsp[0]; }
548 1.1 christos break;
549 1.1 christos case 14:
550 1.1 christos #line 71 "/usr/src/tools/m4/../../usr.bin/m4/parser.y"
551 1.1 christos { yyval = yyvsp[-2] != yyvsp[0]; }
552 1.1 christos break;
553 1.1 christos case 15:
554 1.1 christos #line 72 "/usr/src/tools/m4/../../usr.bin/m4/parser.y"
555 1.1 christos { yyval = yyvsp[-2] & yyvsp[0]; }
556 1.1 christos break;
557 1.1 christos case 16:
558 1.1 christos #line 73 "/usr/src/tools/m4/../../usr.bin/m4/parser.y"
559 1.1 christos { yyval = yyvsp[-2] ^ yyvsp[0]; }
560 1.1 christos break;
561 1.1 christos case 17:
562 1.1 christos #line 74 "/usr/src/tools/m4/../../usr.bin/m4/parser.y"
563 1.1 christos { yyval = yyvsp[-2] | yyvsp[0]; }
564 1.1 christos break;
565 1.1 christos case 18:
566 1.1 christos #line 75 "/usr/src/tools/m4/../../usr.bin/m4/parser.y"
567 1.1 christos { yyval = yyvsp[-2] && yyvsp[0]; }
568 1.1 christos break;
569 1.1 christos case 19:
570 1.1 christos #line 76 "/usr/src/tools/m4/../../usr.bin/m4/parser.y"
571 1.1 christos { yyval = yyvsp[-2] || yyvsp[0]; }
572 1.1 christos break;
573 1.1 christos case 20:
574 1.1 christos #line 77 "/usr/src/tools/m4/../../usr.bin/m4/parser.y"
575 1.1 christos { yyval = yyvsp[-1]; }
576 1.1 christos break;
577 1.1 christos case 21:
578 1.1 christos #line 78 "/usr/src/tools/m4/../../usr.bin/m4/parser.y"
579 1.1 christos { yyval = -yyvsp[0]; }
580 1.1 christos break;
581 1.1 christos case 22:
582 1.1 christos #line 79 "/usr/src/tools/m4/../../usr.bin/m4/parser.y"
583 1.1 christos { yyval = yyvsp[0]; }
584 1.1 christos break;
585 1.1 christos case 23:
586 1.1 christos #line 80 "/usr/src/tools/m4/../../usr.bin/m4/parser.y"
587 1.1 christos { yyval = !yyvsp[0]; }
588 1.1 christos break;
589 1.1 christos case 24:
590 1.1 christos #line 81 "/usr/src/tools/m4/../../usr.bin/m4/parser.y"
591 1.1 christos { yyval = ~yyvsp[0]; }
592 1.1 christos break;
593 1.1 christos #line 591 "parser.c"
594 1.1 christos }
595 1.1 christos yyssp -= yym;
596 1.1 christos yystate = *yyssp;
597 1.1 christos yyvsp -= yym;
598 1.1 christos yym = yylhs[yyn];
599 1.1 christos if (yystate == 0 && yym == 0)
600 1.1 christos {
601 1.1 christos #if YYDEBUG
602 1.1 christos if (yydebug)
603 1.1 christos printf("%sdebug: after reduction, shifting from state 0 to\
604 1.1 christos state %d\n", YYPREFIX, YYFINAL);
605 1.1 christos #endif
606 1.1 christos yystate = YYFINAL;
607 1.1 christos *++yyssp = YYFINAL;
608 1.1 christos *++yyvsp = yyval;
609 1.1 christos if (yychar < 0)
610 1.1 christos {
611 1.1 christos if ((yychar = yylex()) < 0) yychar = 0;
612 1.1 christos #if YYDEBUG
613 1.1 christos if (yydebug)
614 1.1 christos {
615 1.1 christos yys = 0;
616 1.1 christos if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
617 1.1 christos if (!yys) yys = "illegal-symbol";
618 1.1 christos printf("%sdebug: state %d, reading %d (%s)\n",
619 1.1 christos YYPREFIX, YYFINAL, yychar, yys);
620 1.1 christos }
621 1.1 christos #endif
622 1.1 christos }
623 1.1 christos if (yychar == 0) goto yyaccept;
624 1.1 christos goto yyloop;
625 1.1 christos }
626 1.1 christos if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 &&
627 1.1 christos yyn <= YYTABLESIZE && yycheck[yyn] == yystate)
628 1.1 christos yystate = yytable[yyn];
629 1.1 christos else
630 1.1 christos yystate = yydgoto[yym];
631 1.1 christos #if YYDEBUG
632 1.1 christos if (yydebug)
633 1.1 christos printf("%sdebug: after reduction, shifting from state %d \
634 1.1 christos to state %d\n", YYPREFIX, *yyssp, yystate);
635 1.1 christos #endif
636 1.1 christos if (yyssp >= yysslim && yygrowstack())
637 1.1 christos {
638 1.1 christos goto yyoverflow;
639 1.1 christos }
640 1.1 christos *++yyssp = yystate;
641 1.1 christos *++yyvsp = yyval;
642 1.1 christos goto yyloop;
643 1.1 christos yyoverflow:
644 1.1 christos yyerror("yacc stack overflow");
645 1.1 christos yyabort:
646 1.1 christos return (1);
647 1.1 christos yyaccept:
648 1.1 christos return (0);
649 1.1 christos }
650