1 /* A Bison parser, made by GNU Bison 2.3. */
2
3 /* Skeleton implementation for Bison's Yacc-like parsers in C
4
5 Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
6 Free Software Foundation, Inc.
7
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2, or (at your option)
11 any later version.
12
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 Boston, MA 02110-1301, USA. */
22
23 /* As a special exception, you may create a larger work that contains
24 part or all of the Bison parser skeleton and distribute that work
25 under terms of your choice, so long as that work isn't itself a
26 parser generator using the skeleton or a modified version thereof
27 as a parser skeleton. Alternatively, if you modify or redistribute
28 the parser skeleton itself, you may (at your option) remove this
29 special exception, which will cause the skeleton and the resulting
30 Bison output files to be licensed under the GNU General Public
31 License without this special exception.
32
33 This special exception was added by the Free Software Foundation in
34 version 2.2 of Bison. */
35
36 /* C LALR(1) parser skeleton written by Richard Stallman, by
37 simplifying the original so-called "semantic" parser. */
38
39 /* All symbols defined below should begin with yy or YY, to avoid
40 infringing on user name space. This should be done even for local
41 variables, as they might otherwise be expanded by user macros.
42 There are some unavoidable exceptions within include files to
43 define necessary library symbols; they are noted "INFRINGES ON
44 USER NAME SPACE" below. */
45
46 /* Identify Bison output. */
47 #define YYBISON 1
48
49 /* Bison version. */
50 #define YYBISON_VERSION "2.3"
51
52 /* Skeleton name. */
53 #define YYSKELETON_NAME "yacc.c"
54
55 /* Pure parsers. */
56 #define YYPURE 0
57
58 /* Using locations. */
59 #define YYLSP_NEEDED 0
60
61 /* Substitute the variable and function names. */
62 #define yyparse glangparse
63 #define yylex glanglex
64 #define yyerror glangerror
65 #define yylval glanglval
66 #define yychar glangchar
67 #define yydebug glangdebug
68 #define yynerrs glangnerrs
69
70
71 /* Tokens. */
72 #ifndef YYTOKENTYPE
73 # define YYTOKENTYPE
74 /* Put the tokens into the symbol table, so that GDB and other debuggers
75 know about them. */
76 enum yytokentype {
77 GMN = 258,
78 GROUPSTART = 259,
79 GROUPEND = 260,
80 ASEP = 261,
81 EQ = 262,
82 IDENT = 263,
83 BOTTOM = 264,
84 TOP = 265,
85 TAIL = 266,
86 HEAD = 267,
87 PAR = 268,
88 SEQ = 269,
89 APPLY = 270,
90 ABSTRACT = 271
91 };
92 #endif
93 /* Tokens. */
94 #define GMN 258
95 #define GROUPSTART 259
96 #define GROUPEND 260
97 #define ASEP 261
98 #define EQ 262
99 #define IDENT 263
100 #define BOTTOM 264
101 #define TOP 265
102 #define TAIL 266
103 #define HEAD 267
104 #define PAR 268
105 #define SEQ 269
106 #define APPLY 270
107 #define ABSTRACT 271
108
109
110
111
112 /* Copy the first part of user declarations. */
113 #line 1 "glang.y"
114
115
116 #include <iostream>
117 #include <string>
118 #include "glangreader.h"
119
120 #include "glangparse.hpp"
121 #include "glanglex.cpp"
122
123 int glangerror(const char*s);
124
125 //#define parseDebug
126 #ifdef parseDebug
127 #define debug(msg) std::cout << msg << " -" << glangtext << "-" << std::endl;
128 #else
129 #define debug(msg)
130 #endif
131
132 #define clean(a,b,c) delete a; delete b; delete c
133
134 extern guidolang::glangreader* gGLReader;
135 using namespace guidolang;
136
137
138
139 /* Enabling traces. */
140 #ifndef YYDEBUG
141 # define YYDEBUG 0
142 #endif
143
144 /* Enabling verbose error messages. */
145 #ifdef YYERROR_VERBOSE
146 # undef YYERROR_VERBOSE
147 # define YYERROR_VERBOSE 1
148 #else
149 # define YYERROR_VERBOSE 0
150 #endif
151
152 /* Enabling the token table. */
153 #ifndef YYTOKEN_TABLE
154 # define YYTOKEN_TABLE 0
155 #endif
156
157 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
158 typedef union YYSTYPE
159 #line 30 "glang.y"
160 {
161 SGLExpr* exprPtr;
162 std::string * strPtr;
163 }
164 /* Line 193 of yacc.c. */
165 #line 166 "glangparse.cpp"
166 YYSTYPE;
167 # define yystype YYSTYPE /* obsolescent; will be withdrawn */
168 # define YYSTYPE_IS_DECLARED 1
169 # define YYSTYPE_IS_TRIVIAL 1
170 #endif
171
172
173
174 /* Copy the second part of user declarations. */
175
176
177 /* Line 216 of yacc.c. */
178 #line 179 "glangparse.cpp"
179
180 #ifdef short
181 # undef short
182 #endif
183
184 #ifdef YYTYPE_UINT8
185 typedef YYTYPE_UINT8 yytype_uint8;
186 #else
187 typedef unsigned char yytype_uint8;
188 #endif
189
190 #ifdef YYTYPE_INT8
191 typedef YYTYPE_INT8 yytype_int8;
192 #elif (defined __STDC__ || defined __C99__FUNC__ \
193 || defined __cplusplus || defined _MSC_VER)
194 typedef signed char yytype_int8;
195 #else
196 typedef short int yytype_int8;
197 #endif
198
199 #ifdef YYTYPE_UINT16
200 typedef YYTYPE_UINT16 yytype_uint16;
201 #else
202 typedef unsigned short int yytype_uint16;
203 #endif
204
205 #ifdef YYTYPE_INT16
206 typedef YYTYPE_INT16 yytype_int16;
207 #else
208 typedef short int yytype_int16;
209 #endif
210
211 #ifndef YYSIZE_T
212 # ifdef __SIZE_TYPE__
213 # define YYSIZE_T __SIZE_TYPE__
214 # elif defined size_t
215 # define YYSIZE_T size_t
216 # elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \
217 || defined __cplusplus || defined _MSC_VER)
218 # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
219 # define YYSIZE_T size_t
220 # else
221 # define YYSIZE_T unsigned int
222 # endif
223 #endif
224
225 #define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
226
227 #ifndef YY_
228 # if defined YYENABLE_NLS && YYENABLE_NLS
229 # if ENABLE_NLS
230 # include <libintl.h> /* INFRINGES ON USER NAME SPACE */
231 # define YY_(msgid) dgettext ("bison-runtime", msgid)
232 # endif
233 # endif
234 # ifndef YY_
235 # define YY_(msgid) msgid
236 # endif
237 #endif
238
239 /* Suppress unused-variable warnings by "using" E. */
240 #if ! defined lint || defined __GNUC__
241 # define YYUSE(e) ((void) (e))
242 #else
243 # define YYUSE(e) /* empty */
244 #endif
245
246 /* Identity function, used to suppress warnings about constant conditions. */
247 #ifndef lint
248 # define YYID(n) (n)
249 #else
250 #if (defined __STDC__ || defined __C99__FUNC__ \
251 || defined __cplusplus || defined _MSC_VER)
252 static int
YYID(int i)253 YYID (int i)
254 #else
255 static int
256 YYID (i)
257 int i;
258 #endif
259 {
260 return i;
261 }
262 #endif
263
264 #if ! defined yyoverflow || YYERROR_VERBOSE
265
266 /* The parser invokes alloca or malloc; define the necessary symbols. */
267
268 # ifdef YYSTACK_USE_ALLOCA
269 # if YYSTACK_USE_ALLOCA
270 # ifdef __GNUC__
271 # define YYSTACK_ALLOC __builtin_alloca
272 # elif defined __BUILTIN_VA_ARG_INCR
273 # include <alloca.h> /* INFRINGES ON USER NAME SPACE */
274 # elif defined _AIX
275 # define YYSTACK_ALLOC __alloca
276 # elif defined _MSC_VER
277 # include <malloc.h> /* INFRINGES ON USER NAME SPACE */
278 # define alloca _alloca
279 # else
280 # define YYSTACK_ALLOC alloca
281 # if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
282 || defined __cplusplus || defined _MSC_VER)
283 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
284 # ifndef _STDLIB_H
285 # define _STDLIB_H 1
286 # endif
287 # endif
288 # endif
289 # endif
290 # endif
291
292 # ifdef YYSTACK_ALLOC
293 /* Pacify GCC's `empty if-body' warning. */
294 # define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0))
295 # ifndef YYSTACK_ALLOC_MAXIMUM
296 /* The OS might guarantee only one guard page at the bottom of the stack,
297 and a page size can be as small as 4096 bytes. So we cannot safely
298 invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
299 to allow for a few compiler-allocated temporary stack slots. */
300 # define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
301 # endif
302 # else
303 # define YYSTACK_ALLOC YYMALLOC
304 # define YYSTACK_FREE YYFREE
305 # ifndef YYSTACK_ALLOC_MAXIMUM
306 # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
307 # endif
308 # if (defined __cplusplus && ! defined _STDLIB_H \
309 && ! ((defined YYMALLOC || defined malloc) \
310 && (defined YYFREE || defined free)))
311 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
312 # ifndef _STDLIB_H
313 # define _STDLIB_H 1
314 # endif
315 # endif
316 # ifndef YYMALLOC
317 # define YYMALLOC malloc
318 # if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
319 || defined __cplusplus || defined _MSC_VER)
320 void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
321 # endif
322 # endif
323 # ifndef YYFREE
324 # define YYFREE free
325 # if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
326 || defined __cplusplus || defined _MSC_VER)
327 void free (void *); /* INFRINGES ON USER NAME SPACE */
328 # endif
329 # endif
330 # endif
331 #endif /* ! defined yyoverflow || YYERROR_VERBOSE */
332
333
334 #if (! defined yyoverflow \
335 && (! defined __cplusplus \
336 || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
337
338 /* A type that is properly aligned for any stack member. */
339 union yyalloc
340 {
341 yytype_int16 yyss;
342 YYSTYPE yyvs;
343 };
344
345 /* The size of the maximum gap between one aligned stack and the next. */
346 # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
347
348 /* The size of an array large to enough to hold all stacks, each with
349 N elements. */
350 # define YYSTACK_BYTES(N) \
351 ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
352 + YYSTACK_GAP_MAXIMUM)
353
354 /* Copy COUNT objects from FROM to TO. The source and destination do
355 not overlap. */
356 # ifndef YYCOPY
357 # if defined __GNUC__ && 1 < __GNUC__
358 # define YYCOPY(To, From, Count) \
359 __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
360 # else
361 # define YYCOPY(To, From, Count) \
362 do \
363 { \
364 YYSIZE_T yyi; \
365 for (yyi = 0; yyi < (Count); yyi++) \
366 (To)[yyi] = (From)[yyi]; \
367 } \
368 while (YYID (0))
369 # endif
370 # endif
371
372 /* Relocate STACK from its old location to the new one. The
373 local variables YYSIZE and YYSTACKSIZE give the old and new number of
374 elements in the stack, and YYPTR gives the new location of the
375 stack. Advance YYPTR to a properly aligned location for the next
376 stack. */
377 # define YYSTACK_RELOCATE(Stack) \
378 do \
379 { \
380 YYSIZE_T yynewbytes; \
381 YYCOPY (&yyptr->Stack, Stack, yysize); \
382 Stack = &yyptr->Stack; \
383 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
384 yyptr += yynewbytes / sizeof (*yyptr); \
385 } \
386 while (YYID (0))
387
388 #endif
389
390 /* YYFINAL -- State number of the termination state. */
391 #define YYFINAL 5
392 /* YYLAST -- Last index in YYTABLE. */
393 #define YYLAST 46
394
395 /* YYNTOKENS -- Number of terminals. */
396 #define YYNTOKENS 17
397 /* YYNNTS -- Number of nonterminals. */
398 #define YYNNTS 8
399 /* YYNRULES -- Number of rules. */
400 #define YYNRULES 19
401 /* YYNRULES -- Number of states. */
402 #define YYNSTATES 31
403
404 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
405 #define YYUNDEFTOK 2
406 #define YYMAXUTOK 271
407
408 #define YYTRANSLATE(YYX) \
409 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
410
411 /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
412 static const yytype_uint8 yytranslate[] =
413 {
414 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
415 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
416 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
417 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
418 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
419 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
420 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
421 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
422 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
423 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
424 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
425 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
426 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
427 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
428 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
429 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
430 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
431 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
432 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
433 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
434 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
435 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
436 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
437 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
438 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
439 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
440 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
441 15, 16
442 };
443
444 #if YYDEBUG
445 /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
446 YYRHS. */
447 static const yytype_uint8 yyprhs[] =
448 {
449 0, 0, 3, 5, 9, 14, 16, 20, 25, 27,
450 29, 33, 35, 37, 39, 41, 43, 45, 47, 49
451 };
452
453 /* YYRHS -- A `-1'-separated list of the rules' RHS. */
454 static const yytype_int8 yyrhs[] =
455 {
456 18, 0, -1, 19, -1, 24, 7, 20, -1, 19,
457 24, 7, 20, -1, 3, -1, 20, 22, 20, -1,
458 16, 20, 23, 20, -1, 24, -1, 21, -1, 4,
459 20, 5, -1, 14, -1, 13, -1, 12, -1, 11,
460 -1, 10, -1, 9, -1, 15, -1, 6, -1, 8,
461 -1
462 };
463
464 /* YYRLINE[YYN] -- source line where rule number YYN was defined. */
465 static const yytype_uint8 yyrline[] =
466 {
467 0, 62, 62, 64, 65, 68, 70, 71, 72, 74,
468 77, 79, 80, 81, 82, 83, 84, 85, 87, 88
469 };
470 #endif
471
472 #if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
473 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
474 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
475 static const char *const yytname[] =
476 {
477 "$end", "error", "$undefined", "GMN", "GROUPSTART", "GROUPEND", "ASEP",
478 "EQ", "IDENT", "BOTTOM", "TOP", "TAIL", "HEAD", "PAR", "SEQ", "APPLY",
479 "ABSTRACT", "$accept", "program", "deflist", "expr", "group", "op",
480 "asep", "name", 0
481 };
482 #endif
483
484 # ifdef YYPRINT
485 /* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
486 token YYLEX-NUM. */
487 static const yytype_uint16 yytoknum[] =
488 {
489 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
490 265, 266, 267, 268, 269, 270, 271
491 };
492 # endif
493
494 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
495 static const yytype_uint8 yyr1[] =
496 {
497 0, 17, 18, 19, 19, 20, 20, 20, 20, 20,
498 21, 22, 22, 22, 22, 22, 22, 22, 23, 24
499 };
500
501 /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
502 static const yytype_uint8 yyr2[] =
503 {
504 0, 2, 1, 3, 4, 1, 3, 4, 1, 1,
505 3, 1, 1, 1, 1, 1, 1, 1, 1, 1
506 };
507
508 /* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
509 STATE-NUM when YYTABLE doesn't specify something else to do. Zero
510 means the default is an error. */
511 static const yytype_uint8 yydefact[] =
512 {
513 0, 19, 0, 2, 0, 1, 0, 0, 0, 5,
514 0, 0, 3, 9, 8, 4, 0, 0, 16, 15,
515 14, 13, 12, 11, 17, 0, 10, 18, 0, 6,
516 7
517 };
518
519 /* YYDEFGOTO[NTERM-NUM]. */
520 static const yytype_int8 yydefgoto[] =
521 {
522 -1, 2, 3, 12, 13, 25, 28, 14
523 };
524
525 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
526 STATE-NUM. */
527 #define YYPACT_NINF -9
528 static const yytype_int8 yypact[] =
529 {
530 -1, -9, 8, -1, 4, -9, 5, 2, 2, -9,
531 2, 2, 31, -9, -9, 31, 14, 24, -9, -9,
532 -9, -9, -9, -9, -9, 2, -9, -9, 2, 31,
533 -9
534 };
535
536 /* YYPGOTO[NTERM-NUM]. */
537 static const yytype_int8 yypgoto[] =
538 {
539 -9, -9, -9, -8, -9, -9, -9, 1
540 };
541
542 /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
543 positive, shift that token. If negative, reduce the rule which
544 number is the opposite. If zero, do what YYDEFACT says.
545 If YYTABLE_NINF, syntax error. */
546 #define YYTABLE_NINF -1
547 static const yytype_uint8 yytable[] =
548 {
549 15, 4, 16, 17, 6, 9, 10, 1, 5, 0,
550 1, 7, 8, 0, 0, 0, 0, 29, 11, 26,
551 30, 0, 0, 18, 19, 20, 21, 22, 23, 24,
552 27, 0, 0, 18, 19, 20, 21, 22, 23, 24,
553 18, 19, 20, 21, 22, 23, 24
554 };
555
556 static const yytype_int8 yycheck[] =
557 {
558 8, 0, 10, 11, 3, 3, 4, 8, 0, -1,
559 8, 7, 7, -1, -1, -1, -1, 25, 16, 5,
560 28, -1, -1, 9, 10, 11, 12, 13, 14, 15,
561 6, -1, -1, 9, 10, 11, 12, 13, 14, 15,
562 9, 10, 11, 12, 13, 14, 15
563 };
564
565 /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
566 symbol of state STATE-NUM. */
567 static const yytype_uint8 yystos[] =
568 {
569 0, 8, 18, 19, 24, 0, 24, 7, 7, 3,
570 4, 16, 20, 21, 24, 20, 20, 20, 9, 10,
571 11, 12, 13, 14, 15, 22, 5, 6, 23, 20,
572 20
573 };
574
575 #define yyerrok (yyerrstatus = 0)
576 #define yyclearin (yychar = YYEMPTY)
577 #define YYEMPTY (-2)
578 #define YYEOF 0
579
580 #define YYACCEPT goto yyacceptlab
581 #define YYABORT goto yyabortlab
582 #define YYERROR goto yyerrorlab
583
584
585 /* Like YYERROR except do call yyerror. This remains here temporarily
586 to ease the transition to the new meaning of YYERROR, for GCC.
587 Once GCC version 2 has supplanted version 1, this can go. */
588
589 #define YYFAIL goto yyerrlab
590
591 #define YYRECOVERING() (!!yyerrstatus)
592
593 #define YYBACKUP(Token, Value) \
594 do \
595 if (yychar == YYEMPTY && yylen == 1) \
596 { \
597 yychar = (Token); \
598 yylval = (Value); \
599 yytoken = YYTRANSLATE (yychar); \
600 YYPOPSTACK (1); \
601 goto yybackup; \
602 } \
603 else \
604 { \
605 yyerror (YY_("syntax error: cannot back up")); \
606 YYERROR; \
607 } \
608 while (YYID (0))
609
610
611 #define YYTERROR 1
612 #define YYERRCODE 256
613
614
615 /* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
616 If N is 0, then set CURRENT to the empty location which ends
617 the previous symbol: RHS[0] (always defined). */
618
619 #define YYRHSLOC(Rhs, K) ((Rhs)[K])
620 #ifndef YYLLOC_DEFAULT
621 # define YYLLOC_DEFAULT(Current, Rhs, N) \
622 do \
623 if (YYID (N)) \
624 { \
625 (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
626 (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
627 (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
628 (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
629 } \
630 else \
631 { \
632 (Current).first_line = (Current).last_line = \
633 YYRHSLOC (Rhs, 0).last_line; \
634 (Current).first_column = (Current).last_column = \
635 YYRHSLOC (Rhs, 0).last_column; \
636 } \
637 while (YYID (0))
638 #endif
639
640
641 /* YY_LOCATION_PRINT -- Print the location on the stream.
642 This macro was not mandated originally: define only if we know
643 we won't break user code: when these are the locations we know. */
644
645 #ifndef YY_LOCATION_PRINT
646 # if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL
647 # define YY_LOCATION_PRINT(File, Loc) \
648 fprintf (File, "%d.%d-%d.%d", \
649 (Loc).first_line, (Loc).first_column, \
650 (Loc).last_line, (Loc).last_column)
651 # else
652 # define YY_LOCATION_PRINT(File, Loc) ((void) 0)
653 # endif
654 #endif
655
656
657 /* YYLEX -- calling `yylex' with the right arguments. */
658
659 #ifdef YYLEX_PARAM
660 # define YYLEX yylex (YYLEX_PARAM)
661 #else
662 # define YYLEX yylex ()
663 #endif
664
665 /* Enable debugging if requested. */
666 #if YYDEBUG
667
668 # ifndef YYFPRINTF
669 # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
670 # define YYFPRINTF fprintf
671 # endif
672
673 # define YYDPRINTF(Args) \
674 do { \
675 if (yydebug) \
676 YYFPRINTF Args; \
677 } while (YYID (0))
678
679 # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
680 do { \
681 if (yydebug) \
682 { \
683 YYFPRINTF (stderr, "%s ", Title); \
684 yy_symbol_print (stderr, \
685 Type, Value); \
686 YYFPRINTF (stderr, "\n"); \
687 } \
688 } while (YYID (0))
689
690
691 /*--------------------------------.
692 | Print this symbol on YYOUTPUT. |
693 `--------------------------------*/
694
695 /*ARGSUSED*/
696 #if (defined __STDC__ || defined __C99__FUNC__ \
697 || defined __cplusplus || defined _MSC_VER)
698 static void
yy_symbol_value_print(FILE * yyoutput,int yytype,YYSTYPE const * const yyvaluep)699 yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
700 #else
701 static void
702 yy_symbol_value_print (yyoutput, yytype, yyvaluep)
703 FILE *yyoutput;
704 int yytype;
705 YYSTYPE const * const yyvaluep;
706 #endif
707 {
708 if (!yyvaluep)
709 return;
710 # ifdef YYPRINT
711 if (yytype < YYNTOKENS)
712 YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
713 # else
714 YYUSE (yyoutput);
715 # endif
716 switch (yytype)
717 {
718 default:
719 break;
720 }
721 }
722
723
724 /*--------------------------------.
725 | Print this symbol on YYOUTPUT. |
726 `--------------------------------*/
727
728 #if (defined __STDC__ || defined __C99__FUNC__ \
729 || defined __cplusplus || defined _MSC_VER)
730 static void
yy_symbol_print(FILE * yyoutput,int yytype,YYSTYPE const * const yyvaluep)731 yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
732 #else
733 static void
734 yy_symbol_print (yyoutput, yytype, yyvaluep)
735 FILE *yyoutput;
736 int yytype;
737 YYSTYPE const * const yyvaluep;
738 #endif
739 {
740 if (yytype < YYNTOKENS)
741 YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
742 else
743 YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
744
745 yy_symbol_value_print (yyoutput, yytype, yyvaluep);
746 YYFPRINTF (yyoutput, ")");
747 }
748
749 /*------------------------------------------------------------------.
750 | yy_stack_print -- Print the state stack from its BOTTOM up to its |
751 | TOP (included). |
752 `------------------------------------------------------------------*/
753
754 #if (defined __STDC__ || defined __C99__FUNC__ \
755 || defined __cplusplus || defined _MSC_VER)
756 static void
yy_stack_print(yytype_int16 * bottom,yytype_int16 * top)757 yy_stack_print (yytype_int16 *bottom, yytype_int16 *top)
758 #else
759 static void
760 yy_stack_print (bottom, top)
761 yytype_int16 *bottom;
762 yytype_int16 *top;
763 #endif
764 {
765 YYFPRINTF (stderr, "Stack now");
766 for (; bottom <= top; ++bottom)
767 YYFPRINTF (stderr, " %d", *bottom);
768 YYFPRINTF (stderr, "\n");
769 }
770
771 # define YY_STACK_PRINT(Bottom, Top) \
772 do { \
773 if (yydebug) \
774 yy_stack_print ((Bottom), (Top)); \
775 } while (YYID (0))
776
777
778 /*------------------------------------------------.
779 | Report that the YYRULE is going to be reduced. |
780 `------------------------------------------------*/
781
782 #if (defined __STDC__ || defined __C99__FUNC__ \
783 || defined __cplusplus || defined _MSC_VER)
784 static void
yy_reduce_print(YYSTYPE * yyvsp,int yyrule)785 yy_reduce_print (YYSTYPE *yyvsp, int yyrule)
786 #else
787 static void
788 yy_reduce_print (yyvsp, yyrule)
789 YYSTYPE *yyvsp;
790 int yyrule;
791 #endif
792 {
793 int yynrhs = yyr2[yyrule];
794 int yyi;
795 unsigned long int yylno = yyrline[yyrule];
796 YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
797 yyrule - 1, yylno);
798 /* The symbols being reduced. */
799 for (yyi = 0; yyi < yynrhs; yyi++)
800 {
801 fprintf (stderr, " $%d = ", yyi + 1);
802 yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
803 &(yyvsp[(yyi + 1) - (yynrhs)])
804 );
805 fprintf (stderr, "\n");
806 }
807 }
808
809 # define YY_REDUCE_PRINT(Rule) \
810 do { \
811 if (yydebug) \
812 yy_reduce_print (yyvsp, Rule); \
813 } while (YYID (0))
814
815 /* Nonzero means print parse trace. It is left uninitialized so that
816 multiple parsers can coexist. */
817 int yydebug;
818 #else /* !YYDEBUG */
819 # define YYDPRINTF(Args)
820 # define YY_SYMBOL_PRINT(Title, Type, Value, Location)
821 # define YY_STACK_PRINT(Bottom, Top)
822 # define YY_REDUCE_PRINT(Rule)
823 #endif /* !YYDEBUG */
824
825
826 /* YYINITDEPTH -- initial size of the parser's stacks. */
827 #ifndef YYINITDEPTH
828 # define YYINITDEPTH 200
829 #endif
830
831 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
832 if the built-in stack extension method is used).
833
834 Do not make this value too large; the results are undefined if
835 YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
836 evaluated with infinite-precision integer arithmetic. */
837
838 #ifndef YYMAXDEPTH
839 # define YYMAXDEPTH 10000
840 #endif
841
842
843
844 #if YYERROR_VERBOSE
845
846 # ifndef yystrlen
847 # if defined __GLIBC__ && defined _STRING_H
848 # define yystrlen strlen
849 # else
850 /* Return the length of YYSTR. */
851 #if (defined __STDC__ || defined __C99__FUNC__ \
852 || defined __cplusplus || defined _MSC_VER)
853 static YYSIZE_T
yystrlen(const char * yystr)854 yystrlen (const char *yystr)
855 #else
856 static YYSIZE_T
857 yystrlen (yystr)
858 const char *yystr;
859 #endif
860 {
861 YYSIZE_T yylen;
862 for (yylen = 0; yystr[yylen]; yylen++)
863 continue;
864 return yylen;
865 }
866 # endif
867 # endif
868
869 # ifndef yystpcpy
870 # if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
871 # define yystpcpy stpcpy
872 # else
873 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
874 YYDEST. */
875 #if (defined __STDC__ || defined __C99__FUNC__ \
876 || defined __cplusplus || defined _MSC_VER)
877 static char *
yystpcpy(char * yydest,const char * yysrc)878 yystpcpy (char *yydest, const char *yysrc)
879 #else
880 static char *
881 yystpcpy (yydest, yysrc)
882 char *yydest;
883 const char *yysrc;
884 #endif
885 {
886 char *yyd = yydest;
887 const char *yys = yysrc;
888
889 while ((*yyd++ = *yys++) != '\0')
890 continue;
891
892 return yyd - 1;
893 }
894 # endif
895 # endif
896
897 # ifndef yytnamerr
898 /* Copy to YYRES the contents of YYSTR after stripping away unnecessary
899 quotes and backslashes, so that it's suitable for yyerror. The
900 heuristic is that double-quoting is unnecessary unless the string
901 contains an apostrophe, a comma, or backslash (other than
902 backslash-backslash). YYSTR is taken from yytname. If YYRES is
903 null, do not copy; instead, return the length of what the result
904 would have been. */
905 static YYSIZE_T
yytnamerr(char * yyres,const char * yystr)906 yytnamerr (char *yyres, const char *yystr)
907 {
908 if (*yystr == '"')
909 {
910 YYSIZE_T yyn = 0;
911 char const *yyp = yystr;
912
913 for (;;)
914 switch (*++yyp)
915 {
916 case '\'':
917 case ',':
918 goto do_not_strip_quotes;
919
920 case '\\':
921 if (*++yyp != '\\')
922 goto do_not_strip_quotes;
923 /* Fall through. */
924 default:
925 if (yyres)
926 yyres[yyn] = *yyp;
927 yyn++;
928 break;
929
930 case '"':
931 if (yyres)
932 yyres[yyn] = '\0';
933 return yyn;
934 }
935 do_not_strip_quotes: ;
936 }
937
938 if (! yyres)
939 return yystrlen (yystr);
940
941 return yystpcpy (yyres, yystr) - yyres;
942 }
943 # endif
944
945 /* Copy into YYRESULT an error message about the unexpected token
946 YYCHAR while in state YYSTATE. Return the number of bytes copied,
947 including the terminating null byte. If YYRESULT is null, do not
948 copy anything; just return the number of bytes that would be
949 copied. As a special case, return 0 if an ordinary "syntax error"
950 message will do. Return YYSIZE_MAXIMUM if overflow occurs during
951 size calculation. */
952 static YYSIZE_T
yysyntax_error(char * yyresult,int yystate,int yychar)953 yysyntax_error (char *yyresult, int yystate, int yychar)
954 {
955 int yyn = yypact[yystate];
956
957 if (! (YYPACT_NINF < yyn && yyn <= YYLAST))
958 return 0;
959 else
960 {
961 int yytype = YYTRANSLATE (yychar);
962 YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]);
963 YYSIZE_T yysize = yysize0;
964 YYSIZE_T yysize1;
965 int yysize_overflow = 0;
966 enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
967 char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
968 int yyx;
969
970 # if 0
971 /* This is so xgettext sees the translatable formats that are
972 constructed on the fly. */
973 YY_("syntax error, unexpected %s");
974 YY_("syntax error, unexpected %s, expecting %s");
975 YY_("syntax error, unexpected %s, expecting %s or %s");
976 YY_("syntax error, unexpected %s, expecting %s or %s or %s");
977 YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s");
978 # endif
979 char *yyfmt;
980 char const *yyf;
981 static char const yyunexpected[] = "syntax error, unexpected %s";
982 static char const yyexpecting[] = ", expecting %s";
983 static char const yyor[] = " or %s";
984 char yyformat[sizeof yyunexpected
985 + sizeof yyexpecting - 1
986 + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2)
987 * (sizeof yyor - 1))];
988 char const *yyprefix = yyexpecting;
989
990 /* Start YYX at -YYN if negative to avoid negative indexes in
991 YYCHECK. */
992 int yyxbegin = yyn < 0 ? -yyn : 0;
993
994 /* Stay within bounds of both yycheck and yytname. */
995 int yychecklim = YYLAST - yyn + 1;
996 int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
997 int yycount = 1;
998
999 yyarg[0] = yytname[yytype];
1000 yyfmt = yystpcpy (yyformat, yyunexpected);
1001
1002 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
1003 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
1004 {
1005 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
1006 {
1007 yycount = 1;
1008 yysize = yysize0;
1009 yyformat[sizeof yyunexpected - 1] = '\0';
1010 break;
1011 }
1012 yyarg[yycount++] = yytname[yyx];
1013 yysize1 = yysize + yytnamerr (0, yytname[yyx]);
1014 yysize_overflow |= (yysize1 < yysize);
1015 yysize = yysize1;
1016 yyfmt = yystpcpy (yyfmt, yyprefix);
1017 yyprefix = yyor;
1018 }
1019
1020 yyf = YY_(yyformat);
1021 yysize1 = yysize + yystrlen (yyf);
1022 yysize_overflow |= (yysize1 < yysize);
1023 yysize = yysize1;
1024
1025 if (yysize_overflow)
1026 return YYSIZE_MAXIMUM;
1027
1028 if (yyresult)
1029 {
1030 /* Avoid sprintf, as that infringes on the user's name space.
1031 Don't have undefined behavior even if the translation
1032 produced a string with the wrong number of "%s"s. */
1033 char *yyp = yyresult;
1034 int yyi = 0;
1035 while ((*yyp = *yyf) != '\0')
1036 {
1037 if (*yyp == '%' && yyf[1] == 's' && yyi < yycount)
1038 {
1039 yyp += yytnamerr (yyp, yyarg[yyi++]);
1040 yyf += 2;
1041 }
1042 else
1043 {
1044 yyp++;
1045 yyf++;
1046 }
1047 }
1048 }
1049 return yysize;
1050 }
1051 }
1052 #endif /* YYERROR_VERBOSE */
1053
1054
1055 /*-----------------------------------------------.
1056 | Release the memory associated to this symbol. |
1057 `-----------------------------------------------*/
1058
1059 /*ARGSUSED*/
1060 #if (defined __STDC__ || defined __C99__FUNC__ \
1061 || defined __cplusplus || defined _MSC_VER)
1062 static void
yydestruct(const char * yymsg,int yytype,YYSTYPE * yyvaluep)1063 yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
1064 #else
1065 static void
1066 yydestruct (yymsg, yytype, yyvaluep)
1067 const char *yymsg;
1068 int yytype;
1069 YYSTYPE *yyvaluep;
1070 #endif
1071 {
1072 YYUSE (yyvaluep);
1073
1074 if (!yymsg)
1075 yymsg = "Deleting";
1076 YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
1077
1078 switch (yytype)
1079 {
1080
1081 default:
1082 break;
1083 }
1084 }
1085
1086
1087 /* Prevent warnings from -Wmissing-prototypes. */
1088
1089 #ifdef YYPARSE_PARAM
1090 #if defined __STDC__ || defined __cplusplus
1091 int yyparse (void *YYPARSE_PARAM);
1092 #else
1093 int yyparse ();
1094 #endif
1095 #else /* ! YYPARSE_PARAM */
1096 #if defined __STDC__ || defined __cplusplus
1097 int yyparse (void);
1098 #else
1099 int yyparse ();
1100 #endif
1101 #endif /* ! YYPARSE_PARAM */
1102
1103
1104
1105 /* The look-ahead symbol. */
1106 int yychar;
1107
1108 /* The semantic value of the look-ahead symbol. */
1109 YYSTYPE yylval;
1110
1111 /* Number of syntax errors so far. */
1112 int yynerrs;
1113
1114
1115
1116 /*----------.
1117 | yyparse. |
1118 `----------*/
1119
1120 #ifdef YYPARSE_PARAM
1121 #if (defined __STDC__ || defined __C99__FUNC__ \
1122 || defined __cplusplus || defined _MSC_VER)
1123 int
yyparse(void * YYPARSE_PARAM)1124 yyparse (void *YYPARSE_PARAM)
1125 #else
1126 int
1127 yyparse (YYPARSE_PARAM)
1128 void *YYPARSE_PARAM;
1129 #endif
1130 #else /* ! YYPARSE_PARAM */
1131 #if (defined __STDC__ || defined __C99__FUNC__ \
1132 || defined __cplusplus || defined _MSC_VER)
1133 int
1134 yyparse (void)
1135 #else
1136 int
1137 yyparse ()
1138
1139 #endif
1140 #endif
1141 {
1142
1143 int yystate;
1144 int yyn;
1145 int yyresult;
1146 /* Number of tokens to shift before error messages enabled. */
1147 int yyerrstatus;
1148 /* Look-ahead token as an internal (translated) token number. */
1149 int yytoken = 0;
1150 #if YYERROR_VERBOSE
1151 /* Buffer for error messages, and its allocated size. */
1152 char yymsgbuf[128];
1153 char *yymsg = yymsgbuf;
1154 YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
1155 #endif
1156
1157 /* Three stacks and their tools:
1158 `yyss': related to states,
1159 `yyvs': related to semantic values,
1160 `yyls': related to locations.
1161
1162 Refer to the stacks thru separate pointers, to allow yyoverflow
1163 to reallocate them elsewhere. */
1164
1165 /* The state stack. */
1166 yytype_int16 yyssa[YYINITDEPTH];
1167 yytype_int16 *yyss = yyssa;
1168 yytype_int16 *yyssp;
1169
1170 /* The semantic value stack. */
1171 YYSTYPE yyvsa[YYINITDEPTH];
1172 YYSTYPE *yyvs = yyvsa;
1173 YYSTYPE *yyvsp;
1174
1175
1176
1177 #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
1178
1179 YYSIZE_T yystacksize = YYINITDEPTH;
1180
1181 /* The variables used to return semantic value and location from the
1182 action routines. */
1183 YYSTYPE yyval;
1184
1185
1186 /* The number of symbols on the RHS of the reduced rule.
1187 Keep to zero when no symbol should be popped. */
1188 int yylen = 0;
1189
1190 YYDPRINTF ((stderr, "Starting parse\n"));
1191
1192 yystate = 0;
1193 yyerrstatus = 0;
1194 yynerrs = 0;
1195 yychar = YYEMPTY; /* Cause a token to be read. */
1196
1197 /* Initialize stack pointers.
1198 Waste one element of value and location stack
1199 so that they stay on the same level as the state stack.
1200 The wasted elements are never initialized. */
1201
1202 yyssp = yyss;
1203 yyvsp = yyvs;
1204
1205 goto yysetstate;
1206
1207 /*------------------------------------------------------------.
1208 | yynewstate -- Push a new state, which is found in yystate. |
1209 `------------------------------------------------------------*/
1210 yynewstate:
1211 /* In all cases, when you get here, the value and location stacks
1212 have just been pushed. So pushing a state here evens the stacks. */
1213 yyssp++;
1214
1215 yysetstate:
1216 *yyssp = yystate;
1217
1218 if (yyss + yystacksize - 1 <= yyssp)
1219 {
1220 /* Get the current used size of the three stacks, in elements. */
1221 YYSIZE_T yysize = yyssp - yyss + 1;
1222
1223 #ifdef yyoverflow
1224 {
1225 /* Give user a chance to reallocate the stack. Use copies of
1226 these so that the &'s don't force the real ones into
1227 memory. */
1228 YYSTYPE *yyvs1 = yyvs;
1229 yytype_int16 *yyss1 = yyss;
1230
1231
1232 /* Each stack pointer address is followed by the size of the
1233 data in use in that stack, in bytes. This used to be a
1234 conditional around just the two extra args, but that might
1235 be undefined if yyoverflow is a macro. */
1236 yyoverflow (YY_("memory exhausted"),
1237 &yyss1, yysize * sizeof (*yyssp),
1238 &yyvs1, yysize * sizeof (*yyvsp),
1239
1240 &yystacksize);
1241
1242 yyss = yyss1;
1243 yyvs = yyvs1;
1244 }
1245 #else /* no yyoverflow */
1246 # ifndef YYSTACK_RELOCATE
1247 goto yyexhaustedlab;
1248 # else
1249 /* Extend the stack our own way. */
1250 if (YYMAXDEPTH <= yystacksize)
1251 goto yyexhaustedlab;
1252 yystacksize *= 2;
1253 if (YYMAXDEPTH < yystacksize)
1254 yystacksize = YYMAXDEPTH;
1255
1256 {
1257 yytype_int16 *yyss1 = yyss;
1258 union yyalloc *yyptr =
1259 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
1260 if (! yyptr)
1261 goto yyexhaustedlab;
1262 YYSTACK_RELOCATE (yyss);
1263 YYSTACK_RELOCATE (yyvs);
1264
1265 # undef YYSTACK_RELOCATE
1266 if (yyss1 != yyssa)
1267 YYSTACK_FREE (yyss1);
1268 }
1269 # endif
1270 #endif /* no yyoverflow */
1271
1272 yyssp = yyss + yysize - 1;
1273 yyvsp = yyvs + yysize - 1;
1274
1275
1276 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
1277 (unsigned long int) yystacksize));
1278
1279 if (yyss + yystacksize - 1 <= yyssp)
1280 YYABORT;
1281 }
1282
1283 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
1284
1285 goto yybackup;
1286
1287 /*-----------.
1288 | yybackup. |
1289 `-----------*/
1290 yybackup:
1291
1292 /* Do appropriate processing given the current state. Read a
1293 look-ahead token if we need one and don't already have one. */
1294
1295 /* First try to decide what to do without reference to look-ahead token. */
1296 yyn = yypact[yystate];
1297 if (yyn == YYPACT_NINF)
1298 goto yydefault;
1299
1300 /* Not known => get a look-ahead token if don't already have one. */
1301
1302 /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */
1303 if (yychar == YYEMPTY)
1304 {
1305 YYDPRINTF ((stderr, "Reading a token: "));
1306 yychar = YYLEX;
1307 }
1308
1309 if (yychar <= YYEOF)
1310 {
1311 yychar = yytoken = YYEOF;
1312 YYDPRINTF ((stderr, "Now at end of input.\n"));
1313 }
1314 else
1315 {
1316 yytoken = YYTRANSLATE (yychar);
1317 YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
1318 }
1319
1320 /* If the proper action on seeing token YYTOKEN is to reduce or to
1321 detect an error, take that action. */
1322 yyn += yytoken;
1323 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
1324 goto yydefault;
1325 yyn = yytable[yyn];
1326 if (yyn <= 0)
1327 {
1328 if (yyn == 0 || yyn == YYTABLE_NINF)
1329 goto yyerrlab;
1330 yyn = -yyn;
1331 goto yyreduce;
1332 }
1333
1334 if (yyn == YYFINAL)
1335 YYACCEPT;
1336
1337 /* Count tokens shifted since error; after three, turn off error
1338 status. */
1339 if (yyerrstatus)
1340 yyerrstatus--;
1341
1342 /* Shift the look-ahead token. */
1343 YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
1344
1345 /* Discard the shifted token unless it is eof. */
1346 if (yychar != YYEOF)
1347 yychar = YYEMPTY;
1348
1349 yystate = yyn;
1350 *++yyvsp = yylval;
1351
1352 goto yynewstate;
1353
1354
1355 /*-----------------------------------------------------------.
1356 | yydefault -- do the default action for the current state. |
1357 `-----------------------------------------------------------*/
1358 yydefault:
1359 yyn = yydefact[yystate];
1360 if (yyn == 0)
1361 goto yyerrlab;
1362 goto yyreduce;
1363
1364
1365 /*-----------------------------.
1366 | yyreduce -- Do a reduction. |
1367 `-----------------------------*/
1368 yyreduce:
1369 /* yyn is the number of a rule to reduce with. */
1370 yylen = yyr2[yyn];
1371
1372 /* If YYLEN is nonzero, implement the default value of the action:
1373 `$$ = $1'.
1374
1375 Otherwise, the following line sets YYVAL to garbage.
1376 This behavior is undocumented and Bison
1377 users should not rely upon it. Assigning to YYVAL
1378 unconditionally makes the parser a bit smaller, and it avoids a
1379 GCC warning that YYVAL may be used uninitialized. */
1380 yyval = yyvsp[1-yylen];
1381
1382
1383 YY_REDUCE_PRINT (yyn);
1384 switch (yyn)
1385 {
1386 case 2:
1387 #line 62 "glang.y"
1388 { ;}
1389 break;
1390
1391 case 3:
1392 #line 64 "glang.y"
1393 { debug("ident expr"); gGLReader->newIDExpr((yyvsp[(1) - (3)].strPtr)->c_str(), (yyvsp[(3) - (3)].exprPtr)); delete (yyvsp[(1) - (3)].strPtr); delete (yyvsp[(3) - (3)].exprPtr); ;}
1394 break;
1395
1396 case 4:
1397 #line 65 "glang.y"
1398 { debug("deflist..."); gGLReader->newIDExpr((yyvsp[(2) - (4)].strPtr)->c_str(), (yyvsp[(4) - (4)].exprPtr)); delete (yyvsp[(2) - (4)].strPtr); delete (yyvsp[(4) - (4)].exprPtr); ;}
1399 break;
1400
1401 case 5:
1402 #line 68 "glang.y"
1403 { debug("score expr"); (yyval.exprPtr) = gGLReader->newScoreExpr(glangtext);
1404 if (!(yyval.exprPtr)) { glangerror("Error while parsing gmn code"); YYERROR; } ;}
1405 break;
1406
1407 case 6:
1408 #line 70 "glang.y"
1409 { debug("op expr"); (yyval.exprPtr) = gGLReader->newBinaryExpr((yyvsp[(2) - (3)].strPtr)->c_str(),(yyvsp[(1) - (3)].exprPtr),(yyvsp[(3) - (3)].exprPtr)); clean((yyvsp[(1) - (3)].exprPtr),(yyvsp[(2) - (3)].strPtr),(yyvsp[(3) - (3)].exprPtr)); ;}
1410 break;
1411
1412 case 7:
1413 #line 71 "glang.y"
1414 { debug("abstract expr"); (yyval.exprPtr) = gGLReader->newAbstractExpr((yyvsp[(3) - (4)].strPtr)->c_str(),(yyvsp[(2) - (4)].exprPtr),(yyvsp[(4) - (4)].exprPtr)); clean((yyvsp[(2) - (4)].exprPtr),(yyvsp[(3) - (4)].strPtr),(yyvsp[(4) - (4)].exprPtr)); ;}
1415 break;
1416
1417 case 8:
1418 #line 72 "glang.y"
1419 { debug("named expr"); (yyval.exprPtr) = gGLReader->newNamedExpr((yyvsp[(1) - (1)].strPtr)->c_str()); delete (yyvsp[(1) - (1)].strPtr);
1420 if (!(yyval.exprPtr)) { glangerror("Undefined named expression used"); YYERROR; } ;}
1421 break;
1422
1423 case 9:
1424 #line 74 "glang.y"
1425 { debug("group expr"); (yyval.exprPtr) = gGLReader->newGroupExpr((yyvsp[(1) - (1)].exprPtr)); delete (yyvsp[(1) - (1)].exprPtr); ;}
1426 break;
1427
1428 case 10:
1429 #line 77 "glang.y"
1430 { debug("group expr"); (yyval.exprPtr) = (yyvsp[(2) - (3)].exprPtr); ;}
1431 break;
1432
1433 case 11:
1434 #line 79 "glang.y"
1435 { debug("seq"); (yyval.strPtr) = new std::string (glangtext); ;}
1436 break;
1437
1438 case 12:
1439 #line 80 "glang.y"
1440 { debug("par"); (yyval.strPtr) = new std::string (glangtext); ;}
1441 break;
1442
1443 case 13:
1444 #line 81 "glang.y"
1445 { debug("head"); (yyval.strPtr) = new std::string (glangtext); ;}
1446 break;
1447
1448 case 14:
1449 #line 82 "glang.y"
1450 { debug("tail"); (yyval.strPtr) = new std::string (glangtext); ;}
1451 break;
1452
1453 case 15:
1454 #line 83 "glang.y"
1455 { debug("top"); (yyval.strPtr) = new std::string (glangtext); ;}
1456 break;
1457
1458 case 16:
1459 #line 84 "glang.y"
1460 { debug("bottom"); (yyval.strPtr) = new std::string (glangtext); ;}
1461 break;
1462
1463 case 17:
1464 #line 85 "glang.y"
1465 { debug("apply"); (yyval.strPtr) = new std::string (glangtext); ;}
1466 break;
1467
1468 case 18:
1469 #line 87 "glang.y"
1470 { debug("asep"); (yyval.strPtr) = new std::string (glangtext); ;}
1471 break;
1472
1473 case 19:
1474 #line 88 "glang.y"
1475 { debug("name"); (yyval.strPtr) = new std::string (glangtext); ;}
1476 break;
1477
1478
1479 /* Line 1267 of yacc.c. */
1480 #line 1481 "glangparse.cpp"
1481 default: break;
1482 }
1483 YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
1484
1485 YYPOPSTACK (yylen);
1486 yylen = 0;
1487 YY_STACK_PRINT (yyss, yyssp);
1488
1489 *++yyvsp = yyval;
1490
1491
1492 /* Now `shift' the result of the reduction. Determine what state
1493 that goes to, based on the state we popped back to and the rule
1494 number reduced by. */
1495
1496 yyn = yyr1[yyn];
1497
1498 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
1499 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
1500 yystate = yytable[yystate];
1501 else
1502 yystate = yydefgoto[yyn - YYNTOKENS];
1503
1504 goto yynewstate;
1505
1506
1507 /*------------------------------------.
1508 | yyerrlab -- here on detecting error |
1509 `------------------------------------*/
1510 yyerrlab:
1511 /* If not already recovering from an error, report this error. */
1512 if (!yyerrstatus)
1513 {
1514 ++yynerrs;
1515 #if ! YYERROR_VERBOSE
1516 yyerror (YY_("syntax error"));
1517 #else
1518 {
1519 YYSIZE_T yysize = yysyntax_error (0, yystate, yychar);
1520 if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM)
1521 {
1522 YYSIZE_T yyalloc = 2 * yysize;
1523 if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM))
1524 yyalloc = YYSTACK_ALLOC_MAXIMUM;
1525 if (yymsg != yymsgbuf)
1526 YYSTACK_FREE (yymsg);
1527 yymsg = (char *) YYSTACK_ALLOC (yyalloc);
1528 if (yymsg)
1529 yymsg_alloc = yyalloc;
1530 else
1531 {
1532 yymsg = yymsgbuf;
1533 yymsg_alloc = sizeof yymsgbuf;
1534 }
1535 }
1536
1537 if (0 < yysize && yysize <= yymsg_alloc)
1538 {
1539 (void) yysyntax_error (yymsg, yystate, yychar);
1540 yyerror (yymsg);
1541 }
1542 else
1543 {
1544 yyerror (YY_("syntax error"));
1545 if (yysize != 0)
1546 goto yyexhaustedlab;
1547 }
1548 }
1549 #endif
1550 }
1551
1552
1553
1554 if (yyerrstatus == 3)
1555 {
1556 /* If just tried and failed to reuse look-ahead token after an
1557 error, discard it. */
1558
1559 if (yychar <= YYEOF)
1560 {
1561 /* Return failure if at end of input. */
1562 if (yychar == YYEOF)
1563 YYABORT;
1564 }
1565 else
1566 {
1567 yydestruct ("Error: discarding",
1568 yytoken, &yylval);
1569 yychar = YYEMPTY;
1570 }
1571 }
1572
1573 /* Else will try to reuse look-ahead token after shifting the error
1574 token. */
1575 goto yyerrlab1;
1576
1577
1578 /*---------------------------------------------------.
1579 | yyerrorlab -- error raised explicitly by YYERROR. |
1580 `---------------------------------------------------*/
1581 yyerrorlab:
1582
1583 /* Pacify compilers like GCC when the user code never invokes
1584 YYERROR and the label yyerrorlab therefore never appears in user
1585 code. */
1586 if (/*CONSTCOND*/ 0)
1587 goto yyerrorlab;
1588
1589 /* Do not reclaim the symbols of the rule which action triggered
1590 this YYERROR. */
1591 YYPOPSTACK (yylen);
1592 yylen = 0;
1593 YY_STACK_PRINT (yyss, yyssp);
1594 yystate = *yyssp;
1595 goto yyerrlab1;
1596
1597
1598 /*-------------------------------------------------------------.
1599 | yyerrlab1 -- common code for both syntax error and YYERROR. |
1600 `-------------------------------------------------------------*/
1601 yyerrlab1:
1602 yyerrstatus = 3; /* Each real token shifted decrements this. */
1603
1604 for (;;)
1605 {
1606 yyn = yypact[yystate];
1607 if (yyn != YYPACT_NINF)
1608 {
1609 yyn += YYTERROR;
1610 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
1611 {
1612 yyn = yytable[yyn];
1613 if (0 < yyn)
1614 break;
1615 }
1616 }
1617
1618 /* Pop the current state because it cannot handle the error token. */
1619 if (yyssp == yyss)
1620 YYABORT;
1621
1622
1623 yydestruct ("Error: popping",
1624 yystos[yystate], yyvsp);
1625 YYPOPSTACK (1);
1626 yystate = *yyssp;
1627 YY_STACK_PRINT (yyss, yyssp);
1628 }
1629
1630 if (yyn == YYFINAL)
1631 YYACCEPT;
1632
1633 *++yyvsp = yylval;
1634
1635
1636 /* Shift the error token. */
1637 YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
1638
1639 yystate = yyn;
1640 goto yynewstate;
1641
1642
1643 /*-------------------------------------.
1644 | yyacceptlab -- YYACCEPT comes here. |
1645 `-------------------------------------*/
1646 yyacceptlab:
1647 yyresult = 0;
1648 goto yyreturn;
1649
1650 /*-----------------------------------.
1651 | yyabortlab -- YYABORT comes here. |
1652 `-----------------------------------*/
1653 yyabortlab:
1654 yyresult = 1;
1655 goto yyreturn;
1656
1657 #ifndef yyoverflow
1658 /*-------------------------------------------------.
1659 | yyexhaustedlab -- memory exhaustion comes here. |
1660 `-------------------------------------------------*/
1661 yyexhaustedlab:
1662 yyerror (YY_("memory exhausted"));
1663 yyresult = 2;
1664 /* Fall through. */
1665 #endif
1666
1667 yyreturn:
1668 if (yychar != YYEOF && yychar != YYEMPTY)
1669 yydestruct ("Cleanup: discarding lookahead",
1670 yytoken, &yylval);
1671 /* Do not reclaim the symbols of the rule which action triggered
1672 this YYABORT or YYACCEPT. */
1673 YYPOPSTACK (yylen);
1674 YY_STACK_PRINT (yyss, yyssp);
1675 while (yyssp != yyss)
1676 {
1677 yydestruct ("Cleanup: popping",
1678 yystos[*yyssp], yyvsp);
1679 YYPOPSTACK (1);
1680 }
1681 #ifndef yyoverflow
1682 if (yyss != yyssa)
1683 YYSTACK_FREE (yyss);
1684 #endif
1685 #if YYERROR_VERBOSE
1686 if (yymsg != yymsgbuf)
1687 YYSTACK_FREE (yymsg);
1688 #endif
1689 /* Make sure YYID is used. */
1690 return YYID (yyresult);
1691 }
1692
1693
1694 #line 90 "glang.y"
1695
1696
glangwrap()1697 int glangwrap() { return(1); }
1698
glangerror(const char * s)1699 int glangerror(const char* s) {
1700 YY_FLUSH_BUFFER;
1701 return gGLReader->error(s, glanglineno);
1702 return 0;
1703 }
1704
1705
1706