source: liacs/coco/assignment2/gen/y.tab.c@ 75

Last change on this file since 75 was 2, checked in by Rick van der Zwet, 15 years ago

Initial import of data of old repository ('data') worth keeping (e.g. tracking
means of URL access statistics)

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