]> git.saurik.com Git - bison.git/blame - src/bison.hairy
Test also `--verbose', `--defines' and `--name-prefix'. Testing
[bison.git] / src / bison.hairy
CommitLineData
f791019c
RS
1
2extern int timeclock;
3
4
5int yyerror; /* Yyerror and yycost are set by guards. */
6int yycost; /* If yyerror is set to a nonzero value by a */
7 /* guard, the reduction with which the guard */
8 /* is associated is not performed, and the */
9 /* error recovery mechanism is invoked. */
10 /* Yycost indicates the cost of performing */
11 /* the reduction given the attributes of the */
12 /* symbols. */
13
14
15/* YYMAXDEPTH indicates the size of the parser's state and value */
16/* stacks. */
17
18#ifndef YYMAXDEPTH
19#define YYMAXDEPTH 500
20#endif
21
22/* YYMAXRULES must be at least as large as the number of rules that */
23/* could be placed in the rule queue. That number could be determined */
24/* from the grammar and the size of the stack, but, as yet, it is not. */
25
26#ifndef YYMAXRULES
27#define YYMAXRULES 100
28#endif
29
30#ifndef YYMAXBACKUP
31#define YYMAXBACKUP 100
32#endif
33
34
35short yyss[YYMAXDEPTH]; /* the state stack */
36YYSTYPE yyvs[YYMAXDEPTH]; /* the semantic value stack */
37YYLTYPE yyls[YYMAXDEPTH]; /* the location stack */
38short yyrq[YYMAXRULES]; /* the rule queue */
39int yychar; /* the lookahead symbol */
40
41YYSTYPE yylval; /* the semantic value of the */
42 /* lookahead symbol */
43
44YYSTYPE yytval; /* the semantic value for the state */
45 /* at the top of the state stack. */
46
47YYSTYPE yyval; /* the variable used to return */
48 /* semantic values from the action */
49 /* routines */
50
51YYLTYPE yylloc; /* location data for the lookahead */
52 /* symbol */
53
54YYLTYPE yytloc; /* location data for the state at the */
55 /* top of the state stack */
56
57
58int yynunlexed;
59short yyunchar[YYMAXBACKUP];
60YYSTYPE yyunval[YYMAXBACKUP];
61YYLTYPE yyunloc[YYMAXBACKUP];
62
63short *yygssp; /* a pointer to the top of the state */
64 /* stack; only set during error */
65 /* recovery. */
66
67YYSTYPE *yygvsp; /* a pointer to the top of the value */
68 /* stack; only set during error */
69 /* recovery. */
70
71YYLTYPE *yyglsp; /* a pointer to the top of the */
72 /* location stack; only set during */
73 /* error recovery. */
74
75
76/* Yyget is an interface between the parser and the lexical analyzer. */
77/* It is costly to provide such an interface, but it avoids requiring */
78/* the lexical analyzer to be able to back up the scan. */
79
80yyget()
81{
82 if (yynunlexed > 0)
83 {
84 yynunlexed--;
85 yychar = yyunchar[yynunlexed];
86 yylval = yyunval[yynunlexed];
87 yylloc = yyunloc[yynunlexed];
88 }
89 else if (yychar <= 0)
90 yychar = 0;
91 else
92 {
93 yychar = yylex();
94 if (yychar < 0)
95 yychar = 0;
96 else yychar = YYTRANSLATE(yychar);
97 }
98}
99
100
101
102yyunlex(chr, val, loc)
103int chr;
104YYSTYPE val;
105YYLTYPE loc;
106{
107 yyunchar[yynunlexed] = chr;
108 yyunval[yynunlexed] = val;
109 yyunloc[yynunlexed] = loc;
110 yynunlexed++;
111}
112
113
114
115yyrestore(first, last)
116register short *first;
117register short *last;
118{
119 register short *ssp;
120 register short *rp;
121 register int symbol;
122 register int state;
123 register int tvalsaved;
124
125 ssp = yygssp;
126 yyunlex(yychar, yylval, yylloc);
127
128 tvalsaved = 0;
129 while (first != last)
130 {
131 symbol = yystos[*ssp];
132 if (symbol < YYNTBASE)
133 {
134 yyunlex(symbol, yytval, yytloc);
135 tvalsaved = 1;
136 ssp--;
137 }
138
139 ssp--;
140
141 if (first == yyrq)
142 first = yyrq + YYMAXRULES;
143
144 first--;
145
146 for (rp = yyrhs + yyprhs[*first]; symbol = *rp; rp++)
147 {
148 if (symbol < YYNTBASE)
149 state = yytable[yypact[*ssp] + symbol];
150 else
151 {
152 state = yypgoto[symbol - YYNTBASE] + *ssp;
153
154 if (state >= 0 && state <= YYLAST && yycheck[state] == *ssp)
155 state = yytable[state];
156 else
157 state = yydefgoto[symbol - YYNTBASE];
158 }
159
160 *++ssp = state;
161 }
162 }
163
164 if ( ! tvalsaved && ssp > yyss)
165 {
166 yyunlex(yystos[*ssp], yytval, yytloc);
167 ssp--;
168 }
169
170 yygssp = ssp;
171}
172
173
174
175int
176yyparse()
177{
178 register int yystate;
179 register int yyn;
180 register short *yyssp;
181 register short *yyrq0;
182 register short *yyptr;
183 register YYSTYPE *yyvsp;
184
185 int yylen;
186 YYLTYPE *yylsp;
187 short *yyrq1;
188 short *yyrq2;
189
190 yystate = 0;
191 yyssp = yyss - 1;
192 yyvsp = yyvs - 1;
193 yylsp = yyls - 1;
194 yyrq0 = yyrq;
195 yyrq1 = yyrq0;
196 yyrq2 = yyrq0;
197
198 yychar = yylex();
199 if (yychar < 0)
200 yychar = 0;
201 else yychar = YYTRANSLATE(yychar);
202
203yynewstate:
204
205 if (yyssp >= yyss + YYMAXDEPTH - 1)
206 {
207 yyabort("Parser Stack Overflow");
208 YYABORT;
209 }
210
211 *++yyssp = yystate;
212
213yyresume:
214
215 yyn = yypact[yystate];
216 if (yyn == YYFLAG)
217 goto yydefault;
218
219 yyn += yychar;
220 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar)
221 goto yydefault;
222
223 yyn = yytable[yyn];
224 if (yyn < 0)
225 {
226 yyn = -yyn;
227 goto yyreduce;
228 }
229 else if (yyn == 0)
230 goto yyerrlab;
231
232 yystate = yyn;
233
234 yyptr = yyrq2;
235 while (yyptr != yyrq1)
236 {
237 yyn = *yyptr++;
238 yylen = yyr2[yyn];
239 yyvsp -= yylen;
240 yylsp -= yylen;
241
242 yyguard(yyn, yyvsp, yylsp);
243 if (yyerror)
244 goto yysemerr;
245
246 yyaction(yyn, yyvsp, yylsp);
247 *++yyvsp = yyval;
248
249 yylsp++;
250 if (yylen == 0)
251 {
252 yylsp->timestamp = timeclock;
253 yylsp->first_line = yytloc.first_line;
254 yylsp->first_column = yytloc.first_column;
255 yylsp->last_line = (yylsp-1)->last_line;
256 yylsp->last_column = (yylsp-1)->last_column;
257 yylsp->text = 0;
258 }
259 else
260 {
261 yylsp->last_line = (yylsp+yylen-1)->last_line;
262 yylsp->last_column = (yylsp+yylen-1)->last_column;
263 }
264
265 if (yyptr == yyrq + YYMAXRULES)
266 yyptr = yyrq;
267 }
268
269 if (yystate == YYFINAL)
270 YYACCEPT;
271
272 yyrq2 = yyptr;
273 yyrq1 = yyrq0;
274
275 *++yyvsp = yytval;
276 *++yylsp = yytloc;
277 yytval = yylval;
278 yytloc = yylloc;
279 yyget();
280
281 goto yynewstate;
282
283yydefault:
284
285 yyn = yydefact[yystate];
286 if (yyn == 0)
287 goto yyerrlab;
288
289yyreduce:
290
291 *yyrq0++ = yyn;
292
293 if (yyrq0 == yyrq + YYMAXRULES)
294 yyrq0 = yyrq;
295
296 if (yyrq0 == yyrq2)
297 {
298 yyabort("Parser Rule Queue Overflow");
299 YYABORT;
300 }
301
302 yyssp -= yyr2[yyn];
303 yyn = yyr1[yyn];
304
305 yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
306 if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
307 yystate = yytable[yystate];
308 else
309 yystate = yydefgoto[yyn - YYNTBASE];
310
311 goto yynewstate;
312
313yysemerr:
314 *--yyptr = yyn;
315 yyrq2 = yyptr;
316 yyvsp += yyr2[yyn];
317
318yyerrlab:
319
320 yygssp = yyssp;
321 yygvsp = yyvsp;
322 yyglsp = yylsp;
323 yyrestore(yyrq0, yyrq2);
324 yyrecover();
325 yystate = *yygssp;
326 yyssp = yygssp;
327 yyvsp = yygvsp;
328 yyrq0 = yyrq;
329 yyrq1 = yyrq0;
330 yyrq2 = yyrq0;
331 goto yyresume;
332}
333
334$