2 /* A Bison parser, made by GNU Bison 2.4.1. */
4 /* Skeleton implementation for Bison's Yacc-like parsers in C
6 Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
7 Free Software Foundation, Inc.
9 This program is free software: you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation, either version 3 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with this program. If not, see <http://www.gnu.org/licenses/>. */
22 /* As a special exception, you may create a larger work that contains
23 part or all of the Bison parser skeleton and distribute that work
24 under terms of your choice, so long as that work isn't itself a
25 parser generator using the skeleton or a modified version thereof
26 as a parser skeleton. Alternatively, if you modify or redistribute
27 the parser skeleton itself, you may (at your option) remove this
28 special exception, which will cause the skeleton and the resulting
29 Bison output files to be licensed under the GNU General Public
30 License without this special exception.
32 This special exception was added by the Free Software Foundation in
33 version 2.2 of Bison. */
35 /* C LALR(1) parser skeleton written by Richard Stallman, by
36 simplifying the original so-called "semantic" parser. */
38 /* All symbols defined below should begin with yy or YY, to avoid
39 infringing on user name space. This should be done even for local
40 variables, as they might otherwise be expanded by user macros.
41 There are some unavoidable exceptions within include files to
42 define necessary library symbols; they are noted "INFRINGES ON
43 USER NAME SPACE" below. */
45 /* Identify Bison output. */
49 #define YYBISON_VERSION "2.4.1"
52 #define YYSKELETON_NAME "yacc.c"
63 /* Using locations. */
64 #define YYLSP_NEEDED 1
68 /* Copy the first part of user declarations. */
70 /* Line 189 of yacc.c */
71 #line 1 "glcpp/glcpp-parse.y"
74 * Copyright © 2010 Intel Corporation
76 * Permission is hereby granted, free of charge, to any person obtaining a
77 * copy of this software and associated documentation files (the "Software"),
78 * to deal in the Software without restriction, including without limitation
79 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
80 * and/or sell copies of the Software, and to permit persons to whom the
81 * Software is furnished to do so, subject to the following conditions:
83 * The above copyright notice and this permission notice (including the next
84 * paragraph) shall be included in all copies or substantial portions of the
87 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
88 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
89 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
90 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
91 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
92 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
93 * DEALINGS IN THE SOFTWARE.
100 #include <inttypes.h>
103 #include "main/mtypes.h"
105 #define glcpp_print(stream, str) stream = talloc_strdup_append(stream, str)
106 #define glcpp_printf(stream, fmt, args...) \
107 stream = talloc_asprintf_append(stream, fmt, args)
110 yyerror (YYLTYPE
*locp
, glcpp_parser_t
*parser
, const char *error
);
113 _define_object_macro (glcpp_parser_t
*parser
,
116 token_list_t
*replacements
);
119 _define_function_macro (glcpp_parser_t
*parser
,
122 string_list_t
*parameters
,
123 token_list_t
*replacements
);
125 static string_list_t
*
126 _string_list_create (void *ctx
);
129 _string_list_append_item (string_list_t
*list
, const char *str
);
132 _string_list_contains (string_list_t
*list
, const char *member
, int *index
);
135 _string_list_length (string_list_t
*list
);
137 static argument_list_t
*
138 _argument_list_create (void *ctx
);
141 _argument_list_append (argument_list_t
*list
, token_list_t
*argument
);
144 _argument_list_length (argument_list_t
*list
);
146 static token_list_t
*
147 _argument_list_member_at (argument_list_t
*list
, int index
);
149 /* Note: This function talloc_steal()s the str pointer. */
151 _token_create_str (void *ctx
, int type
, char *str
);
154 _token_create_ival (void *ctx
, int type
, int ival
);
156 static token_list_t
*
157 _token_list_create (void *ctx
);
159 /* Note: This function adds a talloc_reference() to token.
161 * You may want to talloc_unlink any current reference if you no
164 _token_list_append (token_list_t
*list
, token_t
*token
);
167 _token_list_append_list (token_list_t
*list
, token_list_t
*tail
);
169 static active_list_t
*
170 _active_list_push (active_list_t
*list
,
171 const char *identifier
,
172 token_node_t
*marker
);
174 static active_list_t
*
175 _active_list_pop (active_list_t
*list
);
178 _active_list_contains (active_list_t
*list
, const char *identifier
);
181 _glcpp_parser_expand_if (glcpp_parser_t
*parser
, int type
, token_list_t
*list
);
184 _glcpp_parser_expand_token_list (glcpp_parser_t
*parser
,
188 _glcpp_parser_print_expanded_token_list (glcpp_parser_t
*parser
,
192 _glcpp_parser_skip_stack_push_if (glcpp_parser_t
*parser
, YYLTYPE
*loc
,
196 _glcpp_parser_skip_stack_change_if (glcpp_parser_t
*parser
, YYLTYPE
*loc
,
197 const char *type
, int condition
);
200 _glcpp_parser_skip_stack_pop (glcpp_parser_t
*parser
, YYLTYPE
*loc
);
202 #define yylex glcpp_parser_lex
205 glcpp_parser_lex (YYSTYPE
*yylval
, YYLTYPE
*yylloc
, glcpp_parser_t
*parser
);
208 glcpp_parser_lex_from (glcpp_parser_t
*parser
, token_list_t
*list
);
211 add_builtin_define(glcpp_parser_t
*parser
, const char *name
, int value
);
215 /* Line 189 of yacc.c */
216 #line 217 "glcpp/glcpp-parse.c"
218 /* Enabling traces. */
223 /* Enabling verbose error messages. */
224 #ifdef YYERROR_VERBOSE
225 # undef YYERROR_VERBOSE
226 # define YYERROR_VERBOSE 1
228 # define YYERROR_VERBOSE 1
231 /* Enabling the token table. */
232 #ifndef YYTOKEN_TABLE
233 # define YYTOKEN_TABLE 0
240 /* Put the tokens into the symbol table, so that GDB and other debuggers
247 HASH_DEFINE_FUNC
= 262,
248 HASH_DEFINE_OBJ
= 263,
260 INTEGER_STRING
= 275,
270 GREATER_OR_EQUAL
= 285,
280 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
282 # define yystype YYSTYPE /* obsolescent; will be withdrawn */
283 # define YYSTYPE_IS_DECLARED 1
286 #if ! defined YYLTYPE && ! defined YYLTYPE_IS_DECLARED
287 typedef struct YYLTYPE
294 # define yyltype YYLTYPE /* obsolescent; will be withdrawn */
295 # define YYLTYPE_IS_DECLARED 1
296 # define YYLTYPE_IS_TRIVIAL 1
300 /* Copy the second part of user declarations. */
303 /* Line 264 of yacc.c */
304 #line 305 "glcpp/glcpp-parse.c"
311 typedef YYTYPE_UINT8 yytype_uint8
;
313 typedef unsigned char yytype_uint8
;
317 typedef YYTYPE_INT8 yytype_int8
;
318 #elif (defined __STDC__ || defined __C99__FUNC__ \
319 || defined __cplusplus || defined _MSC_VER)
320 typedef signed char yytype_int8
;
322 typedef short int yytype_int8
;
326 typedef YYTYPE_UINT16 yytype_uint16
;
328 typedef unsigned short int yytype_uint16
;
332 typedef YYTYPE_INT16 yytype_int16
;
334 typedef short int yytype_int16
;
338 # ifdef __SIZE_TYPE__
339 # define YYSIZE_T __SIZE_TYPE__
340 # elif defined size_t
341 # define YYSIZE_T size_t
342 # elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \
343 || defined __cplusplus || defined _MSC_VER)
344 # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
345 # define YYSIZE_T size_t
347 # define YYSIZE_T unsigned int
351 #define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
356 # include <libintl.h> /* INFRINGES ON USER NAME SPACE */
357 # define YY_(msgid) dgettext ("bison-runtime", msgid)
361 # define YY_(msgid) msgid
365 /* Suppress unused-variable warnings by "using" E. */
366 #if ! defined lint || defined __GNUC__
367 # define YYUSE(e) ((void) (e))
369 # define YYUSE(e) /* empty */
372 /* Identity function, used to suppress warnings about constant conditions. */
376 #if (defined __STDC__ || defined __C99__FUNC__ \
377 || defined __cplusplus || defined _MSC_VER)
390 #if ! defined yyoverflow || YYERROR_VERBOSE
392 /* The parser invokes alloca or malloc; define the necessary symbols. */
394 # ifdef YYSTACK_USE_ALLOCA
395 # if YYSTACK_USE_ALLOCA
397 # define YYSTACK_ALLOC __builtin_alloca
398 # elif defined __BUILTIN_VA_ARG_INCR
399 # include <alloca.h> /* INFRINGES ON USER NAME SPACE */
401 # define YYSTACK_ALLOC __alloca
402 # elif defined _MSC_VER
403 # include <malloc.h> /* INFRINGES ON USER NAME SPACE */
404 # define alloca _alloca
406 # define YYSTACK_ALLOC alloca
407 # if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
408 || defined __cplusplus || defined _MSC_VER)
409 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
418 # ifdef YYSTACK_ALLOC
419 /* Pacify GCC's `empty if-body' warning. */
420 # define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0))
421 # ifndef YYSTACK_ALLOC_MAXIMUM
422 /* The OS might guarantee only one guard page at the bottom of the stack,
423 and a page size can be as small as 4096 bytes. So we cannot safely
424 invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
425 to allow for a few compiler-allocated temporary stack slots. */
426 # define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
429 # define YYSTACK_ALLOC YYMALLOC
430 # define YYSTACK_FREE YYFREE
431 # ifndef YYSTACK_ALLOC_MAXIMUM
432 # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
434 # if (defined __cplusplus && ! defined _STDLIB_H \
435 && ! ((defined YYMALLOC || defined malloc) \
436 && (defined YYFREE || defined free)))
437 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
443 # define YYMALLOC malloc
444 # if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
445 || defined __cplusplus || defined _MSC_VER)
446 void *malloc (YYSIZE_T
); /* INFRINGES ON USER NAME SPACE */
451 # if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
452 || defined __cplusplus || defined _MSC_VER)
453 void free (void *); /* INFRINGES ON USER NAME SPACE */
457 #endif /* ! defined yyoverflow || YYERROR_VERBOSE */
460 #if (! defined yyoverflow \
461 && (! defined __cplusplus \
462 || (defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL \
463 && defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
465 /* A type that is properly aligned for any stack member. */
468 yytype_int16 yyss_alloc
;
473 /* The size of the maximum gap between one aligned stack and the next. */
474 # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
476 /* The size of an array large to enough to hold all stacks, each with
478 # define YYSTACK_BYTES(N) \
479 ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE) + sizeof (YYLTYPE)) \
480 + 2 * YYSTACK_GAP_MAXIMUM)
482 /* Copy COUNT objects from FROM to TO. The source and destination do
485 # if defined __GNUC__ && 1 < __GNUC__
486 # define YYCOPY(To, From, Count) \
487 __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
489 # define YYCOPY(To, From, Count) \
493 for (yyi = 0; yyi < (Count); yyi++) \
494 (To)[yyi] = (From)[yyi]; \
500 /* Relocate STACK from its old location to the new one. The
501 local variables YYSIZE and YYSTACKSIZE give the old and new number of
502 elements in the stack, and YYPTR gives the new location of the
503 stack. Advance YYPTR to a properly aligned location for the next
505 # define YYSTACK_RELOCATE(Stack_alloc, Stack) \
508 YYSIZE_T yynewbytes; \
509 YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \
510 Stack = &yyptr->Stack_alloc; \
511 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
512 yyptr += yynewbytes / sizeof (*yyptr); \
518 /* YYFINAL -- State number of the termination state. */
520 /* YYLAST -- Last index in YYTABLE. */
523 /* YYNTOKENS -- Number of terminals. */
525 /* YYNNTS -- Number of nonterminals. */
527 /* YYNRULES -- Number of rules. */
529 /* YYNRULES -- Number of states. */
530 #define YYNSTATES 162
532 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
534 #define YYMAXUTOK 289
536 #define YYTRANSLATE(YYX) \
537 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
539 /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
540 static const yytype_uint8 yytranslate
[] =
542 0, 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, 47, 2, 2, 2, 43, 30, 2,
546 45, 46, 41, 39, 49, 40, 54, 42, 2, 2,
547 2, 2, 2, 2, 2, 2, 2, 2, 2, 55,
548 33, 56, 34, 2, 2, 2, 2, 2, 2, 2,
549 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
550 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
551 2, 50, 2, 51, 29, 2, 2, 2, 2, 2,
552 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
553 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
554 2, 2, 2, 52, 28, 53, 48, 2, 2, 2,
555 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
556 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
557 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
558 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
559 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
560 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
561 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
562 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
563 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
564 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
565 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
566 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
567 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
568 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
569 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
570 25, 26, 27, 31, 32, 35, 36, 37, 38, 44
574 /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
576 static const yytype_uint16 yyprhs
[] =
578 0, 0, 3, 4, 7, 9, 11, 13, 16, 20,
579 24, 29, 36, 44, 48, 52, 55, 60, 65, 69,
580 72, 75, 78, 82, 85, 87, 89, 91, 95, 99,
581 103, 107, 111, 115, 119, 123, 127, 131, 135, 139,
582 143, 147, 151, 155, 159, 163, 166, 169, 172, 175,
583 179, 181, 185, 187, 190, 193, 194, 196, 197, 199,
584 202, 207, 209, 211, 214, 216, 219, 221, 223, 225,
585 227, 229, 231, 233, 235, 237, 239, 241, 243, 245,
586 247, 249, 251, 253, 255, 257, 259, 261, 263, 265,
587 267, 269, 271, 273, 275, 277, 279, 281, 283, 285,
591 /* YYRHS -- A `-1'-separated list of the rules' RHS. */
592 static const yytype_int8 yyrhs
[] =
594 58, 0, -1, -1, 58, 59, -1, 61, -1, 65,
595 -1, 60, -1, 6, 66, -1, 18, 63, 21, -1,
596 5, 63, 21, -1, 8, 17, 67, 21, -1, 7,
597 17, 45, 46, 67, 21, -1, 7, 17, 45, 64,
598 46, 67, 21, -1, 15, 17, 21, -1, 12, 70,
599 21, -1, 12, 21, -1, 13, 17, 68, 21, -1,
600 14, 17, 68, 21, -1, 9, 70, 21, -1, 9,
601 21, -1, 10, 21, -1, 11, 21, -1, 16, 62,
602 21, -1, 6, 21, -1, 20, -1, 19, -1, 62,
603 -1, 63, 26, 63, -1, 63, 27, 63, -1, 63,
604 28, 63, -1, 63, 29, 63, -1, 63, 30, 63,
605 -1, 63, 31, 63, -1, 63, 32, 63, -1, 63,
606 35, 63, -1, 63, 36, 63, -1, 63, 34, 63,
607 -1, 63, 33, 63, -1, 63, 37, 63, -1, 63,
608 38, 63, -1, 63, 40, 63, -1, 63, 39, 63,
609 -1, 63, 43, 63, -1, 63, 42, 63, -1, 63,
610 41, 63, -1, 47, 63, -1, 48, 63, -1, 40,
611 63, -1, 39, 63, -1, 45, 63, 46, -1, 17,
612 -1, 64, 49, 17, -1, 21, -1, 71, 21, -1,
613 71, 21, -1, -1, 71, -1, -1, 71, -1, 4,
614 17, -1, 4, 45, 17, 46, -1, 72, -1, 69,
615 -1, 70, 69, -1, 72, -1, 71, 72, -1, 17,
616 -1, 20, -1, 73, -1, 22, -1, 24, -1, 50,
617 -1, 51, -1, 45, -1, 46, -1, 52, -1, 53,
618 -1, 54, -1, 30, -1, 41, -1, 39, -1, 40,
619 -1, 48, -1, 47, -1, 42, -1, 43, -1, 38,
620 -1, 37, -1, 33, -1, 34, -1, 36, -1, 35,
621 -1, 32, -1, 31, -1, 29, -1, 28, -1, 27,
622 -1, 26, -1, 55, -1, 49, -1, 56, -1, 25,
626 /* YYRLINE[YYN] -- source line where rule number YYN was defined. */
627 static const yytype_uint16 yyrline
[] =
629 0, 181, 181, 183, 187, 190, 195, 196, 200, 203,
630 209, 212, 215, 218, 226, 245, 255, 260, 265, 284,
631 299, 302, 305, 314, 318, 327, 332, 333, 336, 339,
632 342, 345, 348, 351, 354, 357, 360, 363, 366, 369,
633 372, 375, 378, 381, 384, 387, 390, 393, 396, 399,
634 405, 410, 418, 419, 423, 429, 430, 433, 435, 442,
635 446, 450, 455, 461, 469, 475, 483, 487, 491, 495,
636 499, 506, 507, 508, 509, 510, 511, 512, 513, 514,
637 515, 516, 517, 518, 519, 520, 521, 522, 523, 524,
638 525, 526, 527, 528, 529, 530, 531, 532, 533, 534,
643 #if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
644 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
645 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
646 static const char *const yytname
[] =
648 "$end", "error", "$undefined", "COMMA_FINAL", "DEFINED",
649 "ELIF_EXPANDED", "HASH", "HASH_DEFINE_FUNC", "HASH_DEFINE_OBJ",
650 "HASH_ELIF", "HASH_ELSE", "HASH_ENDIF", "HASH_IF", "HASH_IFDEF",
651 "HASH_IFNDEF", "HASH_UNDEF", "HASH_VERSION", "IDENTIFIER", "IF_EXPANDED",
652 "INTEGER", "INTEGER_STRING", "NEWLINE", "OTHER", "PLACEHOLDER", "SPACE",
653 "PASTE", "OR", "AND", "'|'", "'^'", "'&'", "NOT_EQUAL", "EQUAL", "'<'",
654 "'>'", "GREATER_OR_EQUAL", "LESS_OR_EQUAL", "RIGHT_SHIFT", "LEFT_SHIFT",
655 "'+'", "'-'", "'*'", "'/'", "'%'", "UNARY", "'('", "')'", "'!'", "'~'",
656 "','", "'['", "']'", "'{'", "'}'", "'.'", "';'", "'='", "$accept",
657 "input", "line", "expanded_line", "control_line", "integer_constant",
658 "expression", "identifier_list", "text_line", "non_directive",
659 "replacement_list", "junk", "conditional_token", "conditional_tokens",
660 "pp_tokens", "preprocessing_token", "operator", 0
665 /* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
667 static const yytype_uint16 yytoknum
[] =
669 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
670 265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
671 275, 276, 277, 278, 279, 280, 281, 282, 124, 94,
672 38, 283, 284, 60, 62, 285, 286, 287, 288, 43,
673 45, 42, 47, 37, 289, 40, 41, 33, 126, 44,
674 91, 93, 123, 125, 46, 59, 61
678 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
679 static const yytype_uint8 yyr1
[] =
681 0, 57, 58, 58, 59, 59, 59, 59, 60, 60,
682 61, 61, 61, 61, 61, 61, 61, 61, 61, 61,
683 61, 61, 61, 61, 62, 62, 63, 63, 63, 63,
684 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
685 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
686 64, 64, 65, 65, 66, 67, 67, 68, 68, 69,
687 69, 69, 70, 70, 71, 71, 72, 72, 72, 72,
688 72, 73, 73, 73, 73, 73, 73, 73, 73, 73,
689 73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
690 73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
694 /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
695 static const yytype_uint8 yyr2
[] =
697 0, 2, 0, 2, 1, 1, 1, 2, 3, 3,
698 4, 6, 7, 3, 3, 2, 4, 4, 3, 2,
699 2, 2, 3, 2, 1, 1, 1, 3, 3, 3,
700 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
701 3, 3, 3, 3, 3, 2, 2, 2, 2, 3,
702 1, 3, 1, 2, 2, 0, 1, 0, 1, 2,
703 4, 1, 1, 2, 1, 2, 1, 1, 1, 1,
704 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
705 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
706 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
710 /* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
711 STATE-NUM when YYTABLE doesn't specify something else to do. Zero
712 means the default is an error. */
713 static const yytype_uint8 yydefact
[] =
715 2, 0, 1, 0, 0, 0, 0, 0, 0, 0,
716 0, 0, 0, 0, 0, 66, 0, 67, 52, 69,
717 70, 101, 97, 96, 95, 94, 78, 93, 92, 88,
718 89, 91, 90, 87, 86, 80, 81, 79, 84, 85,
719 73, 74, 83, 82, 99, 71, 72, 75, 76, 77,
720 98, 100, 3, 6, 4, 5, 0, 64, 68, 25,
721 24, 0, 0, 0, 0, 0, 26, 0, 23, 7,
722 0, 0, 55, 0, 19, 62, 0, 61, 20, 21,
723 15, 0, 57, 57, 0, 0, 0, 53, 65, 48,
724 47, 0, 45, 46, 9, 0, 0, 0, 0, 0,
725 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
726 0, 0, 0, 54, 0, 0, 56, 59, 0, 18,
727 63, 14, 0, 58, 0, 13, 22, 8, 49, 27,
728 28, 29, 30, 31, 32, 33, 37, 36, 34, 35,
729 38, 39, 41, 40, 44, 43, 42, 50, 55, 0,
730 10, 0, 16, 17, 0, 55, 0, 60, 11, 0,
734 /* YYDEFGOTO[NTERM-NUM]. */
735 static const yytype_int16 yydefgoto
[] =
737 -1, 1, 52, 53, 54, 66, 67, 149, 55, 69,
738 115, 122, 75, 76, 116, 57, 58
741 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
743 #define YYPACT_NINF -147
744 static const yytype_int16 yypact
[] =
746 -147, 112, -147, 28, -10, 55, 62, 152, -15, 59,
747 192, 85, 86, 87, 51, -147, 28, -147, -147, -147,
748 -147, -147, -147, -147, -147, -147, -147, -147, -147, -147,
749 -147, -147, -147, -147, -147, -147, -147, -147, -147, -147,
750 -147, -147, -147, -147, -147, -147, -147, -147, -147, -147,
751 -147, -147, -147, -147, -147, -147, 312, -147, -147, -147,
752 -147, 28, 28, 28, 28, 28, -147, 428, -147, -147,
753 352, 63, 392, 17, -147, -147, 232, -147, -147, -147,
754 -147, 272, 392, 392, 84, 89, 451, -147, -147, -147,
755 -147, 469, -147, -147, -147, 28, 28, 28, 28, 28,
756 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
757 28, 28, 28, -147, 60, 90, 392, -147, 96, -147,
758 -147, -147, 93, 392, 94, -147, -147, -147, -147, 489,
759 505, 520, 534, 547, 558, 558, 18, 18, 18, 18,
760 563, 563, 23, 23, -147, -147, -147, -147, 392, 32,
761 -147, 61, -147, -147, 110, 392, 118, -147, -147, 149,
765 /* YYPGOTO[NTERM-NUM]. */
766 static const yytype_int16 yypgoto
[] =
768 -147, -147, -147, -147, -147, 157, -11, -147, -147, -147,
769 -146, 92, -68, 200, 0, -7, -147
772 /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
773 positive, shift that token. If negative, reduce the rule which
774 number is the opposite. If zero, do what YYDEFACT says.
775 If YYTABLE_NINF, syntax error. */
776 #define YYTABLE_NINF -1
777 static const yytype_uint8 yytable
[] =
779 77, 56, 154, 77, 70, 86, 78, 15, 120, 159,
780 17, 68, 19, 120, 20, 21, 22, 23, 24, 25,
781 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
782 36, 37, 38, 39, 117, 40, 41, 42, 43, 44,
783 45, 46, 47, 48, 49, 50, 51, 59, 60, 88,
784 89, 90, 91, 92, 93, 106, 107, 108, 109, 110,
785 111, 112, 118, 88, 110, 111, 112, 61, 62, 77,
786 59, 60, 71, 63, 77, 64, 65, 147, 155, 72,
787 79, 156, 123, 123, 129, 130, 131, 132, 133, 134,
788 135, 136, 137, 138, 139, 140, 141, 142, 143, 144,
789 145, 146, 82, 83, 84, 125, 148, 157, 114, 88,
790 126, 150, 2, 151, 152, 153, 88, 3, 4, 5,
791 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
792 16, 158, 17, 18, 19, 160, 20, 21, 22, 23,
793 24, 25, 26, 27, 28, 29, 30, 31, 32, 33,
794 34, 35, 36, 37, 38, 39, 73, 40, 41, 42,
795 43, 44, 45, 46, 47, 48, 49, 50, 51, 15,
796 161, 85, 17, 74, 19, 124, 20, 21, 22, 23,
797 24, 25, 26, 27, 28, 29, 30, 31, 32, 33,
798 34, 35, 36, 37, 38, 39, 73, 40, 41, 42,
799 43, 44, 45, 46, 47, 48, 49, 50, 51, 15,
800 81, 0, 17, 80, 19, 0, 20, 21, 22, 23,
801 24, 25, 26, 27, 28, 29, 30, 31, 32, 33,
802 34, 35, 36, 37, 38, 39, 73, 40, 41, 42,
803 43, 44, 45, 46, 47, 48, 49, 50, 51, 15,
804 0, 0, 17, 119, 19, 0, 20, 21, 22, 23,
805 24, 25, 26, 27, 28, 29, 30, 31, 32, 33,
806 34, 35, 36, 37, 38, 39, 73, 40, 41, 42,
807 43, 44, 45, 46, 47, 48, 49, 50, 51, 15,
808 0, 0, 17, 121, 19, 0, 20, 21, 22, 23,
809 24, 25, 26, 27, 28, 29, 30, 31, 32, 33,
810 34, 35, 36, 37, 38, 39, 0, 40, 41, 42,
811 43, 44, 45, 46, 47, 48, 49, 50, 51, 15,
812 0, 0, 17, 87, 19, 0, 20, 21, 22, 23,
813 24, 25, 26, 27, 28, 29, 30, 31, 32, 33,
814 34, 35, 36, 37, 38, 39, 0, 40, 41, 42,
815 43, 44, 45, 46, 47, 48, 49, 50, 51, 15,
816 0, 0, 17, 113, 19, 0, 20, 21, 22, 23,
817 24, 25, 26, 27, 28, 29, 30, 31, 32, 33,
818 34, 35, 36, 37, 38, 39, 0, 40, 41, 42,
819 43, 44, 45, 46, 47, 48, 49, 50, 51, 15,
820 0, 0, 17, 0, 19, 0, 20, 21, 22, 23,
821 24, 25, 26, 27, 28, 29, 30, 31, 32, 33,
822 34, 35, 36, 37, 38, 39, 0, 40, 41, 42,
823 43, 44, 45, 46, 47, 48, 49, 50, 51, 94,
824 0, 0, 0, 0, 95, 96, 97, 98, 99, 100,
825 101, 102, 103, 104, 105, 106, 107, 108, 109, 110,
826 111, 112, 127, 0, 0, 0, 0, 95, 96, 97,
827 98, 99, 100, 101, 102, 103, 104, 105, 106, 107,
828 108, 109, 110, 111, 112, 95, 96, 97, 98, 99,
829 100, 101, 102, 103, 104, 105, 106, 107, 108, 109,
830 110, 111, 112, 0, 0, 128, 96, 97, 98, 99,
831 100, 101, 102, 103, 104, 105, 106, 107, 108, 109,
832 110, 111, 112, 97, 98, 99, 100, 101, 102, 103,
833 104, 105, 106, 107, 108, 109, 110, 111, 112, 98,
834 99, 100, 101, 102, 103, 104, 105, 106, 107, 108,
835 109, 110, 111, 112, 99, 100, 101, 102, 103, 104,
836 105, 106, 107, 108, 109, 110, 111, 112, 100, 101,
837 102, 103, 104, 105, 106, 107, 108, 109, 110, 111,
838 112, 102, 103, 104, 105, 106, 107, 108, 109, 110,
839 111, 112, 108, 109, 110, 111, 112
842 static const yytype_int16 yycheck
[] =
844 7, 1, 148, 10, 4, 16, 21, 17, 76, 155,
845 20, 21, 22, 81, 24, 25, 26, 27, 28, 29,
846 30, 31, 32, 33, 34, 35, 36, 37, 38, 39,
847 40, 41, 42, 43, 17, 45, 46, 47, 48, 49,
848 50, 51, 52, 53, 54, 55, 56, 19, 20, 56,
849 61, 62, 63, 64, 65, 37, 38, 39, 40, 41,
850 42, 43, 45, 70, 41, 42, 43, 39, 40, 76,
851 19, 20, 17, 45, 81, 47, 48, 17, 46, 17,
852 21, 49, 82, 83, 95, 96, 97, 98, 99, 100,
853 101, 102, 103, 104, 105, 106, 107, 108, 109, 110,
854 111, 112, 17, 17, 17, 21, 46, 46, 45, 116,
855 21, 21, 0, 17, 21, 21, 123, 5, 6, 7,
856 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
857 18, 21, 20, 21, 22, 17, 24, 25, 26, 27,
858 28, 29, 30, 31, 32, 33, 34, 35, 36, 37,
859 38, 39, 40, 41, 42, 43, 4, 45, 46, 47,
860 48, 49, 50, 51, 52, 53, 54, 55, 56, 17,
861 21, 14, 20, 21, 22, 83, 24, 25, 26, 27,
862 28, 29, 30, 31, 32, 33, 34, 35, 36, 37,
863 38, 39, 40, 41, 42, 43, 4, 45, 46, 47,
864 48, 49, 50, 51, 52, 53, 54, 55, 56, 17,
865 10, -1, 20, 21, 22, -1, 24, 25, 26, 27,
866 28, 29, 30, 31, 32, 33, 34, 35, 36, 37,
867 38, 39, 40, 41, 42, 43, 4, 45, 46, 47,
868 48, 49, 50, 51, 52, 53, 54, 55, 56, 17,
869 -1, -1, 20, 21, 22, -1, 24, 25, 26, 27,
870 28, 29, 30, 31, 32, 33, 34, 35, 36, 37,
871 38, 39, 40, 41, 42, 43, 4, 45, 46, 47,
872 48, 49, 50, 51, 52, 53, 54, 55, 56, 17,
873 -1, -1, 20, 21, 22, -1, 24, 25, 26, 27,
874 28, 29, 30, 31, 32, 33, 34, 35, 36, 37,
875 38, 39, 40, 41, 42, 43, -1, 45, 46, 47,
876 48, 49, 50, 51, 52, 53, 54, 55, 56, 17,
877 -1, -1, 20, 21, 22, -1, 24, 25, 26, 27,
878 28, 29, 30, 31, 32, 33, 34, 35, 36, 37,
879 38, 39, 40, 41, 42, 43, -1, 45, 46, 47,
880 48, 49, 50, 51, 52, 53, 54, 55, 56, 17,
881 -1, -1, 20, 21, 22, -1, 24, 25, 26, 27,
882 28, 29, 30, 31, 32, 33, 34, 35, 36, 37,
883 38, 39, 40, 41, 42, 43, -1, 45, 46, 47,
884 48, 49, 50, 51, 52, 53, 54, 55, 56, 17,
885 -1, -1, 20, -1, 22, -1, 24, 25, 26, 27,
886 28, 29, 30, 31, 32, 33, 34, 35, 36, 37,
887 38, 39, 40, 41, 42, 43, -1, 45, 46, 47,
888 48, 49, 50, 51, 52, 53, 54, 55, 56, 21,
889 -1, -1, -1, -1, 26, 27, 28, 29, 30, 31,
890 32, 33, 34, 35, 36, 37, 38, 39, 40, 41,
891 42, 43, 21, -1, -1, -1, -1, 26, 27, 28,
892 29, 30, 31, 32, 33, 34, 35, 36, 37, 38,
893 39, 40, 41, 42, 43, 26, 27, 28, 29, 30,
894 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
895 41, 42, 43, -1, -1, 46, 27, 28, 29, 30,
896 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
897 41, 42, 43, 28, 29, 30, 31, 32, 33, 34,
898 35, 36, 37, 38, 39, 40, 41, 42, 43, 29,
899 30, 31, 32, 33, 34, 35, 36, 37, 38, 39,
900 40, 41, 42, 43, 30, 31, 32, 33, 34, 35,
901 36, 37, 38, 39, 40, 41, 42, 43, 31, 32,
902 33, 34, 35, 36, 37, 38, 39, 40, 41, 42,
903 43, 33, 34, 35, 36, 37, 38, 39, 40, 41,
904 42, 43, 39, 40, 41, 42, 43
907 /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
908 symbol of state STATE-NUM. */
909 static const yytype_uint8 yystos
[] =
911 0, 58, 0, 5, 6, 7, 8, 9, 10, 11,
912 12, 13, 14, 15, 16, 17, 18, 20, 21, 22,
913 24, 25, 26, 27, 28, 29, 30, 31, 32, 33,
914 34, 35, 36, 37, 38, 39, 40, 41, 42, 43,
915 45, 46, 47, 48, 49, 50, 51, 52, 53, 54,
916 55, 56, 59, 60, 61, 65, 71, 72, 73, 19,
917 20, 39, 40, 45, 47, 48, 62, 63, 21, 66,
918 71, 17, 17, 4, 21, 69, 70, 72, 21, 21,
919 21, 70, 17, 17, 17, 62, 63, 21, 72, 63,
920 63, 63, 63, 63, 21, 26, 27, 28, 29, 30,
921 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
922 41, 42, 43, 21, 45, 67, 71, 17, 45, 21,
923 69, 21, 68, 71, 68, 21, 21, 21, 46, 63,
924 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
925 63, 63, 63, 63, 63, 63, 63, 17, 46, 64,
926 21, 17, 21, 21, 67, 46, 49, 46, 21, 67,
930 #define yyerrok (yyerrstatus = 0)
931 #define yyclearin (yychar = YYEMPTY)
935 #define YYACCEPT goto yyacceptlab
936 #define YYABORT goto yyabortlab
937 #define YYERROR goto yyerrorlab
940 /* Like YYERROR except do call yyerror. This remains here temporarily
941 to ease the transition to the new meaning of YYERROR, for GCC.
942 Once GCC version 2 has supplanted version 1, this can go. */
944 #define YYFAIL goto yyerrlab
946 #define YYRECOVERING() (!!yyerrstatus)
948 #define YYBACKUP(Token, Value) \
950 if (yychar == YYEMPTY && yylen == 1) \
954 yytoken = YYTRANSLATE (yychar); \
960 yyerror (&yylloc, parser, YY_("syntax error: cannot back up")); \
967 #define YYERRCODE 256
970 /* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
971 If N is 0, then set CURRENT to the empty location which ends
972 the previous symbol: RHS[0] (always defined). */
974 #define YYRHSLOC(Rhs, K) ((Rhs)[K])
975 #ifndef YYLLOC_DEFAULT
976 # define YYLLOC_DEFAULT(Current, Rhs, N) \
980 (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
981 (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
982 (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
983 (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
987 (Current).first_line = (Current).last_line = \
988 YYRHSLOC (Rhs, 0).last_line; \
989 (Current).first_column = (Current).last_column = \
990 YYRHSLOC (Rhs, 0).last_column; \
996 /* YY_LOCATION_PRINT -- Print the location on the stream.
997 This macro was not mandated originally: define only if we know
998 we won't break user code: when these are the locations we know. */
1000 #ifndef YY_LOCATION_PRINT
1001 # if YYLTYPE_IS_TRIVIAL
1002 # define YY_LOCATION_PRINT(File, Loc) \
1003 fprintf (File, "%d.%d-%d.%d", \
1004 (Loc).first_line, (Loc).first_column, \
1005 (Loc).last_line, (Loc).last_column)
1007 # define YY_LOCATION_PRINT(File, Loc) ((void) 0)
1012 /* YYLEX -- calling `yylex' with the right arguments. */
1015 # define YYLEX yylex (&yylval, &yylloc, YYLEX_PARAM)
1017 # define YYLEX yylex (&yylval, &yylloc, parser)
1020 /* Enable debugging if requested. */
1024 # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
1025 # define YYFPRINTF fprintf
1028 # define YYDPRINTF(Args) \
1034 # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
1038 YYFPRINTF (stderr, "%s ", Title); \
1039 yy_symbol_print (stderr, \
1040 Type, Value, Location, parser); \
1041 YYFPRINTF (stderr, "\n"); \
1046 /*--------------------------------.
1047 | Print this symbol on YYOUTPUT. |
1048 `--------------------------------*/
1051 #if (defined __STDC__ || defined __C99__FUNC__ \
1052 || defined __cplusplus || defined _MSC_VER)
1054 yy_symbol_value_print (FILE *yyoutput
, int yytype
, YYSTYPE
const * const yyvaluep
, YYLTYPE
const * const yylocationp
, glcpp_parser_t
*parser
)
1057 yy_symbol_value_print (yyoutput
, yytype
, yyvaluep
, yylocationp
, parser
)
1060 YYSTYPE
const * const yyvaluep
;
1061 YYLTYPE
const * const yylocationp
;
1062 glcpp_parser_t
*parser
;
1067 YYUSE (yylocationp
);
1070 if (yytype
< YYNTOKENS
)
1071 YYPRINT (yyoutput
, yytoknum
[yytype
], *yyvaluep
);
1083 /*--------------------------------.
1084 | Print this symbol on YYOUTPUT. |
1085 `--------------------------------*/
1087 #if (defined __STDC__ || defined __C99__FUNC__ \
1088 || defined __cplusplus || defined _MSC_VER)
1090 yy_symbol_print (FILE *yyoutput
, int yytype
, YYSTYPE
const * const yyvaluep
, YYLTYPE
const * const yylocationp
, glcpp_parser_t
*parser
)
1093 yy_symbol_print (yyoutput
, yytype
, yyvaluep
, yylocationp
, parser
)
1096 YYSTYPE
const * const yyvaluep
;
1097 YYLTYPE
const * const yylocationp
;
1098 glcpp_parser_t
*parser
;
1101 if (yytype
< YYNTOKENS
)
1102 YYFPRINTF (yyoutput
, "token %s (", yytname
[yytype
]);
1104 YYFPRINTF (yyoutput
, "nterm %s (", yytname
[yytype
]);
1106 YY_LOCATION_PRINT (yyoutput
, *yylocationp
);
1107 YYFPRINTF (yyoutput
, ": ");
1108 yy_symbol_value_print (yyoutput
, yytype
, yyvaluep
, yylocationp
, parser
);
1109 YYFPRINTF (yyoutput
, ")");
1112 /*------------------------------------------------------------------.
1113 | yy_stack_print -- Print the state stack from its BOTTOM up to its |
1115 `------------------------------------------------------------------*/
1117 #if (defined __STDC__ || defined __C99__FUNC__ \
1118 || defined __cplusplus || defined _MSC_VER)
1120 yy_stack_print (yytype_int16
*yybottom
, yytype_int16
*yytop
)
1123 yy_stack_print (yybottom
, yytop
)
1124 yytype_int16
*yybottom
;
1125 yytype_int16
*yytop
;
1128 YYFPRINTF (stderr
, "Stack now");
1129 for (; yybottom
<= yytop
; yybottom
++)
1131 int yybot
= *yybottom
;
1132 YYFPRINTF (stderr
, " %d", yybot
);
1134 YYFPRINTF (stderr
, "\n");
1137 # define YY_STACK_PRINT(Bottom, Top) \
1140 yy_stack_print ((Bottom), (Top)); \
1144 /*------------------------------------------------.
1145 | Report that the YYRULE is going to be reduced. |
1146 `------------------------------------------------*/
1148 #if (defined __STDC__ || defined __C99__FUNC__ \
1149 || defined __cplusplus || defined _MSC_VER)
1151 yy_reduce_print (YYSTYPE
*yyvsp
, YYLTYPE
*yylsp
, int yyrule
, glcpp_parser_t
*parser
)
1154 yy_reduce_print (yyvsp
, yylsp
, yyrule
, parser
)
1158 glcpp_parser_t
*parser
;
1161 int yynrhs
= yyr2
[yyrule
];
1163 unsigned long int yylno
= yyrline
[yyrule
];
1164 YYFPRINTF (stderr
, "Reducing stack by rule %d (line %lu):\n",
1166 /* The symbols being reduced. */
1167 for (yyi
= 0; yyi
< yynrhs
; yyi
++)
1169 YYFPRINTF (stderr
, " $%d = ", yyi
+ 1);
1170 yy_symbol_print (stderr
, yyrhs
[yyprhs
[yyrule
] + yyi
],
1171 &(yyvsp
[(yyi
+ 1) - (yynrhs
)])
1172 , &(yylsp
[(yyi
+ 1) - (yynrhs
)]) , parser
);
1173 YYFPRINTF (stderr
, "\n");
1177 # define YY_REDUCE_PRINT(Rule) \
1180 yy_reduce_print (yyvsp, yylsp, Rule, parser); \
1183 /* Nonzero means print parse trace. It is left uninitialized so that
1184 multiple parsers can coexist. */
1186 #else /* !YYDEBUG */
1187 # define YYDPRINTF(Args)
1188 # define YY_SYMBOL_PRINT(Title, Type, Value, Location)
1189 # define YY_STACK_PRINT(Bottom, Top)
1190 # define YY_REDUCE_PRINT(Rule)
1191 #endif /* !YYDEBUG */
1194 /* YYINITDEPTH -- initial size of the parser's stacks. */
1196 # define YYINITDEPTH 200
1199 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
1200 if the built-in stack extension method is used).
1202 Do not make this value too large; the results are undefined if
1203 YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
1204 evaluated with infinite-precision integer arithmetic. */
1207 # define YYMAXDEPTH 10000
1215 # if defined __GLIBC__ && defined _STRING_H
1216 # define yystrlen strlen
1218 /* Return the length of YYSTR. */
1219 #if (defined __STDC__ || defined __C99__FUNC__ \
1220 || defined __cplusplus || defined _MSC_VER)
1222 yystrlen (const char *yystr
)
1230 for (yylen
= 0; yystr
[yylen
]; yylen
++)
1238 # if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
1239 # define yystpcpy stpcpy
1241 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
1243 #if (defined __STDC__ || defined __C99__FUNC__ \
1244 || defined __cplusplus || defined _MSC_VER)
1246 yystpcpy (char *yydest
, const char *yysrc
)
1249 yystpcpy (yydest
, yysrc
)
1255 const char *yys
= yysrc
;
1257 while ((*yyd
++ = *yys
++) != '\0')
1266 /* Copy to YYRES the contents of YYSTR after stripping away unnecessary
1267 quotes and backslashes, so that it's suitable for yyerror. The
1268 heuristic is that double-quoting is unnecessary unless the string
1269 contains an apostrophe, a comma, or backslash (other than
1270 backslash-backslash). YYSTR is taken from yytname. If YYRES is
1271 null, do not copy; instead, return the length of what the result
1274 yytnamerr (char *yyres
, const char *yystr
)
1279 char const *yyp
= yystr
;
1286 goto do_not_strip_quotes
;
1290 goto do_not_strip_quotes
;
1303 do_not_strip_quotes
: ;
1307 return yystrlen (yystr
);
1309 return yystpcpy (yyres
, yystr
) - yyres
;
1313 /* Copy into YYRESULT an error message about the unexpected token
1314 YYCHAR while in state YYSTATE. Return the number of bytes copied,
1315 including the terminating null byte. If YYRESULT is null, do not
1316 copy anything; just return the number of bytes that would be
1317 copied. As a special case, return 0 if an ordinary "syntax error"
1318 message will do. Return YYSIZE_MAXIMUM if overflow occurs during
1319 size calculation. */
1321 yysyntax_error (char *yyresult
, int yystate
, int yychar
)
1323 int yyn
= yypact
[yystate
];
1325 if (! (YYPACT_NINF
< yyn
&& yyn
<= YYLAST
))
1329 int yytype
= YYTRANSLATE (yychar
);
1330 YYSIZE_T yysize0
= yytnamerr (0, yytname
[yytype
]);
1331 YYSIZE_T yysize
= yysize0
;
1333 int yysize_overflow
= 0;
1334 enum { YYERROR_VERBOSE_ARGS_MAXIMUM
= 5 };
1335 char const *yyarg
[YYERROR_VERBOSE_ARGS_MAXIMUM
];
1339 /* This is so xgettext sees the translatable formats that are
1340 constructed on the fly. */
1341 YY_("syntax error, unexpected %s");
1342 YY_("syntax error, unexpected %s, expecting %s");
1343 YY_("syntax error, unexpected %s, expecting %s or %s");
1344 YY_("syntax error, unexpected %s, expecting %s or %s or %s");
1345 YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s");
1349 static char const yyunexpected
[] = "syntax error, unexpected %s";
1350 static char const yyexpecting
[] = ", expecting %s";
1351 static char const yyor
[] = " or %s";
1352 char yyformat
[sizeof yyunexpected
1353 + sizeof yyexpecting
- 1
1354 + ((YYERROR_VERBOSE_ARGS_MAXIMUM
- 2)
1355 * (sizeof yyor
- 1))];
1356 char const *yyprefix
= yyexpecting
;
1358 /* Start YYX at -YYN if negative to avoid negative indexes in
1360 int yyxbegin
= yyn
< 0 ? -yyn
: 0;
1362 /* Stay within bounds of both yycheck and yytname. */
1363 int yychecklim
= YYLAST
- yyn
+ 1;
1364 int yyxend
= yychecklim
< YYNTOKENS
? yychecklim
: YYNTOKENS
;
1367 yyarg
[0] = yytname
[yytype
];
1368 yyfmt
= yystpcpy (yyformat
, yyunexpected
);
1370 for (yyx
= yyxbegin
; yyx
< yyxend
; ++yyx
)
1371 if (yycheck
[yyx
+ yyn
] == yyx
&& yyx
!= YYTERROR
)
1373 if (yycount
== YYERROR_VERBOSE_ARGS_MAXIMUM
)
1377 yyformat
[sizeof yyunexpected
- 1] = '\0';
1380 yyarg
[yycount
++] = yytname
[yyx
];
1381 yysize1
= yysize
+ yytnamerr (0, yytname
[yyx
]);
1382 yysize_overflow
|= (yysize1
< yysize
);
1384 yyfmt
= yystpcpy (yyfmt
, yyprefix
);
1388 yyf
= YY_(yyformat
);
1389 yysize1
= yysize
+ yystrlen (yyf
);
1390 yysize_overflow
|= (yysize1
< yysize
);
1393 if (yysize_overflow
)
1394 return YYSIZE_MAXIMUM
;
1398 /* Avoid sprintf, as that infringes on the user's name space.
1399 Don't have undefined behavior even if the translation
1400 produced a string with the wrong number of "%s"s. */
1401 char *yyp
= yyresult
;
1403 while ((*yyp
= *yyf
) != '\0')
1405 if (*yyp
== '%' && yyf
[1] == 's' && yyi
< yycount
)
1407 yyp
+= yytnamerr (yyp
, yyarg
[yyi
++]);
1420 #endif /* YYERROR_VERBOSE */
1423 /*-----------------------------------------------.
1424 | Release the memory associated to this symbol. |
1425 `-----------------------------------------------*/
1428 #if (defined __STDC__ || defined __C99__FUNC__ \
1429 || defined __cplusplus || defined _MSC_VER)
1431 yydestruct (const char *yymsg
, int yytype
, YYSTYPE
*yyvaluep
, YYLTYPE
*yylocationp
, glcpp_parser_t
*parser
)
1434 yydestruct (yymsg
, yytype
, yyvaluep
, yylocationp
, parser
)
1438 YYLTYPE
*yylocationp
;
1439 glcpp_parser_t
*parser
;
1443 YYUSE (yylocationp
);
1448 YY_SYMBOL_PRINT (yymsg
, yytype
, yyvaluep
, yylocationp
);
1458 /* Prevent warnings from -Wmissing-prototypes. */
1459 #ifdef YYPARSE_PARAM
1460 #if defined __STDC__ || defined __cplusplus
1461 int yyparse (void *YYPARSE_PARAM
);
1465 #else /* ! YYPARSE_PARAM */
1466 #if defined __STDC__ || defined __cplusplus
1467 int yyparse (glcpp_parser_t
*parser
);
1471 #endif /* ! YYPARSE_PARAM */
1477 /*-------------------------.
1478 | yyparse or yypush_parse. |
1479 `-------------------------*/
1481 #ifdef YYPARSE_PARAM
1482 #if (defined __STDC__ || defined __C99__FUNC__ \
1483 || defined __cplusplus || defined _MSC_VER)
1485 yyparse (void *YYPARSE_PARAM
)
1488 yyparse (YYPARSE_PARAM
)
1489 void *YYPARSE_PARAM
;
1491 #else /* ! YYPARSE_PARAM */
1492 #if (defined __STDC__ || defined __C99__FUNC__ \
1493 || defined __cplusplus || defined _MSC_VER)
1495 yyparse (glcpp_parser_t
*parser
)
1499 glcpp_parser_t
*parser
;
1503 /* The lookahead symbol. */
1506 /* The semantic value of the lookahead symbol. */
1509 /* Location data for the lookahead symbol. */
1512 /* Number of syntax errors so far. */
1516 /* Number of tokens to shift before error messages enabled. */
1519 /* The stacks and their tools:
1520 `yyss': related to states.
1521 `yyvs': related to semantic values.
1522 `yyls': related to locations.
1524 Refer to the stacks thru separate pointers, to allow yyoverflow
1525 to reallocate them elsewhere. */
1527 /* The state stack. */
1528 yytype_int16 yyssa
[YYINITDEPTH
];
1530 yytype_int16
*yyssp
;
1532 /* The semantic value stack. */
1533 YYSTYPE yyvsa
[YYINITDEPTH
];
1537 /* The location stack. */
1538 YYLTYPE yylsa
[YYINITDEPTH
];
1542 /* The locations where the error started and ended. */
1543 YYLTYPE yyerror_range
[2];
1545 YYSIZE_T yystacksize
;
1549 /* Lookahead token as an internal (translated) token number. */
1551 /* The variables used to return semantic value and location from the
1557 /* Buffer for error messages, and its allocated size. */
1559 char *yymsg
= yymsgbuf
;
1560 YYSIZE_T yymsg_alloc
= sizeof yymsgbuf
;
1563 #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N), yylsp -= (N))
1565 /* The number of symbols on the RHS of the reduced rule.
1566 Keep to zero when no symbol should be popped. */
1573 yystacksize
= YYINITDEPTH
;
1575 YYDPRINTF ((stderr
, "Starting parse\n"));
1580 yychar
= YYEMPTY
; /* Cause a token to be read. */
1582 /* Initialize stack pointers.
1583 Waste one element of value and location stack
1584 so that they stay on the same level as the state stack.
1585 The wasted elements are never initialized. */
1590 #if YYLTYPE_IS_TRIVIAL
1591 /* Initialize the default location before parsing starts. */
1592 yylloc
.first_line
= yylloc
.last_line
= 1;
1593 yylloc
.first_column
= yylloc
.last_column
= 1;
1596 /* User initialization code. */
1598 /* Line 1242 of yacc.c */
1599 #line 148 "glcpp/glcpp-parse.y"
1601 yylloc
.first_line
= 1;
1602 yylloc
.first_column
= 1;
1603 yylloc
.last_line
= 1;
1604 yylloc
.last_column
= 1;
1608 /* Line 1242 of yacc.c */
1609 #line 1610 "glcpp/glcpp-parse.c"
1614 /*------------------------------------------------------------.
1615 | yynewstate -- Push a new state, which is found in yystate. |
1616 `------------------------------------------------------------*/
1618 /* In all cases, when you get here, the value and location stacks
1619 have just been pushed. So pushing a state here evens the stacks. */
1625 if (yyss
+ yystacksize
- 1 <= yyssp
)
1627 /* Get the current used size of the three stacks, in elements. */
1628 YYSIZE_T yysize
= yyssp
- yyss
+ 1;
1632 /* Give user a chance to reallocate the stack. Use copies of
1633 these so that the &'s don't force the real ones into
1635 YYSTYPE
*yyvs1
= yyvs
;
1636 yytype_int16
*yyss1
= yyss
;
1637 YYLTYPE
*yyls1
= yyls
;
1639 /* Each stack pointer address is followed by the size of the
1640 data in use in that stack, in bytes. This used to be a
1641 conditional around just the two extra args, but that might
1642 be undefined if yyoverflow is a macro. */
1643 yyoverflow (YY_("memory exhausted"),
1644 &yyss1
, yysize
* sizeof (*yyssp
),
1645 &yyvs1
, yysize
* sizeof (*yyvsp
),
1646 &yyls1
, yysize
* sizeof (*yylsp
),
1653 #else /* no yyoverflow */
1654 # ifndef YYSTACK_RELOCATE
1655 goto yyexhaustedlab
;
1657 /* Extend the stack our own way. */
1658 if (YYMAXDEPTH
<= yystacksize
)
1659 goto yyexhaustedlab
;
1661 if (YYMAXDEPTH
< yystacksize
)
1662 yystacksize
= YYMAXDEPTH
;
1665 yytype_int16
*yyss1
= yyss
;
1666 union yyalloc
*yyptr
=
1667 (union yyalloc
*) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize
));
1669 goto yyexhaustedlab
;
1670 YYSTACK_RELOCATE (yyss_alloc
, yyss
);
1671 YYSTACK_RELOCATE (yyvs_alloc
, yyvs
);
1672 YYSTACK_RELOCATE (yyls_alloc
, yyls
);
1673 # undef YYSTACK_RELOCATE
1675 YYSTACK_FREE (yyss1
);
1678 #endif /* no yyoverflow */
1680 yyssp
= yyss
+ yysize
- 1;
1681 yyvsp
= yyvs
+ yysize
- 1;
1682 yylsp
= yyls
+ yysize
- 1;
1684 YYDPRINTF ((stderr
, "Stack size increased to %lu\n",
1685 (unsigned long int) yystacksize
));
1687 if (yyss
+ yystacksize
- 1 <= yyssp
)
1691 YYDPRINTF ((stderr
, "Entering state %d\n", yystate
));
1693 if (yystate
== YYFINAL
)
1703 /* Do appropriate processing given the current state. Read a
1704 lookahead token if we need one and don't already have one. */
1706 /* First try to decide what to do without reference to lookahead token. */
1707 yyn
= yypact
[yystate
];
1708 if (yyn
== YYPACT_NINF
)
1711 /* Not known => get a lookahead token if don't already have one. */
1713 /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */
1714 if (yychar
== YYEMPTY
)
1716 YYDPRINTF ((stderr
, "Reading a token: "));
1720 if (yychar
<= YYEOF
)
1722 yychar
= yytoken
= YYEOF
;
1723 YYDPRINTF ((stderr
, "Now at end of input.\n"));
1727 yytoken
= YYTRANSLATE (yychar
);
1728 YY_SYMBOL_PRINT ("Next token is", yytoken
, &yylval
, &yylloc
);
1731 /* If the proper action on seeing token YYTOKEN is to reduce or to
1732 detect an error, take that action. */
1734 if (yyn
< 0 || YYLAST
< yyn
|| yycheck
[yyn
] != yytoken
)
1739 if (yyn
== 0 || yyn
== YYTABLE_NINF
)
1745 /* Count tokens shifted since error; after three, turn off error
1750 /* Shift the lookahead token. */
1751 YY_SYMBOL_PRINT ("Shifting", yytoken
, &yylval
, &yylloc
);
1753 /* Discard the shifted token. */
1762 /*-----------------------------------------------------------.
1763 | yydefault -- do the default action for the current state. |
1764 `-----------------------------------------------------------*/
1766 yyn
= yydefact
[yystate
];
1772 /*-----------------------------.
1773 | yyreduce -- Do a reduction. |
1774 `-----------------------------*/
1776 /* yyn is the number of a rule to reduce with. */
1779 /* If YYLEN is nonzero, implement the default value of the action:
1782 Otherwise, the following line sets YYVAL to garbage.
1783 This behavior is undocumented and Bison
1784 users should not rely upon it. Assigning to YYVAL
1785 unconditionally makes the parser a bit smaller, and it avoids a
1786 GCC warning that YYVAL may be used uninitialized. */
1787 yyval
= yyvsp
[1-yylen
];
1789 /* Default location. */
1790 YYLLOC_DEFAULT (yyloc
, (yylsp
- yylen
), yylen
);
1791 YY_REDUCE_PRINT (yyn
);
1796 /* Line 1455 of yacc.c */
1797 #line 187 "glcpp/glcpp-parse.y"
1799 glcpp_print(parser
->output
, "\n");
1805 /* Line 1455 of yacc.c */
1806 #line 190 "glcpp/glcpp-parse.y"
1808 _glcpp_parser_print_expanded_token_list (parser
, (yyvsp
[(1) - (1)].token_list
));
1809 glcpp_print(parser
->output
, "\n");
1810 talloc_free ((yyvsp
[(1) - (1)].token_list
));
1816 /* Line 1455 of yacc.c */
1817 #line 200 "glcpp/glcpp-parse.y"
1819 _glcpp_parser_skip_stack_push_if (parser
, & (yylsp
[(1) - (3)]), (yyvsp
[(2) - (3)].ival
));
1825 /* Line 1455 of yacc.c */
1826 #line 203 "glcpp/glcpp-parse.y"
1828 _glcpp_parser_skip_stack_change_if (parser
, & (yylsp
[(1) - (3)]), "elif", (yyvsp
[(2) - (3)].ival
));
1834 /* Line 1455 of yacc.c */
1835 #line 209 "glcpp/glcpp-parse.y"
1837 _define_object_macro (parser
, & (yylsp
[(2) - (4)]), (yyvsp
[(2) - (4)].str
), (yyvsp
[(3) - (4)].token_list
));
1843 /* Line 1455 of yacc.c */
1844 #line 212 "glcpp/glcpp-parse.y"
1846 _define_function_macro (parser
, & (yylsp
[(2) - (6)]), (yyvsp
[(2) - (6)].str
), NULL
, (yyvsp
[(5) - (6)].token_list
));
1852 /* Line 1455 of yacc.c */
1853 #line 215 "glcpp/glcpp-parse.y"
1855 _define_function_macro (parser
, & (yylsp
[(2) - (7)]), (yyvsp
[(2) - (7)].str
), (yyvsp
[(4) - (7)].string_list
), (yyvsp
[(6) - (7)].token_list
));
1861 /* Line 1455 of yacc.c */
1862 #line 218 "glcpp/glcpp-parse.y"
1864 macro_t
*macro
= hash_table_find (parser
->defines
, (yyvsp
[(2) - (3)].str
));
1866 hash_table_remove (parser
->defines
, (yyvsp
[(2) - (3)].str
));
1867 talloc_free (macro
);
1869 talloc_free ((yyvsp
[(2) - (3)].str
));
1875 /* Line 1455 of yacc.c */
1876 #line 226 "glcpp/glcpp-parse.y"
1878 /* Be careful to only evaluate the 'if' expression if
1879 * we are not skipping. When we are skipping, we
1880 * simply push a new 0-valued 'if' onto the skip
1883 * This avoids generating diagnostics for invalid
1884 * expressions that are being skipped. */
1885 if (parser
->skip_stack
== NULL
||
1886 parser
->skip_stack
->type
== SKIP_NO_SKIP
)
1888 _glcpp_parser_expand_if (parser
, IF_EXPANDED
, (yyvsp
[(2) - (3)].token_list
));
1892 _glcpp_parser_skip_stack_push_if (parser
, & (yylsp
[(1) - (3)]), 0);
1893 parser
->skip_stack
->type
= SKIP_TO_ENDIF
;
1900 /* Line 1455 of yacc.c */
1901 #line 245 "glcpp/glcpp-parse.y"
1903 /* #if without an expression is only an error if we
1904 * are not skipping */
1905 if (parser
->skip_stack
== NULL
||
1906 parser
->skip_stack
->type
== SKIP_NO_SKIP
)
1908 glcpp_error(& (yylsp
[(1) - (2)]), parser
, "#if with no expression");
1910 _glcpp_parser_skip_stack_push_if (parser
, & (yylsp
[(1) - (2)]), 0);
1916 /* Line 1455 of yacc.c */
1917 #line 255 "glcpp/glcpp-parse.y"
1919 macro_t
*macro
= hash_table_find (parser
->defines
, (yyvsp
[(2) - (4)].str
));
1920 talloc_free ((yyvsp
[(2) - (4)].str
));
1921 _glcpp_parser_skip_stack_push_if (parser
, & (yylsp
[(1) - (4)]), macro
!= NULL
);
1927 /* Line 1455 of yacc.c */
1928 #line 260 "glcpp/glcpp-parse.y"
1930 macro_t
*macro
= hash_table_find (parser
->defines
, (yyvsp
[(2) - (4)].str
));
1931 talloc_free ((yyvsp
[(2) - (4)].str
));
1932 _glcpp_parser_skip_stack_push_if (parser
, & (yylsp
[(1) - (4)]), macro
== NULL
);
1938 /* Line 1455 of yacc.c */
1939 #line 265 "glcpp/glcpp-parse.y"
1941 /* Be careful to only evaluate the 'elif' expression
1942 * if we are not skipping. When we are skipping, we
1943 * simply change to a 0-valued 'elif' on the skip
1946 * This avoids generating diagnostics for invalid
1947 * expressions that are being skipped. */
1948 if (parser
->skip_stack
&&
1949 parser
->skip_stack
->type
== SKIP_TO_ELSE
)
1951 _glcpp_parser_expand_if (parser
, ELIF_EXPANDED
, (yyvsp
[(2) - (3)].token_list
));
1955 _glcpp_parser_skip_stack_change_if (parser
, & (yylsp
[(1) - (3)]),
1963 /* Line 1455 of yacc.c */
1964 #line 284 "glcpp/glcpp-parse.y"
1966 /* #elif without an expression is an error unless we
1968 if (parser
->skip_stack
&&
1969 parser
->skip_stack
->type
== SKIP_TO_ELSE
)
1971 glcpp_error(& (yylsp
[(1) - (2)]), parser
, "#elif with no expression");
1975 _glcpp_parser_skip_stack_change_if (parser
, & (yylsp
[(1) - (2)]),
1977 glcpp_warning(& (yylsp
[(1) - (2)]), parser
, "ignoring illegal #elif without expression");
1984 /* Line 1455 of yacc.c */
1985 #line 299 "glcpp/glcpp-parse.y"
1987 _glcpp_parser_skip_stack_change_if (parser
, & (yylsp
[(1) - (2)]), "else", 1);
1993 /* Line 1455 of yacc.c */
1994 #line 302 "glcpp/glcpp-parse.y"
1996 _glcpp_parser_skip_stack_pop (parser
, & (yylsp
[(1) - (2)]));
2002 /* Line 1455 of yacc.c */
2003 #line 305 "glcpp/glcpp-parse.y"
2005 macro_t
*macro
= hash_table_find (parser
->defines
, "__VERSION__");
2007 hash_table_remove (parser
->defines
, "__VERSION__");
2008 talloc_free (macro
);
2010 add_builtin_define (parser
, "__VERSION__", (yyvsp
[(2) - (3)].ival
));
2011 glcpp_printf(parser
->output
, "#version %" PRIiMAX
"\n", (yyvsp
[(2) - (3)].ival
));
2017 /* Line 1455 of yacc.c */
2018 #line 318 "glcpp/glcpp-parse.y"
2020 if (strlen ((yyvsp
[(1) - (1)].str
)) >= 3 && strncmp ((yyvsp
[(1) - (1)].str
), "0x", 2) == 0) {
2021 (yyval
.ival
) = strtoll ((yyvsp
[(1) - (1)].str
) + 2, NULL
, 16);
2022 } else if ((yyvsp
[(1) - (1)].str
)[0] == '0') {
2023 (yyval
.ival
) = strtoll ((yyvsp
[(1) - (1)].str
), NULL
, 8);
2025 (yyval
.ival
) = strtoll ((yyvsp
[(1) - (1)].str
), NULL
, 10);
2032 /* Line 1455 of yacc.c */
2033 #line 327 "glcpp/glcpp-parse.y"
2035 (yyval
.ival
) = (yyvsp
[(1) - (1)].ival
);
2041 /* Line 1455 of yacc.c */
2042 #line 333 "glcpp/glcpp-parse.y"
2044 (yyval
.ival
) = (yyvsp
[(1) - (3)].ival
) || (yyvsp
[(3) - (3)].ival
);
2050 /* Line 1455 of yacc.c */
2051 #line 336 "glcpp/glcpp-parse.y"
2053 (yyval
.ival
) = (yyvsp
[(1) - (3)].ival
) && (yyvsp
[(3) - (3)].ival
);
2059 /* Line 1455 of yacc.c */
2060 #line 339 "glcpp/glcpp-parse.y"
2062 (yyval
.ival
) = (yyvsp
[(1) - (3)].ival
) | (yyvsp
[(3) - (3)].ival
);
2068 /* Line 1455 of yacc.c */
2069 #line 342 "glcpp/glcpp-parse.y"
2071 (yyval
.ival
) = (yyvsp
[(1) - (3)].ival
) ^ (yyvsp
[(3) - (3)].ival
);
2077 /* Line 1455 of yacc.c */
2078 #line 345 "glcpp/glcpp-parse.y"
2080 (yyval
.ival
) = (yyvsp
[(1) - (3)].ival
) & (yyvsp
[(3) - (3)].ival
);
2086 /* Line 1455 of yacc.c */
2087 #line 348 "glcpp/glcpp-parse.y"
2089 (yyval
.ival
) = (yyvsp
[(1) - (3)].ival
) != (yyvsp
[(3) - (3)].ival
);
2095 /* Line 1455 of yacc.c */
2096 #line 351 "glcpp/glcpp-parse.y"
2098 (yyval
.ival
) = (yyvsp
[(1) - (3)].ival
) == (yyvsp
[(3) - (3)].ival
);
2104 /* Line 1455 of yacc.c */
2105 #line 354 "glcpp/glcpp-parse.y"
2107 (yyval
.ival
) = (yyvsp
[(1) - (3)].ival
) >= (yyvsp
[(3) - (3)].ival
);
2113 /* Line 1455 of yacc.c */
2114 #line 357 "glcpp/glcpp-parse.y"
2116 (yyval
.ival
) = (yyvsp
[(1) - (3)].ival
) <= (yyvsp
[(3) - (3)].ival
);
2122 /* Line 1455 of yacc.c */
2123 #line 360 "glcpp/glcpp-parse.y"
2125 (yyval
.ival
) = (yyvsp
[(1) - (3)].ival
) > (yyvsp
[(3) - (3)].ival
);
2131 /* Line 1455 of yacc.c */
2132 #line 363 "glcpp/glcpp-parse.y"
2134 (yyval
.ival
) = (yyvsp
[(1) - (3)].ival
) < (yyvsp
[(3) - (3)].ival
);
2140 /* Line 1455 of yacc.c */
2141 #line 366 "glcpp/glcpp-parse.y"
2143 (yyval
.ival
) = (yyvsp
[(1) - (3)].ival
) >> (yyvsp
[(3) - (3)].ival
);
2149 /* Line 1455 of yacc.c */
2150 #line 369 "glcpp/glcpp-parse.y"
2152 (yyval
.ival
) = (yyvsp
[(1) - (3)].ival
) << (yyvsp
[(3) - (3)].ival
);
2158 /* Line 1455 of yacc.c */
2159 #line 372 "glcpp/glcpp-parse.y"
2161 (yyval
.ival
) = (yyvsp
[(1) - (3)].ival
) - (yyvsp
[(3) - (3)].ival
);
2167 /* Line 1455 of yacc.c */
2168 #line 375 "glcpp/glcpp-parse.y"
2170 (yyval
.ival
) = (yyvsp
[(1) - (3)].ival
) + (yyvsp
[(3) - (3)].ival
);
2176 /* Line 1455 of yacc.c */
2177 #line 378 "glcpp/glcpp-parse.y"
2179 (yyval
.ival
) = (yyvsp
[(1) - (3)].ival
) % (yyvsp
[(3) - (3)].ival
);
2185 /* Line 1455 of yacc.c */
2186 #line 381 "glcpp/glcpp-parse.y"
2188 (yyval
.ival
) = (yyvsp
[(1) - (3)].ival
) / (yyvsp
[(3) - (3)].ival
);
2194 /* Line 1455 of yacc.c */
2195 #line 384 "glcpp/glcpp-parse.y"
2197 (yyval
.ival
) = (yyvsp
[(1) - (3)].ival
) * (yyvsp
[(3) - (3)].ival
);
2203 /* Line 1455 of yacc.c */
2204 #line 387 "glcpp/glcpp-parse.y"
2206 (yyval
.ival
) = ! (yyvsp
[(2) - (2)].ival
);
2212 /* Line 1455 of yacc.c */
2213 #line 390 "glcpp/glcpp-parse.y"
2215 (yyval
.ival
) = ~ (yyvsp
[(2) - (2)].ival
);
2221 /* Line 1455 of yacc.c */
2222 #line 393 "glcpp/glcpp-parse.y"
2224 (yyval
.ival
) = - (yyvsp
[(2) - (2)].ival
);
2230 /* Line 1455 of yacc.c */
2231 #line 396 "glcpp/glcpp-parse.y"
2233 (yyval
.ival
) = + (yyvsp
[(2) - (2)].ival
);
2239 /* Line 1455 of yacc.c */
2240 #line 399 "glcpp/glcpp-parse.y"
2242 (yyval
.ival
) = (yyvsp
[(2) - (3)].ival
);
2248 /* Line 1455 of yacc.c */
2249 #line 405 "glcpp/glcpp-parse.y"
2251 (yyval
.string_list
) = _string_list_create (parser
);
2252 _string_list_append_item ((yyval
.string_list
), (yyvsp
[(1) - (1)].str
));
2253 talloc_steal ((yyval
.string_list
), (yyvsp
[(1) - (1)].str
));
2259 /* Line 1455 of yacc.c */
2260 #line 410 "glcpp/glcpp-parse.y"
2262 (yyval
.string_list
) = (yyvsp
[(1) - (3)].string_list
);
2263 _string_list_append_item ((yyval
.string_list
), (yyvsp
[(3) - (3)].str
));
2264 talloc_steal ((yyval
.string_list
), (yyvsp
[(3) - (3)].str
));
2270 /* Line 1455 of yacc.c */
2271 #line 418 "glcpp/glcpp-parse.y"
2272 { (yyval
.token_list
) = NULL
; ;}
2277 /* Line 1455 of yacc.c */
2278 #line 423 "glcpp/glcpp-parse.y"
2280 yyerror (& (yylsp
[(1) - (2)]), parser
, "Invalid tokens after #");
2286 /* Line 1455 of yacc.c */
2287 #line 429 "glcpp/glcpp-parse.y"
2288 { (yyval
.token_list
) = NULL
; ;}
2293 /* Line 1455 of yacc.c */
2294 #line 435 "glcpp/glcpp-parse.y"
2296 glcpp_warning(&(yylsp
[(1) - (1)]), parser
, "extra tokens at end of directive");
2302 /* Line 1455 of yacc.c */
2303 #line 442 "glcpp/glcpp-parse.y"
2305 int v
= hash_table_find (parser
->defines
, (yyvsp
[(2) - (2)].str
)) ? 1 : 0;
2306 (yyval
.token
) = _token_create_ival (parser
, INTEGER
, v
);
2312 /* Line 1455 of yacc.c */
2313 #line 446 "glcpp/glcpp-parse.y"
2315 int v
= hash_table_find (parser
->defines
, (yyvsp
[(3) - (4)].str
)) ? 1 : 0;
2316 (yyval
.token
) = _token_create_ival (parser
, INTEGER
, v
);
2322 /* Line 1455 of yacc.c */
2323 #line 455 "glcpp/glcpp-parse.y"
2325 parser
->space_tokens
= 1;
2326 (yyval
.token_list
) = _token_list_create (parser
);
2327 _token_list_append ((yyval
.token_list
), (yyvsp
[(1) - (1)].token
));
2328 talloc_unlink (parser
, (yyvsp
[(1) - (1)].token
));
2334 /* Line 1455 of yacc.c */
2335 #line 461 "glcpp/glcpp-parse.y"
2337 (yyval
.token_list
) = (yyvsp
[(1) - (2)].token_list
);
2338 _token_list_append ((yyval
.token_list
), (yyvsp
[(2) - (2)].token
));
2339 talloc_unlink (parser
, (yyvsp
[(2) - (2)].token
));
2345 /* Line 1455 of yacc.c */
2346 #line 469 "glcpp/glcpp-parse.y"
2348 parser
->space_tokens
= 1;
2349 (yyval
.token_list
) = _token_list_create (parser
);
2350 _token_list_append ((yyval
.token_list
), (yyvsp
[(1) - (1)].token
));
2351 talloc_unlink (parser
, (yyvsp
[(1) - (1)].token
));
2357 /* Line 1455 of yacc.c */
2358 #line 475 "glcpp/glcpp-parse.y"
2360 (yyval
.token_list
) = (yyvsp
[(1) - (2)].token_list
);
2361 _token_list_append ((yyval
.token_list
), (yyvsp
[(2) - (2)].token
));
2362 talloc_unlink (parser
, (yyvsp
[(2) - (2)].token
));
2368 /* Line 1455 of yacc.c */
2369 #line 483 "glcpp/glcpp-parse.y"
2371 (yyval
.token
) = _token_create_str (parser
, IDENTIFIER
, (yyvsp
[(1) - (1)].str
));
2372 (yyval
.token
)->location
= yylloc
;
2378 /* Line 1455 of yacc.c */
2379 #line 487 "glcpp/glcpp-parse.y"
2381 (yyval
.token
) = _token_create_str (parser
, INTEGER_STRING
, (yyvsp
[(1) - (1)].str
));
2382 (yyval
.token
)->location
= yylloc
;
2388 /* Line 1455 of yacc.c */
2389 #line 491 "glcpp/glcpp-parse.y"
2391 (yyval
.token
) = _token_create_ival (parser
, (yyvsp
[(1) - (1)].ival
), (yyvsp
[(1) - (1)].ival
));
2392 (yyval
.token
)->location
= yylloc
;
2398 /* Line 1455 of yacc.c */
2399 #line 495 "glcpp/glcpp-parse.y"
2401 (yyval
.token
) = _token_create_str (parser
, OTHER
, (yyvsp
[(1) - (1)].str
));
2402 (yyval
.token
)->location
= yylloc
;
2408 /* Line 1455 of yacc.c */
2409 #line 499 "glcpp/glcpp-parse.y"
2411 (yyval
.token
) = _token_create_ival (parser
, SPACE
, SPACE
);
2412 (yyval
.token
)->location
= yylloc
;
2418 /* Line 1455 of yacc.c */
2419 #line 506 "glcpp/glcpp-parse.y"
2420 { (yyval
.ival
) = '['; ;}
2425 /* Line 1455 of yacc.c */
2426 #line 507 "glcpp/glcpp-parse.y"
2427 { (yyval
.ival
) = ']'; ;}
2432 /* Line 1455 of yacc.c */
2433 #line 508 "glcpp/glcpp-parse.y"
2434 { (yyval
.ival
) = '('; ;}
2439 /* Line 1455 of yacc.c */
2440 #line 509 "glcpp/glcpp-parse.y"
2441 { (yyval
.ival
) = ')'; ;}
2446 /* Line 1455 of yacc.c */
2447 #line 510 "glcpp/glcpp-parse.y"
2448 { (yyval
.ival
) = '{'; ;}
2453 /* Line 1455 of yacc.c */
2454 #line 511 "glcpp/glcpp-parse.y"
2455 { (yyval
.ival
) = '}'; ;}
2460 /* Line 1455 of yacc.c */
2461 #line 512 "glcpp/glcpp-parse.y"
2462 { (yyval
.ival
) = '.'; ;}
2467 /* Line 1455 of yacc.c */
2468 #line 513 "glcpp/glcpp-parse.y"
2469 { (yyval
.ival
) = '&'; ;}
2474 /* Line 1455 of yacc.c */
2475 #line 514 "glcpp/glcpp-parse.y"
2476 { (yyval
.ival
) = '*'; ;}
2481 /* Line 1455 of yacc.c */
2482 #line 515 "glcpp/glcpp-parse.y"
2483 { (yyval
.ival
) = '+'; ;}
2488 /* Line 1455 of yacc.c */
2489 #line 516 "glcpp/glcpp-parse.y"
2490 { (yyval
.ival
) = '-'; ;}
2495 /* Line 1455 of yacc.c */
2496 #line 517 "glcpp/glcpp-parse.y"
2497 { (yyval
.ival
) = '~'; ;}
2502 /* Line 1455 of yacc.c */
2503 #line 518 "glcpp/glcpp-parse.y"
2504 { (yyval
.ival
) = '!'; ;}
2509 /* Line 1455 of yacc.c */
2510 #line 519 "glcpp/glcpp-parse.y"
2511 { (yyval
.ival
) = '/'; ;}
2516 /* Line 1455 of yacc.c */
2517 #line 520 "glcpp/glcpp-parse.y"
2518 { (yyval
.ival
) = '%'; ;}
2523 /* Line 1455 of yacc.c */
2524 #line 521 "glcpp/glcpp-parse.y"
2525 { (yyval
.ival
) = LEFT_SHIFT
; ;}
2530 /* Line 1455 of yacc.c */
2531 #line 522 "glcpp/glcpp-parse.y"
2532 { (yyval
.ival
) = RIGHT_SHIFT
; ;}
2537 /* Line 1455 of yacc.c */
2538 #line 523 "glcpp/glcpp-parse.y"
2539 { (yyval
.ival
) = '<'; ;}
2544 /* Line 1455 of yacc.c */
2545 #line 524 "glcpp/glcpp-parse.y"
2546 { (yyval
.ival
) = '>'; ;}
2551 /* Line 1455 of yacc.c */
2552 #line 525 "glcpp/glcpp-parse.y"
2553 { (yyval
.ival
) = LESS_OR_EQUAL
; ;}
2558 /* Line 1455 of yacc.c */
2559 #line 526 "glcpp/glcpp-parse.y"
2560 { (yyval
.ival
) = GREATER_OR_EQUAL
; ;}
2565 /* Line 1455 of yacc.c */
2566 #line 527 "glcpp/glcpp-parse.y"
2567 { (yyval
.ival
) = EQUAL
; ;}
2572 /* Line 1455 of yacc.c */
2573 #line 528 "glcpp/glcpp-parse.y"
2574 { (yyval
.ival
) = NOT_EQUAL
; ;}
2579 /* Line 1455 of yacc.c */
2580 #line 529 "glcpp/glcpp-parse.y"
2581 { (yyval
.ival
) = '^'; ;}
2586 /* Line 1455 of yacc.c */
2587 #line 530 "glcpp/glcpp-parse.y"
2588 { (yyval
.ival
) = '|'; ;}
2593 /* Line 1455 of yacc.c */
2594 #line 531 "glcpp/glcpp-parse.y"
2595 { (yyval
.ival
) = AND
; ;}
2600 /* Line 1455 of yacc.c */
2601 #line 532 "glcpp/glcpp-parse.y"
2602 { (yyval
.ival
) = OR
; ;}
2607 /* Line 1455 of yacc.c */
2608 #line 533 "glcpp/glcpp-parse.y"
2609 { (yyval
.ival
) = ';'; ;}
2614 /* Line 1455 of yacc.c */
2615 #line 534 "glcpp/glcpp-parse.y"
2616 { (yyval
.ival
) = ','; ;}
2621 /* Line 1455 of yacc.c */
2622 #line 535 "glcpp/glcpp-parse.y"
2623 { (yyval
.ival
) = '='; ;}
2628 /* Line 1455 of yacc.c */
2629 #line 536 "glcpp/glcpp-parse.y"
2630 { (yyval
.ival
) = PASTE
; ;}
2635 /* Line 1455 of yacc.c */
2636 #line 2637 "glcpp/glcpp-parse.c"
2639 YY_SYMBOL_PRINT ("-> $$ =", yyr1
[yyn
], &yyval
, &yyloc
);
2643 YY_STACK_PRINT (yyss
, yyssp
);
2648 /* Now `shift' the result of the reduction. Determine what state
2649 that goes to, based on the state we popped back to and the rule
2650 number reduced by. */
2654 yystate
= yypgoto
[yyn
- YYNTOKENS
] + *yyssp
;
2655 if (0 <= yystate
&& yystate
<= YYLAST
&& yycheck
[yystate
] == *yyssp
)
2656 yystate
= yytable
[yystate
];
2658 yystate
= yydefgoto
[yyn
- YYNTOKENS
];
2663 /*------------------------------------.
2664 | yyerrlab -- here on detecting error |
2665 `------------------------------------*/
2667 /* If not already recovering from an error, report this error. */
2671 #if ! YYERROR_VERBOSE
2672 yyerror (&yylloc
, parser
, YY_("syntax error"));
2675 YYSIZE_T yysize
= yysyntax_error (0, yystate
, yychar
);
2676 if (yymsg_alloc
< yysize
&& yymsg_alloc
< YYSTACK_ALLOC_MAXIMUM
)
2678 YYSIZE_T yyalloc
= 2 * yysize
;
2679 if (! (yysize
<= yyalloc
&& yyalloc
<= YYSTACK_ALLOC_MAXIMUM
))
2680 yyalloc
= YYSTACK_ALLOC_MAXIMUM
;
2681 if (yymsg
!= yymsgbuf
)
2682 YYSTACK_FREE (yymsg
);
2683 yymsg
= (char *) YYSTACK_ALLOC (yyalloc
);
2685 yymsg_alloc
= yyalloc
;
2689 yymsg_alloc
= sizeof yymsgbuf
;
2693 if (0 < yysize
&& yysize
<= yymsg_alloc
)
2695 (void) yysyntax_error (yymsg
, yystate
, yychar
);
2696 yyerror (&yylloc
, parser
, yymsg
);
2700 yyerror (&yylloc
, parser
, YY_("syntax error"));
2702 goto yyexhaustedlab
;
2708 yyerror_range
[0] = yylloc
;
2710 if (yyerrstatus
== 3)
2712 /* If just tried and failed to reuse lookahead token after an
2713 error, discard it. */
2715 if (yychar
<= YYEOF
)
2717 /* Return failure if at end of input. */
2718 if (yychar
== YYEOF
)
2723 yydestruct ("Error: discarding",
2724 yytoken
, &yylval
, &yylloc
, parser
);
2729 /* Else will try to reuse lookahead token after shifting the error
2734 /*---------------------------------------------------.
2735 | yyerrorlab -- error raised explicitly by YYERROR. |
2736 `---------------------------------------------------*/
2739 /* Pacify compilers like GCC when the user code never invokes
2740 YYERROR and the label yyerrorlab therefore never appears in user
2742 if (/*CONSTCOND*/ 0)
2745 yyerror_range
[0] = yylsp
[1-yylen
];
2746 /* Do not reclaim the symbols of the rule which action triggered
2750 YY_STACK_PRINT (yyss
, yyssp
);
2755 /*-------------------------------------------------------------.
2756 | yyerrlab1 -- common code for both syntax error and YYERROR. |
2757 `-------------------------------------------------------------*/
2759 yyerrstatus
= 3; /* Each real token shifted decrements this. */
2763 yyn
= yypact
[yystate
];
2764 if (yyn
!= YYPACT_NINF
)
2767 if (0 <= yyn
&& yyn
<= YYLAST
&& yycheck
[yyn
] == YYTERROR
)
2775 /* Pop the current state because it cannot handle the error token. */
2779 yyerror_range
[0] = *yylsp
;
2780 yydestruct ("Error: popping",
2781 yystos
[yystate
], yyvsp
, yylsp
, parser
);
2784 YY_STACK_PRINT (yyss
, yyssp
);
2789 yyerror_range
[1] = yylloc
;
2790 /* Using YYLLOC is tempting, but would change the location of
2791 the lookahead. YYLOC is available though. */
2792 YYLLOC_DEFAULT (yyloc
, (yyerror_range
- 1), 2);
2795 /* Shift the error token. */
2796 YY_SYMBOL_PRINT ("Shifting", yystos
[yyn
], yyvsp
, yylsp
);
2802 /*-------------------------------------.
2803 | yyacceptlab -- YYACCEPT comes here. |
2804 `-------------------------------------*/
2809 /*-----------------------------------.
2810 | yyabortlab -- YYABORT comes here. |
2811 `-----------------------------------*/
2816 #if !defined(yyoverflow) || YYERROR_VERBOSE
2817 /*-------------------------------------------------.
2818 | yyexhaustedlab -- memory exhaustion comes here. |
2819 `-------------------------------------------------*/
2821 yyerror (&yylloc
, parser
, YY_("memory exhausted"));
2827 if (yychar
!= YYEMPTY
)
2828 yydestruct ("Cleanup: discarding lookahead",
2829 yytoken
, &yylval
, &yylloc
, parser
);
2830 /* Do not reclaim the symbols of the rule which action triggered
2831 this YYABORT or YYACCEPT. */
2833 YY_STACK_PRINT (yyss
, yyssp
);
2834 while (yyssp
!= yyss
)
2836 yydestruct ("Cleanup: popping",
2837 yystos
[*yyssp
], yyvsp
, yylsp
, parser
);
2842 YYSTACK_FREE (yyss
);
2845 if (yymsg
!= yymsgbuf
)
2846 YYSTACK_FREE (yymsg
);
2848 /* Make sure YYID is used. */
2849 return YYID (yyresult
);
2854 /* Line 1675 of yacc.c */
2855 #line 539 "glcpp/glcpp-parse.y"
2859 _string_list_create (void *ctx
)
2861 string_list_t
*list
;
2863 list
= talloc (ctx
, string_list_t
);
2871 _string_list_append_item (string_list_t
*list
, const char *str
)
2873 string_node_t
*node
;
2875 node
= talloc (list
, string_node_t
);
2876 node
->str
= talloc_strdup (node
, str
);
2880 if (list
->head
== NULL
) {
2883 list
->tail
->next
= node
;
2890 _string_list_contains (string_list_t
*list
, const char *member
, int *index
)
2892 string_node_t
*node
;
2898 for (i
= 0, node
= list
->head
; node
; i
++, node
= node
->next
) {
2899 if (strcmp (node
->str
, member
) == 0) {
2910 _string_list_length (string_list_t
*list
)
2913 string_node_t
*node
;
2918 for (node
= list
->head
; node
; node
= node
->next
)
2925 _argument_list_create (void *ctx
)
2927 argument_list_t
*list
;
2929 list
= talloc (ctx
, argument_list_t
);
2937 _argument_list_append (argument_list_t
*list
, token_list_t
*argument
)
2939 argument_node_t
*node
;
2941 node
= talloc (list
, argument_node_t
);
2942 node
->argument
= argument
;
2946 if (list
->head
== NULL
) {
2949 list
->tail
->next
= node
;
2956 _argument_list_length (argument_list_t
*list
)
2959 argument_node_t
*node
;
2964 for (node
= list
->head
; node
; node
= node
->next
)
2971 _argument_list_member_at (argument_list_t
*list
, int index
)
2973 argument_node_t
*node
;
2980 for (i
= 0; i
< index
; i
++) {
2987 return node
->argument
;
2992 /* Note: This function talloc_steal()s the str pointer. */
2994 _token_create_str (void *ctx
, int type
, char *str
)
2998 token
= talloc (ctx
, token_t
);
3000 token
->value
.str
= talloc_steal (token
, str
);
3006 _token_create_ival (void *ctx
, int type
, int ival
)
3010 token
= talloc (ctx
, token_t
);
3012 token
->value
.ival
= ival
;
3018 _token_list_create (void *ctx
)
3022 list
= talloc (ctx
, token_list_t
);
3025 list
->non_space_tail
= NULL
;
3031 _token_list_append (token_list_t
*list
, token_t
*token
)
3035 node
= talloc (list
, token_node_t
);
3036 node
->token
= talloc_reference (list
, token
);
3040 if (list
->head
== NULL
) {
3043 list
->tail
->next
= node
;
3047 if (token
->type
!= SPACE
)
3048 list
->non_space_tail
= node
;
3052 _token_list_append_list (token_list_t
*list
, token_list_t
*tail
)
3054 if (tail
== NULL
|| tail
->head
== NULL
)
3057 if (list
->head
== NULL
) {
3058 list
->head
= tail
->head
;
3060 list
->tail
->next
= tail
->head
;
3063 list
->tail
= tail
->tail
;
3064 list
->non_space_tail
= tail
->non_space_tail
;
3067 static token_list_t
*
3068 _token_list_copy (void *ctx
, token_list_t
*other
)
3076 copy
= _token_list_create (ctx
);
3077 for (node
= other
->head
; node
; node
= node
->next
)
3078 _token_list_append (copy
, node
->token
);
3084 _token_list_trim_trailing_space (token_list_t
*list
)
3086 token_node_t
*tail
, *next
;
3088 if (list
->non_space_tail
) {
3089 tail
= list
->non_space_tail
->next
;
3090 list
->non_space_tail
->next
= NULL
;
3091 list
->tail
= list
->non_space_tail
;
3102 _token_print (char **out
, token_t
*token
)
3104 if (token
->type
< 256) {
3105 glcpp_printf (*out
, "%c", token
->type
);
3109 switch (token
->type
) {
3111 glcpp_printf (*out
, "%" PRIiMAX
, token
->value
.ival
);
3114 case INTEGER_STRING
:
3116 glcpp_print (*out
, token
->value
.str
);
3119 glcpp_print (*out
, " ");
3122 glcpp_print (*out
, "<<");
3125 glcpp_print (*out
, ">>");
3128 glcpp_print (*out
, "<=");
3130 case GREATER_OR_EQUAL
:
3131 glcpp_print (*out
, ">=");
3134 glcpp_print (*out
, "==");
3137 glcpp_print (*out
, "!=");
3140 glcpp_print (*out
, "&&");
3143 glcpp_print (*out
, "||");
3146 glcpp_print (*out
, "##");
3149 glcpp_print (*out
, ",");
3152 /* Nothing to print. */
3155 assert(!"Error: Don't know how to print token.");
3160 /* Return a new token (talloc()ed off of 'token') formed by pasting
3161 * 'token' and 'other'. Note that this function may return 'token' or
3162 * 'other' directly rather than allocating anything new.
3164 * Caution: Only very cursory error-checking is performed to see if
3165 * the final result is a valid single token. */
3167 _token_paste (glcpp_parser_t
*parser
, token_t
*token
, token_t
*other
)
3169 token_t
*combined
= NULL
;
3171 /* Pasting a placeholder onto anything makes no change. */
3172 if (other
->type
== PLACEHOLDER
)
3175 /* When 'token' is a placeholder, just return 'other'. */
3176 if (token
->type
== PLACEHOLDER
)
3179 /* A very few single-character punctuators can be combined
3180 * with another to form a multi-character punctuator. */
3181 switch (token
->type
) {
3183 if (other
->type
== '<')
3184 combined
= _token_create_ival (token
, LEFT_SHIFT
, LEFT_SHIFT
);
3185 else if (other
->type
== '=')
3186 combined
= _token_create_ival (token
, LESS_OR_EQUAL
, LESS_OR_EQUAL
);
3189 if (other
->type
== '>')
3190 combined
= _token_create_ival (token
, RIGHT_SHIFT
, RIGHT_SHIFT
);
3191 else if (other
->type
== '=')
3192 combined
= _token_create_ival (token
, GREATER_OR_EQUAL
, GREATER_OR_EQUAL
);
3195 if (other
->type
== '=')
3196 combined
= _token_create_ival (token
, EQUAL
, EQUAL
);
3199 if (other
->type
== '=')
3200 combined
= _token_create_ival (token
, NOT_EQUAL
, NOT_EQUAL
);
3203 if (other
->type
== '&')
3204 combined
= _token_create_ival (token
, AND
, AND
);
3207 if (other
->type
== '|')
3208 combined
= _token_create_ival (token
, OR
, OR
);
3212 if (combined
!= NULL
) {
3213 /* Inherit the location from the first token */
3214 combined
->location
= token
->location
;
3218 /* Two string-valued tokens can usually just be mashed
3221 * XXX: This isn't actually legitimate. Several things here
3222 * should result in a diagnostic since the result cannot be a
3223 * valid, single pre-processing token. For example, pasting
3224 * "123" and "abc" is not legal, but we don't catch that
3226 if ((token
->type
== IDENTIFIER
|| token
->type
== OTHER
|| token
->type
== INTEGER_STRING
) &&
3227 (other
->type
== IDENTIFIER
|| other
->type
== OTHER
|| other
->type
== INTEGER_STRING
))
3231 str
= talloc_asprintf (token
, "%s%s", token
->value
.str
,
3233 combined
= _token_create_str (token
, token
->type
, str
);
3234 combined
->location
= token
->location
;
3238 glcpp_error (&token
->location
, parser
, "");
3239 glcpp_print (parser
->info_log
, "Pasting \"");
3240 _token_print (&parser
->info_log
, token
);
3241 glcpp_print (parser
->info_log
, "\" and \"");
3242 _token_print (&parser
->info_log
, other
);
3243 glcpp_print (parser
->info_log
, "\" does not give a valid preprocessing token.\n");
3249 _token_list_print (glcpp_parser_t
*parser
, token_list_t
*list
)
3256 for (node
= list
->head
; node
; node
= node
->next
)
3257 _token_print (&parser
->output
, node
->token
);
3261 yyerror (YYLTYPE
*locp
, glcpp_parser_t
*parser
, const char *error
)
3263 glcpp_error(locp
, parser
, "%s", error
);
3266 static void add_builtin_define(glcpp_parser_t
*parser
,
3267 const char *name
, int value
)
3272 tok
= _token_create_ival (parser
, INTEGER
, value
);
3274 list
= _token_list_create(parser
);
3275 _token_list_append(list
, tok
);
3276 _define_object_macro(parser
, NULL
, name
, list
);
3278 talloc_unlink(parser
, tok
);
3282 glcpp_parser_create (const struct gl_extensions
*extensions
)
3284 glcpp_parser_t
*parser
;
3285 int language_version
;
3287 parser
= talloc (NULL
, glcpp_parser_t
);
3289 glcpp_lex_init_extra (parser
, &parser
->scanner
);
3290 parser
->defines
= hash_table_ctor (32, hash_table_string_hash
,
3291 hash_table_string_compare
);
3292 parser
->active
= NULL
;
3293 parser
->lexing_if
= 0;
3294 parser
->space_tokens
= 1;
3295 parser
->newline_as_space
= 0;
3296 parser
->in_control_line
= 0;
3297 parser
->paren_count
= 0;
3299 parser
->skip_stack
= NULL
;
3301 parser
->lex_from_list
= NULL
;
3302 parser
->lex_from_node
= NULL
;
3304 parser
->output
= talloc_strdup(parser
, "");
3305 parser
->info_log
= talloc_strdup(parser
, "");
3308 /* Add pre-defined macros. */
3309 add_builtin_define(parser
, "GL_ARB_draw_buffers", 1);
3310 add_builtin_define(parser
, "GL_ARB_texture_rectangle", 1);
3312 if (extensions
!= NULL
) {
3313 if (extensions
->EXT_texture_array
) {
3314 add_builtin_define(parser
, "GL_EXT_texture_array", 1);
3317 if (extensions
->ARB_fragment_coord_conventions
)
3318 add_builtin_define(parser
, "GL_ARB_fragment_coord_conventions",
3322 language_version
= 110;
3323 add_builtin_define(parser
, "__VERSION__", language_version
);
3329 glcpp_parser_parse (glcpp_parser_t
*parser
)
3331 return yyparse (parser
);
3335 glcpp_parser_destroy (glcpp_parser_t
*parser
)
3337 glcpp_lex_destroy (parser
->scanner
);
3338 hash_table_dtor (parser
->defines
);
3339 talloc_free (parser
);
3342 typedef enum function_status
3344 FUNCTION_STATUS_SUCCESS
,
3345 FUNCTION_NOT_A_FUNCTION
,
3346 FUNCTION_UNBALANCED_PARENTHESES
3347 } function_status_t
;
3349 /* Find a set of function-like macro arguments by looking for a
3350 * balanced set of parentheses.
3352 * When called, 'node' should be the opening-parenthesis token, (or
3353 * perhaps preceeding SPACE tokens). Upon successful return *last will
3354 * be the last consumed node, (corresponding to the closing right
3359 * FUNCTION_STATUS_SUCCESS:
3361 * Successfully parsed a set of function arguments.
3363 * FUNCTION_NOT_A_FUNCTION:
3365 * Macro name not followed by a '('. This is not an error, but
3366 * simply that the macro name should be treated as a non-macro.
3368 * FUNCTION_UNBALANCED_PARENTHESES
3370 * Macro name is not followed by a balanced set of parentheses.
3372 static function_status_t
3373 _arguments_parse (argument_list_t
*arguments
,
3375 token_node_t
**last
)
3377 token_list_t
*argument
;
3382 /* Ignore whitespace before first parenthesis. */
3383 while (node
&& node
->token
->type
== SPACE
)
3386 if (node
== NULL
|| node
->token
->type
!= '(')
3387 return FUNCTION_NOT_A_FUNCTION
;
3391 argument
= _token_list_create (arguments
);
3392 _argument_list_append (arguments
, argument
);
3394 for (paren_count
= 1; node
; node
= node
->next
) {
3395 if (node
->token
->type
== '(')
3399 else if (node
->token
->type
== ')')
3402 if (paren_count
== 0)
3406 if (node
->token
->type
== ',' &&
3409 _token_list_trim_trailing_space (argument
);
3410 argument
= _token_list_create (arguments
);
3411 _argument_list_append (arguments
, argument
);
3414 if (argument
->head
== NULL
) {
3415 /* Don't treat initial whitespace as
3416 * part of the arguement. */
3417 if (node
->token
->type
== SPACE
)
3420 _token_list_append (argument
, node
->token
);
3425 return FUNCTION_UNBALANCED_PARENTHESES
;
3429 return FUNCTION_STATUS_SUCCESS
;
3432 static token_list_t
*
3433 _token_list_create_with_one_space (void *ctx
)
3438 list
= _token_list_create (ctx
);
3439 space
= _token_create_ival (list
, SPACE
, SPACE
);
3440 _token_list_append (list
, space
);
3446 _glcpp_parser_expand_if (glcpp_parser_t
*parser
, int type
, token_list_t
*list
)
3448 token_list_t
*expanded
;
3451 expanded
= _token_list_create (parser
);
3452 token
= _token_create_ival (parser
, type
, type
);
3453 _token_list_append (expanded
, token
);
3454 _glcpp_parser_expand_token_list (parser
, list
);
3455 _token_list_append_list (expanded
, list
);
3456 glcpp_parser_lex_from (parser
, expanded
);
3459 /* This is a helper function that's essentially part of the
3460 * implementation of _glcpp_parser_expand_node. It shouldn't be called
3461 * except for by that function.
3463 * Returns NULL if node is a simple token with no expansion, (that is,
3464 * although 'node' corresponds to an identifier defined as a
3465 * function-like macro, it is not followed with a parenthesized
3468 * Compute the complete expansion of node (which is a function-like
3469 * macro) and subsequent nodes which are arguments.
3471 * Returns the token list that results from the expansion and sets
3472 * *last to the last node in the list that was consumed by the
3473 * expansion. Specifically, *last will be set as follows: as the
3474 * token of the closing right parenthesis.
3476 static token_list_t
*
3477 _glcpp_parser_expand_function (glcpp_parser_t
*parser
,
3479 token_node_t
**last
)
3483 const char *identifier
;
3484 argument_list_t
*arguments
;
3485 function_status_t status
;
3486 token_list_t
*substituted
;
3487 int parameter_index
;
3489 identifier
= node
->token
->value
.str
;
3491 macro
= hash_table_find (parser
->defines
, identifier
);
3493 assert (macro
->is_function
);
3495 arguments
= _argument_list_create (parser
);
3496 status
= _arguments_parse (arguments
, node
, last
);
3499 case FUNCTION_STATUS_SUCCESS
:
3501 case FUNCTION_NOT_A_FUNCTION
:
3503 case FUNCTION_UNBALANCED_PARENTHESES
:
3504 glcpp_error (&node
->token
->location
, parser
, "Macro %s call has unbalanced parentheses\n", identifier
);
3508 /* Replace a macro defined as empty with a SPACE token. */
3509 if (macro
->replacements
== NULL
) {
3510 talloc_free (arguments
);
3511 return _token_list_create_with_one_space (parser
);
3514 if (! ((_argument_list_length (arguments
) ==
3515 _string_list_length (macro
->parameters
)) ||
3516 (_string_list_length (macro
->parameters
) == 0 &&
3517 _argument_list_length (arguments
) == 1 &&
3518 arguments
->head
->argument
->head
== NULL
)))
3520 glcpp_error (&node
->token
->location
, parser
,
3521 "Error: macro %s invoked with %d arguments (expected %d)\n",
3523 _argument_list_length (arguments
),
3524 _string_list_length (macro
->parameters
));
3528 /* Perform argument substitution on the replacement list. */
3529 substituted
= _token_list_create (arguments
);
3531 for (node
= macro
->replacements
->head
; node
; node
= node
->next
)
3533 if (node
->token
->type
== IDENTIFIER
&&
3534 _string_list_contains (macro
->parameters
,
3535 node
->token
->value
.str
,
3538 token_list_t
*argument
;
3539 argument
= _argument_list_member_at (arguments
,
3541 /* Before substituting, we expand the argument
3542 * tokens, or append a placeholder token for
3543 * an empty argument. */
3544 if (argument
->head
) {
3545 token_list_t
*expanded_argument
;
3546 expanded_argument
= _token_list_copy (parser
,
3548 _glcpp_parser_expand_token_list (parser
,
3550 _token_list_append_list (substituted
,
3555 new_token
= _token_create_ival (substituted
,
3558 _token_list_append (substituted
, new_token
);
3561 _token_list_append (substituted
, node
->token
);
3565 /* After argument substitution, and before further expansion
3566 * below, implement token pasting. */
3568 _token_list_trim_trailing_space (substituted
);
3570 node
= substituted
->head
;
3573 token_node_t
*next_non_space
;
3575 /* Look ahead for a PASTE token, skipping space. */
3576 next_non_space
= node
->next
;
3577 while (next_non_space
&& next_non_space
->token
->type
== SPACE
)
3578 next_non_space
= next_non_space
->next
;
3580 if (next_non_space
== NULL
)
3583 if (next_non_space
->token
->type
!= PASTE
) {
3584 node
= next_non_space
;
3588 /* Now find the next non-space token after the PASTE. */
3589 next_non_space
= next_non_space
->next
;
3590 while (next_non_space
&& next_non_space
->token
->type
== SPACE
)
3591 next_non_space
= next_non_space
->next
;
3593 if (next_non_space
== NULL
) {
3594 yyerror (&node
->token
->location
, parser
, "'##' cannot appear at either end of a macro expansion\n");
3598 node
->token
= _token_paste (parser
, node
->token
, next_non_space
->token
);
3599 node
->next
= next_non_space
->next
;
3600 if (next_non_space
== substituted
->tail
)
3601 substituted
->tail
= node
;
3606 substituted
->non_space_tail
= substituted
->tail
;
3611 /* Compute the complete expansion of node, (and subsequent nodes after
3612 * 'node' in the case that 'node' is a function-like macro and
3613 * subsequent nodes are arguments).
3615 * Returns NULL if node is a simple token with no expansion.
3617 * Otherwise, returns the token list that results from the expansion
3618 * and sets *last to the last node in the list that was consumed by
3619 * the expansion. Specifically, *last will be set as follows:
3621 * As 'node' in the case of object-like macro expansion.
3623 * As the token of the closing right parenthesis in the case of
3624 * function-like macro expansion.
3626 static token_list_t
*
3627 _glcpp_parser_expand_node (glcpp_parser_t
*parser
,
3629 token_node_t
**last
)
3631 token_t
*token
= node
->token
;
3632 const char *identifier
;
3635 /* We only expand identifiers */
3636 if (token
->type
!= IDENTIFIER
) {
3637 /* We change any COMMA into a COMMA_FINAL to prevent
3638 * it being mistaken for an argument separator
3640 if (token
->type
== ',') {
3641 token
->type
= COMMA_FINAL
;
3642 token
->value
.ival
= COMMA_FINAL
;
3648 /* Look up this identifier in the hash table. */
3649 identifier
= token
->value
.str
;
3650 macro
= hash_table_find (parser
->defines
, identifier
);
3652 /* Not a macro, so no expansion needed. */
3656 /* Finally, don't expand this macro if we're already actively
3657 * expanding it, (to avoid infinite recursion). */
3658 if (_active_list_contains (parser
->active
, identifier
)) {
3659 /* We change the token type here from IDENTIFIER to
3660 * OTHER to prevent any future expansion of this
3661 * unexpanded token. */
3663 token_list_t
*expansion
;
3666 str
= talloc_strdup (parser
, token
->value
.str
);
3667 final
= _token_create_str (parser
, OTHER
, str
);
3668 expansion
= _token_list_create (parser
);
3669 _token_list_append (expansion
, final
);
3674 if (! macro
->is_function
)
3678 /* Replace a macro defined as empty with a SPACE token. */
3679 if (macro
->replacements
== NULL
)
3680 return _token_list_create_with_one_space (parser
);
3682 return _token_list_copy (parser
, macro
->replacements
);
3685 return _glcpp_parser_expand_function (parser
, node
, last
);
3688 /* Push a new identifier onto the active list, returning the new list.
3690 * Here, 'marker' is the token node that appears in the list after the
3691 * expansion of 'identifier'. That is, when the list iterator begins
3692 * examinging 'marker', then it is time to pop this node from the
3696 _active_list_push (active_list_t
*list
,
3697 const char *identifier
,
3698 token_node_t
*marker
)
3700 active_list_t
*node
;
3702 node
= talloc (list
, active_list_t
);
3703 node
->identifier
= talloc_strdup (node
, identifier
);
3704 node
->marker
= marker
;
3711 _active_list_pop (active_list_t
*list
)
3713 active_list_t
*node
= list
;
3725 _active_list_contains (active_list_t
*list
, const char *identifier
)
3727 active_list_t
*node
;
3732 for (node
= list
; node
; node
= node
->next
)
3733 if (strcmp (node
->identifier
, identifier
) == 0)
3739 /* Walk over the token list replacing nodes with their expansion.
3740 * Whenever nodes are expanded the walking will walk over the new
3741 * nodes, continuing to expand as necessary. The results are placed in
3745 _glcpp_parser_expand_token_list (glcpp_parser_t
*parser
,
3748 token_node_t
*node_prev
;
3749 token_node_t
*node
, *last
= NULL
;
3750 token_list_t
*expansion
;
3755 _token_list_trim_trailing_space (list
);
3762 while (parser
->active
&& parser
->active
->marker
== node
)
3763 parser
->active
= _active_list_pop (parser
->active
);
3765 /* Find the expansion for node, which will replace all
3766 * nodes from node to last, inclusive. */
3767 expansion
= _glcpp_parser_expand_node (parser
, node
, &last
);
3771 for (n
= node
; n
!= last
->next
; n
= n
->next
)
3772 while (parser
->active
&&
3773 parser
->active
->marker
== n
)
3775 parser
->active
= _active_list_pop (parser
->active
);
3778 parser
->active
= _active_list_push (parser
->active
,
3779 node
->token
->value
.str
,
3782 /* Splice expansion into list, supporting a
3783 * simple deletion if the expansion is
3785 if (expansion
->head
) {
3787 node_prev
->next
= expansion
->head
;
3789 list
->head
= expansion
->head
;
3790 expansion
->tail
->next
= last
->next
;
3791 if (last
== list
->tail
)
3792 list
->tail
= expansion
->tail
;
3795 node_prev
->next
= last
->next
;
3797 list
->head
= last
->next
;
3798 if (last
== list
->tail
)
3804 node
= node_prev
? node_prev
->next
: list
->head
;
3807 while (parser
->active
)
3808 parser
->active
= _active_list_pop (parser
->active
);
3810 list
->non_space_tail
= list
->tail
;
3814 _glcpp_parser_print_expanded_token_list (glcpp_parser_t
*parser
,
3820 _glcpp_parser_expand_token_list (parser
, list
);
3822 _token_list_trim_trailing_space (list
);
3824 _token_list_print (parser
, list
);
3828 _check_for_reserved_macro_name (glcpp_parser_t
*parser
, YYLTYPE
*loc
,
3829 const char *identifier
)
3831 /* According to the GLSL specification, macro names starting with "__"
3832 * or "GL_" are reserved for future use. So, don't allow them.
3834 if (strncmp(identifier
, "__", 2) == 0) {
3835 glcpp_error (loc
, parser
, "Macro names starting with \"__\" are reserved.\n");
3837 if (strncmp(identifier
, "GL_", 3) == 0) {
3838 glcpp_error (loc
, parser
, "Macro names starting with \"GL_\" are reserved.\n");
3843 _define_object_macro (glcpp_parser_t
*parser
,
3845 const char *identifier
,
3846 token_list_t
*replacements
)
3851 _check_for_reserved_macro_name(parser
, loc
, identifier
);
3853 macro
= talloc (parser
, macro_t
);
3855 macro
->is_function
= 0;
3856 macro
->parameters
= NULL
;
3857 macro
->identifier
= talloc_strdup (macro
, identifier
);
3858 macro
->replacements
= talloc_steal (macro
, replacements
);
3860 hash_table_insert (parser
->defines
, macro
, identifier
);
3864 _define_function_macro (glcpp_parser_t
*parser
,
3866 const char *identifier
,
3867 string_list_t
*parameters
,
3868 token_list_t
*replacements
)
3872 _check_for_reserved_macro_name(parser
, loc
, identifier
);
3874 macro
= talloc (parser
, macro_t
);
3876 macro
->is_function
= 1;
3877 macro
->parameters
= talloc_steal (macro
, parameters
);
3878 macro
->identifier
= talloc_strdup (macro
, identifier
);
3879 macro
->replacements
= talloc_steal (macro
, replacements
);
3881 hash_table_insert (parser
->defines
, macro
, identifier
);
3885 glcpp_parser_lex (YYSTYPE
*yylval
, YYLTYPE
*yylloc
, glcpp_parser_t
*parser
)
3890 if (parser
->lex_from_list
== NULL
) {
3891 ret
= glcpp_lex (yylval
, yylloc
, parser
->scanner
);
3893 /* XXX: This ugly block of code exists for the sole
3894 * purpose of converting a NEWLINE token into a SPACE
3895 * token, but only in the case where we have seen a
3896 * function-like macro name, but have not yet seen its
3897 * closing parenthesis.
3899 * There's perhaps a more compact way to do this with
3900 * mid-rule actions in the grammar.
3902 * I'm definitely not pleased with the complexity of
3905 if (parser
->newline_as_space
)
3908 parser
->paren_count
++;
3909 } else if (ret
== ')') {
3910 parser
->paren_count
--;
3911 if (parser
->paren_count
== 0)
3912 parser
->newline_as_space
= 0;
3913 } else if (ret
== NEWLINE
) {
3915 } else if (ret
!= SPACE
) {
3916 if (parser
->paren_count
== 0)
3917 parser
->newline_as_space
= 0;
3920 else if (parser
->in_control_line
)
3923 parser
->in_control_line
= 0;
3925 else if (ret
== HASH_DEFINE_OBJ
|| ret
== HASH_DEFINE_FUNC
||
3926 ret
== HASH_UNDEF
|| ret
== HASH_IF
||
3927 ret
== HASH_IFDEF
|| ret
== HASH_IFNDEF
||
3928 ret
== HASH_ELIF
|| ret
== HASH_ELSE
||
3929 ret
== HASH_ENDIF
|| ret
== HASH
)
3931 parser
->in_control_line
= 1;
3933 else if (ret
== IDENTIFIER
)
3936 macro
= hash_table_find (parser
->defines
,
3938 if (macro
&& macro
->is_function
) {
3939 parser
->newline_as_space
= 1;
3940 parser
->paren_count
= 0;
3947 node
= parser
->lex_from_node
;
3950 talloc_free (parser
->lex_from_list
);
3951 parser
->lex_from_list
= NULL
;
3955 *yylval
= node
->token
->value
;
3956 ret
= node
->token
->type
;
3958 parser
->lex_from_node
= node
->next
;
3964 glcpp_parser_lex_from (glcpp_parser_t
*parser
, token_list_t
*list
)
3968 assert (parser
->lex_from_list
== NULL
);
3970 /* Copy list, eliminating any space tokens. */
3971 parser
->lex_from_list
= _token_list_create (parser
);
3973 for (node
= list
->head
; node
; node
= node
->next
) {
3974 if (node
->token
->type
== SPACE
)
3976 _token_list_append (parser
->lex_from_list
, node
->token
);
3981 parser
->lex_from_node
= parser
->lex_from_list
->head
;
3983 /* It's possible the list consisted of nothing but whitespace. */
3984 if (parser
->lex_from_node
== NULL
) {
3985 talloc_free (parser
->lex_from_list
);
3986 parser
->lex_from_list
= NULL
;
3991 _glcpp_parser_skip_stack_push_if (glcpp_parser_t
*parser
, YYLTYPE
*loc
,
3994 skip_type_t current
= SKIP_NO_SKIP
;
3997 if (parser
->skip_stack
)
3998 current
= parser
->skip_stack
->type
;
4000 node
= talloc (parser
, skip_node_t
);
4003 if (current
== SKIP_NO_SKIP
) {
4005 node
->type
= SKIP_NO_SKIP
;
4007 node
->type
= SKIP_TO_ELSE
;
4009 node
->type
= SKIP_TO_ENDIF
;
4012 node
->next
= parser
->skip_stack
;
4013 parser
->skip_stack
= node
;
4017 _glcpp_parser_skip_stack_change_if (glcpp_parser_t
*parser
, YYLTYPE
*loc
,
4018 const char *type
, int condition
)
4020 if (parser
->skip_stack
== NULL
) {
4021 glcpp_error (loc
, parser
, "%s without #if\n", type
);
4025 if (parser
->skip_stack
->type
== SKIP_TO_ELSE
) {
4027 parser
->skip_stack
->type
= SKIP_NO_SKIP
;
4029 parser
->skip_stack
->type
= SKIP_TO_ENDIF
;
4034 _glcpp_parser_skip_stack_pop (glcpp_parser_t
*parser
, YYLTYPE
*loc
)
4038 if (parser
->skip_stack
== NULL
) {
4039 glcpp_error (loc
, parser
, "#endif without #if\n");
4043 node
= parser
->skip_stack
;
4044 parser
->skip_stack
= node
->next
;