* lib/Parrot/Pmc2c/MethodEmitter.pm:
[parrot.git] / languages / cola / parser.c
blobbd4ab02723a2f53221d02d7888229e9c9b19fdfe
1 /* A Bison parser, made by GNU Bison 2.3. */
3 /* Skeleton implementation for Bison's Yacc-like parsers in C
5 Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
6 Free Software Foundation, Inc.
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.
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.
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. */
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.
33 This special exception was added by the Free Software Foundation in
34 version 2.2 of Bison. */
36 /* C LALR(1) parser skeleton written by Richard Stallman, by
37 simplifying the original so-called "semantic" parser. */
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. */
46 /* Identify Bison output. */
47 #define YYBISON 1
49 /* Bison version. */
50 #define YYBISON_VERSION "2.3"
52 /* Skeleton name. */
53 #define YYSKELETON_NAME "yacc.c"
55 /* Pure parsers. */
56 #define YYPURE 0
58 /* Using locations. */
59 #define YYLSP_NEEDED 0
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 ASM = 258,
70 ABSTRACT = 259,
71 BOOL = 260,
72 BREAK = 261,
73 BYTE = 262,
74 CHAR = 263,
75 CLASS = 264,
76 CONST = 265,
77 CONTINUE = 266,
78 DOUBLE = 267,
79 DECIMAL = 268,
80 ELSE = 269,
81 EXTERN = 270,
82 FALSE = 271,
83 FLOAT = 272,
84 FOR = 273,
85 GET = 274,
86 GOTO = 275,
87 IF = 276,
88 INT = 277,
89 INTERNAL = 278,
90 LONG = 279,
91 METHOD = 280,
92 MODIFIER = 281,
93 NEW = 282,
94 NAMESPACE = 283,
95 NULLVAL = 284,
96 OUT = 285,
97 OVERRIDE = 286,
98 OBJECT = 287,
99 PRIVATE = 288,
100 PROTECTED = 289,
101 PUBLIC = 290,
102 REF = 291,
103 READONLY = 292,
104 RETURN = 293,
105 SBYTE = 294,
106 SET = 295,
107 SHORT = 296,
108 STRING = 297,
109 STATIC = 298,
110 THIS = 299,
111 TRUE = 300,
112 TYPE = 301,
113 UINT = 302,
114 USHORT = 303,
115 ULONG = 304,
116 USING = 305,
117 VIRTUAL = 306,
118 VOID = 307,
119 WHILE = 308,
120 IDENTIFIER = 309,
121 LITERAL = 310,
122 RANKSPEC = 311,
123 INC = 312,
124 DEC = 313,
125 LOGICAL_AND = 314,
126 LOGICAL_OR = 315,
127 LOGICAL_EQ = 316,
128 LOGICAL_NE = 317,
129 LOGICAL_LTE = 318,
130 LOGICAL_GTE = 319,
131 LEFT_SHIFT = 320,
132 RIGHT_SHIFT = 321,
133 INDEX = 322,
134 UMINUS = 323
136 #endif
137 /* Tokens. */
138 #define ASM 258
139 #define ABSTRACT 259
140 #define BOOL 260
141 #define BREAK 261
142 #define BYTE 262
143 #define CHAR 263
144 #define CLASS 264
145 #define CONST 265
146 #define CONTINUE 266
147 #define DOUBLE 267
148 #define DECIMAL 268
149 #define ELSE 269
150 #define EXTERN 270
151 #define FALSE 271
152 #define FLOAT 272
153 #define FOR 273
154 #define GET 274
155 #define GOTO 275
156 #define IF 276
157 #define INT 277
158 #define INTERNAL 278
159 #define LONG 279
160 #define METHOD 280
161 #define MODIFIER 281
162 #define NEW 282
163 #define NAMESPACE 283
164 #define NULLVAL 284
165 #define OUT 285
166 #define OVERRIDE 286
167 #define OBJECT 287
168 #define PRIVATE 288
169 #define PROTECTED 289
170 #define PUBLIC 290
171 #define REF 291
172 #define READONLY 292
173 #define RETURN 293
174 #define SBYTE 294
175 #define SET 295
176 #define SHORT 296
177 #define STRING 297
178 #define STATIC 298
179 #define THIS 299
180 #define TRUE 300
181 #define TYPE 301
182 #define UINT 302
183 #define USHORT 303
184 #define ULONG 304
185 #define USING 305
186 #define VIRTUAL 306
187 #define VOID 307
188 #define WHILE 308
189 #define IDENTIFIER 309
190 #define LITERAL 310
191 #define RANKSPEC 311
192 #define INC 312
193 #define DEC 313
194 #define LOGICAL_AND 314
195 #define LOGICAL_OR 315
196 #define LOGICAL_EQ 316
197 #define LOGICAL_NE 317
198 #define LOGICAL_LTE 318
199 #define LOGICAL_GTE 319
200 #define LEFT_SHIFT 320
201 #define RIGHT_SHIFT 321
202 #define INDEX 322
203 #define UMINUS 323
208 /* Copy the first part of user declarations. */
209 #line 1 "cola.y"
212 * cola.y
214 * $Id$
216 * Cola compiler for Parrot
218 * Copyright (C) 2002 Melvin Smith <melvin.smith@mindspring.com>
220 * Borrows heavily from Java and C#
221 * Java is a registered trademark of Sun Microsystems
222 * C# is a registered trademark of Microsoft Corporation
224 * The parser. Grammar for Bison.
228 #include <string.h>
229 #include <stdio.h>
230 #include <stdlib.h>
231 #include "cola.h"
233 int yyerror(char *);
234 int yylex();
235 extern char yytext[];
236 long line;
237 int indent;
239 AST *ast_start = NULL;
241 /* Pointers to the builtin type entries in the symbol table */
245 /* Enabling traces. */
246 #ifndef YYDEBUG
247 # define YYDEBUG 0
248 #endif
250 /* Enabling verbose error messages. */
251 #ifdef YYERROR_VERBOSE
252 # undef YYERROR_VERBOSE
253 # define YYERROR_VERBOSE 1
254 #else
255 # define YYERROR_VERBOSE 0
256 #endif
258 /* Enabling the token table. */
259 #ifndef YYTOKEN_TABLE
260 # define YYTOKEN_TABLE 0
261 #endif
263 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
264 typedef union YYSTYPE
265 #line 36 "cola.y"
267 int ival;
268 Symbol * sym;
269 Type * type;
270 AST * ast;
271 void * p;
273 /* Line 187 of yacc.c. */
274 #line 275 "parser.c"
275 YYSTYPE;
276 # define yystype YYSTYPE /* obsolescent; will be withdrawn */
277 # define YYSTYPE_IS_DECLARED 1
278 # define YYSTYPE_IS_TRIVIAL 1
279 #endif
283 /* Copy the second part of user declarations. */
286 /* Line 216 of yacc.c. */
287 #line 288 "parser.c"
289 #ifdef short
290 # undef short
291 #endif
293 #ifdef YYTYPE_UINT8
294 typedef YYTYPE_UINT8 yytype_uint8;
295 #else
296 typedef unsigned char yytype_uint8;
297 #endif
299 #ifdef YYTYPE_INT8
300 typedef YYTYPE_INT8 yytype_int8;
301 #elif (defined __STDC__ || defined __C99__FUNC__ \
302 || defined __cplusplus || defined _MSC_VER)
303 typedef signed char yytype_int8;
304 #else
305 typedef short int yytype_int8;
306 #endif
308 #ifdef YYTYPE_UINT16
309 typedef YYTYPE_UINT16 yytype_uint16;
310 #else
311 typedef unsigned short int yytype_uint16;
312 #endif
314 #ifdef YYTYPE_INT16
315 typedef YYTYPE_INT16 yytype_int16;
316 #else
317 typedef short int yytype_int16;
318 #endif
320 #ifndef YYSIZE_T
321 # ifdef __SIZE_TYPE__
322 # define YYSIZE_T __SIZE_TYPE__
323 # elif defined size_t
324 # define YYSIZE_T size_t
325 # elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \
326 || defined __cplusplus || defined _MSC_VER)
327 # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
328 # define YYSIZE_T size_t
329 # else
330 # define YYSIZE_T unsigned int
331 # endif
332 #endif
334 #define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
336 #ifndef YY_
337 # if YYENABLE_NLS
338 # if ENABLE_NLS
339 # include <libintl.h> /* INFRINGES ON USER NAME SPACE */
340 # define YY_(msgid) dgettext ("bison-runtime", msgid)
341 # endif
342 # endif
343 # ifndef YY_
344 # define YY_(msgid) msgid
345 # endif
346 #endif
348 /* Suppress unused-variable warnings by "using" E. */
349 #if ! defined lint || defined __GNUC__
350 # define YYUSE(e) ((void) (e))
351 #else
352 # define YYUSE(e) /* empty */
353 #endif
355 /* Identity function, used to suppress warnings about constant conditions. */
356 #ifndef lint
357 # define YYID(n) (n)
358 #else
359 #if (defined __STDC__ || defined __C99__FUNC__ \
360 || defined __cplusplus || defined _MSC_VER)
361 static int
362 YYID (int i)
363 #else
364 static int
365 YYID (i)
366 int i;
367 #endif
369 return i;
371 #endif
373 #if ! defined yyoverflow || YYERROR_VERBOSE
375 /* The parser invokes alloca or malloc; define the necessary symbols. */
377 # ifdef YYSTACK_USE_ALLOCA
378 # if YYSTACK_USE_ALLOCA
379 # ifdef __GNUC__
380 # define YYSTACK_ALLOC __builtin_alloca
381 # elif defined __BUILTIN_VA_ARG_INCR
382 # include <alloca.h> /* INFRINGES ON USER NAME SPACE */
383 # elif defined _AIX
384 # define YYSTACK_ALLOC __alloca
385 # elif defined _MSC_VER
386 # include <malloc.h> /* INFRINGES ON USER NAME SPACE */
387 # define alloca _alloca
388 # else
389 # define YYSTACK_ALLOC alloca
390 # if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
391 || defined __cplusplus || defined _MSC_VER)
392 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
393 # ifndef _STDLIB_H
394 # define _STDLIB_H 1
395 # endif
396 # endif
397 # endif
398 # endif
399 # endif
401 # ifdef YYSTACK_ALLOC
402 /* Pacify GCC's `empty if-body' warning. */
403 # define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0))
404 # ifndef YYSTACK_ALLOC_MAXIMUM
405 /* The OS might guarantee only one guard page at the bottom of the stack,
406 and a page size can be as small as 4096 bytes. So we cannot safely
407 invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
408 to allow for a few compiler-allocated temporary stack slots. */
409 # define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
410 # endif
411 # else
412 # define YYSTACK_ALLOC YYMALLOC
413 # define YYSTACK_FREE YYFREE
414 # ifndef YYSTACK_ALLOC_MAXIMUM
415 # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
416 # endif
417 # if (defined __cplusplus && ! defined _STDLIB_H \
418 && ! ((defined YYMALLOC || defined malloc) \
419 && (defined YYFREE || defined free)))
420 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
421 # ifndef _STDLIB_H
422 # define _STDLIB_H 1
423 # endif
424 # endif
425 # ifndef YYMALLOC
426 # define YYMALLOC malloc
427 # if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
428 || defined __cplusplus || defined _MSC_VER)
429 void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
430 # endif
431 # endif
432 # ifndef YYFREE
433 # define YYFREE free
434 # if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
435 || defined __cplusplus || defined _MSC_VER)
436 void free (void *); /* INFRINGES ON USER NAME SPACE */
437 # endif
438 # endif
439 # endif
440 #endif /* ! defined yyoverflow || YYERROR_VERBOSE */
443 #if (! defined yyoverflow \
444 && (! defined __cplusplus \
445 || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
447 /* A type that is properly aligned for any stack member. */
448 union yyalloc
450 yytype_int16 yyss;
451 YYSTYPE yyvs;
454 /* The size of the maximum gap between one aligned stack and the next. */
455 # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
457 /* The size of an array large to enough to hold all stacks, each with
458 N elements. */
459 # define YYSTACK_BYTES(N) \
460 ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
461 + YYSTACK_GAP_MAXIMUM)
463 /* Copy COUNT objects from FROM to TO. The source and destination do
464 not overlap. */
465 # ifndef YYCOPY
466 # if defined __GNUC__ && 1 < __GNUC__
467 # define YYCOPY(To, From, Count) \
468 __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
469 # else
470 # define YYCOPY(To, From, Count) \
471 do \
473 YYSIZE_T yyi; \
474 for (yyi = 0; yyi < (Count); yyi++) \
475 (To)[yyi] = (From)[yyi]; \
477 while (YYID (0))
478 # endif
479 # endif
481 /* Relocate STACK from its old location to the new one. The
482 local variables YYSIZE and YYSTACKSIZE give the old and new number of
483 elements in the stack, and YYPTR gives the new location of the
484 stack. Advance YYPTR to a properly aligned location for the next
485 stack. */
486 # define YYSTACK_RELOCATE(Stack) \
487 do \
489 YYSIZE_T yynewbytes; \
490 YYCOPY (&yyptr->Stack, Stack, yysize); \
491 Stack = &yyptr->Stack; \
492 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
493 yyptr += yynewbytes / sizeof (*yyptr); \
495 while (YYID (0))
497 #endif
499 /* YYFINAL -- State number of the termination state. */
500 #define YYFINAL 3
501 /* YYLAST -- Last index in YYTABLE. */
502 #define YYLAST 479
504 /* YYNTOKENS -- Number of terminals. */
505 #define YYNTOKENS 93
506 /* YYNNTS -- Number of nonterminals. */
507 #define YYNNTS 80
508 /* YYNRULES -- Number of rules. */
509 #define YYNRULES 165
510 /* YYNRULES -- Number of states. */
511 #define YYNSTATES 269
513 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
514 #define YYUNDEFTOK 2
515 #define YYMAXUTOK 323
517 #define YYTRANSLATE(YYX) \
518 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
520 /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
521 static const yytype_uint8 yytranslate[] =
523 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
524 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
525 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
526 2, 2, 2, 83, 2, 2, 2, 86, 88, 2,
527 74, 81, 70, 69, 80, 68, 77, 71, 2, 2,
528 2, 2, 2, 2, 2, 2, 2, 2, 82, 78,
529 91, 72, 92, 87, 2, 2, 2, 2, 2, 2,
530 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
531 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
532 2, 75, 2, 85, 89, 2, 2, 2, 2, 2,
533 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
534 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
535 2, 2, 2, 76, 90, 79, 84, 2, 2, 2,
536 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
537 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
538 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
539 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
540 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
541 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
542 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
543 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
544 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
545 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
546 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
547 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
548 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
549 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
550 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
551 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
552 35, 36, 37, 38, 39, 40, 41, 42, 43, 44,
553 45, 46, 47, 48, 49, 50, 51, 52, 53, 54,
554 55, 56, 57, 58, 59, 60, 61, 62, 63, 64,
555 65, 66, 67, 73
558 #if YYDEBUG
559 /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
560 YYRHS. */
561 static const yytype_uint16 yyprhs[] =
563 0, 0, 3, 4, 6, 10, 11, 14, 20, 24,
564 25, 28, 31, 33, 37, 42, 43, 46, 48, 50,
565 55, 56, 58, 61, 63, 65, 67, 69, 71, 73,
566 77, 80, 81, 84, 86, 88, 91, 98, 101, 106,
567 108, 112, 116, 118, 121, 128, 135, 136, 138, 140,
568 144, 147, 149, 154, 155, 157, 159, 161, 163, 165,
569 167, 169, 171, 173, 175, 176, 178, 181, 185, 188,
570 191, 194, 198, 202, 205, 211, 213, 217, 218, 220,
571 222, 224, 226, 234, 240, 242, 244, 250, 260, 262,
572 264, 266, 268, 270, 272, 274, 276, 278, 281, 283,
573 286, 288, 290, 292, 294, 296, 298, 302, 305, 308,
574 311, 314, 316, 318, 320, 322, 324, 328, 330, 332,
575 334, 336, 338, 340, 342, 345, 348, 351, 354, 356,
576 358, 363, 365, 370, 372, 378, 380, 384, 388, 392,
577 394, 398, 402, 404, 410, 412, 416, 418, 422, 424,
578 428, 430, 434, 436, 440, 442, 444, 446, 448, 450,
579 454, 456, 460, 464, 466, 470
582 /* YYRHS -- A `-1'-separated list of the rules' RHS. */
583 static const yytype_int16 yyrhs[] =
585 95, 0, -1, -1, 78, -1, 96, 98, 103, -1,
586 -1, 96, 97, -1, 50, 54, 72, 54, 78, -1,
587 50, 54, 78, -1, -1, 100, 102, -1, 28, 101,
588 -1, 54, -1, 101, 77, 54, -1, 76, 96, 103,
589 79, -1, -1, 103, 104, -1, 99, -1, 105, -1,
590 106, 110, 109, 94, -1, -1, 107, -1, 107, 108,
591 -1, 108, -1, 35, -1, 33, -1, 34, -1, 43,
592 -1, 51, -1, 76, 111, 79, -1, 9, 54, -1,
593 -1, 111, 112, -1, 115, -1, 118, -1, 114, 78,
594 -1, 10, 141, 54, 72, 55, 78, -1, 141, 116,
595 -1, 106, 141, 116, 78, -1, 117, -1, 116, 80,
596 117, -1, 54, 72, 152, -1, 54, -1, 119, 123,
597 -1, 106, 141, 54, 74, 120, 81, -1, 106, 52,
598 54, 74, 120, 81, -1, -1, 121, -1, 122, -1,
599 121, 80, 122, -1, 141, 54, -1, 124, -1, 76,
600 125, 128, 79, -1, -1, 124, -1, 130, -1, 136,
601 -1, 138, -1, 131, -1, 132, -1, 133, -1, 126,
602 -1, 113, -1, 129, -1, -1, 127, -1, 128, 127,
603 -1, 54, 82, 127, -1, 146, 78, -1, 6, 78,
604 -1, 11, 78, -1, 20, 54, 78, -1, 38, 152,
605 78, -1, 38, 78, -1, 3, 74, 55, 81, 78,
606 -1, 135, -1, 134, 80, 135, -1, -1, 152, -1,
607 36, -1, 30, -1, 137, -1, 21, 74, 153, 81,
608 126, 14, 126, -1, 21, 74, 153, 81, 126, -1,
609 139, -1, 140, -1, 53, 74, 153, 81, 126, -1,
610 18, 74, 146, 78, 153, 78, 146, 81, 126, -1,
611 101, -1, 142, -1, 144, -1, 5, -1, 42, -1,
612 17, -1, 143, -1, 22, -1, 7, -1, 141, 145,
613 -1, 56, -1, 145, 56, -1, 156, -1, 147, -1,
614 150, -1, 151, -1, 148, -1, 149, -1, 155, 72,
615 152, -1, 57, 155, -1, 58, 155, -1, 154, 57,
616 -1, 154, 58, -1, 163, -1, 147, -1, 152, -1,
617 55, -1, 54, -1, 74, 152, 81, -1, 158, -1,
618 156, -1, 150, -1, 151, -1, 159, -1, 157, -1,
619 154, -1, 69, 155, -1, 68, 155, -1, 83, 155,
620 -1, 84, 155, -1, 148, -1, 149, -1, 154, 74,
621 134, 81, -1, 101, -1, 154, 75, 152, 85, -1,
622 160, -1, 27, 141, 74, 134, 81, -1, 155, -1,
623 161, 70, 155, -1, 161, 71, 155, -1, 161, 86,
624 155, -1, 161, -1, 162, 69, 161, -1, 162, 68,
625 161, -1, 165, -1, 165, 87, 152, 82, 152, -1,
626 168, -1, 164, 59, 168, -1, 164, -1, 165, 60,
627 164, -1, 171, -1, 166, 88, 171, -1, 166, -1,
628 167, 89, 166, -1, 167, -1, 168, 90, 167, -1,
629 91, -1, 92, -1, 63, -1, 64, -1, 172, -1,
630 170, 169, 172, -1, 170, -1, 171, 61, 170, -1,
631 171, 62, 170, -1, 162, -1, 172, 65, 162, -1,
632 172, 66, 162, -1
635 /* YYRLINE[YYN] -- source line where rule number YYN was defined. */
636 static const yytype_uint16 yyrline[] =
638 0, 110, 110, 111, 115, 125, 126, 133, 135, 143,
639 147, 156, 175, 177, 185, 194, 196, 205, 206, 210,
640 221, 222, 226, 228, 232, 234, 236, 238, 240, 245,
641 250, 267, 268, 276, 277, 292, 294, 310, 329, 348,
642 349, 357, 368, 380, 388, 410, 437, 438, 447, 448,
643 456, 478, 483, 496, 500, 502, 504, 506, 508, 510,
644 512, 517, 518, 520, 526, 527, 529, 537, 542, 547,
645 549, 551, 560, 562, 567, 572, 573, 581, 582, 584,
646 586, 591, 595, 600, 607, 608, 612, 619, 631, 636,
647 637, 641, 643, 645, 647, 651, 653, 658, 668, 676,
648 686, 687, 688, 689, 690, 691, 695, 709, 717, 725,
649 733, 741, 748, 757, 761, 768, 777, 781, 782, 783,
650 784, 785, 786, 791, 793, 795, 797, 799, 801, 802,
651 806, 820, 829, 840, 848, 859, 860, 864, 868, 875,
652 876, 880, 887, 888, 896, 897, 904, 905, 912, 913,
653 920, 921, 928, 929, 936, 938, 940, 942, 947, 948,
654 956, 957, 962, 970, 971, 975
656 #endif
658 #if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
659 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
660 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
661 static const char *const yytname[] =
663 "$end", "error", "$undefined", "ASM", "ABSTRACT", "BOOL", "BREAK",
664 "BYTE", "CHAR", "CLASS", "CONST", "CONTINUE", "DOUBLE", "DECIMAL",
665 "ELSE", "EXTERN", "FALSE", "FLOAT", "FOR", "GET", "GOTO", "IF", "INT",
666 "INTERNAL", "LONG", "METHOD", "MODIFIER", "NEW", "NAMESPACE", "NULLVAL",
667 "OUT", "OVERRIDE", "OBJECT", "PRIVATE", "PROTECTED", "PUBLIC", "REF",
668 "READONLY", "RETURN", "SBYTE", "SET", "SHORT", "STRING", "STATIC",
669 "THIS", "TRUE", "TYPE", "UINT", "USHORT", "ULONG", "USING", "VIRTUAL",
670 "VOID", "WHILE", "IDENTIFIER", "LITERAL", "RANKSPEC", "INC", "DEC",
671 "LOGICAL_AND", "LOGICAL_OR", "LOGICAL_EQ", "LOGICAL_NE", "LOGICAL_LTE",
672 "LOGICAL_GTE", "LEFT_SHIFT", "RIGHT_SHIFT", "INDEX", "'-'", "'+'", "'*'",
673 "'/'", "'='", "UMINUS", "'('", "'['", "'{'", "'.'", "';'", "'}'", "','",
674 "')'", "':'", "'!'", "'~'", "']'", "'%'", "'?'", "'&'", "'^'", "'|'",
675 "'<'", "'>'", "$accept", "optional_semi", "compilation_unit",
676 "using_directives", "using_directive", "attribute_list",
677 "namespace_decl", "namespace_scope_start", "qualified_name",
678 "namespace_body", "namespace_member_decls", "namespace_member_decl",
679 "class_decl", "opt_modifiers", "modifiers", "modifier", "class_body",
680 "class_scope_start", "class_member_decl_list", "class_member_decl",
681 "decl_statement", "local_var_decl", "field_decl", "var_declarators",
682 "var_declarator", "method_decl", "method_header", "formal_param_list",
683 "fixed_params", "fixed_param", "method_body", "block", "block_scope",
684 "embedded_statement", "statement", "statement_list", "labeled_statement",
685 "expr_statement", "jump_statement", "return_statement", "asm_block",
686 "arg_list", "arg", "selection_statement", "if_statement",
687 "iteration_statement", "while_statement", "for_statement", "type",
688 "predefined_type", "integral_type", "array_type", "rank_specifiers",
689 "statement_expr", "assignment", "pre_inc_expr", "pre_dec_expr",
690 "post_inc_expr", "post_dec_expr", "expr", "boolean_expr", "primary_expr",
691 "unary_expr", "method_call", "member_access", "element_access",
692 "new_expr", "new_object_expr", "mult_expr", "add_expr",
693 "conditional_expr", "conditional_and_expr", "conditional_or_expr",
694 "and_expr", "exclusive_or_expr", "inclusive_or_expr", "relational_op",
695 "relational_expr", "equality_expr", "shift_expr", 0
697 #endif
699 # ifdef YYPRINT
700 /* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
701 token YYLEX-NUM. */
702 static const yytype_uint16 yytoknum[] =
704 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
705 265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
706 275, 276, 277, 278, 279, 280, 281, 282, 283, 284,
707 285, 286, 287, 288, 289, 290, 291, 292, 293, 294,
708 295, 296, 297, 298, 299, 300, 301, 302, 303, 304,
709 305, 306, 307, 308, 309, 310, 311, 312, 313, 314,
710 315, 316, 317, 318, 319, 320, 321, 322, 45, 43,
711 42, 47, 61, 323, 40, 91, 123, 46, 59, 125,
712 44, 41, 58, 33, 126, 93, 37, 63, 38, 94,
713 124, 60, 62
715 # endif
717 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
718 static const yytype_uint8 yyr1[] =
720 0, 93, 94, 94, 95, 96, 96, 97, 97, 98,
721 99, 100, 101, 101, 102, 103, 103, 104, 104, 105,
722 106, 106, 107, 107, 108, 108, 108, 108, 108, 109,
723 110, 111, 111, 112, 112, 113, 113, 114, 115, 116,
724 116, 117, 117, 118, 119, 119, 120, 120, 121, 121,
725 122, 123, 124, 125, 126, 126, 126, 126, 126, 126,
726 126, 127, 127, 127, 128, 128, 128, 129, 130, 131,
727 131, 131, 132, 132, 133, 134, 134, 135, 135, 135,
728 135, 136, 137, 137, 138, 138, 139, 140, 141, 141,
729 141, 142, 142, 142, 142, 143, 143, 144, 145, 145,
730 146, 146, 146, 146, 146, 146, 147, 148, 149, 150,
731 151, 152, 152, 153, 154, 154, 154, 154, 154, 154,
732 154, 154, 154, 155, 155, 155, 155, 155, 155, 155,
733 156, 157, 158, 159, 160, 161, 161, 161, 161, 162,
734 162, 162, 163, 163, 164, 164, 165, 165, 166, 166,
735 167, 167, 168, 168, 169, 169, 169, 169, 170, 170,
736 171, 171, 171, 172, 172, 172
739 /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
740 static const yytype_uint8 yyr2[] =
742 0, 2, 0, 1, 3, 0, 2, 5, 3, 0,
743 2, 2, 1, 3, 4, 0, 2, 1, 1, 4,
744 0, 1, 2, 1, 1, 1, 1, 1, 1, 3,
745 2, 0, 2, 1, 1, 2, 6, 2, 4, 1,
746 3, 3, 1, 2, 6, 6, 0, 1, 1, 3,
747 2, 1, 4, 0, 1, 1, 1, 1, 1, 1,
748 1, 1, 1, 1, 0, 1, 2, 3, 2, 2,
749 2, 3, 3, 2, 5, 1, 3, 0, 1, 1,
750 1, 1, 7, 5, 1, 1, 5, 9, 1, 1,
751 1, 1, 1, 1, 1, 1, 1, 2, 1, 2,
752 1, 1, 1, 1, 1, 1, 3, 2, 2, 2,
753 2, 1, 1, 1, 1, 1, 3, 1, 1, 1,
754 1, 1, 1, 1, 2, 2, 2, 2, 1, 1,
755 4, 1, 4, 1, 5, 1, 3, 3, 3, 1,
756 3, 3, 1, 5, 1, 3, 1, 3, 1, 3,
757 1, 3, 1, 3, 1, 1, 1, 1, 1, 3,
758 1, 3, 3, 1, 3, 3
761 /* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
762 STATE-NUM when YYTABLE doesn't specify something else to do. Zero
763 means the default is an error. */
764 static const yytype_uint8 yydefact[] =
766 5, 0, 9, 1, 0, 6, 15, 0, 4, 0,
767 8, 0, 25, 26, 24, 27, 28, 17, 0, 16,
768 18, 0, 21, 23, 0, 12, 11, 5, 10, 0,
769 0, 22, 7, 0, 15, 30, 31, 2, 13, 20,
770 20, 3, 19, 14, 29, 0, 32, 33, 34, 0,
771 91, 96, 93, 95, 92, 0, 88, 0, 89, 94,
772 90, 53, 43, 51, 0, 42, 98, 0, 39, 97,
773 64, 46, 0, 46, 38, 0, 99, 0, 0, 0,
774 0, 0, 0, 0, 0, 0, 0, 12, 114, 0,
775 0, 0, 0, 0, 0, 0, 131, 62, 0, 54,
776 61, 65, 0, 63, 55, 58, 59, 60, 56, 81,
777 57, 84, 85, 0, 0, 101, 104, 105, 119, 120,
778 123, 0, 118, 122, 117, 121, 133, 0, 47, 48,
779 0, 12, 131, 112, 128, 129, 119, 120, 41, 135,
780 118, 139, 163, 111, 146, 142, 150, 152, 144, 160,
781 148, 158, 0, 42, 40, 0, 69, 0, 70, 0,
782 0, 0, 0, 73, 0, 0, 0, 107, 108, 125,
783 124, 0, 126, 127, 35, 52, 66, 37, 68, 109,
784 110, 77, 0, 0, 45, 0, 50, 0, 0, 0,
785 0, 0, 0, 0, 0, 0, 0, 0, 156, 157,
786 154, 155, 0, 0, 0, 0, 0, 44, 0, 0,
787 0, 71, 113, 0, 77, 72, 0, 67, 116, 80,
788 79, 0, 75, 78, 0, 106, 49, 136, 137, 138,
789 135, 141, 140, 145, 147, 0, 149, 151, 153, 159,
790 161, 162, 164, 165, 0, 0, 0, 0, 0, 0,
791 77, 130, 132, 0, 74, 0, 0, 83, 134, 86,
792 76, 143, 36, 0, 0, 0, 82, 0, 87
795 /* YYDEFGOTO[NTERM-NUM]. */
796 static const yytype_int16 yydefgoto[] =
798 -1, 42, 1, 2, 5, 6, 17, 18, 132, 28,
799 8, 19, 20, 21, 22, 23, 37, 30, 40, 46,
800 97, 98, 47, 67, 68, 48, 49, 127, 128, 129,
801 62, 99, 70, 100, 101, 102, 103, 104, 105, 106,
802 107, 221, 222, 108, 109, 110, 111, 112, 113, 58,
803 59, 60, 69, 114, 133, 134, 135, 136, 137, 212,
804 213, 120, 139, 140, 123, 124, 125, 126, 141, 142,
805 143, 144, 145, 146, 147, 148, 202, 149, 150, 151
808 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
809 STATE-NUM. */
810 #define YYPACT_NINF -185
811 static const yytype_int16 yypact[] =
813 -185, 7, -21, -185, 20, -185, -185, 4, 44, 27,
814 -185, 31, -185, -185, -185, -185, -185, -185, -38, -185,
815 -185, 25, 130, -185, 10, -185, -19, -185, -185, 84,
816 66, -185, -185, 101, -21, -185, -185, 81, -185, -20,
817 111, -185, -185, -185, -185, 163, -185, -185, -185, 93,
818 -185, -185, -185, -185, -185, 117, -19, 46, -185, -185,
819 -185, -185, -185, -185, 100, 37, -185, 32, -185, 119,
820 313, 245, 290, 245, -185, 124, -185, 109, 108, 245,
821 110, 118, 137, 126, 245, 395, 127, 128, -185, 290,
822 290, 290, 290, 290, 290, 290, -28, -185, 131, -185,
823 -185, -185, 253, -185, -185, -185, -185, -185, -185, -185,
824 -185, -185, -185, 59, 135, -185, 134, 144, -33, -31,
825 33, 147, -12, -185, -185, -185, -185, 140, 142, -185,
826 60, -185, -19, -185, -185, -185, -185, -185, -185, 147,
827 -185, -15, 29, -185, 164, -54, 136, 138, 146, -52,
828 -45, 38, 145, 153, -185, 175, -185, 97, -185, 290,
829 162, 290, -47, -185, 165, 290, 313, -185, -185, -185,
830 -185, 160, -185, -185, -185, -185, -185, 166, -185, -185,
831 -185, 349, 290, 290, -185, 245, -185, 290, 290, 290,
832 290, 290, 290, 290, 290, 290, 290, 290, -185, -185,
833 -185, -185, 290, 290, 290, 290, 290, -185, 161, 172,
834 167, -185, -185, 168, 349, -185, 174, -185, -185, -185,
835 -185, 48, -185, -185, 176, -185, -185, -185, -185, -185,
836 -185, -15, -15, 146, 164, 183, -45, 136, 138, 38,
837 -52, -52, 29, 29, 188, 213, 290, 372, 67, 372,
838 349, -185, -185, 290, -185, 191, 194, 262, -185, -185,
839 -185, -185, -185, 290, 372, 196, -185, 372, -185
842 /* YYPGOTO[NTERM-NUM]. */
843 static const yytype_int16 yypgoto[] =
845 -185, -185, -185, 251, -185, -185, -185, -185, -9, -185,
846 247, -185, -185, 239, -185, 260, -185, -185, -185, -185,
847 -185, -185, -185, 170, 209, -185, -185, 212, -185, 103,
848 -185, 237, -185, -184, -98, -185, -185, -185, -185, -185,
849 -185, 75, 40, -185, -185, -185, -185, -185, -27, -185,
850 -185, -185, -185, -158, -65, -60, -35, -29, -16, -42,
851 -162, -185, -70, -10, -185, -185, -185, -185, -30, -39,
852 -185, 99, -185, 98, 96, 104, -185, -8, 102, 107
855 /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
856 positive, shift that token. If negative, reduce the rule which
857 number is the opposite. If zero, do what YYDEFACT says.
858 If YYTABLE_NINF, syntax error. */
859 #define YYTABLE_NINF -130
860 static const yytype_int16 yytable[] =
862 121, 210, 26, 216, 176, 115, 193, 3, 11, 66,
863 116, 198, 199, 12, 13, 14, 203, 204, 57, 167,
864 168, 169, 170, 15, 172, 173, -88, 214, -88, 4,
865 138, 16, 121, 194, 29, 117, 56, 115, 27, 200,
866 201, 118, 116, 164, 130, -102, 130, -103, -102, 33,
867 -103, 171, 157, -20, 119, 187, 188, 162, 33, 43,
868 122, 96, 56, 257, 56, 259, -100, 117, 217, -100,
869 56, 189, 11, 118, 7, 56, 9, 12, 13, 14,
870 266, 24, 10, 268, 256, 25, 119, 15, 32, 121,
871 179, 180, 122, 96, 115, 16, 121, 190, 191, 116,
872 65, 115, 66, 205, 206, 265, 116, 181, 182, 72,
873 74, 73, 75, 153, 186, 66, 66, 227, 228, 229,
874 230, 230, 230, 230, 117, 230, 230, 230, 250, 251,
875 118, 117, 230, 230, 230, 230, 230, 118, 35, 223,
876 224, 225, 36, 119, 12, 13, 14, 250, 258, 122,
877 119, 209, 235, 66, 15, 38, 122, 96, 130, 41,
878 231, 232, 16, 12, 13, 14, 242, 243, 50, 61,
879 51, 64, 223, 15, 71, 76, 56, 121, 153, 121,
880 52, 16, 115, 155, 115, 53, 156, 116, 158, 116,
881 44, 160, 159, 121, 121, 240, 241, 121, 115, 115,
882 161, 165, 115, 116, 116, 54, -128, 116, 223, 174,
883 166, 261, 117, 178, 117, 55, -129, 25, 118, 183,
884 118, 184, 185, 192, 195, 72, 207, 196, 117, 117,
885 208, 119, 117, 119, 118, 118, 197, 122, 118, 122,
886 211, 218, 244, 215, 245, 246, 75, 119, 119, 247,
887 50, 119, 51, 122, 122, 249, 77, 122, 50, 78,
888 51, 252, 52, 79, 80, 253, 254, 53, 255, 262,
889 52, 81, 263, 82, 83, 53, 264, 267, 34, 45,
890 84, 39, 31, 177, 154, 152, 63, 54, 226, 248,
891 260, 85, 234, 238, 237, 54, 233, 236, 0, 25,
892 0, 0, 0, 0, 0, 0, 86, 87, 88, 239,
893 89, 90, 0, 0, 0, 0, 77, 84, 50, 78,
894 51, 91, 92, 79, 80, 0, 0, 93, 0, 61,
895 52, 81, 175, 82, 83, 53, 94, 95, 0, 0,
896 84, 0, 0, 0, 131, 88, 0, 89, 90, 0,
897 0, 85, 0, 0, 0, 54, 0, 0, 91, 92,
898 0, 0, 0, 0, 93, 0, 86, 87, 88, 0,
899 89, 90, 0, 94, 95, 77, 84, 0, 78, 219,
900 0, 91, 92, 80, 0, 220, 0, 93, 0, 61,
901 81, 0, 82, 83, 0, 0, 94, 95, 0, 84,
902 0, 0, 0, 131, 88, 0, 89, 90, 0, 0,
903 85, 0, 0, 0, 0, 0, 0, 91, 92, 0,
904 0, 0, 84, 93, 0, 86, 131, 88, 0, 89,
905 90, 0, 94, 95, 0, 0, 0, 0, 0, 0,
906 91, 92, 0, 0, 0, 0, 93, 0, 61, 131,
907 88, 0, 89, 90, 0, 94, 95, 0, 0, 0,
908 0, 0, 0, 91, 92, 0, 0, 0, 0, 93,
909 0, 0, 0, 163, 0, 0, 0, 0, 94, 95
912 static const yytype_int16 yycheck[] =
914 70, 159, 11, 165, 102, 70, 60, 0, 28, 56,
915 70, 63, 64, 33, 34, 35, 61, 62, 45, 89,
916 90, 91, 92, 43, 94, 95, 54, 74, 56, 50,
917 72, 51, 102, 87, 9, 70, 45, 102, 76, 91,
918 92, 70, 102, 85, 71, 78, 73, 78, 81, 77,
919 81, 93, 79, 9, 70, 70, 71, 84, 77, 79,
920 70, 70, 71, 247, 73, 249, 78, 102, 166, 81,
921 79, 86, 28, 102, 54, 84, 72, 33, 34, 35,
922 264, 54, 78, 267, 246, 54, 102, 43, 78, 159,
923 57, 58, 102, 102, 159, 51, 166, 68, 69, 159,
924 54, 166, 56, 65, 66, 263, 166, 74, 75, 72,
925 78, 74, 80, 54, 54, 56, 56, 187, 188, 189,
926 190, 191, 192, 193, 159, 195, 196, 197, 80, 81,
927 159, 166, 202, 203, 204, 205, 206, 166, 54, 181,
928 182, 183, 76, 159, 33, 34, 35, 80, 81, 159,
929 166, 54, 194, 56, 43, 54, 166, 166, 185, 78,
930 190, 191, 51, 33, 34, 35, 205, 206, 5, 76,
931 7, 54, 214, 43, 74, 56, 185, 247, 54, 249,
932 17, 51, 247, 74, 249, 22, 78, 247, 78, 249,
933 79, 54, 74, 263, 264, 203, 204, 267, 263, 264,
934 74, 74, 267, 263, 264, 42, 72, 267, 250, 78,
935 82, 253, 247, 78, 249, 52, 72, 54, 247, 72,
936 249, 81, 80, 59, 88, 72, 81, 89, 263, 264,
937 55, 247, 267, 249, 263, 264, 90, 247, 267, 249,
938 78, 81, 81, 78, 72, 78, 80, 263, 264, 81,
939 5, 267, 7, 263, 264, 81, 3, 267, 5, 6,
940 7, 85, 17, 10, 11, 82, 78, 22, 55, 78,
941 17, 18, 78, 20, 21, 22, 14, 81, 27, 40,
942 27, 34, 22, 113, 75, 73, 49, 42, 185, 214,
943 250, 38, 193, 197, 196, 42, 192, 195, -1, 54,
944 -1, -1, -1, -1, -1, -1, 53, 54, 55, 202,
945 57, 58, -1, -1, -1, -1, 3, 27, 5, 6,
946 7, 68, 69, 10, 11, -1, -1, 74, -1, 76,
947 17, 18, 79, 20, 21, 22, 83, 84, -1, -1,
948 27, -1, -1, -1, 54, 55, -1, 57, 58, -1,
949 -1, 38, -1, -1, -1, 42, -1, -1, 68, 69,
950 -1, -1, -1, -1, 74, -1, 53, 54, 55, -1,
951 57, 58, -1, 83, 84, 3, 27, -1, 6, 30,
952 -1, 68, 69, 11, -1, 36, -1, 74, -1, 76,
953 18, -1, 20, 21, -1, -1, 83, 84, -1, 27,
954 -1, -1, -1, 54, 55, -1, 57, 58, -1, -1,
955 38, -1, -1, -1, -1, -1, -1, 68, 69, -1,
956 -1, -1, 27, 74, -1, 53, 54, 55, -1, 57,
957 58, -1, 83, 84, -1, -1, -1, -1, -1, -1,
958 68, 69, -1, -1, -1, -1, 74, -1, 76, 54,
959 55, -1, 57, 58, -1, 83, 84, -1, -1, -1,
960 -1, -1, -1, 68, 69, -1, -1, -1, -1, 74,
961 -1, -1, -1, 78, -1, -1, -1, -1, 83, 84
964 /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
965 symbol of state STATE-NUM. */
966 static const yytype_uint8 yystos[] =
968 0, 95, 96, 0, 50, 97, 98, 54, 103, 72,
969 78, 28, 33, 34, 35, 43, 51, 99, 100, 104,
970 105, 106, 107, 108, 54, 54, 101, 76, 102, 9,
971 110, 108, 78, 77, 96, 54, 76, 109, 54, 103,
972 111, 78, 94, 79, 79, 106, 112, 115, 118, 119,
973 5, 7, 17, 22, 42, 52, 101, 141, 142, 143,
974 144, 76, 123, 124, 54, 54, 56, 116, 117, 145,
975 125, 74, 72, 74, 78, 80, 56, 3, 6, 10,
976 11, 18, 20, 21, 27, 38, 53, 54, 55, 57,
977 58, 68, 69, 74, 83, 84, 101, 113, 114, 124,
978 126, 127, 128, 129, 130, 131, 132, 133, 136, 137,
979 138, 139, 140, 141, 146, 147, 148, 149, 150, 151,
980 154, 155, 156, 157, 158, 159, 160, 120, 121, 122,
981 141, 54, 101, 147, 148, 149, 150, 151, 152, 155,
982 156, 161, 162, 163, 164, 165, 166, 167, 168, 170,
983 171, 172, 120, 54, 117, 74, 78, 141, 78, 74,
984 54, 74, 141, 78, 152, 74, 82, 155, 155, 155,
985 155, 152, 155, 155, 78, 79, 127, 116, 78, 57,
986 58, 74, 75, 72, 81, 80, 54, 70, 71, 86,
987 68, 69, 59, 60, 87, 88, 89, 90, 63, 64,
988 91, 92, 169, 61, 62, 65, 66, 81, 55, 54,
989 146, 78, 152, 153, 74, 78, 153, 127, 81, 30,
990 36, 134, 135, 152, 152, 152, 122, 155, 155, 155,
991 155, 161, 161, 168, 164, 152, 171, 166, 167, 172,
992 170, 170, 162, 162, 81, 72, 78, 81, 134, 81,
993 80, 81, 85, 82, 78, 55, 153, 126, 81, 126,
994 135, 152, 78, 78, 14, 146, 126, 81, 126
997 #define yyerrok (yyerrstatus = 0)
998 #define yyclearin (yychar = YYEMPTY)
999 #define YYEMPTY (-2)
1000 #define YYEOF 0
1002 #define YYACCEPT goto yyacceptlab
1003 #define YYABORT goto yyabortlab
1004 #define YYERROR goto yyerrorlab
1007 /* Like YYERROR except do call yyerror. This remains here temporarily
1008 to ease the transition to the new meaning of YYERROR, for GCC.
1009 Once GCC version 2 has supplanted version 1, this can go. */
1011 #define YYFAIL goto yyerrlab
1013 #define YYRECOVERING() (!!yyerrstatus)
1015 #define YYBACKUP(Token, Value) \
1016 do \
1017 if (yychar == YYEMPTY && yylen == 1) \
1019 yychar = (Token); \
1020 yylval = (Value); \
1021 yytoken = YYTRANSLATE (yychar); \
1022 YYPOPSTACK (1); \
1023 goto yybackup; \
1025 else \
1027 yyerror (YY_("syntax error: cannot back up")); \
1028 YYERROR; \
1030 while (YYID (0))
1033 #define YYTERROR 1
1034 #define YYERRCODE 256
1037 /* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
1038 If N is 0, then set CURRENT to the empty location which ends
1039 the previous symbol: RHS[0] (always defined). */
1041 #define YYRHSLOC(Rhs, K) ((Rhs)[K])
1042 #ifndef YYLLOC_DEFAULT
1043 # define YYLLOC_DEFAULT(Current, Rhs, N) \
1044 do \
1045 if (YYID (N)) \
1047 (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
1048 (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
1049 (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
1050 (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
1052 else \
1054 (Current).first_line = (Current).last_line = \
1055 YYRHSLOC (Rhs, 0).last_line; \
1056 (Current).first_column = (Current).last_column = \
1057 YYRHSLOC (Rhs, 0).last_column; \
1059 while (YYID (0))
1060 #endif
1063 /* YY_LOCATION_PRINT -- Print the location on the stream.
1064 This macro was not mandated originally: define only if we know
1065 we won't break user code: when these are the locations we know. */
1067 #ifndef YY_LOCATION_PRINT
1068 # if YYLTYPE_IS_TRIVIAL
1069 # define YY_LOCATION_PRINT(File, Loc) \
1070 fprintf (File, "%d.%d-%d.%d", \
1071 (Loc).first_line, (Loc).first_column, \
1072 (Loc).last_line, (Loc).last_column)
1073 # else
1074 # define YY_LOCATION_PRINT(File, Loc) ((void) 0)
1075 # endif
1076 #endif
1079 /* YYLEX -- calling `yylex' with the right arguments. */
1081 #ifdef YYLEX_PARAM
1082 # define YYLEX yylex (YYLEX_PARAM)
1083 #else
1084 # define YYLEX yylex ()
1085 #endif
1087 /* Enable debugging if requested. */
1088 #if YYDEBUG
1090 # ifndef YYFPRINTF
1091 # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
1092 # define YYFPRINTF fprintf
1093 # endif
1095 # define YYDPRINTF(Args) \
1096 do { \
1097 if (yydebug) \
1098 YYFPRINTF Args; \
1099 } while (YYID (0))
1101 # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
1102 do { \
1103 if (yydebug) \
1105 YYFPRINTF (stderr, "%s ", Title); \
1106 yy_symbol_print (stderr, \
1107 Type, Value); \
1108 YYFPRINTF (stderr, "\n"); \
1110 } while (YYID (0))
1113 /*--------------------------------.
1114 | Print this symbol on YYOUTPUT. |
1115 `--------------------------------*/
1117 /*ARGSUSED*/
1118 #if (defined __STDC__ || defined __C99__FUNC__ \
1119 || defined __cplusplus || defined _MSC_VER)
1120 static void
1121 yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
1122 #else
1123 static void
1124 yy_symbol_value_print (yyoutput, yytype, yyvaluep)
1125 FILE *yyoutput;
1126 int yytype;
1127 YYSTYPE const * const yyvaluep;
1128 #endif
1130 if (!yyvaluep)
1131 return;
1132 # ifdef YYPRINT
1133 if (yytype < YYNTOKENS)
1134 YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
1135 # else
1136 YYUSE (yyoutput);
1137 # endif
1138 switch (yytype)
1140 default:
1141 break;
1146 /*--------------------------------.
1147 | Print this symbol on YYOUTPUT. |
1148 `--------------------------------*/
1150 #if (defined __STDC__ || defined __C99__FUNC__ \
1151 || defined __cplusplus || defined _MSC_VER)
1152 static void
1153 yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
1154 #else
1155 static void
1156 yy_symbol_print (yyoutput, yytype, yyvaluep)
1157 FILE *yyoutput;
1158 int yytype;
1159 YYSTYPE const * const yyvaluep;
1160 #endif
1162 if (yytype < YYNTOKENS)
1163 YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
1164 else
1165 YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
1167 yy_symbol_value_print (yyoutput, yytype, yyvaluep);
1168 YYFPRINTF (yyoutput, ")");
1171 /*------------------------------------------------------------------.
1172 | yy_stack_print -- Print the state stack from its BOTTOM up to its |
1173 | TOP (included). |
1174 `------------------------------------------------------------------*/
1176 #if (defined __STDC__ || defined __C99__FUNC__ \
1177 || defined __cplusplus || defined _MSC_VER)
1178 static void
1179 yy_stack_print (yytype_int16 *bottom, yytype_int16 *top)
1180 #else
1181 static void
1182 yy_stack_print (bottom, top)
1183 yytype_int16 *bottom;
1184 yytype_int16 *top;
1185 #endif
1187 YYFPRINTF (stderr, "Stack now");
1188 for (; bottom <= top; ++bottom)
1189 YYFPRINTF (stderr, " %d", *bottom);
1190 YYFPRINTF (stderr, "\n");
1193 # define YY_STACK_PRINT(Bottom, Top) \
1194 do { \
1195 if (yydebug) \
1196 yy_stack_print ((Bottom), (Top)); \
1197 } while (YYID (0))
1200 /*------------------------------------------------.
1201 | Report that the YYRULE is going to be reduced. |
1202 `------------------------------------------------*/
1204 #if (defined __STDC__ || defined __C99__FUNC__ \
1205 || defined __cplusplus || defined _MSC_VER)
1206 static void
1207 yy_reduce_print (YYSTYPE *yyvsp, int yyrule)
1208 #else
1209 static void
1210 yy_reduce_print (yyvsp, yyrule)
1211 YYSTYPE *yyvsp;
1212 int yyrule;
1213 #endif
1215 int yynrhs = yyr2[yyrule];
1216 int yyi;
1217 unsigned long int yylno = yyrline[yyrule];
1218 YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
1219 yyrule - 1, yylno);
1220 /* The symbols being reduced. */
1221 for (yyi = 0; yyi < yynrhs; yyi++)
1223 fprintf (stderr, " $%d = ", yyi + 1);
1224 yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
1225 &(yyvsp[(yyi + 1) - (yynrhs)])
1227 fprintf (stderr, "\n");
1231 # define YY_REDUCE_PRINT(Rule) \
1232 do { \
1233 if (yydebug) \
1234 yy_reduce_print (yyvsp, Rule); \
1235 } while (YYID (0))
1237 /* Nonzero means print parse trace. It is left uninitialized so that
1238 multiple parsers can coexist. */
1239 int yydebug;
1240 #else /* !YYDEBUG */
1241 # define YYDPRINTF(Args)
1242 # define YY_SYMBOL_PRINT(Title, Type, Value, Location)
1243 # define YY_STACK_PRINT(Bottom, Top)
1244 # define YY_REDUCE_PRINT(Rule)
1245 #endif /* !YYDEBUG */
1248 /* YYINITDEPTH -- initial size of the parser's stacks. */
1249 #ifndef YYINITDEPTH
1250 # define YYINITDEPTH 200
1251 #endif
1253 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
1254 if the built-in stack extension method is used).
1256 Do not make this value too large; the results are undefined if
1257 YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
1258 evaluated with infinite-precision integer arithmetic. */
1260 #ifndef YYMAXDEPTH
1261 # define YYMAXDEPTH 10000
1262 #endif
1266 #if YYERROR_VERBOSE
1268 # ifndef yystrlen
1269 # if defined __GLIBC__ && defined _STRING_H
1270 # define yystrlen strlen
1271 # else
1272 /* Return the length of YYSTR. */
1273 #if (defined __STDC__ || defined __C99__FUNC__ \
1274 || defined __cplusplus || defined _MSC_VER)
1275 static YYSIZE_T
1276 yystrlen (const char *yystr)
1277 #else
1278 static YYSIZE_T
1279 yystrlen (yystr)
1280 const char *yystr;
1281 #endif
1283 YYSIZE_T yylen;
1284 for (yylen = 0; yystr[yylen]; yylen++)
1285 continue;
1286 return yylen;
1288 # endif
1289 # endif
1291 # ifndef yystpcpy
1292 # if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
1293 # define yystpcpy stpcpy
1294 # else
1295 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
1296 YYDEST. */
1297 #if (defined __STDC__ || defined __C99__FUNC__ \
1298 || defined __cplusplus || defined _MSC_VER)
1299 static char *
1300 yystpcpy (char *yydest, const char *yysrc)
1301 #else
1302 static char *
1303 yystpcpy (yydest, yysrc)
1304 char *yydest;
1305 const char *yysrc;
1306 #endif
1308 char *yyd = yydest;
1309 const char *yys = yysrc;
1311 while ((*yyd++ = *yys++) != '\0')
1312 continue;
1314 return yyd - 1;
1316 # endif
1317 # endif
1319 # ifndef yytnamerr
1320 /* Copy to YYRES the contents of YYSTR after stripping away unnecessary
1321 quotes and backslashes, so that it's suitable for yyerror. The
1322 heuristic is that double-quoting is unnecessary unless the string
1323 contains an apostrophe, a comma, or backslash (other than
1324 backslash-backslash). YYSTR is taken from yytname. If YYRES is
1325 null, do not copy; instead, return the length of what the result
1326 would have been. */
1327 static YYSIZE_T
1328 yytnamerr (char *yyres, const char *yystr)
1330 if (*yystr == '"')
1332 YYSIZE_T yyn = 0;
1333 char const *yyp = yystr;
1335 for (;;)
1336 switch (*++yyp)
1338 case '\'':
1339 case ',':
1340 goto do_not_strip_quotes;
1342 case '\\':
1343 if (*++yyp != '\\')
1344 goto do_not_strip_quotes;
1345 /* Fall through. */
1346 default:
1347 if (yyres)
1348 yyres[yyn] = *yyp;
1349 yyn++;
1350 break;
1352 case '"':
1353 if (yyres)
1354 yyres[yyn] = '\0';
1355 return yyn;
1357 do_not_strip_quotes: ;
1360 if (! yyres)
1361 return yystrlen (yystr);
1363 return yystpcpy (yyres, yystr) - yyres;
1365 # endif
1367 /* Copy into YYRESULT an error message about the unexpected token
1368 YYCHAR while in state YYSTATE. Return the number of bytes copied,
1369 including the terminating null byte. If YYRESULT is null, do not
1370 copy anything; just return the number of bytes that would be
1371 copied. As a special case, return 0 if an ordinary "syntax error"
1372 message will do. Return YYSIZE_MAXIMUM if overflow occurs during
1373 size calculation. */
1374 static YYSIZE_T
1375 yysyntax_error (char *yyresult, int yystate, int yychar)
1377 int yyn = yypact[yystate];
1379 if (! (YYPACT_NINF < yyn && yyn <= YYLAST))
1380 return 0;
1381 else
1383 int yytype = YYTRANSLATE (yychar);
1384 YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]);
1385 YYSIZE_T yysize = yysize0;
1386 YYSIZE_T yysize1;
1387 int yysize_overflow = 0;
1388 enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
1389 char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
1390 int yyx;
1392 # if 0
1393 /* This is so xgettext sees the translatable formats that are
1394 constructed on the fly. */
1395 YY_("syntax error, unexpected %s");
1396 YY_("syntax error, unexpected %s, expecting %s");
1397 YY_("syntax error, unexpected %s, expecting %s or %s");
1398 YY_("syntax error, unexpected %s, expecting %s or %s or %s");
1399 YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s");
1400 # endif
1401 char *yyfmt;
1402 char const *yyf;
1403 static char const yyunexpected[] = "syntax error, unexpected %s";
1404 static char const yyexpecting[] = ", expecting %s";
1405 static char const yyor[] = " or %s";
1406 char yyformat[sizeof yyunexpected
1407 + sizeof yyexpecting - 1
1408 + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2)
1409 * (sizeof yyor - 1))];
1410 char const *yyprefix = yyexpecting;
1412 /* Start YYX at -YYN if negative to avoid negative indexes in
1413 YYCHECK. */
1414 int yyxbegin = yyn < 0 ? -yyn : 0;
1416 /* Stay within bounds of both yycheck and yytname. */
1417 int yychecklim = YYLAST - yyn + 1;
1418 int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
1419 int yycount = 1;
1421 yyarg[0] = yytname[yytype];
1422 yyfmt = yystpcpy (yyformat, yyunexpected);
1424 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
1425 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
1427 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
1429 yycount = 1;
1430 yysize = yysize0;
1431 yyformat[sizeof yyunexpected - 1] = '\0';
1432 break;
1434 yyarg[yycount++] = yytname[yyx];
1435 yysize1 = yysize + yytnamerr (0, yytname[yyx]);
1436 yysize_overflow |= (yysize1 < yysize);
1437 yysize = yysize1;
1438 yyfmt = yystpcpy (yyfmt, yyprefix);
1439 yyprefix = yyor;
1442 yyf = YY_(yyformat);
1443 yysize1 = yysize + yystrlen (yyf);
1444 yysize_overflow |= (yysize1 < yysize);
1445 yysize = yysize1;
1447 if (yysize_overflow)
1448 return YYSIZE_MAXIMUM;
1450 if (yyresult)
1452 /* Avoid sprintf, as that infringes on the user's name space.
1453 Don't have undefined behavior even if the translation
1454 produced a string with the wrong number of "%s"s. */
1455 char *yyp = yyresult;
1456 int yyi = 0;
1457 while ((*yyp = *yyf) != '\0')
1459 if (*yyp == '%' && yyf[1] == 's' && yyi < yycount)
1461 yyp += yytnamerr (yyp, yyarg[yyi++]);
1462 yyf += 2;
1464 else
1466 yyp++;
1467 yyf++;
1471 return yysize;
1474 #endif /* YYERROR_VERBOSE */
1477 /*-----------------------------------------------.
1478 | Release the memory associated to this symbol. |
1479 `-----------------------------------------------*/
1481 /*ARGSUSED*/
1482 #if (defined __STDC__ || defined __C99__FUNC__ \
1483 || defined __cplusplus || defined _MSC_VER)
1484 static void
1485 yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
1486 #else
1487 static void
1488 yydestruct (yymsg, yytype, yyvaluep)
1489 const char *yymsg;
1490 int yytype;
1491 YYSTYPE *yyvaluep;
1492 #endif
1494 YYUSE (yyvaluep);
1496 if (!yymsg)
1497 yymsg = "Deleting";
1498 YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
1500 switch (yytype)
1503 default:
1504 break;
1509 /* Prevent warnings from -Wmissing-prototypes. */
1511 #ifdef YYPARSE_PARAM
1512 #if defined __STDC__ || defined __cplusplus
1513 int yyparse (void *YYPARSE_PARAM);
1514 #else
1515 int yyparse ();
1516 #endif
1517 #else /* ! YYPARSE_PARAM */
1518 #if defined __STDC__ || defined __cplusplus
1519 int yyparse (void);
1520 #else
1521 int yyparse ();
1522 #endif
1523 #endif /* ! YYPARSE_PARAM */
1527 /* The look-ahead symbol. */
1528 int yychar;
1530 /* The semantic value of the look-ahead symbol. */
1531 YYSTYPE yylval;
1533 /* Number of syntax errors so far. */
1534 int yynerrs;
1538 /*----------.
1539 | yyparse. |
1540 `----------*/
1542 #ifdef YYPARSE_PARAM
1543 #if (defined __STDC__ || defined __C99__FUNC__ \
1544 || defined __cplusplus || defined _MSC_VER)
1546 yyparse (void *YYPARSE_PARAM)
1547 #else
1549 yyparse (YYPARSE_PARAM)
1550 void *YYPARSE_PARAM;
1551 #endif
1552 #else /* ! YYPARSE_PARAM */
1553 #if (defined __STDC__ || defined __C99__FUNC__ \
1554 || defined __cplusplus || defined _MSC_VER)
1556 yyparse (void)
1557 #else
1559 yyparse ()
1561 #endif
1562 #endif
1565 int yystate;
1566 int yyn;
1567 int yyresult;
1568 /* Number of tokens to shift before error messages enabled. */
1569 int yyerrstatus;
1570 /* Look-ahead token as an internal (translated) token number. */
1571 int yytoken = 0;
1572 #if YYERROR_VERBOSE
1573 /* Buffer for error messages, and its allocated size. */
1574 char yymsgbuf[128];
1575 char *yymsg = yymsgbuf;
1576 YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
1577 #endif
1579 /* Three stacks and their tools:
1580 `yyss': related to states,
1581 `yyvs': related to semantic values,
1582 `yyls': related to locations.
1584 Refer to the stacks thru separate pointers, to allow yyoverflow
1585 to reallocate them elsewhere. */
1587 /* The state stack. */
1588 yytype_int16 yyssa[YYINITDEPTH];
1589 yytype_int16 *yyss = yyssa;
1590 yytype_int16 *yyssp;
1592 /* The semantic value stack. */
1593 YYSTYPE yyvsa[YYINITDEPTH];
1594 YYSTYPE *yyvs = yyvsa;
1595 YYSTYPE *yyvsp;
1599 #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
1601 YYSIZE_T yystacksize = YYINITDEPTH;
1603 /* The variables used to return semantic value and location from the
1604 action routines. */
1605 YYSTYPE yyval;
1608 /* The number of symbols on the RHS of the reduced rule.
1609 Keep to zero when no symbol should be popped. */
1610 int yylen = 0;
1612 YYDPRINTF ((stderr, "Starting parse\n"));
1614 yystate = 0;
1615 yyerrstatus = 0;
1616 yynerrs = 0;
1617 yychar = YYEMPTY; /* Cause a token to be read. */
1619 /* Initialize stack pointers.
1620 Waste one element of value and location stack
1621 so that they stay on the same level as the state stack.
1622 The wasted elements are never initialized. */
1624 yyssp = yyss;
1625 yyvsp = yyvs;
1627 goto yysetstate;
1629 /*------------------------------------------------------------.
1630 | yynewstate -- Push a new state, which is found in yystate. |
1631 `------------------------------------------------------------*/
1632 yynewstate:
1633 /* In all cases, when you get here, the value and location stacks
1634 have just been pushed. So pushing a state here evens the stacks. */
1635 yyssp++;
1637 yysetstate:
1638 *yyssp = yystate;
1640 if (yyss + yystacksize - 1 <= yyssp)
1642 /* Get the current used size of the three stacks, in elements. */
1643 YYSIZE_T yysize = yyssp - yyss + 1;
1645 #ifdef yyoverflow
1647 /* Give user a chance to reallocate the stack. Use copies of
1648 these so that the &'s don't force the real ones into
1649 memory. */
1650 YYSTYPE *yyvs1 = yyvs;
1651 yytype_int16 *yyss1 = yyss;
1654 /* Each stack pointer address is followed by the size of the
1655 data in use in that stack, in bytes. This used to be a
1656 conditional around just the two extra args, but that might
1657 be undefined if yyoverflow is a macro. */
1658 yyoverflow (YY_("memory exhausted"),
1659 &yyss1, yysize * sizeof (*yyssp),
1660 &yyvs1, yysize * sizeof (*yyvsp),
1662 &yystacksize);
1664 yyss = yyss1;
1665 yyvs = yyvs1;
1667 #else /* no yyoverflow */
1668 # ifndef YYSTACK_RELOCATE
1669 goto yyexhaustedlab;
1670 # else
1671 /* Extend the stack our own way. */
1672 if (YYMAXDEPTH <= yystacksize)
1673 goto yyexhaustedlab;
1674 yystacksize *= 2;
1675 if (YYMAXDEPTH < yystacksize)
1676 yystacksize = YYMAXDEPTH;
1679 yytype_int16 *yyss1 = yyss;
1680 union yyalloc *yyptr =
1681 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
1682 if (! yyptr)
1683 goto yyexhaustedlab;
1684 YYSTACK_RELOCATE (yyss);
1685 YYSTACK_RELOCATE (yyvs);
1687 # undef YYSTACK_RELOCATE
1688 if (yyss1 != yyssa)
1689 YYSTACK_FREE (yyss1);
1691 # endif
1692 #endif /* no yyoverflow */
1694 yyssp = yyss + yysize - 1;
1695 yyvsp = yyvs + yysize - 1;
1698 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
1699 (unsigned long int) yystacksize));
1701 if (yyss + yystacksize - 1 <= yyssp)
1702 YYABORT;
1705 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
1707 goto yybackup;
1709 /*-----------.
1710 | yybackup. |
1711 `-----------*/
1712 yybackup:
1714 /* Do appropriate processing given the current state. Read a
1715 look-ahead token if we need one and don't already have one. */
1717 /* First try to decide what to do without reference to look-ahead token. */
1718 yyn = yypact[yystate];
1719 if (yyn == YYPACT_NINF)
1720 goto yydefault;
1722 /* Not known => get a look-ahead token if don't already have one. */
1724 /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */
1725 if (yychar == YYEMPTY)
1727 YYDPRINTF ((stderr, "Reading a token: "));
1728 yychar = YYLEX;
1731 if (yychar <= YYEOF)
1733 yychar = yytoken = YYEOF;
1734 YYDPRINTF ((stderr, "Now at end of input.\n"));
1736 else
1738 yytoken = YYTRANSLATE (yychar);
1739 YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
1742 /* If the proper action on seeing token YYTOKEN is to reduce or to
1743 detect an error, take that action. */
1744 yyn += yytoken;
1745 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
1746 goto yydefault;
1747 yyn = yytable[yyn];
1748 if (yyn <= 0)
1750 if (yyn == 0 || yyn == YYTABLE_NINF)
1751 goto yyerrlab;
1752 yyn = -yyn;
1753 goto yyreduce;
1756 if (yyn == YYFINAL)
1757 YYACCEPT;
1759 /* Count tokens shifted since error; after three, turn off error
1760 status. */
1761 if (yyerrstatus)
1762 yyerrstatus--;
1764 /* Shift the look-ahead token. */
1765 YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
1767 /* Discard the shifted token unless it is eof. */
1768 if (yychar != YYEOF)
1769 yychar = YYEMPTY;
1771 yystate = yyn;
1772 *++yyvsp = yylval;
1774 goto yynewstate;
1777 /*-----------------------------------------------------------.
1778 | yydefault -- do the default action for the current state. |
1779 `-----------------------------------------------------------*/
1780 yydefault:
1781 yyn = yydefact[yystate];
1782 if (yyn == 0)
1783 goto yyerrlab;
1784 goto yyreduce;
1787 /*-----------------------------.
1788 | yyreduce -- Do a reduction. |
1789 `-----------------------------*/
1790 yyreduce:
1791 /* yyn is the number of a rule to reduce with. */
1792 yylen = yyr2[yyn];
1794 /* If YYLEN is nonzero, implement the default value of the action:
1795 `$$ = $1'.
1797 Otherwise, the following line sets YYVAL to garbage.
1798 This behavior is undocumented and Bison
1799 users should not rely upon it. Assigning to YYVAL
1800 unconditionally makes the parser a bit smaller, and it avoids a
1801 GCC warning that YYVAL may be used uninitialized. */
1802 yyval = yyvsp[1-yylen];
1805 YY_REDUCE_PRINT (yyn);
1806 switch (yyn)
1808 case 4:
1809 #line 116 "cola.y"
1811 unshift_ast(&ast_start, (yyvsp[(1) - (3)].ast));
1812 unshift_ast(&ast_start, (yyvsp[(2) - (3)].ast));
1813 unshift_ast(&ast_start, (yyvsp[(3) - (3)].ast));
1814 printf("DONE: compilation_unit.\n");
1816 break;
1818 case 5:
1819 #line 125 "cola.y"
1820 { (yyval.ast) = NULL; }
1821 break;
1823 case 6:
1824 #line 127 "cola.y"
1826 unshift_ast(&((yyval.ast)), (yyvsp[(1) - (2)].ast));
1828 break;
1830 case 7:
1831 #line 134 "cola.y"
1832 { printf("using_alias_directive\n"); }
1833 break;
1835 case 8:
1836 #line 136 "cola.y"
1838 printf("using_directive\n");
1839 /*load_module($2->name);*/
1841 break;
1843 case 9:
1844 #line 143 "cola.y"
1845 { (yyval.ast) = NULL; }
1846 break;
1848 case 10:
1849 #line 148 "cola.y"
1851 pop_namespace();
1852 (yyval.ast) = new_ast(KIND_DECL, ASTT_NAMESPACE_DECL, (yyvsp[(2) - (2)].ast), NULL);
1853 (yyval.ast)->sym = (yyvsp[(1) - (2)].sym);
1855 break;
1857 case 11:
1858 #line 157 "cola.y"
1860 Symbol *n, *t, *last = current_namespace;
1861 if (lookup_type_symbol((yyvsp[(2) - (2)].sym))) {
1862 printf("Error, redefinition of [%s]\n", (yyvsp[(2) - (2)].sym)->name);
1863 exit(0);
1865 for (n = split(".", (yyvsp[(2) - (2)].sym)->name); n; n = n->tnext) {
1866 n->kind = (yyvsp[(2) - (2)].sym)->kind;
1867 t = mk_namespace_symbol(n);
1868 store_symbol(last->table, t);
1869 last = n;
1871 push_namespace(t);
1872 (yyval.sym) = t;
1874 break;
1876 case 12:
1877 #line 176 "cola.y"
1878 { (yyval.sym) = (yyvsp[(1) - (1)].sym); fprintf(stderr, "qualified_name <- IDENTIFIER\n"); }
1879 break;
1881 case 13:
1882 #line 178 "cola.y"
1884 (yyval.sym) = symbol_join3((yyvsp[(1) - (3)].sym), new_symbol("."), (yyvsp[(3) - (3)].sym));
1885 fprintf(stderr, "qualified_name <- qualified_name . IDENTIFIER\n");
1887 break;
1889 case 14:
1890 #line 186 "cola.y"
1892 (yyval.ast) = (yyvsp[(2) - (4)].ast);
1893 if ((yyvsp[(3) - (4)].ast))
1894 unshift_ast(&((yyval.ast)), (yyvsp[(3) - (4)].ast));
1896 break;
1898 case 15:
1899 #line 194 "cola.y"
1900 { (yyval.ast) = NULL; }
1901 break;
1903 case 16:
1904 #line 197 "cola.y"
1906 (yyval.ast) = (yyvsp[(1) - (2)].ast);
1907 if ((yyvsp[(2) - (2)].ast))
1908 unshift_ast(&((yyval.ast)), (yyvsp[(2) - (2)].ast));
1910 break;
1912 case 19:
1913 #line 211 "cola.y"
1915 pop_namespace();
1916 (yyval.ast) = new_ast(KIND_DECL, ASTT_CLASS_DECL, NULL, NULL);
1917 (yyval.ast)->Attr.Class.body = (yyvsp[(3) - (4)].ast);
1918 (yyval.ast)->sym = (yyvsp[(2) - (4)].sym);
1919 (yyval.ast)->sym->flags = (yyvsp[(1) - (4)].ival);
1921 break;
1923 case 20:
1924 #line 221 "cola.y"
1925 { (yyval.ival) = 0; }
1926 break;
1928 case 22:
1929 #line 227 "cola.y"
1930 { (yyval.ival) = (yyvsp[(1) - (2)].ival) | (yyvsp[(2) - (2)].ival); }
1931 break;
1933 case 24:
1934 #line 233 "cola.y"
1935 { (yyval.ival) = MOD_PUBLIC; }
1936 break;
1938 case 25:
1939 #line 235 "cola.y"
1940 { (yyval.ival) = MOD_PRIVATE; }
1941 break;
1943 case 26:
1944 #line 237 "cola.y"
1945 { (yyval.ival) = MOD_PROTECTED; }
1946 break;
1948 case 27:
1949 #line 239 "cola.y"
1950 { (yyval.ival) = MOD_STATIC; }
1951 break;
1953 case 28:
1954 #line 241 "cola.y"
1955 { (yyval.ival) = MOD_VIRTUAL; }
1956 break;
1958 case 29:
1959 #line 246 "cola.y"
1960 { (yyval.ast) = (yyvsp[(2) - (3)].ast); }
1961 break;
1963 case 30:
1964 #line 251 "cola.y"
1966 /* Create a new namespace for class and put it in effect */
1967 Symbol * c;
1968 #if DEBUG
1969 fprintf(stderr, "\nclass_scope_start <- CLASS IDENTIFIER (%s)\n", (yyvsp[(2) - (2)].sym)->name);
1970 #endif
1971 c = mk_class_symbol((yyvsp[(2) - (2)].sym));
1972 push_namespace(c);
1974 push_scope();
1976 (yyval.sym) = c;
1978 break;
1980 case 31:
1981 #line 267 "cola.y"
1982 { (yyval.ast) = NULL; }
1983 break;
1985 case 32:
1986 #line 269 "cola.y"
1988 (yyval.ast) = (yyvsp[(1) - (2)].ast);
1989 unshift_ast(&((yyval.ast)), (yyvsp[(2) - (2)].ast));
1991 break;
1993 case 35:
1994 #line 293 "cola.y"
1995 { (yyval.ast) = (yyvsp[(1) - (2)].ast); }
1996 break;
1998 case 36:
1999 #line 295 "cola.y"
2001 (yyvsp[(3) - (6)].sym)->typename = (yyvsp[(2) - (6)].sym);
2002 (yyvsp[(3) - (6)].sym)->literal = (yyvsp[(5) - (6)].sym);
2003 check_id_redecl(current_symbol_table, (yyvsp[(3) - (6)].sym)->name);
2004 store_symbol(current_symbol_table, (yyvsp[(3) - (6)].sym));
2005 (yyval.ast) = new_statement(ASTT_CONSTANT_DECL, NULL, NULL);
2006 (yyval.ast)->typename = (yyvsp[(2) - (6)].sym);
2007 if (lookup_symbol_in_tab(current_symbol_table, (yyval.ast)->sym->name)) {
2008 printf("Warning: declaration of '%s' shadows previous instance.\n",
2009 (yyval.ast)->sym->name);
2012 break;
2014 case 37:
2015 #line 311 "cola.y"
2017 AST * decl;
2018 if ((yyvsp[(1) - (2)].sym) == NULL) {
2019 printf("Internal compiler error: local_var_decl: type is NULL\n");
2020 abort();
2022 for (decl=(yyvsp[(2) - (2)].ast); decl; decl = decl->next) {
2023 #if DEBUG
2024 fprintf(stderr, "local_var: [%s] typename [%s]\n",
2025 decl->arg1->sym->name, (yyvsp[(1) - (2)].sym)->name);
2026 #endif
2027 decl->arg1->sym->typename = (yyvsp[(1) - (2)].sym);
2029 (yyval.ast) = (yyvsp[(2) - (2)].ast);
2031 break;
2033 case 38:
2034 #line 330 "cola.y"
2036 AST * decl;
2037 if ((yyvsp[(2) - (4)].sym) == NULL) {
2038 printf("Internal compiler error: field_decl: type is NULL\n");
2039 abort();
2041 for (decl=(yyvsp[(3) - (4)].ast); decl; decl = decl->next) {
2042 #if DEBUG
2043 fprintf(stderr, "field: [%s] typename [%s]\n",
2044 decl->arg1->sym->name, (yyvsp[(2) - (4)].sym)->name);
2045 #endif
2046 decl->arg1->sym->typename = (yyvsp[(2) - (4)].sym);
2048 (yyval.ast) = (yyvsp[(3) - (4)].ast);
2050 break;
2052 case 40:
2053 #line 350 "cola.y"
2055 (yyval.ast) = (yyvsp[(1) - (3)].ast);
2056 unshift_ast(&((yyval.ast)), (yyvsp[(3) - (3)].ast));
2058 break;
2060 case 41:
2061 #line 358 "cola.y"
2063 AST * decl, * init;
2064 decl = new_expr(ASTT_IDENTIFIER, NULL, NULL);
2065 decl->sym = (yyvsp[(1) - (3)].sym);
2066 init = new_expr(ASTT_ASSIGN, decl, (yyvsp[(3) - (3)].ast));
2067 (yyval.ast) = new_statement(ASTT_FIELD_DECL, decl, init);
2068 #if DEBUG
2069 fprintf(stderr, " var_declarator <- IDENTIFER(%s)=init_expr\n", (yyvsp[(1) - (3)].sym)->name);
2070 #endif
2072 break;
2074 case 42:
2075 #line 369 "cola.y"
2077 AST * decl = new_expr(ASTT_IDENTIFIER, NULL, NULL);
2078 decl->sym = (yyvsp[(1) - (1)].sym);
2079 (yyval.ast) = new_statement(ASTT_FIELD_DECL, decl, NULL);
2080 #if DEBUG
2081 fprintf(stderr, " var_declarator <- IDENTIFIER(%s)\n", (yyvsp[(1) - (1)].sym)->name);
2082 #endif
2084 break;
2086 case 43:
2087 #line 381 "cola.y"
2089 (yyval.ast) = (yyvsp[(1) - (2)].ast);
2090 (yyval.ast)->Attr.Method.body = (yyvsp[(2) - (2)].ast);
2092 break;
2094 case 44:
2095 #line 389 "cola.y"
2097 Symbol * param;
2098 (yyval.ast) = new_statement(ASTT_METHOD_DECL, NULL, NULL);
2099 (yyvsp[(3) - (6)].sym)->kind = METHOD;
2100 (yyvsp[(3) - (6)].sym)->typename = (yyvsp[(2) - (6)].sym);
2101 (yyvsp[(3) - (6)].sym)->flags = (yyvsp[(1) - (6)].ival);
2102 (yyval.ast)->sym = (yyvsp[(3) - (6)].sym);
2103 (yyval.ast)->Attr.Method.params = (yyvsp[(5) - (6)].sym);
2104 /* Methods/Fields stored at scope 0 of class namespace.
2105 * We can store these at parse time.
2107 store_symbol(current_symbol_table, (yyval.ast)->sym);
2108 if ((yyvsp[(1) - (6)].ival) & MOD_STATIC) {
2109 if (!strcmp((yyvsp[(3) - (6)].sym)->name, "Main")) {
2110 if (main_method)
2111 fprintf(stderr,
2112 "Warning: multiple definitions of a static Main()\n");
2113 main_method = (yyvsp[(3) - (6)].sym);
2117 break;
2119 case 45:
2120 #line 411 "cola.y"
2122 Symbol * param;
2123 (yyval.ast) = new_statement(ASTT_METHOD_DECL, NULL, NULL);
2124 (yyvsp[(3) - (6)].sym)->kind = METHOD;
2125 (yyvsp[(3) - (6)].sym)->typename = new_type_symbol("void");
2126 (yyvsp[(3) - (6)].sym)->flags = (yyvsp[(1) - (6)].ival);
2127 (yyval.ast)->sym = (yyvsp[(3) - (6)].sym);
2128 (yyval.ast)->Attr.Method.params = (yyvsp[(5) - (6)].sym);
2129 /* Methods/Fields stored at scope 0 of class namespace.
2130 * We can store these at parse time.
2132 store_symbol(current_symbol_table, (yyval.ast)->sym);
2133 if ((yyvsp[(1) - (6)].ival) & MOD_STATIC) {
2134 if (!strcmp((yyvsp[(3) - (6)].sym)->name, "Main")) {
2135 if (main_method)
2136 fprintf(stderr,
2137 "Warning: multiple definitions of a static Main()\n");
2138 main_method = (yyvsp[(3) - (6)].sym);
2142 break;
2144 case 46:
2145 #line 437 "cola.y"
2146 { (yyval.sym) = NULL; }
2147 break;
2149 case 47:
2150 #line 439 "cola.y"
2151 { (yyval.sym) = (yyvsp[(1) - (1)].sym); }
2152 break;
2154 case 49:
2155 #line 449 "cola.y"
2157 (yyval.sym) = (yyvsp[(1) - (3)].sym);
2158 tunshift_sym(&((yyval.sym)), (yyvsp[(3) - (3)].sym));
2160 break;
2162 case 50:
2163 #line 457 "cola.y"
2165 #if DEBUG
2166 fprintf(stderr, " fixed_param <- type IDENTIFIER(%s)\n", (yyvsp[(2) - (2)].sym)->name);
2167 #endif
2168 (yyvsp[(2) - (2)].sym)->typename = (yyvsp[(1) - (2)].sym);
2169 (yyval.sym) = (yyvsp[(2) - (2)].sym);
2171 break;
2173 case 51:
2174 #line 479 "cola.y"
2175 { (yyval.ast) = (yyvsp[(1) - (1)].ast); }
2176 break;
2178 case 52:
2179 #line 484 "cola.y"
2181 (yyval.ast) = (yyvsp[(3) - (4)].ast);
2182 if ((yyval.ast)) {
2183 (yyval.ast)->vars = pop_scope();
2185 else {
2186 discard_scope();
2189 break;
2191 case 53:
2192 #line 496 "cola.y"
2193 { push_scope(); }
2194 break;
2196 case 54:
2197 #line 501 "cola.y"
2198 {(yyval.ast) = (yyvsp[(1) - (1)].ast);}
2199 break;
2201 case 55:
2202 #line 503 "cola.y"
2203 { fprintf(stderr, "##End of expr_statement\n\n"); (yyval.ast) = (yyvsp[(1) - (1)].ast); }
2204 break;
2206 case 56:
2207 #line 505 "cola.y"
2208 { fprintf(stderr, "##End of selection_statement\n\n"); (yyval.ast) = (yyvsp[(1) - (1)].ast); }
2209 break;
2211 case 57:
2212 #line 507 "cola.y"
2213 { fprintf(stderr, "##End of iteration_statement\n\n"); (yyval.ast) = (yyvsp[(1) - (1)].ast); }
2214 break;
2216 case 58:
2217 #line 509 "cola.y"
2218 { fprintf(stderr, "##End of jump_statement\n\n"); (yyval.ast) = (yyvsp[(1) - (1)].ast); }
2219 break;
2221 case 59:
2222 #line 511 "cola.y"
2223 { fprintf(stderr, "##End of return_statement\n\n"); (yyval.ast) = (yyvsp[(1) - (1)].ast); }
2224 break;
2226 case 60:
2227 #line 513 "cola.y"
2228 { (yyval.ast) = (yyvsp[(1) - (1)].ast); }
2229 break;
2231 case 62:
2232 #line 519 "cola.y"
2233 { fprintf(stderr, "##End of decl_statement\n\n"); (yyval.ast) = (yyvsp[(1) - (1)].ast); }
2234 break;
2236 case 63:
2237 #line 521 "cola.y"
2238 { fprintf(stderr, "##End of labeled_statement\n\n"); (yyval.ast) = (yyvsp[(1) - (1)].ast); }
2239 break;
2241 case 64:
2242 #line 526 "cola.y"
2243 { (yyval.ast) = NULL; }
2244 break;
2246 case 65:
2247 #line 528 "cola.y"
2248 { (yyval.ast) = (yyvsp[(1) - (1)].ast); }
2249 break;
2251 case 66:
2252 #line 530 "cola.y"
2254 (yyval.ast) = (yyvsp[(1) - (2)].ast);
2255 unshift_ast(&((yyval.ast)), (yyvsp[(2) - (2)].ast));
2257 break;
2259 case 67:
2260 #line 538 "cola.y"
2261 { (yyval.ast) = (yyvsp[(3) - (3)].ast); (yyval.ast)->sym = (yyvsp[(1) - (3)].sym); }
2262 break;
2264 case 68:
2265 #line 543 "cola.y"
2266 { (yyval.ast) = (yyvsp[(1) - (2)].ast); }
2267 break;
2269 case 69:
2270 #line 548 "cola.y"
2271 { (yyval.ast) = new_statement(ASTT_BREAK, NULL, NULL); }
2272 break;
2274 case 70:
2275 #line 550 "cola.y"
2276 { (yyval.ast) = new_statement(ASTT_CONTINUE, NULL, NULL); }
2277 break;
2279 case 71:
2280 #line 552 "cola.y"
2282 (yyval.ast) = NULL;
2283 printf("GOTO not supported yet.\n");
2284 exit(0);
2286 break;
2288 case 72:
2289 #line 561 "cola.y"
2290 { (yyval.ast) = new_statement(ASTT_RETURN, (yyvsp[(2) - (3)].ast), NULL); }
2291 break;
2293 case 73:
2294 #line 563 "cola.y"
2295 { (yyval.ast) = new_statement(ASTT_RETURN, NULL, NULL); }
2296 break;
2298 case 74:
2299 #line 568 "cola.y"
2300 { (yyval.ast) = NULL; }
2301 break;
2303 case 76:
2304 #line 574 "cola.y"
2306 (yyval.ast) = (yyvsp[(1) - (3)].ast);
2307 unshift_ast(&((yyval.ast)), (yyvsp[(3) - (3)].ast));
2309 break;
2311 case 77:
2312 #line 581 "cola.y"
2313 { (yyval.ast) = NULL; }
2314 break;
2316 case 78:
2317 #line 583 "cola.y"
2318 { (yyval.ast) = (yyvsp[(1) - (1)].ast); }
2319 break;
2321 case 79:
2322 #line 585 "cola.y"
2323 { (yyval.ast) = NULL; }
2324 break;
2326 case 80:
2327 #line 587 "cola.y"
2328 { (yyval.ast) = NULL; }
2329 break;
2331 case 82:
2332 #line 597 "cola.y"
2334 (yyval.ast) = new_if((yyvsp[(3) - (7)].ast), (yyvsp[(5) - (7)].ast), (yyvsp[(7) - (7)].ast));
2336 break;
2338 case 83:
2339 #line 601 "cola.y"
2341 (yyval.ast) = new_if((yyvsp[(3) - (5)].ast), (yyvsp[(5) - (5)].ast), NULL);
2343 break;
2345 case 86:
2346 #line 613 "cola.y"
2348 (yyval.ast) = new_while((yyvsp[(3) - (5)].ast), (yyvsp[(5) - (5)].ast));
2350 break;
2352 case 87:
2353 #line 621 "cola.y"
2355 if ((yyvsp[(3) - (9)].ast) == NULL) {
2356 printf("for_statement: NULL init statement\n");
2357 exit(0);
2359 (yyval.ast) = new_for((yyvsp[(3) - (9)].ast), (yyvsp[(5) - (9)].ast), (yyvsp[(7) - (9)].ast), (yyvsp[(9) - (9)].ast));
2361 break;
2363 case 88:
2364 #line 632 "cola.y"
2366 fprintf(stderr, "!TYPE[%s]\n", (yyvsp[(1) - (1)].sym)->name);
2367 (yyval.sym) = (yyvsp[(1) - (1)].sym);
2369 break;
2371 case 91:
2372 #line 642 "cola.y"
2373 { (yyval.sym) = new_type_symbol("bool"); }
2374 break;
2376 case 92:
2377 #line 644 "cola.y"
2378 { (yyval.sym) = new_type_symbol("string"); }
2379 break;
2381 case 93:
2382 #line 646 "cola.y"
2383 { (yyval.sym) = new_type_symbol("num"); }
2384 break;
2386 case 95:
2387 #line 652 "cola.y"
2388 { (yyval.sym) = new_type_symbol("int"); }
2389 break;
2391 case 96:
2392 #line 654 "cola.y"
2393 { (yyval.sym) = new_type_symbol("byte"); }
2394 break;
2396 case 97:
2397 #line 659 "cola.y"
2399 (yyval.sym) = symbol_concat((yyvsp[(1) - (2)].sym), (yyvsp[(2) - (2)].sym));
2400 #if DEBUG
2401 fprintf(stderr, " array_type: %s\n", (yyvsp[(1) - (2)].sym)->name);
2402 #endif
2404 break;
2406 case 98:
2407 #line 669 "cola.y"
2409 /* $1 is the dimension of the current rank */
2410 (yyval.sym) = (yyvsp[(1) - (1)].sym);
2411 #if DEBUG
2412 fprintf(stderr, " rank_spec /%s/\n", (yyvsp[(1) - (1)].sym)->name);
2413 #endif
2415 break;
2417 case 99:
2418 #line 677 "cola.y"
2420 (yyval.sym) = symbol_concat((yyvsp[(1) - (2)].sym), (yyvsp[(2) - (2)].sym));
2422 break;
2424 case 106:
2425 #line 696 "cola.y"
2426 { (yyval.ast) = new_expr(ASTT_ASSIGN, (yyvsp[(1) - (3)].ast), (yyvsp[(3) - (3)].ast)); }
2427 break;
2429 case 107:
2430 #line 710 "cola.y"
2432 (yyval.ast) = new_expr(ASTT_PREINC, (yyvsp[(2) - (2)].ast), NULL);
2433 (yyval.ast)->op = INC;
2435 break;
2437 case 108:
2438 #line 718 "cola.y"
2440 (yyval.ast) = new_expr(ASTT_PREINC, (yyvsp[(2) - (2)].ast), NULL);
2441 (yyval.ast)->op = DEC;
2443 break;
2445 case 109:
2446 #line 726 "cola.y"
2448 (yyval.ast) = new_expr(ASTT_POSTINC, (yyvsp[(1) - (2)].ast), NULL);
2449 (yyval.ast)->op = INC;
2451 break;
2453 case 110:
2454 #line 734 "cola.y"
2456 (yyval.ast) = new_expr(ASTT_POSTINC, (yyvsp[(1) - (2)].ast), NULL);
2457 (yyval.ast)->op = DEC;
2459 break;
2461 case 111:
2462 #line 742 "cola.y"
2464 (yyval.ast) = (yyvsp[(1) - (1)].ast);
2465 #if DEBUG
2466 fprintf(stderr, " expr <- conditional_expr\n");
2467 #endif
2469 break;
2471 case 114:
2472 #line 762 "cola.y"
2474 (yyval.ast) = new_expr(ASTT_LITERAL, NULL, NULL); (yyval.ast)->sym = (yyvsp[(1) - (1)].sym);
2475 #if DEBUG
2476 fprintf(stderr, " primary_expr <- LITERAL(%s)\n", (yyvsp[(1) - (1)].sym)->name);
2477 #endif
2479 break;
2481 case 115:
2482 #line 769 "cola.y"
2484 Symbol * orig;
2485 (yyval.ast) = new_expr(ASTT_IDENTIFIER, NULL, NULL);
2486 (yyval.ast)->sym = (yyvsp[(1) - (1)].sym);
2487 #if DEBUG
2488 fprintf(stderr, " primary_expr <- IDENTIFIER(%s)\n", (yyvsp[(1) - (1)].sym)->name);
2489 #endif
2491 break;
2493 case 116:
2494 #line 778 "cola.y"
2496 (yyval.ast) = (yyvsp[(2) - (3)].ast);
2498 break;
2500 case 122:
2501 #line 787 "cola.y"
2502 { (yyval.ast) = new_expr(ASTT_IDENTIFIER, NULL, NULL); (yyval.ast)->sym = (yyvsp[(1) - (1)].sym); }
2503 break;
2505 case 123:
2506 #line 792 "cola.y"
2507 { (yyval.ast) = (yyvsp[(1) - (1)].ast); }
2508 break;
2510 case 124:
2511 #line 794 "cola.y"
2512 { (yyval.ast) = (yyvsp[(2) - (2)].ast); (yyval.ast)->op = '+'; }
2513 break;
2515 case 125:
2516 #line 796 "cola.y"
2517 { (yyval.ast) = (yyvsp[(2) - (2)].ast); (yyval.ast)->op = '-'; }
2518 break;
2520 case 126:
2521 #line 798 "cola.y"
2522 { (yyval.ast) = (yyvsp[(2) - (2)].ast); (yyval.ast)->op = '!'; }
2523 break;
2525 case 127:
2526 #line 800 "cola.y"
2527 { (yyval.ast) = (yyvsp[(2) - (2)].ast); (yyval.ast)->op = '~'; }
2528 break;
2530 case 130:
2531 #line 807 "cola.y"
2533 if ((yyvsp[(1) - (4)].ast)->asttype != ASTT_IDENTIFIER) {
2534 fprintf(stderr, "Error (line %d), method call must be a simple name or member access.\n", line);
2535 exit(0);
2537 (yyval.ast) = new_expr(ASTT_METHOD_CALL, (yyvsp[(1) - (4)].ast), (yyvsp[(3) - (4)].ast));
2538 #if DEBUG
2539 fprintf(stderr, " method_call <- primary_expr ( arg_list )\n");
2540 #endif
2542 break;
2544 case 131:
2545 #line 821 "cola.y"
2546 { (yyval.sym) = (yyvsp[(1) - (1)].sym);
2547 #if DEBUG
2548 fprintf(stderr, " member_access <- qualified_name\n");
2549 #endif
2551 break;
2553 case 132:
2554 #line 830 "cola.y"
2556 (yyval.ast) = new_expr(ASTT_INDEX, (yyvsp[(1) - (4)].ast), (yyvsp[(3) - (4)].ast));
2557 (yyval.ast)->op = INDEX;
2558 #if DEBUG
2559 fprintf(stderr, " element_access <- primary-expr(pex[ex])\n");
2560 #endif
2562 break;
2564 case 134:
2565 #line 849 "cola.y"
2567 (yyval.ast) = new_expr(ASTT_NEW_OBJECT, (yyvsp[(4) - (5)].ast), NULL);
2568 /* $2 is a Symbol of a typename, will resolve to a real type
2569 * in semantic pass.
2571 (yyval.ast)->typename = (yyvsp[(2) - (5)].sym);
2573 break;
2575 case 136:
2576 #line 861 "cola.y"
2578 (yyval.ast) = new_op_expr((yyvsp[(1) - (3)].ast), '*', (yyvsp[(3) - (3)].ast));
2580 break;
2582 case 137:
2583 #line 865 "cola.y"
2585 (yyval.ast) = new_op_expr((yyvsp[(1) - (3)].ast), '/', (yyvsp[(3) - (3)].ast));
2587 break;
2589 case 138:
2590 #line 869 "cola.y"
2592 (yyval.ast) = new_op_expr((yyvsp[(1) - (3)].ast), '%', (yyvsp[(3) - (3)].ast));
2594 break;
2596 case 140:
2597 #line 877 "cola.y"
2599 (yyval.ast) = new_op_expr((yyvsp[(1) - (3)].ast), '+', (yyvsp[(3) - (3)].ast));
2601 break;
2603 case 141:
2604 #line 881 "cola.y"
2606 (yyval.ast) = new_op_expr((yyvsp[(1) - (3)].ast), '-', (yyvsp[(3) - (3)].ast));
2608 break;
2610 case 143:
2611 #line 889 "cola.y"
2613 /* Ternary is just a if/then/else statement which can return a value */
2614 (yyval.ast) = new_conditional((yyvsp[(1) - (5)].ast), (yyvsp[(3) - (5)].ast), (yyvsp[(5) - (5)].ast));
2616 break;
2618 case 145:
2619 #line 898 "cola.y"
2621 (yyval.ast) = new_logical_expr((yyvsp[(1) - (3)].ast), LOGICAL_AND, (yyvsp[(3) - (3)].ast));
2623 break;
2625 case 147:
2626 #line 906 "cola.y"
2628 (yyval.ast) = new_logical_expr((yyvsp[(1) - (3)].ast), LOGICAL_OR, (yyvsp[(3) - (3)].ast));
2630 break;
2632 case 149:
2633 #line 914 "cola.y"
2635 (yyval.ast) = new_op_expr((yyvsp[(1) - (3)].ast), '&', (yyvsp[(3) - (3)].ast));
2637 break;
2639 case 151:
2640 #line 922 "cola.y"
2642 (yyval.ast) = new_op_expr((yyvsp[(1) - (3)].ast), '~', (yyvsp[(3) - (3)].ast));
2644 break;
2646 case 153:
2647 #line 930 "cola.y"
2649 (yyval.ast) = new_op_expr((yyvsp[(1) - (3)].ast), '|', (yyvsp[(3) - (3)].ast));
2651 break;
2653 case 154:
2654 #line 937 "cola.y"
2655 {(yyval.ival) = '<';}
2656 break;
2658 case 155:
2659 #line 939 "cola.y"
2660 {(yyval.ival) = '>';}
2661 break;
2663 case 156:
2664 #line 941 "cola.y"
2665 {(yyval.ival) = LOGICAL_LTE;}
2666 break;
2668 case 157:
2669 #line 943 "cola.y"
2670 {(yyval.ival) = LOGICAL_GTE;}
2671 break;
2673 case 159:
2674 #line 949 "cola.y"
2676 (yyval.ast) = new_expr(ASTT_COMPARISON, (yyvsp[(1) - (3)].ast), (yyvsp[(3) - (3)].ast));
2677 (yyval.ast)->op = (yyvsp[(2) - (3)].ival);
2679 break;
2681 case 161:
2682 #line 958 "cola.y"
2684 (yyval.ast) = new_expr(ASTT_COMPARISON, (yyvsp[(1) - (3)].ast), (yyvsp[(3) - (3)].ast));
2685 (yyval.ast)->op = LOGICAL_EQ;
2687 break;
2689 case 162:
2690 #line 963 "cola.y"
2692 (yyval.ast) = new_expr(ASTT_COMPARISON, (yyvsp[(1) - (3)].ast), (yyvsp[(3) - (3)].ast));
2693 (yyval.ast)->op = LOGICAL_NE;
2695 break;
2697 case 164:
2698 #line 972 "cola.y"
2700 (yyval.ast) = new_op_expr((yyvsp[(1) - (3)].ast), LEFT_SHIFT, (yyvsp[(3) - (3)].ast));
2702 break;
2704 case 165:
2705 #line 976 "cola.y"
2707 (yyval.ast) = new_op_expr((yyvsp[(1) - (3)].ast), RIGHT_SHIFT, (yyvsp[(3) - (3)].ast));
2709 break;
2712 /* Line 1267 of yacc.c. */
2713 #line 2714 "parser.c"
2714 default: break;
2716 YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
2718 YYPOPSTACK (yylen);
2719 yylen = 0;
2720 YY_STACK_PRINT (yyss, yyssp);
2722 *++yyvsp = yyval;
2725 /* Now `shift' the result of the reduction. Determine what state
2726 that goes to, based on the state we popped back to and the rule
2727 number reduced by. */
2729 yyn = yyr1[yyn];
2731 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
2732 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
2733 yystate = yytable[yystate];
2734 else
2735 yystate = yydefgoto[yyn - YYNTOKENS];
2737 goto yynewstate;
2740 /*------------------------------------.
2741 | yyerrlab -- here on detecting error |
2742 `------------------------------------*/
2743 yyerrlab:
2744 /* If not already recovering from an error, report this error. */
2745 if (!yyerrstatus)
2747 ++yynerrs;
2748 #if ! YYERROR_VERBOSE
2749 yyerror (YY_("syntax error"));
2750 #else
2752 YYSIZE_T yysize = yysyntax_error (0, yystate, yychar);
2753 if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM)
2755 YYSIZE_T yyalloc = 2 * yysize;
2756 if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM))
2757 yyalloc = YYSTACK_ALLOC_MAXIMUM;
2758 if (yymsg != yymsgbuf)
2759 YYSTACK_FREE (yymsg);
2760 yymsg = (char *) YYSTACK_ALLOC (yyalloc);
2761 if (yymsg)
2762 yymsg_alloc = yyalloc;
2763 else
2765 yymsg = yymsgbuf;
2766 yymsg_alloc = sizeof yymsgbuf;
2770 if (0 < yysize && yysize <= yymsg_alloc)
2772 (void) yysyntax_error (yymsg, yystate, yychar);
2773 yyerror (yymsg);
2775 else
2777 yyerror (YY_("syntax error"));
2778 if (yysize != 0)
2779 goto yyexhaustedlab;
2782 #endif
2787 if (yyerrstatus == 3)
2789 /* If just tried and failed to reuse look-ahead token after an
2790 error, discard it. */
2792 if (yychar <= YYEOF)
2794 /* Return failure if at end of input. */
2795 if (yychar == YYEOF)
2796 YYABORT;
2798 else
2800 yydestruct ("Error: discarding",
2801 yytoken, &yylval);
2802 yychar = YYEMPTY;
2806 /* Else will try to reuse look-ahead token after shifting the error
2807 token. */
2808 goto yyerrlab1;
2811 /*---------------------------------------------------.
2812 | yyerrorlab -- error raised explicitly by YYERROR. |
2813 `---------------------------------------------------*/
2814 yyerrorlab:
2816 /* Pacify compilers like GCC when the user code never invokes
2817 YYERROR and the label yyerrorlab therefore never appears in user
2818 code. */
2819 if (/*CONSTCOND*/ 0)
2820 goto yyerrorlab;
2822 /* Do not reclaim the symbols of the rule which action triggered
2823 this YYERROR. */
2824 YYPOPSTACK (yylen);
2825 yylen = 0;
2826 YY_STACK_PRINT (yyss, yyssp);
2827 yystate = *yyssp;
2828 goto yyerrlab1;
2831 /*-------------------------------------------------------------.
2832 | yyerrlab1 -- common code for both syntax error and YYERROR. |
2833 `-------------------------------------------------------------*/
2834 yyerrlab1:
2835 yyerrstatus = 3; /* Each real token shifted decrements this. */
2837 for (;;)
2839 yyn = yypact[yystate];
2840 if (yyn != YYPACT_NINF)
2842 yyn += YYTERROR;
2843 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
2845 yyn = yytable[yyn];
2846 if (0 < yyn)
2847 break;
2851 /* Pop the current state because it cannot handle the error token. */
2852 if (yyssp == yyss)
2853 YYABORT;
2856 yydestruct ("Error: popping",
2857 yystos[yystate], yyvsp);
2858 YYPOPSTACK (1);
2859 yystate = *yyssp;
2860 YY_STACK_PRINT (yyss, yyssp);
2863 if (yyn == YYFINAL)
2864 YYACCEPT;
2866 *++yyvsp = yylval;
2869 /* Shift the error token. */
2870 YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
2872 yystate = yyn;
2873 goto yynewstate;
2876 /*-------------------------------------.
2877 | yyacceptlab -- YYACCEPT comes here. |
2878 `-------------------------------------*/
2879 yyacceptlab:
2880 yyresult = 0;
2881 goto yyreturn;
2883 /*-----------------------------------.
2884 | yyabortlab -- YYABORT comes here. |
2885 `-----------------------------------*/
2886 yyabortlab:
2887 yyresult = 1;
2888 goto yyreturn;
2890 #ifndef yyoverflow
2891 /*-------------------------------------------------.
2892 | yyexhaustedlab -- memory exhaustion comes here. |
2893 `-------------------------------------------------*/
2894 yyexhaustedlab:
2895 yyerror (YY_("memory exhausted"));
2896 yyresult = 2;
2897 /* Fall through. */
2898 #endif
2900 yyreturn:
2901 if (yychar != YYEOF && yychar != YYEMPTY)
2902 yydestruct ("Cleanup: discarding lookahead",
2903 yytoken, &yylval);
2904 /* Do not reclaim the symbols of the rule which action triggered
2905 this YYABORT or YYACCEPT. */
2906 YYPOPSTACK (yylen);
2907 YY_STACK_PRINT (yyss, yyssp);
2908 while (yyssp != yyss)
2910 yydestruct ("Cleanup: popping",
2911 yystos[*yyssp], yyvsp);
2912 YYPOPSTACK (1);
2914 #ifndef yyoverflow
2915 if (yyss != yyssa)
2916 YYSTACK_FREE (yyss);
2917 #endif
2918 #if YYERROR_VERBOSE
2919 if (yymsg != yymsgbuf)
2920 YYSTACK_FREE (yymsg);
2921 #endif
2922 /* Make sure YYID is used. */
2923 return YYID (yyresult);
2927 #line 982 "cola.y"
2932 extern FILE *yyin;
2935 int main(int argc, char * argv[])
2937 fprintf(stderr, "Cola - Copyright (C) 2002 Melvin Smith <melvins@us.ibm.com>\n");
2938 fprintf(stderr, "colac version %s\n\n", COLA_VERSION);
2939 if (argc > 1) {
2940 if (!(yyin = fopen(argv[1], "r"))) {
2941 printf("Error reading source file %s.\n", argv[1]);
2942 exit(0);
2945 else {
2946 printf("No source file specified.\n");
2947 exit(0);
2950 line = 1;
2951 init_symbol_tables();
2952 init_builtin_types();
2953 /* Kludge - fake routines by adding them to symbol table
2954 * and emitting them.
2957 store_method(current_symbol_table, "puts", t_void);
2958 store_method(current_symbol_table, "puti", t_void);
2959 store_method(current_symbol_table, "putf", t_void);
2960 store_method(current_symbol_table, "gets", t_string);
2961 store_method(current_symbol_table, "substr", t_string);
2962 store_method(current_symbol_table, "strlen", t_int32);
2963 store_method(current_symbol_table, "strchop", t_string);
2964 store_method(current_symbol_table, "strrep", t_string);
2965 store_method(current_symbol_table, "ord", t_int32);
2966 store_method(current_symbol_table, "sleep", t_void);
2969 fprintf(stderr, "Pass 1: Starting parse...\n");
2970 yyparse();
2971 fclose(yyin);
2973 fprintf(stderr, "Pass 2: Type checking...\n");
2974 fprintf(stderr, "Pass 2: Start scope is [%d]\n", scope);
2975 build_ast(ast_start);
2977 fprintf(stderr, "Pass 3: Semantic checking...\n");
2978 /*semant_ast(ast_start); */
2980 freopen("a.pir", "w", stdout);
2981 fprintf(stderr, "Compiling intermediate code to a.pir\n");
2983 printf("#Dump of global namespace:\n");
2984 indent = 0;
2985 dump_namespace(current_namespace);
2987 printf("# Cola (%s) generated\n#\n", COLA_VERSION);
2989 fprintf(stderr, "Pass 4: Code generation...\n");
2991 if (ast_start) {
2992 gen_ast(ast_start);
2995 printf("# Include standard API stuff\n");
2996 printf(".include \"core.pir\"\n\n");
2997 fflush(stdout);
2998 fprintf(stderr, "%ld lines compiled to PIR.\n", line);
2999 fprintf(stderr, "Generating PASM\n");
3000 system("../../parrot -o a.pasm a.pir");
3001 fprintf(stderr, "Generating PBC (Bytecode)\n");
3002 system("../../parrot -o a.pbc a.pir");
3003 return 0;
3006 int yyerror(char * s)
3009 fprintf(stderr, "last token = [%s]\n", yylval.sym->name);
3011 fprintf(stderr, "(error) line %ld: %s\n", line, s);
3012 fprintf(stderr, "Didn't create output asm.\n");
3013 exit(0);
3018 * Local variables:
3019 * c-file-style: "parrot"
3020 * End:
3021 * vim: expandtab shiftwidth=4: