1 : /* A Bison parser, made by GNU Bison 1.875d. */
2 :
3 : /* Skeleton parser for GLR parsing with Bison,
4 : Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
5 :
6 : This program is free software; you can redistribute it and/or modify
7 : it under the terms of the GNU General Public License as published by
8 : the Free Software Foundation; either version 2, or (at your option)
9 : any later version.
10 :
11 : This program is distributed in the hope that it will be useful,
12 : but WITHOUT ANY WARRANTY; without even the implied warranty of
13 : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 : GNU General Public License for more details.
15 :
16 : You should have received a copy of the GNU General Public License
17 : along with this program; if not, write to the Free Software
18 : Foundation, Inc., 59 Temple Place - Suite 330,
19 : Boston, MA 02111-1307, USA. */
20 :
21 : /* This is the parser code for GLR (Generalized LR) parser. */
22 :
23 : #include <stdio.h>
24 : #include <stdlib.h>
25 : #include <string.h>
26 : #include <stdarg.h>
27 : #include <setjmp.h>
28 :
29 : /* Identify Bison output. */
30 : #define YYBISON 1
31 :
32 : /* Skeleton name. */
33 : #define YYSKELETON_NAME "glr.c"
34 :
35 : /* Pure parsers. */
36 : #define YYPURE 1
37 :
38 : /* Using locations. */
39 : #define YYLSP_NEEDED 1
40 :
41 :
42 :
43 : /* Tokens. */
44 : #ifndef YYTOKENTYPE
45 : # define YYTOKENTYPE
46 : /* Put the tokens into the symbol table, so that GDB and other debuggers
47 : know about them. */
48 : enum yytokentype {
49 : ID = 258,
50 : INT = 259,
51 : STR = 260,
52 : PATH = 261,
53 : URI = 262,
54 : IF = 263,
55 : THEN = 264,
56 : ELSE = 265,
57 : ASSERT = 266,
58 : WITH = 267,
59 : LET = 268,
60 : REC = 269,
61 : INHERIT = 270,
62 : EQ = 271,
63 : NEQ = 272,
64 : AND = 273,
65 : OR = 274,
66 : IMPL = 275,
67 : UPDATE = 276,
68 : NEG = 277
69 : };
70 : #endif
71 : #define ID 258
72 : #define INT 259
73 : #define STR 260
74 : #define PATH 261
75 : #define URI 262
76 : #define IF 263
77 : #define THEN 264
78 : #define ELSE 265
79 : #define ASSERT 266
80 : #define WITH 267
81 : #define LET 268
82 : #define REC 269
83 : #define INHERIT 270
84 : #define EQ 271
85 : #define NEQ 272
86 : #define AND 273
87 : #define OR 274
88 : #define IMPL 275
89 : #define UPDATE 276
90 : #define NEG 277
91 :
92 :
93 :
94 :
95 : /* Copy the first part of user declarations. */
96 : #line 9 "parser.y"
97 :
98 : #include <stdio.h>
99 : #include <stdlib.h>
100 : #include <string.h>
101 : #include <aterm2.h>
102 :
103 : #include "parser-tab.h"
104 : #include "lexer-tab.h"
105 :
106 : typedef ATerm Expr;
107 : typedef ATerm Pos;
108 :
109 : #include "nixexpr-ast.hh"
110 :
111 : void setParseResult(void * data, ATerm t);
112 : void parseError(void * data, char * error, int line, int column);
113 : ATerm absParsedPath(void * data, ATerm t);
114 : ATerm fixAttrs(int recursive, ATermList as);
115 : const char * getPath(void * data);
116 :
117 : void yyerror(YYLTYPE * loc, yyscan_t scanner, void * data, char * s)
118 : {
119 : parseError(data, s, loc->first_line, loc->first_column);
120 : }
121 :
122 : ATerm toATerm(const char * s)
123 : {
124 : return (ATerm) ATmakeAppl0(ATmakeAFun((char *) s, 0, ATtrue));
125 : }
126 :
127 : static Pos makeCurPos(YYLTYPE * loc, void * data)
128 : {
129 : return makePos(toATerm(getPath(data)),
130 : loc->first_line, loc->first_column);
131 : }
132 :
133 : #define CUR_POS makeCurPos(yylocp, data)
134 :
135 :
136 :
137 : /* Enabling traces. */
138 : #ifndef YYDEBUG
139 : # define YYDEBUG 0
140 : #endif
141 :
142 : /* Enabling verbose error messages. */
143 : #ifdef YYERROR_VERBOSE
144 : # undef YYERROR_VERBOSE
145 : # define YYERROR_VERBOSE 1
146 : #else
147 : # define YYERROR_VERBOSE 1
148 : #endif
149 :
150 : #if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)
151 : #line 49 "parser.y"
152 : typedef union YYSTYPE {
153 : ATerm t;
154 : ATermList ts;
155 : } YYSTYPE;
156 : /* Line 187 of glr.c. */
157 : #line 158 "parser-tab.c"
158 : # define YYSTYPE_IS_DECLARED 1
159 : # define YYSTYPE_IS_TRIVIAL 1
160 : #endif
161 :
162 : #if ! defined (YYLTYPE) && ! defined (YYLTYPE_IS_DECLARED)
163 : typedef struct YYLTYPE
164 : {
165 :
166 : int first_line;
167 : int first_column;
168 : int last_line;
169 : int last_column;
170 :
171 : } YYLTYPE;
172 : # define YYLTYPE_IS_DECLARED 1
173 : # define YYLTYPE_IS_TRIVIAL 1
174 : #endif
175 :
176 : /* Default (constant) values used for initialization for null
177 : right-hand sides. Unlike the standard yacc.c template,
178 : here we set the default values of $$ and $@ to zeroed-out
179 : values. Since the default value of these quantities is undefined,
180 : this behavior is technically correct. */
181 : static YYSTYPE yyval_default;
182 : static YYLTYPE yyloc_default;
183 :
184 : /* Copy the second part of user declarations. */
185 :
186 :
187 : /* Line 219 of glr.c. */
188 : #line 189 "parser-tab.c"
189 :
190 : #ifndef YYFREE
191 : # define YYFREE free
192 : #endif
193 : #ifndef YYMALLOC
194 : # define YYMALLOC malloc
195 : #endif
196 : #ifndef YYREALLOC
197 : # define YYREALLOC realloc
198 : #endif
199 :
200 : #ifdef __cplusplus
201 : typedef bool yybool;
202 : #else
203 : typedef unsigned char yybool;
204 : #endif
205 : #define yytrue 1
206 : #define yyfalse 0
207 :
208 : /*-----------------.
209 : | GCC extensions. |
210 : `-----------------*/
211 :
212 : #ifndef __attribute__
213 : /* This feature is available in gcc versions 2.5 and later. */
214 : # if !defined (__GNUC__) || __GNUC__ < 2 || \
215 : (__GNUC__ == 2 && __GNUC_MINOR__ < 5) || __STRICT_ANSI__
216 : # define __attribute__(Spec) /* empty */
217 : # endif
218 : #endif
219 :
220 : #ifndef YYASSERT
221 : # define YYASSERT(condition) ((void) ((condition) || (abort (), 0)))
222 : #endif
223 :
224 : #ifndef ATTRIBUTE_UNUSED
225 : # define ATTRIBUTE_UNUSED __attribute__ ((__unused__))
226 : #endif
227 :
228 : /* YYFINAL -- State number of the termination state. */
229 : #define YYFINAL 39
230 : /* YYLAST -- Last index in YYTABLE. */
231 : #define YYLAST 156
232 :
233 : /* YYNTOKENS -- Number of terminals. */
234 : #define YYNTOKENS 38
235 : /* YYNNTS -- Number of nonterminals. */
236 : #define YYNNTS 16
237 : /* YYNRULES -- Number of rules. */
238 : #define YYNRULES 49
239 : /* YYNRULES -- Number of states. */
240 : #define YYNSTATES 98
241 : /* YYMAXRHS -- Maximum number of symbols on right-hand side of rule. */
242 : #define YYMAXRHS 6
243 : /* YYMAXLEFT -- Maximum number of symbols to the left of a handle
244 : accessed by $0, $-1, etc., in any rule. */
245 : #define YYMAXLEFT 0
246 :
247 : /* YYTRANSLATE(X) -- Bison symbol number corresponding to X. */
248 : #define YYUNDEFTOK 2
249 : #define YYMAXUTOK 277
250 :
251 : #define YYTRANSLATE(YYX) \
252 : ((YYX <= 0) ? YYEOF : \
253 : (unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
254 :
255 : /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
256 : static const unsigned char yytranslate[] =
257 : {
258 : 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
259 : 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
260 : 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
261 : 2, 2, 2, 30, 2, 2, 2, 2, 2, 2,
262 : 32, 33, 2, 23, 37, 2, 31, 2, 2, 2,
263 : 2, 2, 2, 2, 2, 2, 2, 2, 28, 29,
264 : 2, 36, 2, 24, 2, 2, 2, 2, 2, 2,
265 : 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
266 : 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
267 : 2, 34, 2, 35, 2, 2, 2, 2, 2, 2,
268 : 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
269 : 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
270 : 2, 2, 2, 26, 2, 27, 25, 2, 2, 2,
271 : 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
272 : 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
273 : 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
274 : 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
275 : 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
276 : 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
277 : 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
278 : 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
279 : 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
280 : 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
281 : 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
282 : 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
283 : 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
284 : 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
285 : 15, 16, 17, 18, 19, 20, 21, 22
286 : };
287 :
288 : #if YYDEBUG
289 : /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
290 : YYRHS. */
291 : static const unsigned char yyprhs[] =
292 : {
293 : 0, 0, 3, 5, 7, 13, 17, 22, 27, 29,
294 : 36, 38, 41, 45, 49, 53, 57, 61, 65, 69,
295 : 73, 77, 79, 82, 84, 88, 90, 92, 94, 96,
296 : 98, 100, 104, 109, 114, 118, 122, 125, 126, 131,
297 : 136, 140, 141, 144, 145, 148, 149, 153, 155, 157
298 : };
299 :
300 : /* YYRHS -- A `-1'-separated list of the rules' RHS. */
301 : static const signed char yyrhs[] =
302 : {
303 : 39, 0, -1, 40, -1, 41, -1, 26, 52, 27,
304 : 28, 41, -1, 3, 28, 41, -1, 11, 40, 29,
305 : 41, -1, 12, 40, 29, 41, -1, 42, -1, 8,
306 : 40, 9, 40, 10, 40, -1, 43, -1, 30, 43,
307 : -1, 43, 16, 43, -1, 43, 17, 43, -1, 43,
308 : 18, 43, -1, 43, 19, 43, -1, 43, 20, 43,
309 : -1, 43, 21, 43, -1, 43, 25, 43, -1, 43,
310 : 24, 3, -1, 43, 23, 43, -1, 44, -1, 44,
311 : 45, -1, 45, -1, 45, 31, 3, -1, 46, -1,
312 : 3, -1, 4, -1, 5, -1, 6, -1, 7, -1,
313 : 32, 40, 33, -1, 13, 26, 47, 27, -1, 14,
314 : 26, 47, 27, -1, 26, 47, 27, -1, 34, 51,
315 : 35, -1, 47, 48, -1, -1, 3, 36, 40, 29,
316 : -1, 15, 49, 50, 29, -1, 32, 40, 33, -1,
317 : -1, 50, 3, -1, -1, 45, 51, -1, -1, 53,
318 : 37, 52, -1, 53, -1, 3, -1, 3, 24, 40,
319 : -1
320 : };
321 :
322 : /* YYRLINE[YYN] -- source line where rule number YYN was defined. */
323 : static const unsigned char yyrline[] =
324 : {
325 : 0, 72, 72, 74, 77, 79, 81, 83, 85, 89,
326 : 91, 95, 96, 97, 98, 99, 100, 101, 102, 103,
327 : 104, 105, 109, 111, 115, 117, 121, 122, 123, 124,
328 : 125, 126, 129, 131, 133, 135, 139, 140, 144, 146,
329 : 151, 152, 155, 155, 158, 162, 166, 167, 171, 172
330 : };
331 : #endif
332 :
333 : #if (YYDEBUG) || YYERROR_VERBOSE
334 : /* YYTNME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
335 : First, the terminals, then, starting at YYNTOKENS, nonterminals. */
336 : static const char *const yytname[] =
337 : {
338 : "$end", "error", "$undefined", "ID", "INT", "STR", "PATH", "URI", "IF",
339 : "THEN", "ELSE", "ASSERT", "WITH", "LET", "REC", "INHERIT", "EQ", "NEQ",
340 : "AND", "OR", "IMPL", "UPDATE", "NEG", "'+'", "'?'", "'~'", "'{'", "'}'",
341 : "':'", "';'", "'!'", "'.'", "'('", "')'", "'['", "']'", "'='", "','",
342 : "$accept", "start", "expr", "expr_function", "expr_if", "expr_op",
343 : "expr_app", "expr_select", "expr_simple", "binds", "bind", "inheritsrc",
344 : "ids", "expr_list", "formals", "formal", 0
345 : };
346 : #endif
347 :
348 : /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
349 : static const unsigned char yyr1[] =
350 : {
351 : 0, 38, 39, 40, 41, 41, 41, 41, 41, 42,
352 : 42, 43, 43, 43, 43, 43, 43, 43, 43, 43,
353 : 43, 43, 44, 44, 45, 45, 46, 46, 46, 46,
354 : 46, 46, 46, 46, 46, 46, 47, 47, 48, 48,
355 : 49, 49, 50, 50, 51, 51, 52, 52, 53, 53
356 : };
357 :
358 : /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
359 : static const unsigned char yyr2[] =
360 : {
361 : 0, 2, 1, 1, 5, 3, 4, 4, 1, 6,
362 : 1, 2, 3, 3, 3, 3, 3, 3, 3, 3,
363 : 3, 1, 2, 1, 3, 1, 1, 1, 1, 1,
364 : 1, 3, 4, 4, 3, 3, 2, 0, 4, 4,
365 : 3, 0, 2, 0, 2, 0, 3, 1, 1, 3
366 : };
367 :
368 : /* YYDPREC[RULE-NUM] -- Dynamic precedence of rule #RULE-NUM (0 if none). */
369 : static const unsigned char yydprec[] =
370 : {
371 : 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
372 : 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
373 : 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
374 : 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
375 : 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
376 : };
377 :
378 : /* YYMERGER[RULE-NUM] -- Index of merging function for rule #RULE-NUM. */
379 : static const unsigned char yymerger[] =
380 : {
381 : 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
382 : 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
383 : 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
384 : 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
385 : 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
386 : };
387 :
388 : /* YYDEFACT[S] -- default rule to reduce with in state S when YYTABLE
389 : doesn't specify something else to do. Zero means the default is an
390 : error. */
391 : static const unsigned char yydefact[] =
392 : {
393 : 0, 26, 27, 28, 29, 30, 0, 0, 0, 0,
394 : 0, 37, 0, 0, 45, 0, 2, 3, 8, 10,
395 : 21, 23, 25, 0, 0, 0, 0, 37, 37, 48,
396 : 0, 0, 47, 26, 37, 11, 0, 45, 0, 1,
397 : 0, 0, 0, 0, 0, 0, 0, 0, 0, 22,
398 : 0, 5, 0, 0, 0, 0, 0, 0, 0, 41,
399 : 34, 36, 0, 0, 31, 44, 35, 12, 13, 14,
400 : 15, 16, 17, 20, 19, 18, 24, 0, 6, 7,
401 : 32, 33, 49, 0, 0, 43, 0, 46, 0, 0,
402 : 0, 0, 4, 9, 38, 40, 42, 39
403 : };
404 :
405 : /* YYPDEFGOTO[NTERM-NUM]. */
406 : static const signed char yydefgoto[] =
407 : {
408 : -1, 15, 16, 17, 18, 19, 20, 21, 22, 30,
409 : 61, 85, 91, 38, 31, 32
410 : };
411 :
412 : /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
413 : STATE-NUM. */
414 : #define YYPACT_NINF -23
415 : static const short int yypact[] =
416 : {
417 : 49, -22, -23, -23, -23, -23, 49, 49, 49, -16,
418 : -14, 13, 81, 49, 118, 25, -23, -23, -23, 85,
419 : 118, 14, -23, 49, 41, 45, 47, -23, -23, 46,
420 : 2, 53, 59, -23, -23, 24, 64, 86, 63, -23,
421 : 81, 81, 81, 81, 81, 81, 81, 111, 81, 14,
422 : 113, -23, 49, 49, 49, 8, 16, 49, 83, 94,
423 : -23, -23, 99, 125, -23, -23, -23, -3, -3, 48,
424 : 130, 117, 3, 34, -23, 104, -23, 120, -23, -23,
425 : -23, -23, -23, 49, 49, -23, 49, -23, 49, 110,
426 : 112, 1, -23, -23, -23, -23, -23, -23
427 : };
428 :
429 : /* YYPGOTO[NTERM-NUM]. */
430 : static const signed char yypgoto[] =
431 : {
432 : -23, -23, -6, -20, -23, -4, -23, -5, -23, 40,
433 : -23, -23, -23, 106, 93, -23
434 : };
435 :
436 : /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
437 : positive, shift that token. If negative, reduce the rule which
438 : number is the opposite. If zero, do what YYDEFACT says.
439 : If YYTABLE_NINF, syntax error. */
440 : #define YYTABLE_NINF -1
441 : static const signed char yytable[] =
442 : {
443 : 24, 25, 26, 51, 96, 58, 23, 36, 35, 37,
444 : 27, 58, 28, -1, -1, 49, 29, 59, 45, 58,
445 : 46, 47, 48, 59, 45, 39, 46, 47, 48, 60,
446 : 97, 59, 37, 78, 79, 80, 67, 68, 69, 70,
447 : 71, 72, 73, 81, 75, 50, 77, 46, 47, 48,
448 : 52, 82, 1, 2, 3, 4, 5, 6, 47, 48,
449 : 7, 8, 9, 10, 40, 41, 92, 55, 56, 45,
450 : 57, 46, 47, 48, 53, 11, 54, 89, 90, 12,
451 : 62, 13, 93, 14, 33, 2, 3, 4, 5, 33,
452 : 2, 3, 4, 5, 9, 10, 63, 64, 66, 9,
453 : 10, 40, 41, 42, 43, 44, 45, 34, 46, 47,
454 : 48, 12, 34, 13, 74, 14, 76, 50, 13, 83,
455 : 14, 33, 2, 3, 4, 5, 84, 86, 29, -1,
456 : 88, 9, 10, 40, 41, 42, 43, -1, 45, 94,
457 : 46, 47, 48, 65, 34, 95, 40, 41, 42, 0,
458 : 13, 45, 14, 46, 47, 48, 87
459 : };
460 :
461 : /* YYCONFLP[YYPACT[STATE-NUM]] -- Pointer into YYCONFL of start of
462 : list of conflicting reductions corresponding to action entry for
463 : state STATE-NUM in yytable. 0 means no conflicts. The list in
464 : yyconfl is terminated by a rule number of 0. */
465 : static const unsigned char yyconflp[] =
466 : {
467 : 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
468 : 0, 0, 0, 0, 0, 0, 1, 0, 0, 0,
469 : 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
470 : 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
471 : 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
472 : 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
473 : 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
474 : 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
475 : 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
476 : 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
477 : 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
478 : 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
479 : 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
480 : 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
481 : 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
482 : 0, 0, 0, 0, 0, 0, 0
483 : };
484 :
485 : /* YYCONFL[I] -- lists of conflicting rule numbers, each terminated by
486 : 0, pointed into by YYCONFLP. */
487 : static const short int yyconfl[] =
488 : {
489 : 0, 37, 0
490 : };
491 :
492 : static const signed char yycheck[] =
493 : {
494 : 6, 7, 8, 23, 3, 3, 28, 13, 12, 14,
495 : 26, 3, 26, 16, 17, 20, 3, 15, 21, 3,
496 : 23, 24, 25, 15, 21, 0, 23, 24, 25, 27,
497 : 29, 15, 37, 53, 54, 27, 40, 41, 42, 43,
498 : 44, 45, 46, 27, 48, 31, 52, 23, 24, 25,
499 : 9, 57, 3, 4, 5, 6, 7, 8, 24, 25,
500 : 11, 12, 13, 14, 16, 17, 86, 27, 28, 21,
501 : 24, 23, 24, 25, 29, 26, 29, 83, 84, 30,
502 : 27, 32, 88, 34, 3, 4, 5, 6, 7, 3,
503 : 4, 5, 6, 7, 13, 14, 37, 33, 35, 13,
504 : 14, 16, 17, 18, 19, 20, 21, 26, 23, 24,
505 : 25, 30, 26, 32, 3, 34, 3, 31, 32, 36,
506 : 34, 3, 4, 5, 6, 7, 32, 28, 3, 25,
507 : 10, 13, 14, 16, 17, 18, 19, 20, 21, 29,
508 : 23, 24, 25, 37, 26, 33, 16, 17, 18, -1,
509 : 32, 21, 34, 23, 24, 25, 63
510 : };
511 :
512 : /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
513 : symbol of state STATE-NUM. */
514 : static const unsigned char yystos[] =
515 : {
516 : 0, 3, 4, 5, 6, 7, 8, 11, 12, 13,
517 : 14, 26, 30, 32, 34, 39, 40, 41, 42, 43,
518 : 44, 45, 46, 28, 40, 40, 40, 26, 26, 3,
519 : 47, 52, 53, 3, 26, 43, 40, 45, 51, 0,
520 : 16, 17, 18, 19, 20, 21, 23, 24, 25, 45,
521 : 31, 41, 9, 29, 29, 47, 47, 24, 3, 15,
522 : 27, 48, 27, 37, 33, 51, 35, 43, 43, 43,
523 : 43, 43, 43, 43, 3, 43, 3, 40, 41, 41,
524 : 27, 27, 40, 36, 32, 49, 28, 52, 10, 40,
525 : 40, 50, 41, 40, 29, 33, 3, 29
526 : };
527 :
528 :
529 : /* Prevent warning if -Wmissing-prototypes. */
530 : int yyparse ( yyscan_t scanner , void * data );
531 :
532 : /* Error token number */
533 : #define YYTERROR 1
534 :
535 : /* YYLLOC_DEFAULT -- Compute the default location (before the actions
536 : are run). */
537 :
538 :
539 : #define YYRHSLOC(yyRhs,YYK) ((yyRhs)[YYK].yystate.yyloc)
540 :
541 : #ifndef YYLLOC_DEFAULT
542 : # define YYLLOC_DEFAULT(yyCurrent, yyRhs, YYN) \
543 : ((yyCurrent).first_line = YYRHSLOC(yyRhs, 1).first_line, \
544 : (yyCurrent).first_column = YYRHSLOC(yyRhs, 1).first_column, \
545 : (yyCurrent).last_line = YYRHSLOC(yyRhs, YYN).last_line, \
546 : (yyCurrent).last_column = YYRHSLOC(yyRhs, YYN).last_column)
547 : #endif
548 :
549 :
550 :
551 : /* YYLEX -- calling `yylex' with the right arguments. */
552 : #define YYLEX yylex (yylvalp, yyllocp, scanner)
553 :
554 :
555 : #undef yynerrs
556 : #define yynerrs (yystack->yyerrcnt)
557 : #undef yychar
558 : #define yychar (yystack->yyrawchar)
559 :
560 : static const int YYEOF = 0;
561 : static const int YYEMPTY = -2;
562 :
563 : typedef enum { yyok, yyaccept, yyabort, yyerr } YYRESULTTAG;
564 :
565 : #define YYCHK(YYE) \
566 : do { YYRESULTTAG yyflag = YYE; if (yyflag != yyok) return yyflag; } \
567 : while (0)
568 :
569 : #if YYDEBUG
570 :
571 : #if ! defined (YYFPRINTF)
572 : # define YYFPRINTF fprintf
573 : #endif
574 :
575 : # define YYDPRINTF(Args) \
576 : do { \
577 : if (yydebug) \
578 : YYFPRINTF Args; \
579 : } while (0)
580 :
581 : /*--------------------------------.
582 : | Print this symbol on YYOUTPUT. |
583 : `--------------------------------*/
584 :
585 : static void
586 : yysymprint (FILE *yyoutput, int yytype, YYSTYPE *yyvaluep, YYLTYPE *yylocationp)
587 : {
588 : /* Pacify ``unused variable'' warnings. */
589 : (void) yyvaluep;
590 : (void) yylocationp;
591 :
592 : if (yytype < YYNTOKENS)
593 : {
594 : YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
595 : # ifdef YYPRINT
596 : YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
597 : # endif
598 : }
599 : else
600 : YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
601 :
602 : switch (yytype)
603 : {
604 : default:
605 : break;
606 : }
607 : YYFPRINTF (yyoutput, ")");
608 : }
609 :
610 :
611 : # define YYDSYMPRINT(Args) \
612 : do { \
613 : if (yydebug) \
614 : yysymprint Args; \
615 : } while (0)
616 :
617 : # define YYDSYMPRINTF(Title, Token, Value, Location) \
618 : do { \
619 : if (yydebug) \
620 : { \
621 : YYFPRINTF (stderr, "%s ", Title); \
622 : yysymprint (stderr, \
623 : Token, Value, Location); \
624 : YYFPRINTF (stderr, "\n"); \
625 : } \
626 : } while (0)
627 :
628 : /* Nonzero means print parse trace. It is left uninitialized so that
629 : multiple parsers can coexist. */
630 : int yydebug;
631 :
632 : #else /* !YYDEBUG */
633 :
634 : /* Avoid empty `if' bodies. */
635 : # define YYDPRINTF(Args)
636 : # define YYDSYMPRINT(Args)
637 : # define YYDSYMPRINTF(Title, Token, Value, Location)
638 :
639 : #endif /* !YYDEBUG */
640 :
641 : /* YYINITDEPTH -- initial size of the parser's stacks. */
642 : #ifndef YYINITDEPTH
643 : # define YYINITDEPTH 200
644 : #endif
645 :
646 : /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
647 : if the built-in stack extension method is used).
648 :
649 : Do not make this value too large; the results are undefined if
650 : SIZE_MAX < YYMAXDEPTH * sizeof (GLRStackItem)
651 : evaluated with infinite-precision integer arithmetic. */
652 :
653 : #if YYMAXDEPTH == 0
654 : # undef YYMAXDEPTH
655 : #endif
656 :
657 : #ifndef YYMAXDEPTH
658 : # define YYMAXDEPTH 10000
659 : #endif
660 :
661 : /* Minimum number of free items on the stack allowed after an
662 : allocation. This is to allow allocation and initialization
663 : to be completed by functions that call expandGLRStack before the
664 : stack is expanded, thus insuring that all necessary pointers get
665 : properly redirected to new data. */
666 : #define YYHEADROOM 2
667 :
668 : #if (! defined (YYSTACKEXPANDABLE) \
669 : && (! defined (__cplusplus) \
670 : || (defined (YYLTYPE_IS_TRIVIAL) && YYLTYPE_IS_TRIVIAL \
671 : && defined (YYSTYPE_IS_TRIVIAL) && YYSTYPE_IS_TRIVIAL)))
672 : #define YYSTACKEXPANDABLE 1
673 : #else
674 : #define YYSTACKEXPANDABLE 0
675 : #endif
676 :
677 : /** State numbers, as in LALR(1) machine */
678 : typedef int yyStateNum;
679 :
680 : /** Rule numbers, as in LALR(1) machine */
681 : typedef int yyRuleNum;
682 :
683 : /** Grammar symbol */
684 : typedef short int yySymbol;
685 :
686 : /** Item references, as in LALR(1) machine */
687 : typedef short int yyItemNum;
688 :
689 : typedef struct yyGLRState yyGLRState;
690 : typedef struct yySemanticOption yySemanticOption;
691 : typedef union yyGLRStackItem yyGLRStackItem;
692 : typedef struct yyGLRStack yyGLRStack;
693 : typedef struct yyGLRStateSet yyGLRStateSet;
694 :
695 : struct yyGLRState {
696 : yybool yyisState;
697 : yybool yyresolved;
698 : yyStateNum yylrState;
699 : yyGLRState* yypred;
700 : size_t yyposn;
701 : union {
702 : yySemanticOption* yyfirstVal;
703 : YYSTYPE yysval;
704 : } yysemantics;
705 : YYLTYPE yyloc;
706 : };
707 :
708 : struct yyGLRStateSet {
709 : yyGLRState** yystates;
710 : size_t yysize, yycapacity;
711 : };
712 :
713 : struct yySemanticOption {
714 : yybool yyisState;
715 : yyRuleNum yyrule;
716 : yyGLRState* yystate;
717 : yySemanticOption* yynext;
718 : };
719 :
720 : union yyGLRStackItem {
721 : yyGLRState yystate;
722 : yySemanticOption yyoption;
723 : };
724 :
725 : struct yyGLRStack {
726 : int yyerrflag;
727 : int yyerrState;
728 :
729 : int yyerrcnt;
730 : int yyrawchar;
731 :
732 : yySymbol* yytokenp;
733 : jmp_buf yyexception_buffer;
734 : yyGLRStackItem* yyitems;
735 : yyGLRStackItem* yynextFree;
736 : int yyspaceLeft;
737 : yyGLRState* yysplitPoint;
738 : yyGLRState* yylastDeleted;
739 : yyGLRStateSet yytops;
740 : };
741 :
742 : static void yyinitGLRStack (yyGLRStack* yystack, size_t yysize);
743 : static void yyexpandGLRStack (yyGLRStack* yystack, YYLTYPE *yylocp, yyscan_t scanner , void * data );
744 : static void yyfreeGLRStack (yyGLRStack* yystack);
745 :
746 : static void
747 : yyFail (yyGLRStack* yystack, YYLTYPE *yylocp, yyscan_t scanner , void * data , const char* yyformat, ...)
748 0 : {
749 0 : yystack->yyerrflag = 1;
750 0 : if (yyformat != NULL)
751 : {
752 0 : char yymsg[256];
753 0 : va_list yyap;
754 0 : va_start (yyap, yyformat);
755 0 : vsprintf (yymsg, yyformat, yyap);
756 0 : yyerror (yylocp, scanner, data, yymsg);
757 : }
758 0 : longjmp (yystack->yyexception_buffer, 1);
759 : }
760 :
761 : #if YYDEBUG || YYERROR_VERBOSE
762 : /** A printable representation of TOKEN. Valid until next call to
763 : * tokenName. */
764 : static inline const char*
765 : yytokenName (yySymbol yytoken)
766 0 : {
767 0 : if (yytoken == YYEMPTY)
768 0 : return "";
769 :
770 0 : return yytname[yytoken];
771 : }
772 : #endif
773 :
774 : /** Fill in YYVSP[YYLOW1 .. YYLOW0-1] from the chain of states starting
775 : * at YYVSP[YYLOW0].yystate.yypred. Leaves YYVSP[YYLOW1].yystate.yypred
776 : * containing the pointer to the next state in the chain. Assumes
777 : * YYLOW1 < YYLOW0. */
778 : static void yyfillin (yyGLRStackItem *, int, int) ATTRIBUTE_UNUSED;
779 : static void
780 : yyfillin (yyGLRStackItem *yyvsp, int yylow0, int yylow1)
781 8 : {
782 8 : yyGLRState* s;
783 8 : int i;
784 8 : s = yyvsp[yylow0].yystate.yypred;
785 16 : for (i = yylow0-1; i >= yylow1; i -= 1)
786 : {
787 8 : YYASSERT (s->yyresolved);
788 8 : yyvsp[i].yystate.yyresolved = yytrue;
789 8 : yyvsp[i].yystate.yysemantics.yysval = s->yysemantics.yysval;
790 8 : yyvsp[i].yystate.yyloc = s->yyloc;
791 8 : s = yyvsp[i].yystate.yypred = s->yypred;
792 : }
793 : }
794 :
795 : /* Do nothing if YYNORMAL or if *YYLOW <= YYLOW1. Otherwise, fill in
796 : YYVSP[YYLOW1 .. *YYLOW-1] as in yyfillin and set *YYLOW = YYLOW1.
797 : For convenience, always return YYLOW1. */
798 : static inline int yyfill (yyGLRStackItem *, int *, int, yybool)
799 : ATTRIBUTE_UNUSED;
800 : static inline int
801 : yyfill (yyGLRStackItem *yyvsp, int *yylow, int yylow1, yybool yynormal)
802 3951 : {
803 3951 : if (!yynormal && yylow1 < *yylow)
804 : {
805 8 : yyfillin (yyvsp, *yylow, yylow1);
806 8 : *yylow = yylow1;
807 : }
808 3951 : return yylow1;
809 : }
810 :
811 : /** Perform user action for rule number YYN, with RHS length YYRHSLEN,
812 : * and top stack item YYVSP. YYLVALP points to place to put semantic
813 : * value ($$), and yylocp points to place for location information
814 : * (@$). Returns yyok for normal return, yyaccept for YYACCEPT,
815 : * yyerr for YYERROR, yyabort for YYABORT. */
816 : static YYRESULTTAG
817 : yyuserAction (yyRuleNum yyn, int yyrhslen, yyGLRStackItem* yyvsp,
818 : YYSTYPE* yyvalp, YYLTYPE* yylocp, yyGLRStack* yystack
819 : , yyscan_t scanner , void * data )
820 2191 : {
821 2191 : yybool yynormal ATTRIBUTE_UNUSED = (yystack->yysplitPoint == NULL);
822 2191 : int yylow;
823 :
824 : # undef yyerrok
825 : # define yyerrok (yystack->yyerrState = 0)
826 : # undef YYACCEPT
827 : # define YYACCEPT return yyaccept
828 : # undef YYABORT
829 : # define YYABORT return yyabort
830 : # undef YYERROR
831 : # define YYERROR return yyerrok, yyerr
832 : # undef YYRECOVERING
833 : # define YYRECOVERING (yystack->yyerrState != 0)
834 : # undef yyclearin
835 : # define yyclearin (yychar = *(yystack->yytokenp) = YYEMPTY)
836 : # undef YYFILL
837 : # define YYFILL(N) yyfill (yyvsp, &yylow, N, yynormal)
838 : # undef YYBACKUP
839 : # define YYBACKUP(Token, Value) \
840 : return yyerror (yylocp, scanner, data, "syntax error: cannot back up"), \
841 : yyerrok, yyerr
842 :
843 2191 : yylow = 1;
844 2191 : if (yyrhslen == 0)
845 : {
846 72 : *yyvalp = yyval_default;
847 72 : *yylocp = yyloc_default;
848 : }
849 : else
850 : {
851 2119 : *yyvalp = yyvsp[YYFILL (1-yyrhslen)].yystate.yysemantics.yysval;
852 2119 : YYLLOC_DEFAULT (*yylocp, yyvsp - yyrhslen, yyrhslen);
853 : }
854 :
855 :
856 2191 : switch (yyn)
857 : {
858 : case 2:
859 : #line 72 "parser.y"
860 : { setParseResult(data, ((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.t); ;}
861 : break;
862 :
863 : case 4:
864 : #line 78 "parser.y"
865 : { (*yyvalp).t = makeFunction(((yyGLRStackItem const *)yyvsp)[YYFILL (-3)].yystate.yysemantics.yysval.ts, ((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.t, CUR_POS); ;}
866 : break;
867 :
868 : case 5:
869 : #line 80 "parser.y"
870 : { (*yyvalp).t = makeFunction1(((yyGLRStackItem const *)yyvsp)[YYFILL (-2)].yystate.yysemantics.yysval.t, ((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.t, CUR_POS); ;}
871 : break;
872 :
873 : case 6:
874 : #line 82 "parser.y"
875 : { (*yyvalp).t = makeAssert(((yyGLRStackItem const *)yyvsp)[YYFILL (-2)].yystate.yysemantics.yysval.t, ((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.t, CUR_POS); ;}
876 : break;
877 :
878 : case 7:
879 : #line 84 "parser.y"
880 : { (*yyvalp).t = makeWith(((yyGLRStackItem const *)yyvsp)[YYFILL (-2)].yystate.yysemantics.yysval.t, ((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.t, CUR_POS); ;}
881 : break;
882 :
883 : case 9:
884 : #line 90 "parser.y"
885 : { (*yyvalp).t = makeIf(((yyGLRStackItem const *)yyvsp)[YYFILL (-4)].yystate.yysemantics.yysval.t, ((yyGLRStackItem const *)yyvsp)[YYFILL (-2)].yystate.yysemantics.yysval.t, ((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.t); ;}
886 : break;
887 :
888 : case 11:
889 : #line 95 "parser.y"
890 : { (*yyvalp).t = makeOpNot(((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.t); ;}
891 : break;
892 :
893 : case 12:
894 : #line 96 "parser.y"
895 : { (*yyvalp).t = makeOpEq(((yyGLRStackItem const *)yyvsp)[YYFILL (-2)].yystate.yysemantics.yysval.t, ((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.t); ;}
896 : break;
897 :
898 : case 13:
899 : #line 97 "parser.y"
900 : { (*yyvalp).t = makeOpNEq(((yyGLRStackItem const *)yyvsp)[YYFILL (-2)].yystate.yysemantics.yysval.t, ((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.t); ;}
901 : break;
902 :
903 : case 14:
904 : #line 98 "parser.y"
905 : { (*yyvalp).t = makeOpAnd(((yyGLRStackItem const *)yyvsp)[YYFILL (-2)].yystate.yysemantics.yysval.t, ((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.t); ;}
906 : break;
907 :
908 : case 15:
909 : #line 99 "parser.y"
910 : { (*yyvalp).t = makeOpOr(((yyGLRStackItem const *)yyvsp)[YYFILL (-2)].yystate.yysemantics.yysval.t, ((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.t); ;}
911 : break;
912 :
913 : case 16:
914 : #line 100 "parser.y"
915 : { (*yyvalp).t = makeOpImpl(((yyGLRStackItem const *)yyvsp)[YYFILL (-2)].yystate.yysemantics.yysval.t, ((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.t); ;}
916 : break;
917 :
918 : case 17:
919 : #line 101 "parser.y"
920 : { (*yyvalp).t = makeOpUpdate(((yyGLRStackItem const *)yyvsp)[YYFILL (-2)].yystate.yysemantics.yysval.t, ((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.t); ;}
921 : break;
922 :
923 : case 18:
924 : #line 102 "parser.y"
925 : { (*yyvalp).t = makeSubPath(((yyGLRStackItem const *)yyvsp)[YYFILL (-2)].yystate.yysemantics.yysval.t, ((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.t); ;}
926 : break;
927 :
928 : case 19:
929 : #line 103 "parser.y"
930 : { (*yyvalp).t = makeOpHasAttr(((yyGLRStackItem const *)yyvsp)[YYFILL (-2)].yystate.yysemantics.yysval.t, ((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.t); ;}
931 : break;
932 :
933 : case 20:
934 : #line 104 "parser.y"
935 : { (*yyvalp).t = makeOpPlus(((yyGLRStackItem const *)yyvsp)[YYFILL (-2)].yystate.yysemantics.yysval.t, ((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.t); ;}
936 : break;
937 :
938 : case 22:
939 : #line 110 "parser.y"
940 : { (*yyvalp).t = makeCall(((yyGLRStackItem const *)yyvsp)[YYFILL (-1)].yystate.yysemantics.yysval.t, ((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.t); ;}
941 : break;
942 :
943 : case 23:
944 : #line 111 "parser.y"
945 : { (*yyvalp).t = ((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.t; ;}
946 : break;
947 :
948 : case 24:
949 : #line 116 "parser.y"
950 : { (*yyvalp).t = makeSelect(((yyGLRStackItem const *)yyvsp)[YYFILL (-2)].yystate.yysemantics.yysval.t, ((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.t); ;}
951 : break;
952 :
953 : case 25:
954 : #line 117 "parser.y"
955 : { (*yyvalp).t = ((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.t; ;}
956 : break;
957 :
958 : case 26:
959 : #line 121 "parser.y"
960 : { (*yyvalp).t = makeVar(((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.t); ;}
961 : break;
962 :
963 : case 27:
964 : #line 122 "parser.y"
965 : { (*yyvalp).t = makeInt(ATgetInt((ATermInt) ((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.t)); ;}
966 : break;
967 :
968 : case 28:
969 : #line 123 "parser.y"
970 : { (*yyvalp).t = makeStr(((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.t); ;}
971 : break;
972 :
973 : case 29:
974 : #line 124 "parser.y"
975 : { (*yyvalp).t = makePath(absParsedPath(data, ((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.t)); ;}
976 : break;
977 :
978 : case 30:
979 : #line 125 "parser.y"
980 : { (*yyvalp).t = makeUri(((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.t); ;}
981 : break;
982 :
983 : case 31:
984 : #line 126 "parser.y"
985 : { (*yyvalp).t = ((yyGLRStackItem const *)yyvsp)[YYFILL (-1)].yystate.yysemantics.yysval.t; ;}
986 : break;
987 :
988 : case 32:
989 : #line 130 "parser.y"
990 : { (*yyvalp).t = makeSelect(fixAttrs(1, ((yyGLRStackItem const *)yyvsp)[YYFILL (-1)].yystate.yysemantics.yysval.ts), toATerm("body")); ;}
991 : break;
992 :
993 : case 33:
994 : #line 132 "parser.y"
995 : { (*yyvalp).t = fixAttrs(1, ((yyGLRStackItem const *)yyvsp)[YYFILL (-1)].yystate.yysemantics.yysval.ts); ;}
996 : break;
997 :
998 : case 34:
999 : #line 134 "parser.y"
1000 : { (*yyvalp).t = fixAttrs(0, ((yyGLRStackItem const *)yyvsp)[YYFILL (-1)].yystate.yysemantics.yysval.ts); ;}
1001 : break;
1002 :
1003 : case 35:
1004 : #line 135 "parser.y"
1005 : { (*yyvalp).t = makeList(((yyGLRStackItem const *)yyvsp)[YYFILL (-1)].yystate.yysemantics.yysval.ts); ;}
1006 : break;
1007 :
1008 : case 36:
1009 : #line 139 "parser.y"
1010 : { (*yyvalp).ts = ATinsert(((yyGLRStackItem const *)yyvsp)[YYFILL (-1)].yystate.yysemantics.yysval.ts, ((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.t); ;}
1011 : break;
1012 :
1013 : case 37:
1014 : #line 140 "parser.y"
1015 : { (*yyvalp).ts = ATempty; ;}
1016 : break;
1017 :
1018 : case 38:
1019 : #line 145 "parser.y"
1020 : { (*yyvalp).t = makeBind(((yyGLRStackItem const *)yyvsp)[YYFILL (-3)].yystate.yysemantics.yysval.t, ((yyGLRStackItem const *)yyvsp)[YYFILL (-1)].yystate.yysemantics.yysval.t, CUR_POS); ;}
1021 : break;
1022 :
1023 : case 39:
1024 : #line 147 "parser.y"
1025 : { (*yyvalp).t = makeInherit(((yyGLRStackItem const *)yyvsp)[YYFILL (-2)].yystate.yysemantics.yysval.t, ((yyGLRStackItem const *)yyvsp)[YYFILL (-1)].yystate.yysemantics.yysval.ts, CUR_POS); ;}
1026 : break;
1027 :
1028 : case 40:
1029 : #line 151 "parser.y"
1030 : { (*yyvalp).t = ((yyGLRStackItem const *)yyvsp)[YYFILL (-1)].yystate.yysemantics.yysval.t; ;}
1031 : break;
1032 :
1033 : case 41:
1034 : #line 152 "parser.y"
1035 : { (*yyvalp).t = makeScope(); ;}
1036 : break;
1037 :
1038 : case 42:
1039 : #line 155 "parser.y"
1040 : { (*yyvalp).ts = ATinsert(((yyGLRStackItem const *)yyvsp)[YYFILL (-1)].yystate.yysemantics.yysval.ts, ((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.t); ;}
1041 : break;
1042 :
1043 : case 43:
1044 : #line 155 "parser.y"
1045 : { (*yyvalp).ts = ATempty; ;}
1046 : break;
1047 :
1048 : case 44:
1049 : #line 158 "parser.y"
1050 : { (*yyvalp).ts = ATinsert(((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.ts, ((yyGLRStackItem const *)yyvsp)[YYFILL (-1)].yystate.yysemantics.yysval.t); ;}
1051 : break;
1052 :
1053 : case 45:
1054 : #line 162 "parser.y"
1055 : { (*yyvalp).ts = ATempty; ;}
1056 : break;
1057 :
1058 : case 46:
1059 : #line 166 "parser.y"
1060 : { (*yyvalp).ts = ATinsert(((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.ts, ((yyGLRStackItem const *)yyvsp)[YYFILL (-2)].yystate.yysemantics.yysval.t); ;}
1061 : break;
1062 :
1063 : case 47:
1064 : #line 167 "parser.y"
1065 : { (*yyvalp).ts = ATinsert(ATempty, ((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.t); ;}
1066 : break;
1067 :
1068 : case 48:
1069 : #line 171 "parser.y"
1070 : { (*yyvalp).t = makeNoDefFormal(((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.t); ;}
1071 : break;
1072 :
1073 : case 49:
1074 : #line 172 "parser.y"
1075 : { (*yyvalp).t = makeDefFormal(((yyGLRStackItem const *)yyvsp)[YYFILL (-2)].yystate.yysemantics.yysval.t, ((yyGLRStackItem const *)yyvsp)[YYFILL (0)].yystate.yysemantics.yysval.t); ;}
1076 : break;
1077 :
1078 :
1079 : }
1080 :
1081 : return yyok;
1082 : # undef yyerrok
1083 : # undef YYABORT
1084 : # undef YYACCEPT
1085 : # undef YYERROR
1086 : # undef YYBACKUP
1087 : # undef yyclearin
1088 : # undef YYRECOVERING
1089 : /* Line 741 of glr.c. */
1090 : #line 1091 "parser-tab.c"
1091 : }
1092 :
1093 :
1094 : static void
1095 : yyuserMerge (int yyn, YYSTYPE* yy0, YYSTYPE* yy1)
1096 0 : {
1097 : /* `Use' the arguments. */
1098 0 : (void) yy0;
1099 0 : (void) yy1;
1100 :
1101 0 : switch (yyn)
1102 : {
1103 :
1104 : }
1105 : }
1106 :
1107 : /* Bison grammar-table manipulation. */
1108 :
1109 : /*-----------------------------------------------.
1110 : | Release the memory associated to this symbol. |
1111 : `-----------------------------------------------*/
1112 :
1113 : static void
1114 : yydestruct (int yytype, YYSTYPE *yyvaluep, YYLTYPE *yylocationp)
1115 0 : {
1116 : /* Pacify ``unused variable'' warnings. */
1117 0 : (void) yyvaluep;
1118 0 : (void) yylocationp;
1119 :
1120 0 : switch (yytype)
1121 : {
1122 :
1123 : default:
1124 0 : break;
1125 : }
1126 : }
1127 :
1128 : /** Number of symbols composing the right hand side of rule #RULE. */
1129 : static inline int
1130 : yyrhsLength (yyRuleNum yyrule)
1131 2208 : {
1132 2208 : return yyr2[yyrule];
1133 : }
1134 :
1135 : /** Left-hand-side symbol for rule #RULE. */
1136 : static inline yySymbol
1137 : yylhsNonterm (yyRuleNum yyrule)
1138 2199 : {
1139 2199 : return yyr1[yyrule];
1140 : }
1141 :
1142 : #define yyis_pact_ninf(yystate) \
1143 : ((yystate) == YYPACT_NINF)
1144 :
1145 : /** True iff LR state STATE has only a default reduction (regardless
1146 : * of token). */
1147 : static inline yybool
1148 : yyisDefaultedState (yyStateNum yystate)
1149 3178 : {
1150 3178 : return yyis_pact_ninf (yypact[yystate]);
1151 : }
1152 :
1153 : /** The default reduction for STATE, assuming it has one. */
1154 : static inline yyRuleNum
1155 : yydefaultAction (yyStateNum yystate)
1156 1386 : {
1157 1386 : return yydefact[yystate];
1158 : }
1159 :
1160 : #define yyis_table_ninf(yytable_value) \
1161 : ((yytable_value) == YYTABLE_NINF)
1162 :
1163 : /** Set *YYACTION to the action to take in YYSTATE on seeing YYTOKEN.
1164 : * Result R means
1165 : * R < 0: Reduce on rule -R.
1166 : * R = 0: Error.
1167 : * R > 0: Shift to state R.
1168 : * Set *CONFLICTS to a pointer into yyconfl to 0-terminated list of
1169 : * conflicting reductions.
1170 : */
1171 : static inline void
1172 : yygetLRActions (yyStateNum yystate, int yytoken,
1173 : int* yyaction, const short int** yyconflicts)
1174 1792 : {
1175 1792 : int yyindex = yypact[yystate] + yytoken;
1176 1792 : if (yyindex < 0 || YYLAST < yyindex || yycheck[yyindex] != yytoken)
1177 : {
1178 813 : *yyaction = -yydefact[yystate];
1179 813 : *yyconflicts = yyconfl;
1180 : }
1181 979 : else if (! yyis_table_ninf (yytable[yyindex]))
1182 : {
1183 979 : *yyaction = yytable[yyindex];
1184 979 : *yyconflicts = yyconfl + yyconflp[yyindex];
1185 : }
1186 : else
1187 : {
1188 0 : *yyaction = 0;
1189 0 : *yyconflicts = yyconfl + yyconflp[yyindex];
1190 : }
1191 : }
1192 :
1193 : static inline yyStateNum
1194 : yyLRgotoState (yyStateNum yystate, yySymbol yylhs)
1195 2199 : {
1196 2199 : int yyr;
1197 2199 : yyr = yypgoto[yylhs - YYNTOKENS] + yystate;
1198 2199 : if (0 <= yyr && yyr <= YYLAST && yycheck[yyr] == yystate)
1199 464 : return yytable[yyr];
1200 : else
1201 1735 : return yydefgoto[yylhs - YYNTOKENS];
1202 : }
1203 :
1204 : static inline yybool
1205 : yyisShiftAction (int yyaction)
1206 1785 : {
1207 1785 : return 0 < yyaction;
1208 : }
1209 :
1210 : static inline yybool
1211 : yyisErrorAction (int yyaction)
1212 813 : {
1213 813 : return yyaction == 0;
1214 : }
1215 :
1216 : /* GLRStates */
1217 :
1218 : static void
1219 : yyaddDeferredAction (yyGLRStack* yystack, yyGLRState* yystate,
1220 : yyGLRState* rhs, yyRuleNum yyrule, YYLTYPE *yylocp, yyscan_t scanner , void * data )
1221 17 : {
1222 17 : yySemanticOption* yynewItem;
1223 17 : yynewItem = &yystack->yynextFree->yyoption;
1224 17 : yystack->yyspaceLeft -= 1;
1225 17 : yystack->yynextFree += 1;
1226 17 : yynewItem->yyisState = yyfalse;
1227 17 : yynewItem->yystate = rhs;
1228 17 : yynewItem->yyrule = yyrule;
1229 17 : yynewItem->yynext = yystate->yysemantics.yyfirstVal;
1230 17 : yystate->yysemantics.yyfirstVal = yynewItem;
1231 17 : if (yystack->yyspaceLeft < YYHEADROOM)
1232 0 : yyexpandGLRStack (yystack, yylocp, scanner, data);
1233 : }
1234 :
1235 : /* GLRStacks */
1236 :
1237 : /** Initialize SET to a singleton set containing an empty stack. */
1238 : static void
1239 : yyinitStateSet (yyGLRStateSet* yyset)
1240 23 : {
1241 23 : yyset->yysize = 1;
1242 23 : yyset->yycapacity = 16;
1243 23 : yyset->yystates = (yyGLRState**) YYMALLOC (16 * sizeof yyset->yystates[0]);
1244 23 : yyset->yystates[0] = NULL;
1245 : }
1246 :
1247 : static void yyfreeStateSet (yyGLRStateSet* yyset)
1248 23 : {
1249 23 : YYFREE (yyset->yystates);
1250 : }
1251 :
1252 : /** Initialize STACK to a single empty stack, with total maximum
1253 : * capacity for all stacks of SIZE. */
1254 : static void
1255 : yyinitGLRStack (yyGLRStack* yystack, size_t yysize)
1256 23 : {
1257 23 : yystack->yyerrflag = 0;
1258 23 : yystack->yyerrState = 0;
1259 23 : yynerrs = 0;
1260 23 : yystack->yyspaceLeft = yysize;
1261 23 : yystack->yynextFree = yystack->yyitems =
1262 : (yyGLRStackItem*) YYMALLOC (yysize * sizeof yystack->yynextFree[0]);
1263 23 : yystack->yysplitPoint = NULL;
1264 23 : yystack->yylastDeleted = NULL;
1265 23 : yyinitStateSet (&yystack->yytops);
1266 : }
1267 :
1268 : #define YYRELOC(YYFROMITEMS,YYTOITEMS,YYX,YYTYPE) \
1269 : &((YYTOITEMS) - ((YYFROMITEMS) - (yyGLRStackItem*) (YYX)))->YYTYPE
1270 :
1271 : /** If STACK is expandable, extend it. WARNING: Pointers into the
1272 : stack from outside should be considered invalid after this call.
1273 : We always expand when there are 1 or fewer items left AFTER an
1274 : allocation, so that we can avoid having external pointers exist
1275 : across an allocation. */
1276 : static void
1277 : yyexpandGLRStack (yyGLRStack* yystack, YYLTYPE *yylocp, yyscan_t scanner , void * data )
1278 0 : {
1279 : #if YYSTACKEXPANDABLE
1280 0 : yyGLRStack yynewStack;
1281 0 : yyGLRStackItem* yyp0, *yyp1;
1282 0 : size_t yysize, yynewSize;
1283 0 : size_t yyn;
1284 0 : yysize = yystack->yynextFree - yystack->yyitems;
1285 0 : if (YYMAXDEPTH <= yysize)
1286 0 : yyFail (yystack, yylocp, scanner, data, "parser stack overflow");
1287 0 : yynewSize = 2*yysize;
1288 0 : if (YYMAXDEPTH < yynewSize)
1289 0 : yynewSize = YYMAXDEPTH;
1290 0 : yyinitGLRStack (&yynewStack, yynewSize);
1291 0 : for (yyp0 = yystack->yyitems, yyp1 = yynewStack.yyitems, yyn = yysize;
1292 : 0 < yyn;
1293 : yyn -= 1, yyp0 += 1, yyp1 += 1)
1294 : {
1295 0 : *yyp1 = *yyp0;
1296 0 : if (*(yybool *) yyp0)
1297 : {
1298 0 : yyGLRState* yys0 = &yyp0->yystate;
1299 0 : yyGLRState* yys1 = &yyp1->yystate;
1300 0 : if (yys0->yypred != NULL)
1301 0 : yys1->yypred =
1302 : YYRELOC (yyp0, yyp1, yys0->yypred, yystate);
1303 0 : if (! yys0->yyresolved && yys0->yysemantics.yyfirstVal != NULL)
1304 0 : yys1->yysemantics.yyfirstVal =
1305 : YYRELOC(yyp0, yyp1, yys0->yysemantics.yyfirstVal, yyoption);
1306 : }
1307 : else
1308 : {
1309 0 : yySemanticOption* yyv0 = &yyp0->yyoption;
1310 0 : yySemanticOption* yyv1 = &yyp1->yyoption;
1311 0 : if (yyv0->yystate != NULL)
1312 0 : yyv1->yystate = YYRELOC (yyp0, yyp1, yyv0->yystate, yystate);
1313 0 : if (yyv0->yynext != NULL)
1314 0 : yyv1->yynext = YYRELOC (yyp0, yyp1, yyv0->yynext, yyoption);
1315 : }
1316 : }
1317 0 : if (yystack->yysplitPoint != NULL)
1318 0 : yystack->yysplitPoint = YYRELOC (yystack->yyitems, yynewStack.yyitems,
1319 : yystack->yysplitPoint, yystate);
1320 :
1321 0 : for (yyn = 0; yyn < yystack->yytops.yysize; yyn += 1)
1322 0 : if (yystack->yytops.yystates[yyn] != NULL)
1323 0 : yystack->yytops.yystates[yyn] =
1324 : YYRELOC (yystack->yyitems, yynewStack.yyitems,
1325 : yystack->yytops.yystates[yyn], yystate);
1326 0 : YYFREE (yystack->yyitems);
1327 0 : yystack->yyitems = yynewStack.yyitems;
1328 0 : yystack->yynextFree = yynewStack.yynextFree + yysize;
1329 0 : yystack->yyspaceLeft = yynewStack.yyspaceLeft - yysize;
1330 :
1331 : #else
1332 :
1333 : yyFail (yystack, yylocp, scanner, data, "parser stack overflow");
1334 : #endif
1335 : }
1336 :
1337 : static void
1338 : yyfreeGLRStack (yyGLRStack* yystack)
1339 23 : {
1340 23 : YYFREE (yystack->yyitems);
1341 23 : yyfreeStateSet (&yystack->yytops);
1342 : }
1343 :
1344 : /** Assuming that S is a GLRState somewhere on STACK, update the
1345 : * splitpoint of STACK, if needed, so that it is at least as deep as
1346 : * S. */
1347 : static inline void
1348 : yyupdateSplit (yyGLRStack* yystack, yyGLRState* yys)
1349 17 : {
1350 17 : if (yystack->yysplitPoint != NULL && yystack->yysplitPoint > yys)
1351 0 : yystack->yysplitPoint = yys;
1352 : }
1353 :
1354 : /** Invalidate stack #K in STACK. */
1355 : static inline void
1356 : yymarkStackDeleted (yyGLRStack* yystack, int yyk)
1357 7 : {
1358 7 : if (yystack->yytops.yystates[yyk] != NULL)
1359 7 : yystack->yylastDeleted = yystack->yytops.yystates[yyk];
1360 7 : yystack->yytops.yystates[yyk] = NULL;
1361 : }
1362 :
1363 : /** Undelete the last stack that was marked as deleted. Can only be
1364 : done once after a deletion, and only when all other stacks have
1365 : been deleted. */
1366 : static void
1367 : yyundeleteLastStack (yyGLRStack* yystack)
1368 0 : {
1369 0 : if (yystack->yylastDeleted == NULL || yystack->yytops.yysize != 0)
1370 0 : return;
1371 0 : yystack->yytops.yystates[0] = yystack->yylastDeleted;
1372 0 : yystack->yytops.yysize = 1;
1373 : YYDPRINTF ((stderr, "Restoring last deleted stack as stack #0.\n"));
1374 0 : yystack->yylastDeleted = NULL;
1375 : }
1376 :
1377 : static inline void
1378 : yyremoveDeletes (yyGLRStack* yystack)
1379 14 : {
1380 14 : size_t yyi, yyj;
1381 14 : yyi = yyj = 0;
1382 42 : while (yyj < yystack->yytops.yysize)
1383 : {
1384 28 : if (yystack->yytops.yystates[yyi] == NULL)
1385 : {
1386 7 : if (yyi == yyj)
1387 : {
1388 : YYDPRINTF ((stderr, "Removing dead stacks.\n"));
1389 : }
1390 7 : yystack->yytops.yysize -= 1;
1391 : }
1392 : else
1393 : {
1394 21 : yystack->yytops.yystates[yyj] = yystack->yytops.yystates[yyi];
1395 21 : if (yyj != yyi)
1396 : {
1397 : YYDPRINTF ((stderr, "Rename stack %lu -> %lu.\n",
1398 : (unsigned long int) yyi, (unsigned long int) yyj));
1399 : }
1400 21 : yyj += 1;
1401 : }
1402 28 : yyi += 1;
1403 : }
1404 : }
1405 :
1406 : /** Shift to a new state on stack #K of STACK, corresponding to LR state
1407 : * LRSTATE, at input position POSN, with (resolved) semantic value SVAL. */
1408 : static inline void
1409 : yyglrShift (yyGLRStack* yystack, int yyk, yyStateNum yylrState, size_t yyposn,
1410 : YYSTYPE yysval, YYLTYPE* yylocp, yyscan_t scanner , void * data )
1411 3177 : {
1412 3177 : yyGLRStackItem* yynewItem;
1413 :
1414 3177 : yynewItem = yystack->yynextFree;
1415 3177 : yystack->yynextFree += 1;
1416 3177 : yystack->yyspaceLeft -= 1;
1417 3177 : yynewItem->yystate.yyisState = yytrue;
1418 3177 : yynewItem->yystate.yylrState = yylrState;
1419 3177 : yynewItem->yystate.yyposn = yyposn;
1420 3177 : yynewItem->yystate.yyresolved = yytrue;
1421 3177 : yynewItem->yystate.yypred = yystack->yytops.yystates[yyk];
1422 3177 : yystack->yytops.yystates[yyk] = &yynewItem->yystate;
1423 3177 : yynewItem->yystate.yysemantics.yysval = yysval;
1424 3177 : yynewItem->yystate.yyloc = *yylocp;
1425 3177 : if (yystack->yyspaceLeft < YYHEADROOM)
1426 0 : yyexpandGLRStack (yystack, yylocp, scanner, data);
1427 : }
1428 :
1429 : /** Shift stack #K of YYSTACK, to a new state corresponding to LR
1430 : * state YYLRSTATE, at input position YYPOSN, with the (unresolved)
1431 : * semantic value of YYRHS under the action for YYRULE. */
1432 : static inline void
1433 : yyglrShiftDefer (yyGLRStack* yystack, int yyk, yyStateNum yylrState,
1434 : size_t yyposn, yyGLRState* rhs, yyRuleNum yyrule, YYLTYPE *yylocp, yyscan_t scanner , void * data )
1435 17 : {
1436 17 : yyGLRStackItem* yynewItem;
1437 :
1438 17 : yynewItem = yystack->yynextFree;
1439 17 : yynewItem->yystate.yyisState = yytrue;
1440 17 : yynewItem->yystate.yylrState = yylrState;
1441 17 : yynewItem->yystate.yyposn = yyposn;
1442 17 : yynewItem->yystate.yyresolved = yyfalse;
1443 17 : yynewItem->yystate.yypred = yystack->yytops.yystates[yyk];
1444 17 : yynewItem->yystate.yysemantics.yyfirstVal = NULL;
1445 17 : yystack->yytops.yystates[yyk] = &yynewItem->yystate;
1446 17 : yystack->yynextFree += 1;
1447 17 : yystack->yyspaceLeft -= 1;
1448 17 : yyaddDeferredAction (yystack, &yynewItem->yystate, rhs, yyrule, yylocp, scanner, data);
1449 : }
1450 :
1451 : /** Pop the symbols consumed by reduction #RULE from the top of stack
1452 : * #K of STACK, and perform the appropriate semantic action on their
1453 : * semantic values. Assumes that all ambiguities in semantic values
1454 : * have been previously resolved. Set *VALP to the resulting value,
1455 : * and *LOCP to the computed location (if any). Return value is as
1456 : * for userAction. */
1457 : static inline YYRESULTTAG
1458 : yydoAction (yyGLRStack* yystack, int yyk, yyRuleNum yyrule,
1459 : YYSTYPE* yyvalp, YYLTYPE* yylocp, yyscan_t scanner , void * data )
1460 2182 : {
1461 2182 : int yynrhs = yyrhsLength (yyrule);
1462 :
1463 2182 : if (yystack->yysplitPoint == NULL)
1464 : {
1465 : /* Standard special case: single stack. */
1466 2182 : yyGLRStackItem* rhs = (yyGLRStackItem*) yystack->yytops.yystates[yyk];
1467 2182 : YYASSERT (yyk == 0);
1468 2182 : yystack->yynextFree -= yynrhs;
1469 2182 : yystack->yyspaceLeft += yynrhs;
1470 2182 : yystack->yytops.yystates[0] = & yystack->yynextFree[-1].yystate;
1471 2182 : return yyuserAction (yyrule, yynrhs, rhs,
1472 : yyvalp, yylocp, yystack, scanner, data);
1473 : }
1474 : else
1475 : {
1476 0 : int yyi;
1477 0 : yyGLRState* yys;
1478 0 : yyGLRStackItem yyrhsVals[YYMAXRHS + YYMAXLEFT + 1];
1479 0 : yys = yyrhsVals[YYMAXRHS + YYMAXLEFT].yystate.yypred
1480 : = yystack->yytops.yystates[yyk];
1481 0 : for (yyi = 0; yyi < yynrhs; yyi += 1)
1482 : {
1483 0 : yys = yys->yypred;
1484 0 : YYASSERT (yys);
1485 : }
1486 0 : yyupdateSplit (yystack, yys);
1487 0 : yystack->yytops.yystates[yyk] = yys;
1488 0 : return yyuserAction (yyrule, yynrhs, yyrhsVals + YYMAXRHS + YYMAXLEFT - 1,
1489 : yyvalp, yylocp, yystack, scanner, data);
1490 : }
1491 : }
1492 :
1493 : #if !YYDEBUG
1494 : # define YY_REDUCE_PRINT(K, Rule)
1495 : #else
1496 : # define YY_REDUCE_PRINT(K, Rule) \
1497 : do { \
1498 : if (yydebug) \
1499 : yy_reduce_print (K, Rule); \
1500 : } while (0)
1501 :
1502 : /*----------------------------------------------------------.
1503 : | Report that the RULE is going to be reduced on stack #K. |
1504 : `----------------------------------------------------------*/
1505 :
1506 : static inline void
1507 : yy_reduce_print (size_t yyk, yyRuleNum yyrule)
1508 : {
1509 : int yyi;
1510 : YYFPRINTF (stderr, "Reducing stack %lu by rule %d (line %lu), ",
1511 : (unsigned long int) yyk, yyrule - 1,
1512 : (unsigned long int) yyrline[yyrule]);
1513 : /* Print the symbols being reduced, and their result. */
1514 : for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++)
1515 : YYFPRINTF (stderr, "%s ", yytokenName (yyrhs[yyi]));
1516 : YYFPRINTF (stderr, "-> %s\n", yytokenName (yyr1[yyrule]));
1517 : }
1518 : #endif
1519 :
1520 : /** Pop items off stack #K of STACK according to grammar rule RULE,
1521 : * and push back on the resulting nonterminal symbol. Perform the
1522 : * semantic action associated with RULE and store its value with the
1523 : * newly pushed state, if FORCEEVAL or if STACK is currently
1524 : * unambiguous. Otherwise, store the deferred semantic action with
1525 : * the new state. If the new state would have an identical input
1526 : * position, LR state, and predecessor to an existing state on the stack,
1527 : * it is identified with that existing state, eliminating stack #K from
1528 : * the STACK. In this case, the (necessarily deferred) semantic value is
1529 : * added to the options for the existing state's semantic value.
1530 : */
1531 : static inline YYRESULTTAG
1532 : yyglrReduce (yyGLRStack* yystack, size_t yyk, yyRuleNum yyrule,
1533 : yybool yyforceEval, YYLTYPE *yylocp, yyscan_t scanner , void * data )
1534 2199 : {
1535 2199 : size_t yyposn = yystack->yytops.yystates[yyk]->yyposn;
1536 :
1537 2199 : if (yyforceEval || yystack->yysplitPoint == NULL)
1538 : {
1539 2182 : YYSTYPE yysval;
1540 2182 : YYLTYPE yyloc;
1541 :
1542 : YY_REDUCE_PRINT (yyk, yyrule);
1543 2182 : YYCHK (yydoAction (yystack, yyk, yyrule, &yysval, &yyloc, scanner, data));
1544 2182 : yyglrShift (yystack, yyk,
1545 : yyLRgotoState (yystack->yytops.yystates[yyk]->yylrState,
1546 : yylhsNonterm (yyrule)),
1547 : yyposn, yysval, &yyloc, scanner, data);
1548 : }
1549 : else
1550 : {
1551 17 : size_t yyi;
1552 17 : int yyn;
1553 17 : yyGLRState* yys, *yys0 = yystack->yytops.yystates[yyk];
1554 17 : yyStateNum yynewLRState;
1555 :
1556 27 : for (yys = yystack->yytops.yystates[yyk], yyn = yyrhsLength (yyrule);
1557 : 0 < yyn; yyn -= 1)
1558 : {
1559 10 : yys = yys->yypred;
1560 10 : YYASSERT (yys);
1561 : }
1562 17 : yyupdateSplit (yystack, yys);
1563 17 : yynewLRState = yyLRgotoState (yys->yylrState, yylhsNonterm (yyrule));
1564 : YYDPRINTF ((stderr,
1565 : "Reduced stack %lu by rule #%d; action deferred. Now in state %d.\n",
1566 : (unsigned long int) yyk, yyrule - 1, yynewLRState));
1567 51 : for (yyi = 0; yyi < yystack->yytops.yysize; yyi += 1)
1568 34 : if (yyi != yyk && yystack->yytops.yystates[yyi] != NULL)
1569 : {
1570 17 : yyGLRState* yyp, *yysplit = yystack->yysplitPoint;
1571 17 : yyp = yystack->yytops.yystates[yyi];
1572 27 : while (yyp != yys && yyp != yysplit && yyp->yyposn >= yyposn)
1573 : {
1574 10 : if (yyp->yylrState == yynewLRState && yyp->yypred == yys)
1575 : {
1576 0 : yyaddDeferredAction (yystack, yyp, yys0, yyrule, yylocp, scanner, data);
1577 0 : yymarkStackDeleted (yystack, yyk);
1578 : YYDPRINTF ((stderr, "Merging stack %lu into stack %lu.\n",
1579 : (unsigned long int) yyk,
1580 : (unsigned long int) yyi));
1581 0 : return yyok;
1582 : }
1583 10 : yyp = yyp->yypred;
1584 : }
1585 : }
1586 17 : yystack->yytops.yystates[yyk] = yys;
1587 17 : yyglrShiftDefer (yystack, yyk, yynewLRState, yyposn, yys0, yyrule, yylocp, scanner, data);
1588 : }
1589 2199 : return yyok;
1590 : }
1591 :
1592 : static int
1593 : yysplitStack (yyGLRStack* yystack, int yyk)
1594 7 : {
1595 7 : if (yystack->yysplitPoint == NULL)
1596 : {
1597 7 : YYASSERT (yyk == 0);
1598 7 : yystack->yysplitPoint = yystack->yytops.yystates[yyk];
1599 : }
1600 7 : if (yystack->yytops.yysize >= yystack->yytops.yycapacity)
1601 : {
1602 0 : yystack->yytops.yycapacity *= 2;
1603 0 : yystack->yytops.yystates =
1604 : (yyGLRState**) YYREALLOC (yystack->yytops.yystates,
1605 : (yystack->yytops.yycapacity
1606 : * sizeof yystack->yytops.yystates[0]));
1607 : }
1608 7 : yystack->yytops.yystates[yystack->yytops.yysize]
1609 : = yystack->yytops.yystates[yyk];
1610 7 : yystack->yytops.yysize += 1;
1611 7 : return yystack->yytops.yysize-1;
1612 : }
1613 :
1614 : /** True iff Y0 and Y1 represent identical options at the top level.
1615 : * That is, they represent the same rule applied to RHS symbols
1616 : * that produce the same terminal symbols. */
1617 : static yybool
1618 : yyidenticalOptions (yySemanticOption* yyy0, yySemanticOption* yyy1)
1619 0 : {
1620 0 : if (yyy0->yyrule == yyy1->yyrule)
1621 : {
1622 0 : yyGLRState *yys0, *yys1;
1623 0 : int yyn;
1624 : for (yys0 = yyy0->yystate, yys1 = yyy1->yystate,
1625 0 : yyn = yyrhsLength (yyy0->yyrule);
1626 : yyn > 0;
1627 : yys0 = yys0->yypred, yys1 = yys1->yypred, yyn -= 1)
1628 0 : if (yys0->yyposn != yys1->yyposn)
1629 0 : return yyfalse;
1630 0 : return yytrue;
1631 : }
1632 : else
1633 0 : return yyfalse;
1634 : }
1635 :
1636 : /** Assuming identicalOptions (Y0,Y1), (destructively) merge the
1637 : * alternative semantic values for the RHS-symbols of Y1 into the
1638 : * corresponding semantic value sets of the symbols of Y0. */
1639 : static void
1640 : yymergeOptionSets (yySemanticOption* yyy0, yySemanticOption* yyy1)
1641 0 : {
1642 0 : yyGLRState *yys0, *yys1;
1643 0 : int yyn;
1644 : for (yys0 = yyy0->yystate, yys1 = yyy1->yystate,
1645 0 : yyn = yyrhsLength (yyy0->yyrule);
1646 : yyn > 0;
1647 : yys0 = yys0->yypred, yys1 = yys1->yypred, yyn -= 1)
1648 0 : if (yys0 == yys1)
1649 0 : break;
1650 0 : else if (! yys0->yyresolved && ! yys1->yyresolved)
1651 : {
1652 0 : yySemanticOption* yyz;
1653 0 : for (yyz = yys0->yysemantics.yyfirstVal; yyz->yynext != NULL;
1654 : yyz = yyz->yynext)
1655 0 : continue;
1656 0 : yyz->yynext = yys1->yysemantics.yyfirstVal;
1657 : }
1658 : }
1659 :
1660 : /** Y0 and Y1 represent two possible actions to take in a given
1661 : * parsing state; return 0 if no combination is possible,
1662 : * 1 if user-mergeable, 2 if Y0 is preferred, 3 if Y1 is preferred. */
1663 : static int
1664 : yypreference (yySemanticOption* y0, yySemanticOption* y1)
1665 0 : {
1666 0 : yyRuleNum r0 = y0->yyrule, r1 = y1->yyrule;
1667 0 : int p0 = yydprec[r0], p1 = yydprec[r1];
1668 :
1669 0 : if (p0 == p1)
1670 : {
1671 0 : if (yymerger[r0] == 0 || yymerger[r0] != yymerger[r1])
1672 0 : return 0;
1673 : else
1674 0 : return 1;
1675 : }
1676 0 : if (p0 == 0 || p1 == 0)
1677 0 : return 0;
1678 0 : if (p0 < p1)
1679 0 : return 3;
1680 0 : if (p1 < p0)
1681 0 : return 2;
1682 0 : return 0;
1683 : }
1684 :
1685 : static YYRESULTTAG yyresolveValue (yySemanticOption* yyoptionList,
1686 : yyGLRStack* yystack, YYSTYPE* yyvalp,
1687 : YYLTYPE* yylocp, yyscan_t scanner , void * data );
1688 :
1689 : static YYRESULTTAG
1690 : yyresolveStates (yyGLRState* yys, int yyn, yyGLRStack* yystack, yyscan_t scanner , void * data )
1691 39 : {
1692 39 : YYRESULTTAG yyflag;
1693 39 : if (0 < yyn)
1694 : {
1695 23 : YYASSERT (yys->yypred);
1696 23 : yyflag = yyresolveStates (yys->yypred, yyn-1, yystack, scanner, data);
1697 23 : if (yyflag != yyok)
1698 0 : return yyflag;
1699 23 : if (! yys->yyresolved)
1700 : {
1701 9 : yyflag = yyresolveValue (yys->yysemantics.yyfirstVal, yystack,
1702 : &yys->yysemantics.yysval, &yys->yyloc
1703 : , scanner, data);
1704 9 : if (yyflag != yyok)
1705 0 : return yyflag;
1706 9 : yys->yyresolved = yytrue;
1707 : }
1708 : }
1709 39 : return yyok;
1710 : }
1711 :
1712 : static YYRESULTTAG
1713 : yyresolveAction (yySemanticOption* yyopt, yyGLRStack* yystack,
1714 : YYSTYPE* yyvalp, YYLTYPE* yylocp, yyscan_t scanner , void * data )
1715 9 : {
1716 9 : yyGLRStackItem yyrhsVals[YYMAXRHS + YYMAXLEFT + 1];
1717 9 : int yynrhs;
1718 :
1719 9 : yynrhs = yyrhsLength (yyopt->yyrule);
1720 9 : YYCHK (yyresolveStates (yyopt->yystate, yynrhs, yystack, scanner, data));
1721 9 : yyrhsVals[YYMAXRHS + YYMAXLEFT].yystate.yypred = yyopt->yystate;
1722 9 : return yyuserAction (yyopt->yyrule, yynrhs,
1723 : yyrhsVals + YYMAXRHS + YYMAXLEFT - 1,
1724 : yyvalp, yylocp, yystack, scanner, data);
1725 : }
1726 :
1727 : #if YYDEBUG
1728 : static void
1729 : yyreportTree (yySemanticOption* yyx, int yyindent)
1730 : {
1731 : int yynrhs = yyrhsLength (yyx->yyrule);
1732 : int yyi;
1733 : yyGLRState* yys;
1734 : yyGLRState* yystates[YYMAXRHS];
1735 : yyGLRState yyleftmost_state;
1736 :
1737 : for (yyi = yynrhs, yys = yyx->yystate; 0 < yyi; yyi -= 1, yys = yys->yypred)
1738 : yystates[yyi] = yys;
1739 : if (yys == NULL)
1740 : {
1741 : yyleftmost_state.yyposn = 0;
1742 : yystates[0] = &yyleftmost_state;
1743 : }
1744 : else
1745 : yystates[0] = yys;
1746 :
1747 : if (yyx->yystate->yyposn < yys->yyposn + 1)
1748 : YYFPRINTF (stderr, "%*s%s -> <Rule %d, empty>\n",
1749 : yyindent, "", yytokenName (yylhsNonterm (yyx->yyrule)),
1750 : yyx->yyrule);
1751 : else
1752 : YYFPRINTF (stderr, "%*s%s -> <Rule %d, tokens %lu .. %lu>\n",
1753 : yyindent, "", yytokenName (yylhsNonterm (yyx->yyrule)),
1754 : yyx->yyrule, (unsigned long int) (yys->yyposn + 1),
1755 : (unsigned long int) yyx->yystate->yyposn);
1756 : for (yyi = 1; yyi <= yynrhs; yyi += 1)
1757 : {
1758 : if (yystates[yyi]->yyresolved)
1759 : {
1760 : if (yystates[yyi-1]->yyposn+1 > yystates[yyi]->yyposn)
1761 : YYFPRINTF (stderr, "%*s%s <empty>\n", yyindent+2, "",
1762 : yytokenName (yyrhs[yyprhs[yyx->yyrule]+yyi-1]));
1763 : else
1764 : YYFPRINTF (stderr, "%*s%s <tokens %lu .. %lu>\n", yyindent+2, "",
1765 : yytokenName (yyrhs[yyprhs[yyx->yyrule]+yyi-1]),
1766 : (unsigned long int) (yystates[yyi - 1]->yyposn + 1),
1767 : (unsigned long int) yystates[yyi]->yyposn);
1768 : }
1769 : else
1770 : yyreportTree (yystates[yyi]->yysemantics.yyfirstVal, yyindent+2);
1771 : }
1772 : }
1773 : #endif
1774 :
1775 : static void
1776 : yyreportAmbiguity (yySemanticOption* yyx0, yySemanticOption* yyx1,
1777 : yyGLRStack* yystack, YYLTYPE *yylocp, yyscan_t scanner , void * data )
1778 0 : {
1779 : /* `Unused' warnings. */
1780 0 : (void) yyx0;
1781 0 : (void) yyx1;
1782 :
1783 : #if YYDEBUG
1784 : YYFPRINTF (stderr, "Ambiguity detected.\n");
1785 : YYFPRINTF (stderr, "Option 1,\n");
1786 : yyreportTree (yyx0, 2);
1787 : YYFPRINTF (stderr, "\nOption 2,\n");
1788 : yyreportTree (yyx1, 2);
1789 : YYFPRINTF (stderr, "\n");
1790 : #endif
1791 0 : yyFail (yystack, yylocp, scanner, data, "ambiguity detected");
1792 : }
1793 :
1794 :
1795 : /** Resolve the ambiguity represented by OPTIONLIST, perform the indicated
1796 : * actions, and return the result. */
1797 : static YYRESULTTAG
1798 : yyresolveValue (yySemanticOption* yyoptionList, yyGLRStack* yystack,
1799 : YYSTYPE* yyvalp, YYLTYPE* yylocp, yyscan_t scanner , void * data )
1800 9 : {
1801 9 : yySemanticOption* yybest;
1802 9 : yySemanticOption* yyp;
1803 9 : int yymerge;
1804 :
1805 9 : yybest = yyoptionList;
1806 9 : yymerge = 0;
1807 9 : for (yyp = yyoptionList->yynext; yyp != NULL; yyp = yyp->yynext)
1808 : {
1809 0 : if (yyidenticalOptions (yybest, yyp))
1810 0 : yymergeOptionSets (yybest, yyp);
1811 : else
1812 0 : switch (yypreference (yybest, yyp))
1813 : {
1814 : case 0:
1815 0 : yyreportAmbiguity (yybest, yyp, yystack, yylocp, scanner, data);
1816 0 : break;
1817 : case 1:
1818 0 : yymerge = 1;
1819 0 : break;
1820 : case 2:
1821 0 : break;
1822 : case 3:
1823 0 : yybest = yyp;
1824 0 : yymerge = 0;
1825 0 : break;
1826 : }
1827 : }
1828 :
1829 9 : if (yymerge)
1830 : {
1831 0 : int yyprec = yydprec[yybest->yyrule];
1832 0 : YYCHK (yyresolveAction (yybest, yystack, yyvalp, yylocp, scanner, data));
1833 0 : for (yyp = yybest->yynext; yyp != NULL; yyp = yyp->yynext)
1834 : {
1835 0 : if (yyprec == yydprec[yyp->yyrule])
1836 : {
1837 0 : YYSTYPE yyval1;
1838 0 : YYLTYPE yydummy;
1839 0 : YYCHK (yyresolveAction (yyp, yystack, &yyval1, &yydummy, scanner, data));
1840 0 : yyuserMerge (yymerger[yyp->yyrule], yyvalp, &yyval1);
1841 : }
1842 : }
1843 0 : return yyok;
1844 : }
1845 : else
1846 9 : return yyresolveAction (yybest, yystack, yyvalp, yylocp, scanner, data);
1847 : }
1848 :
1849 : static YYRESULTTAG
1850 : yyresolveStack (yyGLRStack* yystack, yyscan_t scanner , void * data )
1851 7 : {
1852 7 : if (yystack->yysplitPoint != NULL)
1853 : {
1854 7 : yyGLRState* yys;
1855 7 : int yyn;
1856 :
1857 22 : for (yyn = 0, yys = yystack->yytops.yystates[0];
1858 : yys != yystack->yysplitPoint;
1859 : yys = yys->yypred, yyn += 1)
1860 15 : continue;
1861 7 : YYCHK (yyresolveStates (yystack->yytops.yystates[0], yyn, yystack
1862 : , scanner, data));
1863 : }
1864 7 : return yyok;
1865 : }
1866 :
1867 : static void
1868 : yycompressStack (yyGLRStack* yystack)
1869 7 : {
1870 7 : yyGLRState* yyp, *yyq, *yyr;
1871 :
1872 7 : if (yystack->yytops.yysize != 1 || yystack->yysplitPoint == NULL)
1873 0 : return;
1874 :
1875 22 : for (yyp = yystack->yytops.yystates[0], yyq = yyp->yypred, yyr = NULL;
1876 : yyp != yystack->yysplitPoint;
1877 : yyr = yyp, yyp = yyq, yyq = yyp->yypred)
1878 15 : yyp->yypred = yyr;
1879 :
1880 7 : yystack->yyspaceLeft += yystack->yynextFree - yystack->yyitems;
1881 7 : yystack->yynextFree = ((yyGLRStackItem*) yystack->yysplitPoint) + 1;
1882 7 : yystack->yyspaceLeft -= yystack->yynextFree - yystack->yyitems;
1883 7 : yystack->yysplitPoint = NULL;
1884 7 : yystack->yylastDeleted = NULL;
1885 :
1886 22 : while (yyr != NULL)
1887 : {
1888 15 : yystack->yynextFree->yystate = *yyr;
1889 15 : yyr = yyr->yypred;
1890 15 : yystack->yynextFree->yystate.yypred = & yystack->yynextFree[-1].yystate;
1891 15 : yystack->yytops.yystates[0] = &yystack->yynextFree->yystate;
1892 15 : yystack->yynextFree += 1;
1893 15 : yystack->yyspaceLeft -= 1;
1894 : }
1895 : }
1896 :
1897 : static YYRESULTTAG
1898 : yyprocessOneStack (yyGLRStack* yystack, int yyk,
1899 : size_t yyposn, YYSTYPE* yylvalp, YYLTYPE* yyllocp
1900 : , yyscan_t scanner , void * data )
1901 28 : {
1902 28 : int yyaction;
1903 28 : const short int* yyconflicts;
1904 28 : yyRuleNum yyrule;
1905 28 : yySymbol* const yytokenp = yystack->yytokenp;
1906 :
1907 38 : while (yystack->yytops.yystates[yyk] != NULL)
1908 : {
1909 38 : yyStateNum yystate = yystack->yytops.yystates[yyk]->yylrState;
1910 : YYDPRINTF ((stderr, "Stack %d Entering state %d\n", yyk, yystate));
1911 :
1912 38 : YYASSERT (yystate != YYFINAL);
1913 :
1914 38 : if (yyisDefaultedState (yystate))
1915 : {
1916 0 : yyrule = yydefaultAction (yystate);
1917 0 : if (yyrule == 0)
1918 : {
1919 : YYDPRINTF ((stderr, "Stack %d dies.\n", yyk));
1920 0 : yymarkStackDeleted (yystack, yyk);
1921 0 : return yyok;
1922 : }
1923 0 : YYCHK (yyglrReduce (yystack, yyk, yyrule, yyfalse, yyllocp, scanner, data));
1924 : }
1925 : else
1926 : {
1927 38 : if (*yytokenp == YYEMPTY)
1928 : {
1929 : YYDPRINTF ((stderr, "Reading a token: "));
1930 7 : yychar = YYLEX;
1931 7 : *yytokenp = YYTRANSLATE (yychar);
1932 : YYDSYMPRINTF ("Next token is", *yytokenp, yylvalp, yyllocp);
1933 : }
1934 38 : yygetLRActions (yystate, *yytokenp, &yyaction, &yyconflicts);
1935 :
1936 45 : while (*yyconflicts != 0)
1937 : {
1938 7 : int yynewStack = yysplitStack (yystack, yyk);
1939 : YYDPRINTF ((stderr, "Splitting off stack %d from %d.\n",
1940 : yynewStack, yyk));
1941 7 : YYCHK (yyglrReduce (yystack, yynewStack,
1942 : *yyconflicts, yyfalse, yyllocp, scanner, data));
1943 7 : YYCHK (yyprocessOneStack (yystack, yynewStack, yyposn,
1944 : yylvalp, yyllocp, scanner, data));
1945 7 : yyconflicts += 1;
1946 : }
1947 :
1948 38 : if (yyisShiftAction (yyaction))
1949 : {
1950 : YYDPRINTF ((stderr, "Shifting token %s on stack %d, ",
1951 : yytokenName (*yytokenp), yyk));
1952 21 : yyglrShift (yystack, yyk, yyaction, yyposn+1,
1953 : *yylvalp, yyllocp, scanner, data);
1954 : YYDPRINTF ((stderr, "which is now in state #%d\n",
1955 : yystack->yytops.yystates[yyk]->yylrState));
1956 21 : break;
1957 : }
1958 17 : else if (yyisErrorAction (yyaction))
1959 : {
1960 : YYDPRINTF ((stderr, "Stack %d dies.\n", yyk));
1961 7 : yymarkStackDeleted (yystack, yyk);
1962 7 : break;
1963 : }
1964 : else
1965 10 : YYCHK (yyglrReduce (yystack, yyk, -yyaction, yyfalse, yyllocp, scanner, data));
1966 : }
1967 : }
1968 28 : return yyok;
1969 : }
1970 :
1971 : static void
1972 : yyreportSyntaxError (yyGLRStack* yystack,
1973 : YYSTYPE* yylvalp, YYLTYPE* yyllocp, yyscan_t scanner , void * data )
1974 0 : {
1975 : /* `Unused' warnings. */
1976 0 : (void) yylvalp;
1977 0 : (void) yyllocp;
1978 :
1979 0 : if (yystack->yyerrState == 0)
1980 : {
1981 : #if YYERROR_VERBOSE
1982 0 : yySymbol* const yytokenp = yystack->yytokenp;
1983 0 : int yyn;
1984 0 : yyn = yypact[yystack->yytops.yystates[0]->yylrState];
1985 0 : if (YYPACT_NINF < yyn && yyn < YYLAST)
1986 : {
1987 0 : size_t yysize = 0;
1988 0 : const char* yyprefix;
1989 0 : char* yymsg;
1990 0 : int yyx;
1991 :
1992 : /* Start YYX at -YYN if negative to avoid negative indexes in
1993 : YYCHECK. */
1994 0 : int yyxbegin = yyn < 0 ? -yyn : 0;
1995 :
1996 : /* Stay within bounds of both yycheck and yytname. */
1997 0 : int yychecklim = YYLAST - yyn;
1998 0 : int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
1999 0 : int yycount = 0;
2000 :
2001 0 : yyprefix = ", expecting ";
2002 0 : for (yyx = yyxbegin; yyx < yyxend; ++yyx)
2003 0 : if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
2004 : {
2005 0 : yysize += strlen (yyprefix) + strlen (yytokenName (yyx));
2006 0 : yycount += 1;
2007 0 : if (yycount == 5)
2008 : {
2009 0 : yysize = 0;
2010 0 : break;
2011 : }
2012 0 : yyprefix = " or ";
2013 : }
2014 0 : yysize += (sizeof ("syntax error, unexpected ")
2015 : + strlen (yytokenName (*yytokenp)));
2016 0 : yymsg = (char*) YYMALLOC (yysize);
2017 0 : if (yymsg != 0)
2018 : {
2019 0 : char* yyp = yymsg;
2020 0 : sprintf (yyp, "syntax error%s%s",
2021 : (*yytokenp == YYEMPTY ? "" : ", unexpected "),
2022 : yytokenName (*yytokenp));
2023 0 : yyp += strlen (yyp);
2024 0 : if (yycount < 5)
2025 : {
2026 0 : yyprefix = ", expecting ";
2027 0 : for (yyx = yyxbegin; yyx < yyxend; ++yyx)
2028 0 : if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
2029 : {
2030 0 : sprintf (yyp, "%s%s", yyprefix, yytokenName (yyx));
2031 0 : yyp += strlen (yyp);
2032 0 : yyprefix = " or ";
2033 : }
2034 : }
2035 0 : yyerror (yyllocp, scanner, data, yymsg);
2036 0 : YYFREE (yymsg);
2037 : }
2038 : else
2039 0 : yyerror (yyllocp, scanner, data, "syntax error; also virtual memory exhausted");
2040 : }
2041 : else
2042 : #endif /* YYERROR_VERBOSE */
2043 0 : yyerror (yyllocp, scanner, data, "syntax error");
2044 0 : yynerrs += 1;
2045 : }
2046 : }
2047 :
2048 : /* Recover from a syntax error on YYSTACK, assuming that YYTOKENP,
2049 : YYLVALP, and YYLLOCP point to the syntactic category, semantic
2050 : value, and location of the lookahead. */
2051 : static void
2052 : yyrecoverSyntaxError (yyGLRStack* yystack,
2053 : YYSTYPE* yylvalp, YYLTYPE* yyllocp, yyscan_t scanner , void * data )
2054 0 : {
2055 0 : yySymbol* const yytokenp = yystack->yytokenp;
2056 0 : size_t yyk;
2057 0 : int yyj;
2058 :
2059 0 : if (yystack->yyerrState == 3)
2060 : /* We just shifted the error token and (perhaps) took some
2061 : reductions. Skip tokens until we can proceed. */
2062 0 : while (yytrue)
2063 : {
2064 0 : if (*yytokenp == YYEOF)
2065 : {
2066 : /* Now pop stack until empty and fail. */
2067 0 : while (yystack->yytops.yystates[0] != NULL)
2068 : {
2069 0 : yyGLRState *yys = yystack->yytops.yystates[0];
2070 : YYDSYMPRINTF ("Error: popping",
2071 : yystos[yys->yylrState],
2072 : &yys->yysemantics.yysval, &yys->yyloc);
2073 0 : yydestruct (yystos[yys->yylrState],
2074 : &yys->yysemantics.yysval, &yys->yyloc);
2075 0 : yystack->yytops.yystates[0] = yys->yypred;
2076 0 : yystack->yynextFree -= 1;
2077 0 : yystack->yyspaceLeft += 1;
2078 : }
2079 0 : yyFail (yystack, yyllocp, scanner, data, NULL);
2080 : }
2081 0 : if (*yytokenp != YYEMPTY)
2082 : {
2083 : YYDSYMPRINTF ("Error: discarding", *yytokenp, yylvalp, yyllocp);
2084 0 : yydestruct (*yytokenp, yylvalp, yyllocp);
2085 : }
2086 : YYDPRINTF ((stderr, "Reading a token: "));
2087 0 : yychar = YYLEX;
2088 0 : *yytokenp = YYTRANSLATE (yychar);
2089 : YYDSYMPRINTF ("Next token is", *yytokenp, yylvalp, yyllocp);
2090 0 : yyj = yypact[yystack->yytops.yystates[0]->yylrState];
2091 0 : if (yyis_pact_ninf (yyj))
2092 0 : return;
2093 0 : yyj += *yytokenp;
2094 0 : if (yyj < 0 || YYLAST < yyj || yycheck[yyj] != *yytokenp)
2095 : {
2096 0 : if (yydefact[yystack->yytops.yystates[0]->yylrState] != 0)
2097 0 : return;
2098 : }
2099 0 : else if (yytable[yyj] != 0 && ! yyis_table_ninf (yytable[yyj]))
2100 0 : return;
2101 : }
2102 :
2103 : /* Reduce to one stack. */
2104 0 : for (yyk = 0; yyk < yystack->yytops.yysize; yyk += 1)
2105 0 : if (yystack->yytops.yystates[yyk] != NULL)
2106 0 : break;
2107 0 : if (yyk >= yystack->yytops.yysize)
2108 0 : yyFail (yystack, yyllocp, scanner, data, NULL);
2109 0 : for (yyk += 1; yyk < yystack->yytops.yysize; yyk += 1)
2110 0 : yymarkStackDeleted (yystack, yyk);
2111 0 : yyremoveDeletes (yystack);
2112 0 : yycompressStack (yystack);
2113 :
2114 : /* Now pop stack until we find a state that shifts the error token. */
2115 0 : yystack->yyerrState = 3;
2116 0 : while (yystack->yytops.yystates[0] != NULL)
2117 : {
2118 0 : yyGLRState *yys = yystack->yytops.yystates[0];
2119 0 : yyj = yypact[yys->yylrState];
2120 0 : if (! yyis_pact_ninf (yyj))
2121 : {
2122 0 : yyj += YYTERROR;
2123 0 : if (0 <= yyj && yyj <= YYLAST && yycheck[yyj] == YYTERROR
2124 : && yyisShiftAction (yytable[yyj]))
2125 : {
2126 : YYDPRINTF ((stderr, "Shifting error token, "));
2127 0 : yyglrShift (yystack, 0, yytable[yyj],
2128 : yys->yyposn, *yylvalp, yyllocp, scanner, data);
2129 0 : break;
2130 : }
2131 : }
2132 : YYDSYMPRINTF ("Error: popping",
2133 : yystos[yys->yylrState],
2134 : &yys->yysemantics.yysval, &yys->yyloc);
2135 0 : yydestruct (yystos[yys->yylrState],
2136 : &yys->yysemantics.yysval, &yys->yyloc);
2137 0 : yystack->yytops.yystates[0] = yys->yypred;
2138 0 : yystack->yynextFree -= 1;
2139 0 : yystack->yyspaceLeft += 1;
2140 : }
2141 0 : if (yystack->yytops.yystates[0] == NULL)
2142 0 : yyFail (yystack, yyllocp, scanner, data, NULL);
2143 : }
2144 :
2145 : #define YYCHK1(YYE) \
2146 : do { \
2147 : switch (YYE) { \
2148 : default: \
2149 : break; \
2150 : case yyabort: \
2151 : yystack.yyerrflag = 1; \
2152 : goto yyDone; \
2153 : case yyaccept: \
2154 : yystack.yyerrflag = 0; \
2155 : goto yyDone; \
2156 : case yyerr: \
2157 : goto yyuser_error; \
2158 : } \
2159 : } while (0)
2160 :
2161 :
2162 : /*----------.
2163 : | yyparse. |
2164 : `----------*/
2165 :
2166 : int
2167 : yyparse ( yyscan_t scanner , void * data )
2168 23 : {
2169 23 : yySymbol yytoken;
2170 23 : yyGLRStack yystack;
2171 23 : size_t yyposn;
2172 :
2173 23 : YYSTYPE yylval;
2174 23 : YYLTYPE yylloc;
2175 : #undef yychar
2176 : #define yychar (yystack.yyrawchar)
2177 :
2178 :
2179 23 : YYSTYPE* const yylvalp = &yylval;
2180 23 : YYLTYPE* const yyllocp = &yylloc;
2181 :
2182 23 : yyinitGLRStack (&yystack, YYINITDEPTH);
2183 23 : yystack.yytokenp = &yytoken;
2184 :
2185 : YYDPRINTF ((stderr, "Starting parse\n"));
2186 :
2187 23 : if (setjmp (yystack.yyexception_buffer) != 0)
2188 0 : goto yyDone;
2189 :
2190 23 : yyglrShift (&yystack, 0, 0, 0, yyval_default, &yyloc_default, scanner, data);
2191 23 : yytoken = YYEMPTY;
2192 23 : yyposn = 0;
2193 :
2194 3163 : while (yytrue)
2195 : {
2196 : /* For efficiency, we have two loops, the first of which is
2197 : specialized to deterministic operation (single stack, no
2198 : potential ambiguity). */
2199 : /* Standard mode */
2200 3163 : while (yytrue)
2201 : {
2202 3163 : yyRuleNum yyrule;
2203 3163 : int yyaction;
2204 3163 : const short int* yyconflicts;
2205 :
2206 3163 : yyStateNum yystate = yystack.yytops.yystates[0]->yylrState;
2207 : YYDPRINTF ((stderr, "Entering state %d\n", yystate));
2208 3163 : if (yystate == YYFINAL)
2209 23 : goto yyDone;
2210 3140 : if (yyisDefaultedState (yystate))
2211 : {
2212 1386 : yyrule = yydefaultAction (yystate);
2213 1386 : if (yyrule == 0)
2214 : {
2215 0 : yyreportSyntaxError (&yystack, yylvalp, yyllocp, scanner, data);
2216 0 : goto yyuser_error;
2217 : }
2218 1386 : YYCHK1 (yyglrReduce (&yystack, 0, yyrule, yytrue, yyllocp, scanner, data));
2219 : }
2220 : else
2221 : {
2222 1754 : if (yytoken == YYEMPTY)
2223 : {
2224 : YYDPRINTF ((stderr, "Reading a token: "));
2225 958 : yychar = YYLEX;
2226 958 : yytoken = YYTRANSLATE (yychar);
2227 : YYDSYMPRINTF ("Next token is", yytoken, yylvalp, yyllocp);
2228 : }
2229 1754 : yygetLRActions (yystate, yytoken, &yyaction, &yyconflicts);
2230 1754 : if (*yyconflicts != 0)
2231 7 : break;
2232 1747 : if (yyisShiftAction (yyaction))
2233 : {
2234 : YYDPRINTF ((stderr, "Shifting token %s, ",
2235 : yytokenName (yytoken)));
2236 951 : if (yytoken != YYEOF)
2237 928 : yytoken = YYEMPTY;
2238 951 : yyposn += 1;
2239 951 : yyglrShift (&yystack, 0, yyaction, yyposn,
2240 : yylval, yyllocp, scanner, data);
2241 951 : if (0 < yystack.yyerrState)
2242 0 : yystack.yyerrState -= 1;
2243 : }
2244 796 : else if (yyisErrorAction (yyaction))
2245 : {
2246 0 : yyreportSyntaxError (&yystack, yylvalp, yyllocp, scanner, data);
2247 0 : goto yyuser_error;
2248 : }
2249 : else
2250 796 : YYCHK1 (yyglrReduce (&yystack, 0, -yyaction, yytrue, yyllocp, scanner, data));
2251 : }
2252 : }
2253 :
2254 14 : while (yytrue)
2255 : {
2256 14 : int yys;
2257 14 : int yyn = yystack.yytops.yysize;
2258 35 : for (yys = 0; yys < yyn; yys += 1)
2259 21 : YYCHK1 (yyprocessOneStack (&yystack, yys, yyposn,
2260 : yylvalp, yyllocp, scanner, data));
2261 14 : yytoken = YYEMPTY;
2262 14 : yyposn += 1;
2263 14 : yyremoveDeletes (&yystack);
2264 14 : if (yystack.yytops.yysize == 0)
2265 : {
2266 0 : yyundeleteLastStack (&yystack);
2267 0 : if (yystack.yytops.yysize == 0)
2268 0 : yyFail (&yystack, yyllocp, scanner, data, "syntax error");
2269 0 : YYCHK1 (yyresolveStack (&yystack, scanner, data));
2270 : YYDPRINTF ((stderr, "Returning to deterministic operation.\n"));
2271 0 : yyreportSyntaxError (&yystack, yylvalp, yyllocp, scanner, data);
2272 0 : goto yyuser_error;
2273 : }
2274 14 : else if (yystack.yytops.yysize == 1)
2275 : {
2276 7 : YYCHK1 (yyresolveStack (&yystack, scanner, data));
2277 : YYDPRINTF ((stderr, "Returning to deterministic operation.\n"));
2278 7 : yycompressStack (&yystack);
2279 7 : break;
2280 : }
2281 : }
2282 0 : continue;
2283 : yyuser_error:
2284 0 : yyrecoverSyntaxError (&yystack, yylvalp, yyllocp, scanner, data);
2285 0 : yyposn = yystack.yytops.yystates[0]->yyposn;
2286 : }
2287 : yyDone:
2288 : ;
2289 :
2290 23 : yyfreeGLRStack (&yystack);
2291 23 : return yystack.yyerrflag;
2292 : }
2293 :
2294 : /* DEBUGGING ONLY */
2295 : static void yypstack (yyGLRStack* yystack, int yyk) ATTRIBUTE_UNUSED;
2296 : static void yypdumpstack (yyGLRStack* yystack) ATTRIBUTE_UNUSED;
2297 :
2298 : static void
2299 : yy_yypstack (yyGLRState* yys)
2300 0 : {
2301 0 : if (yys->yypred)
2302 : {
2303 0 : yy_yypstack (yys->yypred);
2304 0 : fprintf (stderr, " -> ");
2305 : }
2306 0 : fprintf (stderr, "%d@%lu", yys->yylrState, (unsigned long int) yys->yyposn);
2307 : }
2308 :
2309 : static void
2310 : yypstates (yyGLRState* yyst)
2311 0 : {
2312 0 : if (yyst == NULL)
2313 0 : fprintf (stderr, "<null>");
2314 : else
2315 0 : yy_yypstack (yyst);
2316 0 : fprintf (stderr, "\n");
2317 : }
2318 :
2319 : static void
2320 : yypstack (yyGLRStack* yystack, int yyk)
2321 0 : {
2322 0 : yypstates (yystack->yytops.yystates[yyk]);
2323 : }
2324 :
2325 : #define YYINDEX(YYX) \
2326 : ((YYX) == NULL ? -1 : (yyGLRStackItem*) (YYX) - yystack->yyitems)
2327 :
2328 :
2329 : static void
2330 : yypdumpstack (yyGLRStack* yystack)
2331 0 : {
2332 0 : yyGLRStackItem* yyp;
2333 0 : size_t yyi;
2334 0 : for (yyp = yystack->yyitems; yyp < yystack->yynextFree; yyp += 1)
2335 : {
2336 0 : fprintf (stderr, "%3lu. ", (unsigned long int) (yyp - yystack->yyitems));
2337 0 : if (*(yybool *) yyp)
2338 : {
2339 0 : fprintf (stderr, "Res: %d, LR State: %d, posn: %lu, pred: %ld",
2340 : yyp->yystate.yyresolved, yyp->yystate.yylrState,
2341 : (unsigned long int) yyp->yystate.yyposn,
2342 : (long int) YYINDEX (yyp->yystate.yypred));
2343 0 : if (! yyp->yystate.yyresolved)
2344 0 : fprintf (stderr, ", firstVal: %ld",
2345 : (long int) YYINDEX (yyp->yystate.yysemantics.yyfirstVal));
2346 : }
2347 : else
2348 : {
2349 0 : fprintf (stderr, "Option. rule: %d, state: %ld, next: %ld",
2350 : yyp->yyoption.yyrule,
2351 : (long int) YYINDEX (yyp->yyoption.yystate),
2352 : (long int) YYINDEX (yyp->yyoption.yynext));
2353 : }
2354 0 : fprintf (stderr, "\n");
2355 : }
2356 0 : fprintf (stderr, "Tops:");
2357 0 : for (yyi = 0; yyi < yystack->yytops.yysize; yyi += 1)
2358 0 : fprintf (stderr, "%lu: %ld; ", (unsigned long int) yyi,
2359 : (long int) YYINDEX (yystack->yytops.yystates[yyi]));
2360 0 : fprintf (stderr, "\n");
2361 : }
2362 :
2363 :
2364 : #line 175 "parser.y"
2365 :
2366 :
|