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)
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. */
50 #define YYBISON_VERSION "2.3"
53 #define YYSKELETON_NAME "yacc.c"
58 /* Using locations. */
59 #define YYLSP_NEEDED 0
66 /* Put the tokens into the symbol table, so that GDB and other debuggers
163 #define NAMESPACE 283
169 #define PROTECTED 289
189 #define IDENTIFIER 309
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
208 /* Copy the first part of user declarations. */
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.
235 extern char yytext
[];
239 AST
*ast_start
= NULL
;
241 /* Pointers to the builtin type entries in the symbol table */
245 /* Enabling traces. */
250 /* Enabling verbose error messages. */
251 #ifdef YYERROR_VERBOSE
252 # undef YYERROR_VERBOSE
253 # define YYERROR_VERBOSE 1
255 # define YYERROR_VERBOSE 0
258 /* Enabling the token table. */
259 #ifndef YYTOKEN_TABLE
260 # define YYTOKEN_TABLE 0
263 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
264 typedef union YYSTYPE
273 /* Line 187 of yacc.c. */
276 # define yystype YYSTYPE /* obsolescent; will be withdrawn */
277 # define YYSTYPE_IS_DECLARED 1
278 # define YYSTYPE_IS_TRIVIAL 1
283 /* Copy the second part of user declarations. */
286 /* Line 216 of yacc.c. */
294 typedef YYTYPE_UINT8 yytype_uint8
;
296 typedef unsigned char yytype_uint8
;
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
;
305 typedef short int yytype_int8
;
309 typedef YYTYPE_UINT16 yytype_uint16
;
311 typedef unsigned short int yytype_uint16
;
315 typedef YYTYPE_INT16 yytype_int16
;
317 typedef short int yytype_int16
;
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
330 # define YYSIZE_T unsigned int
334 #define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
339 # include <libintl.h> /* INFRINGES ON USER NAME SPACE */
340 # define YY_(msgid) dgettext ("bison-runtime", msgid)
344 # define YY_(msgid) msgid
348 /* Suppress unused-variable warnings by "using" E. */
349 #if ! defined lint || defined __GNUC__
350 # define YYUSE(e) ((void) (e))
352 # define YYUSE(e) /* empty */
355 /* Identity function, used to suppress warnings about constant conditions. */
359 #if (defined __STDC__ || defined __C99__FUNC__ \
360 || defined __cplusplus || defined _MSC_VER)
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
380 # define YYSTACK_ALLOC __builtin_alloca
381 # elif defined __BUILTIN_VA_ARG_INCR
382 # include <alloca.h> /* INFRINGES ON USER NAME SPACE */
384 # define YYSTACK_ALLOC __alloca
385 # elif defined _MSC_VER
386 # include <malloc.h> /* INFRINGES ON USER NAME SPACE */
387 # define alloca _alloca
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 */
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 */
412 # define YYSTACK_ALLOC YYMALLOC
413 # define YYSTACK_FREE YYFREE
414 # ifndef YYSTACK_ALLOC_MAXIMUM
415 # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
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 */
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 */
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 */
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. */
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
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
466 # if defined __GNUC__ && 1 < __GNUC__
467 # define YYCOPY(To, From, Count) \
468 __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
470 # define YYCOPY(To, From, Count) \
474 for (yyi = 0; yyi < (Count); yyi++) \
475 (To)[yyi] = (From)[yyi]; \
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
486 # define YYSTACK_RELOCATE(Stack) \
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); \
499 /* YYFINAL -- State number of the termination state. */
501 /* YYLAST -- Last index in YYTABLE. */
504 /* YYNTOKENS -- Number of terminals. */
506 /* YYNNTS -- Number of nonterminals. */
508 /* YYNRULES -- Number of rules. */
510 /* YYNRULES -- Number of states. */
511 #define YYNSTATES 269
513 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
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,
559 /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
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,
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
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
700 /* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
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,
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,
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
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)
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) \
1017 if (yychar == YYEMPTY && yylen == 1) \
1021 yytoken = YYTRANSLATE (yychar); \
1027 yyerror (YY_("syntax error: cannot back up")); \
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) \
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; \
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; \
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)
1074 # define YY_LOCATION_PRINT(File, Loc) ((void) 0)
1079 /* YYLEX -- calling `yylex' with the right arguments. */
1082 # define YYLEX yylex (YYLEX_PARAM)
1084 # define YYLEX yylex ()
1087 /* Enable debugging if requested. */
1091 # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
1092 # define YYFPRINTF fprintf
1095 # define YYDPRINTF(Args) \
1101 # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
1105 YYFPRINTF (stderr, "%s ", Title); \
1106 yy_symbol_print (stderr, \
1108 YYFPRINTF (stderr, "\n"); \
1113 /*--------------------------------.
1114 | Print this symbol on YYOUTPUT. |
1115 `--------------------------------*/
1118 #if (defined __STDC__ || defined __C99__FUNC__ \
1119 || defined __cplusplus || defined _MSC_VER)
1121 yy_symbol_value_print (FILE *yyoutput
, int yytype
, YYSTYPE
const * const yyvaluep
)
1124 yy_symbol_value_print (yyoutput
, yytype
, yyvaluep
)
1127 YYSTYPE
const * const yyvaluep
;
1133 if (yytype
< YYNTOKENS
)
1134 YYPRINT (yyoutput
, yytoknum
[yytype
], *yyvaluep
);
1146 /*--------------------------------.
1147 | Print this symbol on YYOUTPUT. |
1148 `--------------------------------*/
1150 #if (defined __STDC__ || defined __C99__FUNC__ \
1151 || defined __cplusplus || defined _MSC_VER)
1153 yy_symbol_print (FILE *yyoutput
, int yytype
, YYSTYPE
const * const yyvaluep
)
1156 yy_symbol_print (yyoutput
, yytype
, yyvaluep
)
1159 YYSTYPE
const * const yyvaluep
;
1162 if (yytype
< YYNTOKENS
)
1163 YYFPRINTF (yyoutput
, "token %s (", yytname
[yytype
]);
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 |
1174 `------------------------------------------------------------------*/
1176 #if (defined __STDC__ || defined __C99__FUNC__ \
1177 || defined __cplusplus || defined _MSC_VER)
1179 yy_stack_print (yytype_int16
*bottom
, yytype_int16
*top
)
1182 yy_stack_print (bottom
, top
)
1183 yytype_int16
*bottom
;
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) \
1196 yy_stack_print ((Bottom), (Top)); \
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)
1207 yy_reduce_print (YYSTYPE
*yyvsp
, int yyrule
)
1210 yy_reduce_print (yyvsp
, yyrule
)
1215 int yynrhs
= yyr2
[yyrule
];
1217 unsigned long int yylno
= yyrline
[yyrule
];
1218 YYFPRINTF (stderr
, "Reducing stack by rule %d (line %lu):\n",
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) \
1234 yy_reduce_print (yyvsp, Rule); \
1237 /* Nonzero means print parse trace. It is left uninitialized so that
1238 multiple parsers can coexist. */
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. */
1250 # define YYINITDEPTH 200
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. */
1261 # define YYMAXDEPTH 10000
1269 # if defined __GLIBC__ && defined _STRING_H
1270 # define yystrlen strlen
1272 /* Return the length of YYSTR. */
1273 #if (defined __STDC__ || defined __C99__FUNC__ \
1274 || defined __cplusplus || defined _MSC_VER)
1276 yystrlen (const char *yystr
)
1284 for (yylen
= 0; yystr
[yylen
]; yylen
++)
1292 # if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
1293 # define yystpcpy stpcpy
1295 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
1297 #if (defined __STDC__ || defined __C99__FUNC__ \
1298 || defined __cplusplus || defined _MSC_VER)
1300 yystpcpy (char *yydest
, const char *yysrc
)
1303 yystpcpy (yydest
, yysrc
)
1309 const char *yys
= yysrc
;
1311 while ((*yyd
++ = *yys
++) != '\0')
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
1328 yytnamerr (char *yyres
, const char *yystr
)
1333 char const *yyp
= yystr
;
1340 goto do_not_strip_quotes
;
1344 goto do_not_strip_quotes
;
1357 do_not_strip_quotes
: ;
1361 return yystrlen (yystr
);
1363 return yystpcpy (yyres
, yystr
) - yyres
;
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. */
1375 yysyntax_error (char *yyresult
, int yystate
, int yychar
)
1377 int yyn
= yypact
[yystate
];
1379 if (! (YYPACT_NINF
< yyn
&& yyn
<= YYLAST
))
1383 int yytype
= YYTRANSLATE (yychar
);
1384 YYSIZE_T yysize0
= yytnamerr (0, yytname
[yytype
]);
1385 YYSIZE_T yysize
= yysize0
;
1387 int yysize_overflow
= 0;
1388 enum { YYERROR_VERBOSE_ARGS_MAXIMUM
= 5 };
1389 char const *yyarg
[YYERROR_VERBOSE_ARGS_MAXIMUM
];
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");
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
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
;
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
)
1431 yyformat
[sizeof yyunexpected
- 1] = '\0';
1434 yyarg
[yycount
++] = yytname
[yyx
];
1435 yysize1
= yysize
+ yytnamerr (0, yytname
[yyx
]);
1436 yysize_overflow
|= (yysize1
< yysize
);
1438 yyfmt
= yystpcpy (yyfmt
, yyprefix
);
1442 yyf
= YY_(yyformat
);
1443 yysize1
= yysize
+ yystrlen (yyf
);
1444 yysize_overflow
|= (yysize1
< yysize
);
1447 if (yysize_overflow
)
1448 return YYSIZE_MAXIMUM
;
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
;
1457 while ((*yyp
= *yyf
) != '\0')
1459 if (*yyp
== '%' && yyf
[1] == 's' && yyi
< yycount
)
1461 yyp
+= yytnamerr (yyp
, yyarg
[yyi
++]);
1474 #endif /* YYERROR_VERBOSE */
1477 /*-----------------------------------------------.
1478 | Release the memory associated to this symbol. |
1479 `-----------------------------------------------*/
1482 #if (defined __STDC__ || defined __C99__FUNC__ \
1483 || defined __cplusplus || defined _MSC_VER)
1485 yydestruct (const char *yymsg
, int yytype
, YYSTYPE
*yyvaluep
)
1488 yydestruct (yymsg
, yytype
, yyvaluep
)
1498 YY_SYMBOL_PRINT (yymsg
, yytype
, yyvaluep
, yylocationp
);
1509 /* Prevent warnings from -Wmissing-prototypes. */
1511 #ifdef YYPARSE_PARAM
1512 #if defined __STDC__ || defined __cplusplus
1513 int yyparse (void *YYPARSE_PARAM
);
1517 #else /* ! YYPARSE_PARAM */
1518 #if defined __STDC__ || defined __cplusplus
1523 #endif /* ! YYPARSE_PARAM */
1527 /* The look-ahead symbol. */
1530 /* The semantic value of the look-ahead symbol. */
1533 /* Number of syntax errors so far. */
1542 #ifdef YYPARSE_PARAM
1543 #if (defined __STDC__ || defined __C99__FUNC__ \
1544 || defined __cplusplus || defined _MSC_VER)
1546 yyparse (void *YYPARSE_PARAM
)
1549 yyparse (YYPARSE_PARAM
)
1550 void *YYPARSE_PARAM
;
1552 #else /* ! YYPARSE_PARAM */
1553 #if (defined __STDC__ || defined __C99__FUNC__ \
1554 || defined __cplusplus || defined _MSC_VER)
1568 /* Number of tokens to shift before error messages enabled. */
1570 /* Look-ahead token as an internal (translated) token number. */
1573 /* Buffer for error messages, and its allocated size. */
1575 char *yymsg
= yymsgbuf
;
1576 YYSIZE_T yymsg_alloc
= sizeof yymsgbuf
;
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
;
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
1608 /* The number of symbols on the RHS of the reduced rule.
1609 Keep to zero when no symbol should be popped. */
1612 YYDPRINTF ((stderr
, "Starting parse\n"));
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. */
1629 /*------------------------------------------------------------.
1630 | yynewstate -- Push a new state, which is found in yystate. |
1631 `------------------------------------------------------------*/
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. */
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;
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
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
),
1667 #else /* no yyoverflow */
1668 # ifndef YYSTACK_RELOCATE
1669 goto yyexhaustedlab
;
1671 /* Extend the stack our own way. */
1672 if (YYMAXDEPTH
<= yystacksize
)
1673 goto yyexhaustedlab
;
1675 if (YYMAXDEPTH
< yystacksize
)
1676 yystacksize
= YYMAXDEPTH
;
1679 yytype_int16
*yyss1
= yyss
;
1680 union yyalloc
*yyptr
=
1681 (union yyalloc
*) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize
));
1683 goto yyexhaustedlab
;
1684 YYSTACK_RELOCATE (yyss
);
1685 YYSTACK_RELOCATE (yyvs
);
1687 # undef YYSTACK_RELOCATE
1689 YYSTACK_FREE (yyss1
);
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
)
1705 YYDPRINTF ((stderr
, "Entering state %d\n", yystate
));
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
)
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: "));
1731 if (yychar
<= YYEOF
)
1733 yychar
= yytoken
= YYEOF
;
1734 YYDPRINTF ((stderr
, "Now at end of input.\n"));
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. */
1745 if (yyn
< 0 || YYLAST
< yyn
|| yycheck
[yyn
] != yytoken
)
1750 if (yyn
== 0 || yyn
== YYTABLE_NINF
)
1759 /* Count tokens shifted since error; after three, turn off error
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
)
1777 /*-----------------------------------------------------------.
1778 | yydefault -- do the default action for the current state. |
1779 `-----------------------------------------------------------*/
1781 yyn
= yydefact
[yystate
];
1787 /*-----------------------------.
1788 | yyreduce -- Do a reduction. |
1789 `-----------------------------*/
1791 /* yyn is the number of a rule to reduce with. */
1794 /* If YYLEN is nonzero, implement the default value of the action:
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
);
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");
1820 { (yyval
.ast
) = NULL
; }
1826 unshift_ast(&((yyval
.ast
)), (yyvsp
[(1) - (2)].ast
));
1832 { printf("using_alias_directive\n"); }
1838 printf("using_directive\n");
1839 /*load_module($2->name);*/
1845 { (yyval
.ast
) = NULL
; }
1852 (yyval
.ast
) = new_ast(KIND_DECL
, ASTT_NAMESPACE_DECL
, (yyvsp
[(2) - (2)].ast
), NULL
);
1853 (yyval
.ast
)->sym
= (yyvsp
[(1) - (2)].sym
);
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
);
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
);
1878 { (yyval
.sym
) = (yyvsp
[(1) - (1)].sym
); fprintf(stderr
, "qualified_name <- IDENTIFIER\n"); }
1884 (yyval
.sym
) = symbol_join3((yyvsp
[(1) - (3)].sym
), new_symbol("."), (yyvsp
[(3) - (3)].sym
));
1885 fprintf(stderr
, "qualified_name <- qualified_name . IDENTIFIER\n");
1892 (yyval
.ast
) = (yyvsp
[(2) - (4)].ast
);
1893 if ((yyvsp
[(3) - (4)].ast
))
1894 unshift_ast(&((yyval
.ast
)), (yyvsp
[(3) - (4)].ast
));
1900 { (yyval
.ast
) = NULL
; }
1906 (yyval
.ast
) = (yyvsp
[(1) - (2)].ast
);
1907 if ((yyvsp
[(2) - (2)].ast
))
1908 unshift_ast(&((yyval
.ast
)), (yyvsp
[(2) - (2)].ast
));
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
);
1925 { (yyval
.ival
) = 0; }
1930 { (yyval
.ival
) = (yyvsp
[(1) - (2)].ival
) | (yyvsp
[(2) - (2)].ival
); }
1935 { (yyval
.ival
) = MOD_PUBLIC
; }
1940 { (yyval
.ival
) = MOD_PRIVATE
; }
1945 { (yyval
.ival
) = MOD_PROTECTED
; }
1950 { (yyval
.ival
) = MOD_STATIC
; }
1955 { (yyval
.ival
) = MOD_VIRTUAL
; }
1960 { (yyval
.ast
) = (yyvsp
[(2) - (3)].ast
); }
1966 /* Create a new namespace for class and put it in effect */
1969 fprintf(stderr
, "\nclass_scope_start <- CLASS IDENTIFIER (%s)\n", (yyvsp
[(2) - (2)].sym
)->name
);
1971 c
= mk_class_symbol((yyvsp
[(2) - (2)].sym
));
1982 { (yyval
.ast
) = NULL
; }
1988 (yyval
.ast
) = (yyvsp
[(1) - (2)].ast
);
1989 unshift_ast(&((yyval
.ast
)), (yyvsp
[(2) - (2)].ast
));
1995 { (yyval
.ast
) = (yyvsp
[(1) - (2)].ast
); }
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
);
2018 if ((yyvsp
[(1) - (2)].sym
) == NULL
) {
2019 printf("Internal compiler error: local_var_decl: type is NULL\n");
2022 for (decl
=(yyvsp
[(2) - (2)].ast
); decl
; decl
= decl
->next
) {
2024 fprintf(stderr
, "local_var: [%s] typename [%s]\n",
2025 decl
->arg1
->sym
->name
, (yyvsp
[(1) - (2)].sym
)->name
);
2027 decl
->arg1
->sym
->typename
= (yyvsp
[(1) - (2)].sym
);
2029 (yyval
.ast
) = (yyvsp
[(2) - (2)].ast
);
2037 if ((yyvsp
[(2) - (4)].sym
) == NULL
) {
2038 printf("Internal compiler error: field_decl: type is NULL\n");
2041 for (decl
=(yyvsp
[(3) - (4)].ast
); decl
; decl
= decl
->next
) {
2043 fprintf(stderr
, "field: [%s] typename [%s]\n",
2044 decl
->arg1
->sym
->name
, (yyvsp
[(2) - (4)].sym
)->name
);
2046 decl
->arg1
->sym
->typename
= (yyvsp
[(2) - (4)].sym
);
2048 (yyval
.ast
) = (yyvsp
[(3) - (4)].ast
);
2055 (yyval
.ast
) = (yyvsp
[(1) - (3)].ast
);
2056 unshift_ast(&((yyval
.ast
)), (yyvsp
[(3) - (3)].ast
));
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
);
2069 fprintf(stderr
, " var_declarator <- IDENTIFER(%s)=init_expr\n", (yyvsp
[(1) - (3)].sym
)->name
);
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
);
2081 fprintf(stderr
, " var_declarator <- IDENTIFIER(%s)\n", (yyvsp
[(1) - (1)].sym
)->name
);
2089 (yyval
.ast
) = (yyvsp
[(1) - (2)].ast
);
2090 (yyval
.ast
)->Attr
.Method
.body
= (yyvsp
[(2) - (2)].ast
);
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")) {
2112 "Warning: multiple definitions of a static Main()\n");
2113 main_method
= (yyvsp
[(3) - (6)].sym
);
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")) {
2137 "Warning: multiple definitions of a static Main()\n");
2138 main_method
= (yyvsp
[(3) - (6)].sym
);
2146 { (yyval
.sym
) = NULL
; }
2151 { (yyval
.sym
) = (yyvsp
[(1) - (1)].sym
); }
2157 (yyval
.sym
) = (yyvsp
[(1) - (3)].sym
);
2158 tunshift_sym(&((yyval
.sym
)), (yyvsp
[(3) - (3)].sym
));
2166 fprintf(stderr
, " fixed_param <- type IDENTIFIER(%s)\n", (yyvsp
[(2) - (2)].sym
)->name
);
2168 (yyvsp
[(2) - (2)].sym
)->typename
= (yyvsp
[(1) - (2)].sym
);
2169 (yyval
.sym
) = (yyvsp
[(2) - (2)].sym
);
2175 { (yyval
.ast
) = (yyvsp
[(1) - (1)].ast
); }
2181 (yyval
.ast
) = (yyvsp
[(3) - (4)].ast
);
2183 (yyval
.ast
)->vars
= pop_scope();
2198 {(yyval
.ast
) = (yyvsp
[(1) - (1)].ast
);}
2203 { fprintf(stderr
, "##End of expr_statement\n\n"); (yyval
.ast
) = (yyvsp
[(1) - (1)].ast
); }
2208 { fprintf(stderr
, "##End of selection_statement\n\n"); (yyval
.ast
) = (yyvsp
[(1) - (1)].ast
); }
2213 { fprintf(stderr
, "##End of iteration_statement\n\n"); (yyval
.ast
) = (yyvsp
[(1) - (1)].ast
); }
2218 { fprintf(stderr
, "##End of jump_statement\n\n"); (yyval
.ast
) = (yyvsp
[(1) - (1)].ast
); }
2223 { fprintf(stderr
, "##End of return_statement\n\n"); (yyval
.ast
) = (yyvsp
[(1) - (1)].ast
); }
2228 { (yyval
.ast
) = (yyvsp
[(1) - (1)].ast
); }
2233 { fprintf(stderr
, "##End of decl_statement\n\n"); (yyval
.ast
) = (yyvsp
[(1) - (1)].ast
); }
2238 { fprintf(stderr
, "##End of labeled_statement\n\n"); (yyval
.ast
) = (yyvsp
[(1) - (1)].ast
); }
2243 { (yyval
.ast
) = NULL
; }
2248 { (yyval
.ast
) = (yyvsp
[(1) - (1)].ast
); }
2254 (yyval
.ast
) = (yyvsp
[(1) - (2)].ast
);
2255 unshift_ast(&((yyval
.ast
)), (yyvsp
[(2) - (2)].ast
));
2261 { (yyval
.ast
) = (yyvsp
[(3) - (3)].ast
); (yyval
.ast
)->sym
= (yyvsp
[(1) - (3)].sym
); }
2266 { (yyval
.ast
) = (yyvsp
[(1) - (2)].ast
); }
2271 { (yyval
.ast
) = new_statement(ASTT_BREAK
, NULL
, NULL
); }
2276 { (yyval
.ast
) = new_statement(ASTT_CONTINUE
, NULL
, NULL
); }
2283 printf("GOTO not supported yet.\n");
2290 { (yyval
.ast
) = new_statement(ASTT_RETURN
, (yyvsp
[(2) - (3)].ast
), NULL
); }
2295 { (yyval
.ast
) = new_statement(ASTT_RETURN
, NULL
, NULL
); }
2300 { (yyval
.ast
) = NULL
; }
2306 (yyval
.ast
) = (yyvsp
[(1) - (3)].ast
);
2307 unshift_ast(&((yyval
.ast
)), (yyvsp
[(3) - (3)].ast
));
2313 { (yyval
.ast
) = NULL
; }
2318 { (yyval
.ast
) = (yyvsp
[(1) - (1)].ast
); }
2323 { (yyval
.ast
) = NULL
; }
2328 { (yyval
.ast
) = NULL
; }
2334 (yyval
.ast
) = new_if((yyvsp
[(3) - (7)].ast
), (yyvsp
[(5) - (7)].ast
), (yyvsp
[(7) - (7)].ast
));
2341 (yyval
.ast
) = new_if((yyvsp
[(3) - (5)].ast
), (yyvsp
[(5) - (5)].ast
), NULL
);
2348 (yyval
.ast
) = new_while((yyvsp
[(3) - (5)].ast
), (yyvsp
[(5) - (5)].ast
));
2355 if ((yyvsp
[(3) - (9)].ast
) == NULL
) {
2356 printf("for_statement: NULL init statement\n");
2359 (yyval
.ast
) = new_for((yyvsp
[(3) - (9)].ast
), (yyvsp
[(5) - (9)].ast
), (yyvsp
[(7) - (9)].ast
), (yyvsp
[(9) - (9)].ast
));
2366 fprintf(stderr
, "!TYPE[%s]\n", (yyvsp
[(1) - (1)].sym
)->name
);
2367 (yyval
.sym
) = (yyvsp
[(1) - (1)].sym
);
2373 { (yyval
.sym
) = new_type_symbol("bool"); }
2378 { (yyval
.sym
) = new_type_symbol("string"); }
2383 { (yyval
.sym
) = new_type_symbol("num"); }
2388 { (yyval
.sym
) = new_type_symbol("int"); }
2393 { (yyval
.sym
) = new_type_symbol("byte"); }
2399 (yyval
.sym
) = symbol_concat((yyvsp
[(1) - (2)].sym
), (yyvsp
[(2) - (2)].sym
));
2401 fprintf(stderr
, " array_type: %s\n", (yyvsp
[(1) - (2)].sym
)->name
);
2409 /* $1 is the dimension of the current rank */
2410 (yyval
.sym
) = (yyvsp
[(1) - (1)].sym
);
2412 fprintf(stderr
, " rank_spec /%s/\n", (yyvsp
[(1) - (1)].sym
)->name
);
2420 (yyval
.sym
) = symbol_concat((yyvsp
[(1) - (2)].sym
), (yyvsp
[(2) - (2)].sym
));
2426 { (yyval
.ast
) = new_expr(ASTT_ASSIGN
, (yyvsp
[(1) - (3)].ast
), (yyvsp
[(3) - (3)].ast
)); }
2432 (yyval
.ast
) = new_expr(ASTT_PREINC
, (yyvsp
[(2) - (2)].ast
), NULL
);
2433 (yyval
.ast
)->op
= INC
;
2440 (yyval
.ast
) = new_expr(ASTT_PREINC
, (yyvsp
[(2) - (2)].ast
), NULL
);
2441 (yyval
.ast
)->op
= DEC
;
2448 (yyval
.ast
) = new_expr(ASTT_POSTINC
, (yyvsp
[(1) - (2)].ast
), NULL
);
2449 (yyval
.ast
)->op
= INC
;
2456 (yyval
.ast
) = new_expr(ASTT_POSTINC
, (yyvsp
[(1) - (2)].ast
), NULL
);
2457 (yyval
.ast
)->op
= DEC
;
2464 (yyval
.ast
) = (yyvsp
[(1) - (1)].ast
);
2466 fprintf(stderr
, " expr <- conditional_expr\n");
2474 (yyval
.ast
) = new_expr(ASTT_LITERAL
, NULL
, NULL
); (yyval
.ast
)->sym
= (yyvsp
[(1) - (1)].sym
);
2476 fprintf(stderr
, " primary_expr <- LITERAL(%s)\n", (yyvsp
[(1) - (1)].sym
)->name
);
2485 (yyval
.ast
) = new_expr(ASTT_IDENTIFIER
, NULL
, NULL
);
2486 (yyval
.ast
)->sym
= (yyvsp
[(1) - (1)].sym
);
2488 fprintf(stderr
, " primary_expr <- IDENTIFIER(%s)\n", (yyvsp
[(1) - (1)].sym
)->name
);
2496 (yyval
.ast
) = (yyvsp
[(2) - (3)].ast
);
2502 { (yyval
.ast
) = new_expr(ASTT_IDENTIFIER
, NULL
, NULL
); (yyval
.ast
)->sym
= (yyvsp
[(1) - (1)].sym
); }
2507 { (yyval
.ast
) = (yyvsp
[(1) - (1)].ast
); }
2512 { (yyval
.ast
) = (yyvsp
[(2) - (2)].ast
); (yyval
.ast
)->op
= '+'; }
2517 { (yyval
.ast
) = (yyvsp
[(2) - (2)].ast
); (yyval
.ast
)->op
= '-'; }
2522 { (yyval
.ast
) = (yyvsp
[(2) - (2)].ast
); (yyval
.ast
)->op
= '!'; }
2527 { (yyval
.ast
) = (yyvsp
[(2) - (2)].ast
); (yyval
.ast
)->op
= '~'; }
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
);
2537 (yyval
.ast
) = new_expr(ASTT_METHOD_CALL
, (yyvsp
[(1) - (4)].ast
), (yyvsp
[(3) - (4)].ast
));
2539 fprintf(stderr
, " method_call <- primary_expr ( arg_list )\n");
2546 { (yyval
.sym
) = (yyvsp
[(1) - (1)].sym
);
2548 fprintf(stderr
, " member_access <- qualified_name\n");
2556 (yyval
.ast
) = new_expr(ASTT_INDEX
, (yyvsp
[(1) - (4)].ast
), (yyvsp
[(3) - (4)].ast
));
2557 (yyval
.ast
)->op
= INDEX
;
2559 fprintf(stderr
, " element_access <- primary-expr(pex[ex])\n");
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
2571 (yyval
.ast
)->typename
= (yyvsp
[(2) - (5)].sym
);
2578 (yyval
.ast
) = new_op_expr((yyvsp
[(1) - (3)].ast
), '*', (yyvsp
[(3) - (3)].ast
));
2585 (yyval
.ast
) = new_op_expr((yyvsp
[(1) - (3)].ast
), '/', (yyvsp
[(3) - (3)].ast
));
2592 (yyval
.ast
) = new_op_expr((yyvsp
[(1) - (3)].ast
), '%', (yyvsp
[(3) - (3)].ast
));
2599 (yyval
.ast
) = new_op_expr((yyvsp
[(1) - (3)].ast
), '+', (yyvsp
[(3) - (3)].ast
));
2606 (yyval
.ast
) = new_op_expr((yyvsp
[(1) - (3)].ast
), '-', (yyvsp
[(3) - (3)].ast
));
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
));
2621 (yyval
.ast
) = new_logical_expr((yyvsp
[(1) - (3)].ast
), LOGICAL_AND
, (yyvsp
[(3) - (3)].ast
));
2628 (yyval
.ast
) = new_logical_expr((yyvsp
[(1) - (3)].ast
), LOGICAL_OR
, (yyvsp
[(3) - (3)].ast
));
2635 (yyval
.ast
) = new_op_expr((yyvsp
[(1) - (3)].ast
), '&', (yyvsp
[(3) - (3)].ast
));
2642 (yyval
.ast
) = new_op_expr((yyvsp
[(1) - (3)].ast
), '~', (yyvsp
[(3) - (3)].ast
));
2649 (yyval
.ast
) = new_op_expr((yyvsp
[(1) - (3)].ast
), '|', (yyvsp
[(3) - (3)].ast
));
2655 {(yyval
.ival
) = '<';}
2660 {(yyval
.ival
) = '>';}
2665 {(yyval
.ival
) = LOGICAL_LTE
;}
2670 {(yyval
.ival
) = LOGICAL_GTE
;}
2676 (yyval
.ast
) = new_expr(ASTT_COMPARISON
, (yyvsp
[(1) - (3)].ast
), (yyvsp
[(3) - (3)].ast
));
2677 (yyval
.ast
)->op
= (yyvsp
[(2) - (3)].ival
);
2684 (yyval
.ast
) = new_expr(ASTT_COMPARISON
, (yyvsp
[(1) - (3)].ast
), (yyvsp
[(3) - (3)].ast
));
2685 (yyval
.ast
)->op
= LOGICAL_EQ
;
2692 (yyval
.ast
) = new_expr(ASTT_COMPARISON
, (yyvsp
[(1) - (3)].ast
), (yyvsp
[(3) - (3)].ast
));
2693 (yyval
.ast
)->op
= LOGICAL_NE
;
2700 (yyval
.ast
) = new_op_expr((yyvsp
[(1) - (3)].ast
), LEFT_SHIFT
, (yyvsp
[(3) - (3)].ast
));
2707 (yyval
.ast
) = new_op_expr((yyvsp
[(1) - (3)].ast
), RIGHT_SHIFT
, (yyvsp
[(3) - (3)].ast
));
2712 /* Line 1267 of yacc.c. */
2713 #line 2714 "parser.c"
2716 YY_SYMBOL_PRINT ("-> $$ =", yyr1
[yyn
], &yyval
, &yyloc
);
2720 YY_STACK_PRINT (yyss
, yyssp
);
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. */
2731 yystate
= yypgoto
[yyn
- YYNTOKENS
] + *yyssp
;
2732 if (0 <= yystate
&& yystate
<= YYLAST
&& yycheck
[yystate
] == *yyssp
)
2733 yystate
= yytable
[yystate
];
2735 yystate
= yydefgoto
[yyn
- YYNTOKENS
];
2740 /*------------------------------------.
2741 | yyerrlab -- here on detecting error |
2742 `------------------------------------*/
2744 /* If not already recovering from an error, report this error. */
2748 #if ! YYERROR_VERBOSE
2749 yyerror (YY_("syntax error"));
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
);
2762 yymsg_alloc
= yyalloc
;
2766 yymsg_alloc
= sizeof yymsgbuf
;
2770 if (0 < yysize
&& yysize
<= yymsg_alloc
)
2772 (void) yysyntax_error (yymsg
, yystate
, yychar
);
2777 yyerror (YY_("syntax error"));
2779 goto yyexhaustedlab
;
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
)
2800 yydestruct ("Error: discarding",
2806 /* Else will try to reuse look-ahead token after shifting the error
2811 /*---------------------------------------------------.
2812 | yyerrorlab -- error raised explicitly by YYERROR. |
2813 `---------------------------------------------------*/
2816 /* Pacify compilers like GCC when the user code never invokes
2817 YYERROR and the label yyerrorlab therefore never appears in user
2819 if (/*CONSTCOND*/ 0)
2822 /* Do not reclaim the symbols of the rule which action triggered
2826 YY_STACK_PRINT (yyss
, yyssp
);
2831 /*-------------------------------------------------------------.
2832 | yyerrlab1 -- common code for both syntax error and YYERROR. |
2833 `-------------------------------------------------------------*/
2835 yyerrstatus
= 3; /* Each real token shifted decrements this. */
2839 yyn
= yypact
[yystate
];
2840 if (yyn
!= YYPACT_NINF
)
2843 if (0 <= yyn
&& yyn
<= YYLAST
&& yycheck
[yyn
] == YYTERROR
)
2851 /* Pop the current state because it cannot handle the error token. */
2856 yydestruct ("Error: popping",
2857 yystos
[yystate
], yyvsp
);
2860 YY_STACK_PRINT (yyss
, yyssp
);
2869 /* Shift the error token. */
2870 YY_SYMBOL_PRINT ("Shifting", yystos
[yyn
], yyvsp
, yylsp
);
2876 /*-------------------------------------.
2877 | yyacceptlab -- YYACCEPT comes here. |
2878 `-------------------------------------*/
2883 /*-----------------------------------.
2884 | yyabortlab -- YYABORT comes here. |
2885 `-----------------------------------*/
2891 /*-------------------------------------------------.
2892 | yyexhaustedlab -- memory exhaustion comes here. |
2893 `-------------------------------------------------*/
2895 yyerror (YY_("memory exhausted"));
2901 if (yychar
!= YYEOF
&& yychar
!= YYEMPTY
)
2902 yydestruct ("Cleanup: discarding lookahead",
2904 /* Do not reclaim the symbols of the rule which action triggered
2905 this YYABORT or YYACCEPT. */
2907 YY_STACK_PRINT (yyss
, yyssp
);
2908 while (yyssp
!= yyss
)
2910 yydestruct ("Cleanup: popping",
2911 yystos
[*yyssp
], yyvsp
);
2916 YYSTACK_FREE (yyss
);
2919 if (yymsg
!= yymsgbuf
)
2920 YYSTACK_FREE (yymsg
);
2922 /* Make sure YYID is used. */
2923 return YYID (yyresult
);
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
);
2940 if (!(yyin
= fopen(argv
[1], "r"))) {
2941 printf("Error reading source file %s.\n", argv
[1]);
2946 printf("No source file specified.\n");
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");
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");
2985 dump_namespace(current_namespace);
2987 printf("# Cola (%s) generated\n#\n", COLA_VERSION
);
2989 fprintf(stderr
, "Pass 4: Code generation...\n");
2995 printf("# Include standard API stuff\n");
2996 printf(".include \"core.pir\"\n\n");
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");
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");
3019 * c-file-style: "parrot"
3021 * vim: expandtab shiftwidth=4: