1 /* A Bison parser, made by GNU Bison 2.4.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 2009, 2010 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 3 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program. If not, see <http://www.gnu.org/licenses/>. */
21 /* As a special exception, you may create a larger work that contains
22 part or all of the Bison parser skeleton and distribute that work
23 under terms of your choice, so long as that work isn't itself a
24 parser generator using the skeleton or a modified version thereof
25 as a parser skeleton. Alternatively, if you modify or redistribute
26 the parser skeleton itself, you may (at your option) remove this
27 special exception, which will cause the skeleton and the resulting
28 Bison output files to be licensed under the GNU General Public
29 License without this special exception.
31 This special exception was added by the Free Software Foundation in
32 version 2.2 of Bison. */
34 /* C LALR(1) parser skeleton written by Richard Stallman, by
35 simplifying the original so-called "semantic" parser. */
37 /* All symbols defined below should begin with yy or YY, to avoid
38 infringing on user name space. This should be done even for local
39 variables, as they might otherwise be expanded by user macros.
40 There are some unavoidable exceptions within include files to
41 define necessary library symbols; they are noted "INFRINGES ON
42 USER NAME SPACE" below. */
44 /* Identify Bison output. */
48 #define YYBISON_VERSION "2.4.3"
51 #define YYSKELETON_NAME "yacc.c"
62 /* Using locations. */
63 #define YYLSP_NEEDED 1
67 /* Copy the first part of user declarations. */
69 /* Line 189 of yacc.c */
70 #line 1 "glcpp/glcpp-parse.y"
73 * Copyright © 2010 Intel Corporation
75 * Permission is hereby granted, free of charge, to any person obtaining a
76 * copy of this software and associated documentation files (the "Software"),
77 * to deal in the Software without restriction, including without limitation
78 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
79 * and/or sell copies of the Software, and to permit persons to whom the
80 * Software is furnished to do so, subject to the following conditions:
82 * The above copyright notice and this permission notice (including the next
83 * paragraph) shall be included in all copies or substantial portions of the
86 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
87 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
88 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
89 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
90 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
91 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
92 * DEALINGS IN THE SOFTWARE.
102 #include "main/core.h" /* for struct gl_extensions */
103 #include "main/mtypes.h" /* for gl_api enum */
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
);
138 _string_list_equal (string_list_t
*a
, string_list_t
*b
);
140 static argument_list_t
*
141 _argument_list_create (void *ctx
);
144 _argument_list_append (argument_list_t
*list
, token_list_t
*argument
);
147 _argument_list_length (argument_list_t
*list
);
149 static token_list_t
*
150 _argument_list_member_at (argument_list_t
*list
, int index
);
152 /* Note: This function talloc_steal()s the str pointer. */
154 _token_create_str (void *ctx
, int type
, char *str
);
157 _token_create_ival (void *ctx
, int type
, int ival
);
159 static token_list_t
*
160 _token_list_create (void *ctx
);
162 /* Note: This function adds a talloc_reference() to token.
164 * You may want to talloc_unlink any current reference if you no
167 _token_list_append (token_list_t
*list
, token_t
*token
);
170 _token_list_append_list (token_list_t
*list
, token_list_t
*tail
);
173 _token_list_equal_ignoring_space (token_list_t
*a
, token_list_t
*b
);
175 static active_list_t
*
176 _active_list_push (active_list_t
*list
,
177 const char *identifier
,
178 token_node_t
*marker
);
180 static active_list_t
*
181 _active_list_pop (active_list_t
*list
);
184 _active_list_contains (active_list_t
*list
, const char *identifier
);
187 _glcpp_parser_expand_if (glcpp_parser_t
*parser
, int type
, token_list_t
*list
);
190 _glcpp_parser_expand_token_list (glcpp_parser_t
*parser
,
194 _glcpp_parser_print_expanded_token_list (glcpp_parser_t
*parser
,
198 _glcpp_parser_skip_stack_push_if (glcpp_parser_t
*parser
, YYLTYPE
*loc
,
202 _glcpp_parser_skip_stack_change_if (glcpp_parser_t
*parser
, YYLTYPE
*loc
,
203 const char *type
, int condition
);
206 _glcpp_parser_skip_stack_pop (glcpp_parser_t
*parser
, YYLTYPE
*loc
);
208 #define yylex glcpp_parser_lex
211 glcpp_parser_lex (YYSTYPE
*yylval
, YYLTYPE
*yylloc
, glcpp_parser_t
*parser
);
214 glcpp_parser_lex_from (glcpp_parser_t
*parser
, token_list_t
*list
);
217 add_builtin_define(glcpp_parser_t
*parser
, const char *name
, int value
);
221 /* Line 189 of yacc.c */
222 #line 223 "glcpp/glcpp-parse.c"
224 /* Enabling traces. */
229 /* Enabling verbose error messages. */
230 #ifdef YYERROR_VERBOSE
231 # undef YYERROR_VERBOSE
232 # define YYERROR_VERBOSE 1
234 # define YYERROR_VERBOSE 1
237 /* Enabling the token table. */
238 #ifndef YYTOKEN_TABLE
239 # define YYTOKEN_TABLE 0
246 /* Put the tokens into the symbol table, so that GDB and other debuggers
253 HASH_DEFINE_FUNC
= 262,
254 HASH_DEFINE_OBJ
= 263,
266 INTEGER_STRING
= 275,
276 GREATER_OR_EQUAL
= 285,
286 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
288 # define yystype YYSTYPE /* obsolescent; will be withdrawn */
289 # define YYSTYPE_IS_DECLARED 1
292 #if ! defined YYLTYPE && ! defined YYLTYPE_IS_DECLARED
293 typedef struct YYLTYPE
300 # define yyltype YYLTYPE /* obsolescent; will be withdrawn */
301 # define YYLTYPE_IS_DECLARED 1
302 # define YYLTYPE_IS_TRIVIAL 1
306 /* Copy the second part of user declarations. */
309 /* Line 264 of yacc.c */
310 #line 311 "glcpp/glcpp-parse.c"
317 typedef YYTYPE_UINT8 yytype_uint8
;
319 typedef unsigned char yytype_uint8
;
323 typedef YYTYPE_INT8 yytype_int8
;
324 #elif (defined __STDC__ || defined __C99__FUNC__ \
325 || defined __cplusplus || defined _MSC_VER)
326 typedef signed char yytype_int8
;
328 typedef short int yytype_int8
;
332 typedef YYTYPE_UINT16 yytype_uint16
;
334 typedef unsigned short int yytype_uint16
;
338 typedef YYTYPE_INT16 yytype_int16
;
340 typedef short int yytype_int16
;
344 # ifdef __SIZE_TYPE__
345 # define YYSIZE_T __SIZE_TYPE__
346 # elif defined size_t
347 # define YYSIZE_T size_t
348 # elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \
349 || defined __cplusplus || defined _MSC_VER)
350 # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
351 # define YYSIZE_T size_t
353 # define YYSIZE_T unsigned int
357 #define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
360 # if defined YYENABLE_NLS && YYENABLE_NLS
362 # include <libintl.h> /* INFRINGES ON USER NAME SPACE */
363 # define YY_(msgid) dgettext ("bison-runtime", msgid)
367 # define YY_(msgid) msgid
371 /* Suppress unused-variable warnings by "using" E. */
372 #if ! defined lint || defined __GNUC__
373 # define YYUSE(e) ((void) (e))
375 # define YYUSE(e) /* empty */
378 /* Identity function, used to suppress warnings about constant conditions. */
382 #if (defined __STDC__ || defined __C99__FUNC__ \
383 || defined __cplusplus || defined _MSC_VER)
396 #if ! defined yyoverflow || YYERROR_VERBOSE
398 /* The parser invokes alloca or malloc; define the necessary symbols. */
400 # ifdef YYSTACK_USE_ALLOCA
401 # if YYSTACK_USE_ALLOCA
403 # define YYSTACK_ALLOC __builtin_alloca
404 # elif defined __BUILTIN_VA_ARG_INCR
405 # include <alloca.h> /* INFRINGES ON USER NAME SPACE */
407 # define YYSTACK_ALLOC __alloca
408 # elif defined _MSC_VER
409 # include <malloc.h> /* INFRINGES ON USER NAME SPACE */
410 # define alloca _alloca
412 # define YYSTACK_ALLOC alloca
413 # if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
414 || defined __cplusplus || defined _MSC_VER)
415 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
424 # ifdef YYSTACK_ALLOC
425 /* Pacify GCC's `empty if-body' warning. */
426 # define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0))
427 # ifndef YYSTACK_ALLOC_MAXIMUM
428 /* The OS might guarantee only one guard page at the bottom of the stack,
429 and a page size can be as small as 4096 bytes. So we cannot safely
430 invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
431 to allow for a few compiler-allocated temporary stack slots. */
432 # define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
435 # define YYSTACK_ALLOC YYMALLOC
436 # define YYSTACK_FREE YYFREE
437 # ifndef YYSTACK_ALLOC_MAXIMUM
438 # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
440 # if (defined __cplusplus && ! defined _STDLIB_H \
441 && ! ((defined YYMALLOC || defined malloc) \
442 && (defined YYFREE || defined free)))
443 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
449 # define YYMALLOC malloc
450 # if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
451 || defined __cplusplus || defined _MSC_VER)
452 void *malloc (YYSIZE_T
); /* INFRINGES ON USER NAME SPACE */
457 # if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
458 || defined __cplusplus || defined _MSC_VER)
459 void free (void *); /* INFRINGES ON USER NAME SPACE */
463 #endif /* ! defined yyoverflow || YYERROR_VERBOSE */
466 #if (! defined yyoverflow \
467 && (! defined __cplusplus \
468 || (defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL \
469 && defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
471 /* A type that is properly aligned for any stack member. */
474 yytype_int16 yyss_alloc
;
479 /* The size of the maximum gap between one aligned stack and the next. */
480 # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
482 /* The size of an array large to enough to hold all stacks, each with
484 # define YYSTACK_BYTES(N) \
485 ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE) + sizeof (YYLTYPE)) \
486 + 2 * YYSTACK_GAP_MAXIMUM)
488 /* Copy COUNT objects from FROM to TO. The source and destination do
491 # if defined __GNUC__ && 1 < __GNUC__
492 # define YYCOPY(To, From, Count) \
493 __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
495 # define YYCOPY(To, From, Count) \
499 for (yyi = 0; yyi < (Count); yyi++) \
500 (To)[yyi] = (From)[yyi]; \
506 /* Relocate STACK from its old location to the new one. The
507 local variables YYSIZE and YYSTACKSIZE give the old and new number of
508 elements in the stack, and YYPTR gives the new location of the
509 stack. Advance YYPTR to a properly aligned location for the next
511 # define YYSTACK_RELOCATE(Stack_alloc, Stack) \
514 YYSIZE_T yynewbytes; \
515 YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \
516 Stack = &yyptr->Stack_alloc; \
517 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
518 yyptr += yynewbytes / sizeof (*yyptr); \
524 /* YYFINAL -- State number of the termination state. */
526 /* YYLAST -- Last index in YYTABLE. */
529 /* YYNTOKENS -- Number of terminals. */
531 /* YYNNTS -- Number of nonterminals. */
533 /* YYNRULES -- Number of rules. */
535 /* YYNRULES -- Number of states. */
536 #define YYNSTATES 162
538 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
540 #define YYMAXUTOK 289
542 #define YYTRANSLATE(YYX) \
543 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
545 /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
546 static const yytype_uint8 yytranslate
[] =
548 0, 2, 2, 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, 2, 2, 47, 2, 2, 2, 43, 30, 2,
552 45, 46, 41, 39, 49, 40, 54, 42, 2, 2,
553 2, 2, 2, 2, 2, 2, 2, 2, 2, 55,
554 33, 56, 34, 2, 2, 2, 2, 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, 50, 2, 51, 29, 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, 52, 28, 53, 48, 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, 2, 2, 2, 2,
568 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
569 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
570 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
571 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
572 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
573 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
574 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
575 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
576 25, 26, 27, 31, 32, 35, 36, 37, 38, 44
580 /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
582 static const yytype_uint16 yyprhs
[] =
584 0, 0, 3, 4, 7, 9, 11, 13, 16, 20,
585 24, 29, 36, 44, 48, 52, 55, 60, 65, 69,
586 72, 75, 78, 82, 85, 87, 89, 91, 95, 99,
587 103, 107, 111, 115, 119, 123, 127, 131, 135, 139,
588 143, 147, 151, 155, 159, 163, 166, 169, 172, 175,
589 179, 181, 185, 187, 190, 193, 194, 196, 197, 199,
590 202, 207, 209, 211, 214, 216, 219, 221, 223, 225,
591 227, 229, 231, 233, 235, 237, 239, 241, 243, 245,
592 247, 249, 251, 253, 255, 257, 259, 261, 263, 265,
593 267, 269, 271, 273, 275, 277, 279, 281, 283, 285,
597 /* YYRHS -- A `-1'-separated list of the rules' RHS. */
598 static const yytype_int8 yyrhs
[] =
600 58, 0, -1, -1, 58, 59, -1, 61, -1, 65,
601 -1, 60, -1, 6, 66, -1, 18, 63, 21, -1,
602 5, 63, 21, -1, 8, 17, 67, 21, -1, 7,
603 17, 45, 46, 67, 21, -1, 7, 17, 45, 64,
604 46, 67, 21, -1, 15, 17, 21, -1, 12, 70,
605 21, -1, 12, 21, -1, 13, 17, 68, 21, -1,
606 14, 17, 68, 21, -1, 9, 70, 21, -1, 9,
607 21, -1, 10, 21, -1, 11, 21, -1, 16, 62,
608 21, -1, 6, 21, -1, 20, -1, 19, -1, 62,
609 -1, 63, 26, 63, -1, 63, 27, 63, -1, 63,
610 28, 63, -1, 63, 29, 63, -1, 63, 30, 63,
611 -1, 63, 31, 63, -1, 63, 32, 63, -1, 63,
612 35, 63, -1, 63, 36, 63, -1, 63, 34, 63,
613 -1, 63, 33, 63, -1, 63, 37, 63, -1, 63,
614 38, 63, -1, 63, 40, 63, -1, 63, 39, 63,
615 -1, 63, 43, 63, -1, 63, 42, 63, -1, 63,
616 41, 63, -1, 47, 63, -1, 48, 63, -1, 40,
617 63, -1, 39, 63, -1, 45, 63, 46, -1, 17,
618 -1, 64, 49, 17, -1, 21, -1, 71, 21, -1,
619 71, 21, -1, -1, 71, -1, -1, 71, -1, 4,
620 17, -1, 4, 45, 17, 46, -1, 72, -1, 69,
621 -1, 70, 69, -1, 72, -1, 71, 72, -1, 17,
622 -1, 20, -1, 73, -1, 22, -1, 24, -1, 50,
623 -1, 51, -1, 45, -1, 46, -1, 52, -1, 53,
624 -1, 54, -1, 30, -1, 41, -1, 39, -1, 40,
625 -1, 48, -1, 47, -1, 42, -1, 43, -1, 38,
626 -1, 37, -1, 33, -1, 34, -1, 36, -1, 35,
627 -1, 32, -1, 31, -1, 29, -1, 28, -1, 27,
628 -1, 26, -1, 55, -1, 49, -1, 56, -1, 25,
632 /* YYRLINE[YYN] -- source line where rule number YYN was defined. */
633 static const yytype_uint16 yyrline
[] =
635 0, 188, 188, 190, 194, 197, 202, 203, 207, 210,
636 216, 219, 222, 225, 233, 252, 262, 267, 272, 291,
637 306, 309, 312, 325, 329, 338, 343, 344, 347, 350,
638 353, 356, 359, 362, 365, 368, 371, 374, 377, 380,
639 383, 386, 389, 392, 395, 398, 401, 404, 407, 410,
640 416, 421, 429, 430, 434, 440, 441, 444, 446, 453,
641 457, 461, 466, 472, 480, 486, 494, 498, 502, 506,
642 510, 517, 518, 519, 520, 521, 522, 523, 524, 525,
643 526, 527, 528, 529, 530, 531, 532, 533, 534, 535,
644 536, 537, 538, 539, 540, 541, 542, 543, 544, 545,
649 #if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
650 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
651 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
652 static const char *const yytname
[] =
654 "$end", "error", "$undefined", "COMMA_FINAL", "DEFINED",
655 "ELIF_EXPANDED", "HASH", "HASH_DEFINE_FUNC", "HASH_DEFINE_OBJ",
656 "HASH_ELIF", "HASH_ELSE", "HASH_ENDIF", "HASH_IF", "HASH_IFDEF",
657 "HASH_IFNDEF", "HASH_UNDEF", "HASH_VERSION", "IDENTIFIER", "IF_EXPANDED",
658 "INTEGER", "INTEGER_STRING", "NEWLINE", "OTHER", "PLACEHOLDER", "SPACE",
659 "PASTE", "OR", "AND", "'|'", "'^'", "'&'", "NOT_EQUAL", "EQUAL", "'<'",
660 "'>'", "GREATER_OR_EQUAL", "LESS_OR_EQUAL", "RIGHT_SHIFT", "LEFT_SHIFT",
661 "'+'", "'-'", "'*'", "'/'", "'%'", "UNARY", "'('", "')'", "'!'", "'~'",
662 "','", "'['", "']'", "'{'", "'}'", "'.'", "';'", "'='", "$accept",
663 "input", "line", "expanded_line", "control_line", "integer_constant",
664 "expression", "identifier_list", "text_line", "non_directive",
665 "replacement_list", "junk", "conditional_token", "conditional_tokens",
666 "pp_tokens", "preprocessing_token", "operator", 0
671 /* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
673 static const yytype_uint16 yytoknum
[] =
675 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
676 265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
677 275, 276, 277, 278, 279, 280, 281, 282, 124, 94,
678 38, 283, 284, 60, 62, 285, 286, 287, 288, 43,
679 45, 42, 47, 37, 289, 40, 41, 33, 126, 44,
680 91, 93, 123, 125, 46, 59, 61
684 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
685 static const yytype_uint8 yyr1
[] =
687 0, 57, 58, 58, 59, 59, 59, 59, 60, 60,
688 61, 61, 61, 61, 61, 61, 61, 61, 61, 61,
689 61, 61, 61, 61, 62, 62, 63, 63, 63, 63,
690 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
691 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
692 64, 64, 65, 65, 66, 67, 67, 68, 68, 69,
693 69, 69, 70, 70, 71, 71, 72, 72, 72, 72,
694 72, 73, 73, 73, 73, 73, 73, 73, 73, 73,
695 73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
696 73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
700 /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
701 static const yytype_uint8 yyr2
[] =
703 0, 2, 0, 2, 1, 1, 1, 2, 3, 3,
704 4, 6, 7, 3, 3, 2, 4, 4, 3, 2,
705 2, 2, 3, 2, 1, 1, 1, 3, 3, 3,
706 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
707 3, 3, 3, 3, 3, 2, 2, 2, 2, 3,
708 1, 3, 1, 2, 2, 0, 1, 0, 1, 2,
709 4, 1, 1, 2, 1, 2, 1, 1, 1, 1,
710 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
711 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
712 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
716 /* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
717 STATE-NUM when YYTABLE doesn't specify something else to do. Zero
718 means the default is an error. */
719 static const yytype_uint8 yydefact
[] =
721 2, 0, 1, 0, 0, 0, 0, 0, 0, 0,
722 0, 0, 0, 0, 0, 66, 0, 67, 52, 69,
723 70, 101, 97, 96, 95, 94, 78, 93, 92, 88,
724 89, 91, 90, 87, 86, 80, 81, 79, 84, 85,
725 73, 74, 83, 82, 99, 71, 72, 75, 76, 77,
726 98, 100, 3, 6, 4, 5, 0, 64, 68, 25,
727 24, 0, 0, 0, 0, 0, 26, 0, 23, 7,
728 0, 0, 55, 0, 19, 62, 0, 61, 20, 21,
729 15, 0, 57, 57, 0, 0, 0, 53, 65, 48,
730 47, 0, 45, 46, 9, 0, 0, 0, 0, 0,
731 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
732 0, 0, 0, 54, 0, 0, 56, 59, 0, 18,
733 63, 14, 0, 58, 0, 13, 22, 8, 49, 27,
734 28, 29, 30, 31, 32, 33, 37, 36, 34, 35,
735 38, 39, 41, 40, 44, 43, 42, 50, 55, 0,
736 10, 0, 16, 17, 0, 55, 0, 60, 11, 0,
740 /* YYDEFGOTO[NTERM-NUM]. */
741 static const yytype_int16 yydefgoto
[] =
743 -1, 1, 52, 53, 54, 66, 67, 149, 55, 69,
744 115, 122, 75, 76, 116, 57, 58
747 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
749 #define YYPACT_NINF -147
750 static const yytype_int16 yypact
[] =
752 -147, 112, -147, 28, -10, 55, 62, 152, -15, 59,
753 192, 85, 86, 87, 51, -147, 28, -147, -147, -147,
754 -147, -147, -147, -147, -147, -147, -147, -147, -147, -147,
755 -147, -147, -147, -147, -147, -147, -147, -147, -147, -147,
756 -147, -147, -147, -147, -147, -147, -147, -147, -147, -147,
757 -147, -147, -147, -147, -147, -147, 312, -147, -147, -147,
758 -147, 28, 28, 28, 28, 28, -147, 428, -147, -147,
759 352, 63, 392, 17, -147, -147, 232, -147, -147, -147,
760 -147, 272, 392, 392, 84, 89, 451, -147, -147, -147,
761 -147, 469, -147, -147, -147, 28, 28, 28, 28, 28,
762 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
763 28, 28, 28, -147, 60, 90, 392, -147, 96, -147,
764 -147, -147, 93, 392, 94, -147, -147, -147, -147, 489,
765 505, 520, 534, 547, 558, 558, 18, 18, 18, 18,
766 563, 563, 23, 23, -147, -147, -147, -147, 392, 32,
767 -147, 61, -147, -147, 110, 392, 118, -147, -147, 149,
771 /* YYPGOTO[NTERM-NUM]. */
772 static const yytype_int16 yypgoto
[] =
774 -147, -147, -147, -147, -147, 157, -11, -147, -147, -147,
775 -146, 92, -68, 200, 0, -7, -147
778 /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
779 positive, shift that token. If negative, reduce the rule which
780 number is the opposite. If zero, do what YYDEFACT says.
781 If YYTABLE_NINF, syntax error. */
782 #define YYTABLE_NINF -1
783 static const yytype_uint8 yytable
[] =
785 77, 56, 154, 77, 70, 86, 78, 15, 120, 159,
786 17, 68, 19, 120, 20, 21, 22, 23, 24, 25,
787 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
788 36, 37, 38, 39, 117, 40, 41, 42, 43, 44,
789 45, 46, 47, 48, 49, 50, 51, 59, 60, 88,
790 89, 90, 91, 92, 93, 106, 107, 108, 109, 110,
791 111, 112, 118, 88, 110, 111, 112, 61, 62, 77,
792 59, 60, 71, 63, 77, 64, 65, 147, 155, 72,
793 79, 156, 123, 123, 129, 130, 131, 132, 133, 134,
794 135, 136, 137, 138, 139, 140, 141, 142, 143, 144,
795 145, 146, 82, 83, 84, 125, 148, 157, 114, 88,
796 126, 150, 2, 151, 152, 153, 88, 3, 4, 5,
797 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
798 16, 158, 17, 18, 19, 160, 20, 21, 22, 23,
799 24, 25, 26, 27, 28, 29, 30, 31, 32, 33,
800 34, 35, 36, 37, 38, 39, 73, 40, 41, 42,
801 43, 44, 45, 46, 47, 48, 49, 50, 51, 15,
802 161, 85, 17, 74, 19, 124, 20, 21, 22, 23,
803 24, 25, 26, 27, 28, 29, 30, 31, 32, 33,
804 34, 35, 36, 37, 38, 39, 73, 40, 41, 42,
805 43, 44, 45, 46, 47, 48, 49, 50, 51, 15,
806 81, 0, 17, 80, 19, 0, 20, 21, 22, 23,
807 24, 25, 26, 27, 28, 29, 30, 31, 32, 33,
808 34, 35, 36, 37, 38, 39, 73, 40, 41, 42,
809 43, 44, 45, 46, 47, 48, 49, 50, 51, 15,
810 0, 0, 17, 119, 19, 0, 20, 21, 22, 23,
811 24, 25, 26, 27, 28, 29, 30, 31, 32, 33,
812 34, 35, 36, 37, 38, 39, 73, 40, 41, 42,
813 43, 44, 45, 46, 47, 48, 49, 50, 51, 15,
814 0, 0, 17, 121, 19, 0, 20, 21, 22, 23,
815 24, 25, 26, 27, 28, 29, 30, 31, 32, 33,
816 34, 35, 36, 37, 38, 39, 0, 40, 41, 42,
817 43, 44, 45, 46, 47, 48, 49, 50, 51, 15,
818 0, 0, 17, 87, 19, 0, 20, 21, 22, 23,
819 24, 25, 26, 27, 28, 29, 30, 31, 32, 33,
820 34, 35, 36, 37, 38, 39, 0, 40, 41, 42,
821 43, 44, 45, 46, 47, 48, 49, 50, 51, 15,
822 0, 0, 17, 113, 19, 0, 20, 21, 22, 23,
823 24, 25, 26, 27, 28, 29, 30, 31, 32, 33,
824 34, 35, 36, 37, 38, 39, 0, 40, 41, 42,
825 43, 44, 45, 46, 47, 48, 49, 50, 51, 15,
826 0, 0, 17, 0, 19, 0, 20, 21, 22, 23,
827 24, 25, 26, 27, 28, 29, 30, 31, 32, 33,
828 34, 35, 36, 37, 38, 39, 0, 40, 41, 42,
829 43, 44, 45, 46, 47, 48, 49, 50, 51, 94,
830 0, 0, 0, 0, 95, 96, 97, 98, 99, 100,
831 101, 102, 103, 104, 105, 106, 107, 108, 109, 110,
832 111, 112, 127, 0, 0, 0, 0, 95, 96, 97,
833 98, 99, 100, 101, 102, 103, 104, 105, 106, 107,
834 108, 109, 110, 111, 112, 95, 96, 97, 98, 99,
835 100, 101, 102, 103, 104, 105, 106, 107, 108, 109,
836 110, 111, 112, 0, 0, 128, 96, 97, 98, 99,
837 100, 101, 102, 103, 104, 105, 106, 107, 108, 109,
838 110, 111, 112, 97, 98, 99, 100, 101, 102, 103,
839 104, 105, 106, 107, 108, 109, 110, 111, 112, 98,
840 99, 100, 101, 102, 103, 104, 105, 106, 107, 108,
841 109, 110, 111, 112, 99, 100, 101, 102, 103, 104,
842 105, 106, 107, 108, 109, 110, 111, 112, 100, 101,
843 102, 103, 104, 105, 106, 107, 108, 109, 110, 111,
844 112, 102, 103, 104, 105, 106, 107, 108, 109, 110,
845 111, 112, 108, 109, 110, 111, 112
848 static const yytype_int16 yycheck
[] =
850 7, 1, 148, 10, 4, 16, 21, 17, 76, 155,
851 20, 21, 22, 81, 24, 25, 26, 27, 28, 29,
852 30, 31, 32, 33, 34, 35, 36, 37, 38, 39,
853 40, 41, 42, 43, 17, 45, 46, 47, 48, 49,
854 50, 51, 52, 53, 54, 55, 56, 19, 20, 56,
855 61, 62, 63, 64, 65, 37, 38, 39, 40, 41,
856 42, 43, 45, 70, 41, 42, 43, 39, 40, 76,
857 19, 20, 17, 45, 81, 47, 48, 17, 46, 17,
858 21, 49, 82, 83, 95, 96, 97, 98, 99, 100,
859 101, 102, 103, 104, 105, 106, 107, 108, 109, 110,
860 111, 112, 17, 17, 17, 21, 46, 46, 45, 116,
861 21, 21, 0, 17, 21, 21, 123, 5, 6, 7,
862 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
863 18, 21, 20, 21, 22, 17, 24, 25, 26, 27,
864 28, 29, 30, 31, 32, 33, 34, 35, 36, 37,
865 38, 39, 40, 41, 42, 43, 4, 45, 46, 47,
866 48, 49, 50, 51, 52, 53, 54, 55, 56, 17,
867 21, 14, 20, 21, 22, 83, 24, 25, 26, 27,
868 28, 29, 30, 31, 32, 33, 34, 35, 36, 37,
869 38, 39, 40, 41, 42, 43, 4, 45, 46, 47,
870 48, 49, 50, 51, 52, 53, 54, 55, 56, 17,
871 10, -1, 20, 21, 22, -1, 24, 25, 26, 27,
872 28, 29, 30, 31, 32, 33, 34, 35, 36, 37,
873 38, 39, 40, 41, 42, 43, 4, 45, 46, 47,
874 48, 49, 50, 51, 52, 53, 54, 55, 56, 17,
875 -1, -1, 20, 21, 22, -1, 24, 25, 26, 27,
876 28, 29, 30, 31, 32, 33, 34, 35, 36, 37,
877 38, 39, 40, 41, 42, 43, 4, 45, 46, 47,
878 48, 49, 50, 51, 52, 53, 54, 55, 56, 17,
879 -1, -1, 20, 21, 22, -1, 24, 25, 26, 27,
880 28, 29, 30, 31, 32, 33, 34, 35, 36, 37,
881 38, 39, 40, 41, 42, 43, -1, 45, 46, 47,
882 48, 49, 50, 51, 52, 53, 54, 55, 56, 17,
883 -1, -1, 20, 21, 22, -1, 24, 25, 26, 27,
884 28, 29, 30, 31, 32, 33, 34, 35, 36, 37,
885 38, 39, 40, 41, 42, 43, -1, 45, 46, 47,
886 48, 49, 50, 51, 52, 53, 54, 55, 56, 17,
887 -1, -1, 20, 21, 22, -1, 24, 25, 26, 27,
888 28, 29, 30, 31, 32, 33, 34, 35, 36, 37,
889 38, 39, 40, 41, 42, 43, -1, 45, 46, 47,
890 48, 49, 50, 51, 52, 53, 54, 55, 56, 17,
891 -1, -1, 20, -1, 22, -1, 24, 25, 26, 27,
892 28, 29, 30, 31, 32, 33, 34, 35, 36, 37,
893 38, 39, 40, 41, 42, 43, -1, 45, 46, 47,
894 48, 49, 50, 51, 52, 53, 54, 55, 56, 21,
895 -1, -1, -1, -1, 26, 27, 28, 29, 30, 31,
896 32, 33, 34, 35, 36, 37, 38, 39, 40, 41,
897 42, 43, 21, -1, -1, -1, -1, 26, 27, 28,
898 29, 30, 31, 32, 33, 34, 35, 36, 37, 38,
899 39, 40, 41, 42, 43, 26, 27, 28, 29, 30,
900 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
901 41, 42, 43, -1, -1, 46, 27, 28, 29, 30,
902 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
903 41, 42, 43, 28, 29, 30, 31, 32, 33, 34,
904 35, 36, 37, 38, 39, 40, 41, 42, 43, 29,
905 30, 31, 32, 33, 34, 35, 36, 37, 38, 39,
906 40, 41, 42, 43, 30, 31, 32, 33, 34, 35,
907 36, 37, 38, 39, 40, 41, 42, 43, 31, 32,
908 33, 34, 35, 36, 37, 38, 39, 40, 41, 42,
909 43, 33, 34, 35, 36, 37, 38, 39, 40, 41,
910 42, 43, 39, 40, 41, 42, 43
913 /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
914 symbol of state STATE-NUM. */
915 static const yytype_uint8 yystos
[] =
917 0, 58, 0, 5, 6, 7, 8, 9, 10, 11,
918 12, 13, 14, 15, 16, 17, 18, 20, 21, 22,
919 24, 25, 26, 27, 28, 29, 30, 31, 32, 33,
920 34, 35, 36, 37, 38, 39, 40, 41, 42, 43,
921 45, 46, 47, 48, 49, 50, 51, 52, 53, 54,
922 55, 56, 59, 60, 61, 65, 71, 72, 73, 19,
923 20, 39, 40, 45, 47, 48, 62, 63, 21, 66,
924 71, 17, 17, 4, 21, 69, 70, 72, 21, 21,
925 21, 70, 17, 17, 17, 62, 63, 21, 72, 63,
926 63, 63, 63, 63, 21, 26, 27, 28, 29, 30,
927 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
928 41, 42, 43, 21, 45, 67, 71, 17, 45, 21,
929 69, 21, 68, 71, 68, 21, 21, 21, 46, 63,
930 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
931 63, 63, 63, 63, 63, 63, 63, 17, 46, 64,
932 21, 17, 21, 21, 67, 46, 49, 46, 21, 67,
936 #define yyerrok (yyerrstatus = 0)
937 #define yyclearin (yychar = YYEMPTY)
941 #define YYACCEPT goto yyacceptlab
942 #define YYABORT goto yyabortlab
943 #define YYERROR goto yyerrorlab
946 /* Like YYERROR except do call yyerror. This remains here temporarily
947 to ease the transition to the new meaning of YYERROR, for GCC.
948 Once GCC version 2 has supplanted version 1, this can go. However,
949 YYFAIL appears to be in use. Nevertheless, it is formally deprecated
950 in Bison 2.4.2's NEWS entry, where a plan to phase it out is
953 #define YYFAIL goto yyerrlab
955 /* This is here to suppress warnings from the GCC cpp's
956 -Wunused-macros. Normally we don't worry about that warning, but
957 some users do, and we want to make it easy for users to remove
958 YYFAIL uses, which will produce warnings from Bison 2.5. */
961 #define YYRECOVERING() (!!yyerrstatus)
963 #define YYBACKUP(Token, Value) \
965 if (yychar == YYEMPTY && yylen == 1) \
969 yytoken = YYTRANSLATE (yychar); \
975 yyerror (&yylloc, parser, YY_("syntax error: cannot back up")); \
982 #define YYERRCODE 256
985 /* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
986 If N is 0, then set CURRENT to the empty location which ends
987 the previous symbol: RHS[0] (always defined). */
989 #define YYRHSLOC(Rhs, K) ((Rhs)[K])
990 #ifndef YYLLOC_DEFAULT
991 # define YYLLOC_DEFAULT(Current, Rhs, N) \
995 (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
996 (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
997 (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
998 (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
1002 (Current).first_line = (Current).last_line = \
1003 YYRHSLOC (Rhs, 0).last_line; \
1004 (Current).first_column = (Current).last_column = \
1005 YYRHSLOC (Rhs, 0).last_column; \
1011 /* YY_LOCATION_PRINT -- Print the location on the stream.
1012 This macro was not mandated originally: define only if we know
1013 we won't break user code: when these are the locations we know. */
1015 #ifndef YY_LOCATION_PRINT
1016 # if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL
1017 # define YY_LOCATION_PRINT(File, Loc) \
1018 fprintf (File, "%d.%d-%d.%d", \
1019 (Loc).first_line, (Loc).first_column, \
1020 (Loc).last_line, (Loc).last_column)
1022 # define YY_LOCATION_PRINT(File, Loc) ((void) 0)
1027 /* YYLEX -- calling `yylex' with the right arguments. */
1030 # define YYLEX yylex (&yylval, &yylloc, YYLEX_PARAM)
1032 # define YYLEX yylex (&yylval, &yylloc, parser)
1035 /* Enable debugging if requested. */
1039 # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
1040 # define YYFPRINTF fprintf
1043 # define YYDPRINTF(Args) \
1049 # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
1053 YYFPRINTF (stderr, "%s ", Title); \
1054 yy_symbol_print (stderr, \
1055 Type, Value, Location, parser); \
1056 YYFPRINTF (stderr, "\n"); \
1061 /*--------------------------------.
1062 | Print this symbol on YYOUTPUT. |
1063 `--------------------------------*/
1066 #if (defined __STDC__ || defined __C99__FUNC__ \
1067 || defined __cplusplus || defined _MSC_VER)
1069 yy_symbol_value_print (FILE *yyoutput
, int yytype
, YYSTYPE
const * const yyvaluep
, YYLTYPE
const * const yylocationp
, glcpp_parser_t
*parser
)
1072 yy_symbol_value_print (yyoutput
, yytype
, yyvaluep
, yylocationp
, parser
)
1075 YYSTYPE
const * const yyvaluep
;
1076 YYLTYPE
const * const yylocationp
;
1077 glcpp_parser_t
*parser
;
1082 YYUSE (yylocationp
);
1085 if (yytype
< YYNTOKENS
)
1086 YYPRINT (yyoutput
, yytoknum
[yytype
], *yyvaluep
);
1098 /*--------------------------------.
1099 | Print this symbol on YYOUTPUT. |
1100 `--------------------------------*/
1102 #if (defined __STDC__ || defined __C99__FUNC__ \
1103 || defined __cplusplus || defined _MSC_VER)
1105 yy_symbol_print (FILE *yyoutput
, int yytype
, YYSTYPE
const * const yyvaluep
, YYLTYPE
const * const yylocationp
, glcpp_parser_t
*parser
)
1108 yy_symbol_print (yyoutput
, yytype
, yyvaluep
, yylocationp
, parser
)
1111 YYSTYPE
const * const yyvaluep
;
1112 YYLTYPE
const * const yylocationp
;
1113 glcpp_parser_t
*parser
;
1116 if (yytype
< YYNTOKENS
)
1117 YYFPRINTF (yyoutput
, "token %s (", yytname
[yytype
]);
1119 YYFPRINTF (yyoutput
, "nterm %s (", yytname
[yytype
]);
1121 YY_LOCATION_PRINT (yyoutput
, *yylocationp
);
1122 YYFPRINTF (yyoutput
, ": ");
1123 yy_symbol_value_print (yyoutput
, yytype
, yyvaluep
, yylocationp
, parser
);
1124 YYFPRINTF (yyoutput
, ")");
1127 /*------------------------------------------------------------------.
1128 | yy_stack_print -- Print the state stack from its BOTTOM up to its |
1130 `------------------------------------------------------------------*/
1132 #if (defined __STDC__ || defined __C99__FUNC__ \
1133 || defined __cplusplus || defined _MSC_VER)
1135 yy_stack_print (yytype_int16
*yybottom
, yytype_int16
*yytop
)
1138 yy_stack_print (yybottom
, yytop
)
1139 yytype_int16
*yybottom
;
1140 yytype_int16
*yytop
;
1143 YYFPRINTF (stderr
, "Stack now");
1144 for (; yybottom
<= yytop
; yybottom
++)
1146 int yybot
= *yybottom
;
1147 YYFPRINTF (stderr
, " %d", yybot
);
1149 YYFPRINTF (stderr
, "\n");
1152 # define YY_STACK_PRINT(Bottom, Top) \
1155 yy_stack_print ((Bottom), (Top)); \
1159 /*------------------------------------------------.
1160 | Report that the YYRULE is going to be reduced. |
1161 `------------------------------------------------*/
1163 #if (defined __STDC__ || defined __C99__FUNC__ \
1164 || defined __cplusplus || defined _MSC_VER)
1166 yy_reduce_print (YYSTYPE
*yyvsp
, YYLTYPE
*yylsp
, int yyrule
, glcpp_parser_t
*parser
)
1169 yy_reduce_print (yyvsp
, yylsp
, yyrule
, parser
)
1173 glcpp_parser_t
*parser
;
1176 int yynrhs
= yyr2
[yyrule
];
1178 unsigned long int yylno
= yyrline
[yyrule
];
1179 YYFPRINTF (stderr
, "Reducing stack by rule %d (line %lu):\n",
1181 /* The symbols being reduced. */
1182 for (yyi
= 0; yyi
< yynrhs
; yyi
++)
1184 YYFPRINTF (stderr
, " $%d = ", yyi
+ 1);
1185 yy_symbol_print (stderr
, yyrhs
[yyprhs
[yyrule
] + yyi
],
1186 &(yyvsp
[(yyi
+ 1) - (yynrhs
)])
1187 , &(yylsp
[(yyi
+ 1) - (yynrhs
)]) , parser
);
1188 YYFPRINTF (stderr
, "\n");
1192 # define YY_REDUCE_PRINT(Rule) \
1195 yy_reduce_print (yyvsp, yylsp, Rule, parser); \
1198 /* Nonzero means print parse trace. It is left uninitialized so that
1199 multiple parsers can coexist. */
1201 #else /* !YYDEBUG */
1202 # define YYDPRINTF(Args)
1203 # define YY_SYMBOL_PRINT(Title, Type, Value, Location)
1204 # define YY_STACK_PRINT(Bottom, Top)
1205 # define YY_REDUCE_PRINT(Rule)
1206 #endif /* !YYDEBUG */
1209 /* YYINITDEPTH -- initial size of the parser's stacks. */
1211 # define YYINITDEPTH 200
1214 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
1215 if the built-in stack extension method is used).
1217 Do not make this value too large; the results are undefined if
1218 YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
1219 evaluated with infinite-precision integer arithmetic. */
1222 # define YYMAXDEPTH 10000
1230 # if defined __GLIBC__ && defined _STRING_H
1231 # define yystrlen strlen
1233 /* Return the length of YYSTR. */
1234 #if (defined __STDC__ || defined __C99__FUNC__ \
1235 || defined __cplusplus || defined _MSC_VER)
1237 yystrlen (const char *yystr
)
1245 for (yylen
= 0; yystr
[yylen
]; yylen
++)
1253 # if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
1254 # define yystpcpy stpcpy
1256 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
1258 #if (defined __STDC__ || defined __C99__FUNC__ \
1259 || defined __cplusplus || defined _MSC_VER)
1261 yystpcpy (char *yydest
, const char *yysrc
)
1264 yystpcpy (yydest
, yysrc
)
1270 const char *yys
= yysrc
;
1272 while ((*yyd
++ = *yys
++) != '\0')
1281 /* Copy to YYRES the contents of YYSTR after stripping away unnecessary
1282 quotes and backslashes, so that it's suitable for yyerror. The
1283 heuristic is that double-quoting is unnecessary unless the string
1284 contains an apostrophe, a comma, or backslash (other than
1285 backslash-backslash). YYSTR is taken from yytname. If YYRES is
1286 null, do not copy; instead, return the length of what the result
1289 yytnamerr (char *yyres
, const char *yystr
)
1294 char const *yyp
= yystr
;
1301 goto do_not_strip_quotes
;
1305 goto do_not_strip_quotes
;
1318 do_not_strip_quotes
: ;
1322 return yystrlen (yystr
);
1324 return yystpcpy (yyres
, yystr
) - yyres
;
1328 /* Copy into YYRESULT an error message about the unexpected token
1329 YYCHAR while in state YYSTATE. Return the number of bytes copied,
1330 including the terminating null byte. If YYRESULT is null, do not
1331 copy anything; just return the number of bytes that would be
1332 copied. As a special case, return 0 if an ordinary "syntax error"
1333 message will do. Return YYSIZE_MAXIMUM if overflow occurs during
1334 size calculation. */
1336 yysyntax_error (char *yyresult
, int yystate
, int yychar
)
1338 int yyn
= yypact
[yystate
];
1340 if (! (YYPACT_NINF
< yyn
&& yyn
<= YYLAST
))
1344 int yytype
= YYTRANSLATE (yychar
);
1345 YYSIZE_T yysize0
= yytnamerr (0, yytname
[yytype
]);
1346 YYSIZE_T yysize
= yysize0
;
1348 int yysize_overflow
= 0;
1349 enum { YYERROR_VERBOSE_ARGS_MAXIMUM
= 5 };
1350 char const *yyarg
[YYERROR_VERBOSE_ARGS_MAXIMUM
];
1354 /* This is so xgettext sees the translatable formats that are
1355 constructed on the fly. */
1356 YY_("syntax error, unexpected %s");
1357 YY_("syntax error, unexpected %s, expecting %s");
1358 YY_("syntax error, unexpected %s, expecting %s or %s");
1359 YY_("syntax error, unexpected %s, expecting %s or %s or %s");
1360 YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s");
1364 static char const yyunexpected
[] = "syntax error, unexpected %s";
1365 static char const yyexpecting
[] = ", expecting %s";
1366 static char const yyor
[] = " or %s";
1367 char yyformat
[sizeof yyunexpected
1368 + sizeof yyexpecting
- 1
1369 + ((YYERROR_VERBOSE_ARGS_MAXIMUM
- 2)
1370 * (sizeof yyor
- 1))];
1371 char const *yyprefix
= yyexpecting
;
1373 /* Start YYX at -YYN if negative to avoid negative indexes in
1375 int yyxbegin
= yyn
< 0 ? -yyn
: 0;
1377 /* Stay within bounds of both yycheck and yytname. */
1378 int yychecklim
= YYLAST
- yyn
+ 1;
1379 int yyxend
= yychecklim
< YYNTOKENS
? yychecklim
: YYNTOKENS
;
1382 yyarg
[0] = yytname
[yytype
];
1383 yyfmt
= yystpcpy (yyformat
, yyunexpected
);
1385 for (yyx
= yyxbegin
; yyx
< yyxend
; ++yyx
)
1386 if (yycheck
[yyx
+ yyn
] == yyx
&& yyx
!= YYTERROR
)
1388 if (yycount
== YYERROR_VERBOSE_ARGS_MAXIMUM
)
1392 yyformat
[sizeof yyunexpected
- 1] = '\0';
1395 yyarg
[yycount
++] = yytname
[yyx
];
1396 yysize1
= yysize
+ yytnamerr (0, yytname
[yyx
]);
1397 yysize_overflow
|= (yysize1
< yysize
);
1399 yyfmt
= yystpcpy (yyfmt
, yyprefix
);
1403 yyf
= YY_(yyformat
);
1404 yysize1
= yysize
+ yystrlen (yyf
);
1405 yysize_overflow
|= (yysize1
< yysize
);
1408 if (yysize_overflow
)
1409 return YYSIZE_MAXIMUM
;
1413 /* Avoid sprintf, as that infringes on the user's name space.
1414 Don't have undefined behavior even if the translation
1415 produced a string with the wrong number of "%s"s. */
1416 char *yyp
= yyresult
;
1418 while ((*yyp
= *yyf
) != '\0')
1420 if (*yyp
== '%' && yyf
[1] == 's' && yyi
< yycount
)
1422 yyp
+= yytnamerr (yyp
, yyarg
[yyi
++]);
1435 #endif /* YYERROR_VERBOSE */
1438 /*-----------------------------------------------.
1439 | Release the memory associated to this symbol. |
1440 `-----------------------------------------------*/
1443 #if (defined __STDC__ || defined __C99__FUNC__ \
1444 || defined __cplusplus || defined _MSC_VER)
1446 yydestruct (const char *yymsg
, int yytype
, YYSTYPE
*yyvaluep
, YYLTYPE
*yylocationp
, glcpp_parser_t
*parser
)
1449 yydestruct (yymsg
, yytype
, yyvaluep
, yylocationp
, parser
)
1453 YYLTYPE
*yylocationp
;
1454 glcpp_parser_t
*parser
;
1458 YYUSE (yylocationp
);
1463 YY_SYMBOL_PRINT (yymsg
, yytype
, yyvaluep
, yylocationp
);
1473 /* Prevent warnings from -Wmissing-prototypes. */
1474 #ifdef YYPARSE_PARAM
1475 #if defined __STDC__ || defined __cplusplus
1476 int yyparse (void *YYPARSE_PARAM
);
1480 #else /* ! YYPARSE_PARAM */
1481 #if defined __STDC__ || defined __cplusplus
1482 int yyparse (glcpp_parser_t
*parser
);
1486 #endif /* ! YYPARSE_PARAM */
1492 /*-------------------------.
1493 | yyparse or yypush_parse. |
1494 `-------------------------*/
1496 #ifdef YYPARSE_PARAM
1497 #if (defined __STDC__ || defined __C99__FUNC__ \
1498 || defined __cplusplus || defined _MSC_VER)
1500 yyparse (void *YYPARSE_PARAM
)
1503 yyparse (YYPARSE_PARAM
)
1504 void *YYPARSE_PARAM
;
1506 #else /* ! YYPARSE_PARAM */
1507 #if (defined __STDC__ || defined __C99__FUNC__ \
1508 || defined __cplusplus || defined _MSC_VER)
1510 yyparse (glcpp_parser_t
*parser
)
1514 glcpp_parser_t
*parser
;
1518 /* The lookahead symbol. */
1521 /* The semantic value of the lookahead symbol. */
1524 /* Location data for the lookahead symbol. */
1527 /* Number of syntax errors so far. */
1531 /* Number of tokens to shift before error messages enabled. */
1534 /* The stacks and their tools:
1535 `yyss': related to states.
1536 `yyvs': related to semantic values.
1537 `yyls': related to locations.
1539 Refer to the stacks thru separate pointers, to allow yyoverflow
1540 to reallocate them elsewhere. */
1542 /* The state stack. */
1543 yytype_int16 yyssa
[YYINITDEPTH
];
1545 yytype_int16
*yyssp
;
1547 /* The semantic value stack. */
1548 YYSTYPE yyvsa
[YYINITDEPTH
];
1552 /* The location stack. */
1553 YYLTYPE yylsa
[YYINITDEPTH
];
1557 /* The locations where the error started and ended. */
1558 YYLTYPE yyerror_range
[3];
1560 YYSIZE_T yystacksize
;
1564 /* Lookahead token as an internal (translated) token number. */
1566 /* The variables used to return semantic value and location from the
1572 /* Buffer for error messages, and its allocated size. */
1574 char *yymsg
= yymsgbuf
;
1575 YYSIZE_T yymsg_alloc
= sizeof yymsgbuf
;
1578 #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N), yylsp -= (N))
1580 /* The number of symbols on the RHS of the reduced rule.
1581 Keep to zero when no symbol should be popped. */
1588 yystacksize
= YYINITDEPTH
;
1590 YYDPRINTF ((stderr
, "Starting parse\n"));
1595 yychar
= YYEMPTY
; /* Cause a token to be read. */
1597 /* Initialize stack pointers.
1598 Waste one element of value and location stack
1599 so that they stay on the same level as the state stack.
1600 The wasted elements are never initialized. */
1605 #if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL
1606 /* Initialize the default location before parsing starts. */
1607 yylloc
.first_line
= yylloc
.last_line
= 1;
1608 yylloc
.first_column
= yylloc
.last_column
= 1;
1611 /* User initialization code. */
1613 /* Line 1251 of yacc.c */
1614 #line 155 "glcpp/glcpp-parse.y"
1616 yylloc
.first_line
= 1;
1617 yylloc
.first_column
= 1;
1618 yylloc
.last_line
= 1;
1619 yylloc
.last_column
= 1;
1623 /* Line 1251 of yacc.c */
1624 #line 1625 "glcpp/glcpp-parse.c"
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
;
1652 YYLTYPE
*yyls1
= yyls
;
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
),
1661 &yyls1
, yysize
* sizeof (*yylsp
),
1668 #else /* no yyoverflow */
1669 # ifndef YYSTACK_RELOCATE
1670 goto yyexhaustedlab
;
1672 /* Extend the stack our own way. */
1673 if (YYMAXDEPTH
<= yystacksize
)
1674 goto yyexhaustedlab
;
1676 if (YYMAXDEPTH
< yystacksize
)
1677 yystacksize
= YYMAXDEPTH
;
1680 yytype_int16
*yyss1
= yyss
;
1681 union yyalloc
*yyptr
=
1682 (union yyalloc
*) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize
));
1684 goto yyexhaustedlab
;
1685 YYSTACK_RELOCATE (yyss_alloc
, yyss
);
1686 YYSTACK_RELOCATE (yyvs_alloc
, yyvs
);
1687 YYSTACK_RELOCATE (yyls_alloc
, yyls
);
1688 # undef YYSTACK_RELOCATE
1690 YYSTACK_FREE (yyss1
);
1693 #endif /* no yyoverflow */
1695 yyssp
= yyss
+ yysize
- 1;
1696 yyvsp
= yyvs
+ yysize
- 1;
1697 yylsp
= yyls
+ yysize
- 1;
1699 YYDPRINTF ((stderr
, "Stack size increased to %lu\n",
1700 (unsigned long int) yystacksize
));
1702 if (yyss
+ yystacksize
- 1 <= yyssp
)
1706 YYDPRINTF ((stderr
, "Entering state %d\n", yystate
));
1708 if (yystate
== YYFINAL
)
1718 /* Do appropriate processing given the current state. Read a
1719 lookahead token if we need one and don't already have one. */
1721 /* First try to decide what to do without reference to lookahead token. */
1722 yyn
= yypact
[yystate
];
1723 if (yyn
== YYPACT_NINF
)
1726 /* Not known => get a lookahead token if don't already have one. */
1728 /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */
1729 if (yychar
== YYEMPTY
)
1731 YYDPRINTF ((stderr
, "Reading a token: "));
1735 if (yychar
<= YYEOF
)
1737 yychar
= yytoken
= YYEOF
;
1738 YYDPRINTF ((stderr
, "Now at end of input.\n"));
1742 yytoken
= YYTRANSLATE (yychar
);
1743 YY_SYMBOL_PRINT ("Next token is", yytoken
, &yylval
, &yylloc
);
1746 /* If the proper action on seeing token YYTOKEN is to reduce or to
1747 detect an error, take that action. */
1749 if (yyn
< 0 || YYLAST
< yyn
|| yycheck
[yyn
] != yytoken
)
1754 if (yyn
== 0 || yyn
== YYTABLE_NINF
)
1760 /* Count tokens shifted since error; after three, turn off error
1765 /* Shift the lookahead token. */
1766 YY_SYMBOL_PRINT ("Shifting", yytoken
, &yylval
, &yylloc
);
1768 /* Discard the shifted token. */
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
];
1804 /* Default location. */
1805 YYLLOC_DEFAULT (yyloc
, (yylsp
- yylen
), yylen
);
1806 YY_REDUCE_PRINT (yyn
);
1811 /* Line 1464 of yacc.c */
1812 #line 194 "glcpp/glcpp-parse.y"
1814 glcpp_print(parser
->output
, "\n");
1820 /* Line 1464 of yacc.c */
1821 #line 197 "glcpp/glcpp-parse.y"
1823 _glcpp_parser_print_expanded_token_list (parser
, (yyvsp
[(1) - (1)].token_list
));
1824 glcpp_print(parser
->output
, "\n");
1825 talloc_free ((yyvsp
[(1) - (1)].token_list
));
1831 /* Line 1464 of yacc.c */
1832 #line 207 "glcpp/glcpp-parse.y"
1834 _glcpp_parser_skip_stack_push_if (parser
, & (yylsp
[(1) - (3)]), (yyvsp
[(2) - (3)].ival
));
1840 /* Line 1464 of yacc.c */
1841 #line 210 "glcpp/glcpp-parse.y"
1843 _glcpp_parser_skip_stack_change_if (parser
, & (yylsp
[(1) - (3)]), "elif", (yyvsp
[(2) - (3)].ival
));
1849 /* Line 1464 of yacc.c */
1850 #line 216 "glcpp/glcpp-parse.y"
1852 _define_object_macro (parser
, & (yylsp
[(2) - (4)]), (yyvsp
[(2) - (4)].str
), (yyvsp
[(3) - (4)].token_list
));
1858 /* Line 1464 of yacc.c */
1859 #line 219 "glcpp/glcpp-parse.y"
1861 _define_function_macro (parser
, & (yylsp
[(2) - (6)]), (yyvsp
[(2) - (6)].str
), NULL
, (yyvsp
[(5) - (6)].token_list
));
1867 /* Line 1464 of yacc.c */
1868 #line 222 "glcpp/glcpp-parse.y"
1870 _define_function_macro (parser
, & (yylsp
[(2) - (7)]), (yyvsp
[(2) - (7)].str
), (yyvsp
[(4) - (7)].string_list
), (yyvsp
[(6) - (7)].token_list
));
1876 /* Line 1464 of yacc.c */
1877 #line 225 "glcpp/glcpp-parse.y"
1879 macro_t
*macro
= hash_table_find (parser
->defines
, (yyvsp
[(2) - (3)].str
));
1881 hash_table_remove (parser
->defines
, (yyvsp
[(2) - (3)].str
));
1882 talloc_free (macro
);
1884 talloc_free ((yyvsp
[(2) - (3)].str
));
1890 /* Line 1464 of yacc.c */
1891 #line 233 "glcpp/glcpp-parse.y"
1893 /* Be careful to only evaluate the 'if' expression if
1894 * we are not skipping. When we are skipping, we
1895 * simply push a new 0-valued 'if' onto the skip
1898 * This avoids generating diagnostics for invalid
1899 * expressions that are being skipped. */
1900 if (parser
->skip_stack
== NULL
||
1901 parser
->skip_stack
->type
== SKIP_NO_SKIP
)
1903 _glcpp_parser_expand_if (parser
, IF_EXPANDED
, (yyvsp
[(2) - (3)].token_list
));
1907 _glcpp_parser_skip_stack_push_if (parser
, & (yylsp
[(1) - (3)]), 0);
1908 parser
->skip_stack
->type
= SKIP_TO_ENDIF
;
1915 /* Line 1464 of yacc.c */
1916 #line 252 "glcpp/glcpp-parse.y"
1918 /* #if without an expression is only an error if we
1919 * are not skipping */
1920 if (parser
->skip_stack
== NULL
||
1921 parser
->skip_stack
->type
== SKIP_NO_SKIP
)
1923 glcpp_error(& (yylsp
[(1) - (2)]), parser
, "#if with no expression");
1925 _glcpp_parser_skip_stack_push_if (parser
, & (yylsp
[(1) - (2)]), 0);
1931 /* Line 1464 of yacc.c */
1932 #line 262 "glcpp/glcpp-parse.y"
1934 macro_t
*macro
= hash_table_find (parser
->defines
, (yyvsp
[(2) - (4)].str
));
1935 talloc_free ((yyvsp
[(2) - (4)].str
));
1936 _glcpp_parser_skip_stack_push_if (parser
, & (yylsp
[(1) - (4)]), macro
!= NULL
);
1942 /* Line 1464 of yacc.c */
1943 #line 267 "glcpp/glcpp-parse.y"
1945 macro_t
*macro
= hash_table_find (parser
->defines
, (yyvsp
[(2) - (4)].str
));
1946 talloc_free ((yyvsp
[(2) - (4)].str
));
1947 _glcpp_parser_skip_stack_push_if (parser
, & (yylsp
[(1) - (4)]), macro
== NULL
);
1953 /* Line 1464 of yacc.c */
1954 #line 272 "glcpp/glcpp-parse.y"
1956 /* Be careful to only evaluate the 'elif' expression
1957 * if we are not skipping. When we are skipping, we
1958 * simply change to a 0-valued 'elif' on the skip
1961 * This avoids generating diagnostics for invalid
1962 * expressions that are being skipped. */
1963 if (parser
->skip_stack
&&
1964 parser
->skip_stack
->type
== SKIP_TO_ELSE
)
1966 _glcpp_parser_expand_if (parser
, ELIF_EXPANDED
, (yyvsp
[(2) - (3)].token_list
));
1970 _glcpp_parser_skip_stack_change_if (parser
, & (yylsp
[(1) - (3)]),
1978 /* Line 1464 of yacc.c */
1979 #line 291 "glcpp/glcpp-parse.y"
1981 /* #elif without an expression is an error unless we
1983 if (parser
->skip_stack
&&
1984 parser
->skip_stack
->type
== SKIP_TO_ELSE
)
1986 glcpp_error(& (yylsp
[(1) - (2)]), parser
, "#elif with no expression");
1990 _glcpp_parser_skip_stack_change_if (parser
, & (yylsp
[(1) - (2)]),
1992 glcpp_warning(& (yylsp
[(1) - (2)]), parser
, "ignoring illegal #elif without expression");
1999 /* Line 1464 of yacc.c */
2000 #line 306 "glcpp/glcpp-parse.y"
2002 _glcpp_parser_skip_stack_change_if (parser
, & (yylsp
[(1) - (2)]), "else", 1);
2008 /* Line 1464 of yacc.c */
2009 #line 309 "glcpp/glcpp-parse.y"
2011 _glcpp_parser_skip_stack_pop (parser
, & (yylsp
[(1) - (2)]));
2017 /* Line 1464 of yacc.c */
2018 #line 312 "glcpp/glcpp-parse.y"
2020 macro_t
*macro
= hash_table_find (parser
->defines
, "__VERSION__");
2022 hash_table_remove (parser
->defines
, "__VERSION__");
2023 talloc_free (macro
);
2025 add_builtin_define (parser
, "__VERSION__", (yyvsp
[(2) - (3)].ival
));
2027 if ((yyvsp
[(2) - (3)].ival
) == 100)
2028 add_builtin_define (parser
, "GL_ES", 1);
2030 glcpp_printf(parser
->output
, "#version %" PRIiMAX
, (yyvsp
[(2) - (3)].ival
));
2036 /* Line 1464 of yacc.c */
2037 #line 329 "glcpp/glcpp-parse.y"
2039 if (strlen ((yyvsp
[(1) - (1)].str
)) >= 3 && strncmp ((yyvsp
[(1) - (1)].str
), "0x", 2) == 0) {
2040 (yyval
.ival
) = strtoll ((yyvsp
[(1) - (1)].str
) + 2, NULL
, 16);
2041 } else if ((yyvsp
[(1) - (1)].str
)[0] == '0') {
2042 (yyval
.ival
) = strtoll ((yyvsp
[(1) - (1)].str
), NULL
, 8);
2044 (yyval
.ival
) = strtoll ((yyvsp
[(1) - (1)].str
), NULL
, 10);
2051 /* Line 1464 of yacc.c */
2052 #line 338 "glcpp/glcpp-parse.y"
2054 (yyval
.ival
) = (yyvsp
[(1) - (1)].ival
);
2060 /* Line 1464 of yacc.c */
2061 #line 344 "glcpp/glcpp-parse.y"
2063 (yyval
.ival
) = (yyvsp
[(1) - (3)].ival
) || (yyvsp
[(3) - (3)].ival
);
2069 /* Line 1464 of yacc.c */
2070 #line 347 "glcpp/glcpp-parse.y"
2072 (yyval
.ival
) = (yyvsp
[(1) - (3)].ival
) && (yyvsp
[(3) - (3)].ival
);
2078 /* Line 1464 of yacc.c */
2079 #line 350 "glcpp/glcpp-parse.y"
2081 (yyval
.ival
) = (yyvsp
[(1) - (3)].ival
) | (yyvsp
[(3) - (3)].ival
);
2087 /* Line 1464 of yacc.c */
2088 #line 353 "glcpp/glcpp-parse.y"
2090 (yyval
.ival
) = (yyvsp
[(1) - (3)].ival
) ^ (yyvsp
[(3) - (3)].ival
);
2096 /* Line 1464 of yacc.c */
2097 #line 356 "glcpp/glcpp-parse.y"
2099 (yyval
.ival
) = (yyvsp
[(1) - (3)].ival
) & (yyvsp
[(3) - (3)].ival
);
2105 /* Line 1464 of yacc.c */
2106 #line 359 "glcpp/glcpp-parse.y"
2108 (yyval
.ival
) = (yyvsp
[(1) - (3)].ival
) != (yyvsp
[(3) - (3)].ival
);
2114 /* Line 1464 of yacc.c */
2115 #line 362 "glcpp/glcpp-parse.y"
2117 (yyval
.ival
) = (yyvsp
[(1) - (3)].ival
) == (yyvsp
[(3) - (3)].ival
);
2123 /* Line 1464 of yacc.c */
2124 #line 365 "glcpp/glcpp-parse.y"
2126 (yyval
.ival
) = (yyvsp
[(1) - (3)].ival
) >= (yyvsp
[(3) - (3)].ival
);
2132 /* Line 1464 of yacc.c */
2133 #line 368 "glcpp/glcpp-parse.y"
2135 (yyval
.ival
) = (yyvsp
[(1) - (3)].ival
) <= (yyvsp
[(3) - (3)].ival
);
2141 /* Line 1464 of yacc.c */
2142 #line 371 "glcpp/glcpp-parse.y"
2144 (yyval
.ival
) = (yyvsp
[(1) - (3)].ival
) > (yyvsp
[(3) - (3)].ival
);
2150 /* Line 1464 of yacc.c */
2151 #line 374 "glcpp/glcpp-parse.y"
2153 (yyval
.ival
) = (yyvsp
[(1) - (3)].ival
) < (yyvsp
[(3) - (3)].ival
);
2159 /* Line 1464 of yacc.c */
2160 #line 377 "glcpp/glcpp-parse.y"
2162 (yyval
.ival
) = (yyvsp
[(1) - (3)].ival
) >> (yyvsp
[(3) - (3)].ival
);
2168 /* Line 1464 of yacc.c */
2169 #line 380 "glcpp/glcpp-parse.y"
2171 (yyval
.ival
) = (yyvsp
[(1) - (3)].ival
) << (yyvsp
[(3) - (3)].ival
);
2177 /* Line 1464 of yacc.c */
2178 #line 383 "glcpp/glcpp-parse.y"
2180 (yyval
.ival
) = (yyvsp
[(1) - (3)].ival
) - (yyvsp
[(3) - (3)].ival
);
2186 /* Line 1464 of yacc.c */
2187 #line 386 "glcpp/glcpp-parse.y"
2189 (yyval
.ival
) = (yyvsp
[(1) - (3)].ival
) + (yyvsp
[(3) - (3)].ival
);
2195 /* Line 1464 of yacc.c */
2196 #line 389 "glcpp/glcpp-parse.y"
2198 (yyval
.ival
) = (yyvsp
[(1) - (3)].ival
) % (yyvsp
[(3) - (3)].ival
);
2204 /* Line 1464 of yacc.c */
2205 #line 392 "glcpp/glcpp-parse.y"
2207 (yyval
.ival
) = (yyvsp
[(1) - (3)].ival
) / (yyvsp
[(3) - (3)].ival
);
2213 /* Line 1464 of yacc.c */
2214 #line 395 "glcpp/glcpp-parse.y"
2216 (yyval
.ival
) = (yyvsp
[(1) - (3)].ival
) * (yyvsp
[(3) - (3)].ival
);
2222 /* Line 1464 of yacc.c */
2223 #line 398 "glcpp/glcpp-parse.y"
2225 (yyval
.ival
) = ! (yyvsp
[(2) - (2)].ival
);
2231 /* Line 1464 of yacc.c */
2232 #line 401 "glcpp/glcpp-parse.y"
2234 (yyval
.ival
) = ~ (yyvsp
[(2) - (2)].ival
);
2240 /* Line 1464 of yacc.c */
2241 #line 404 "glcpp/glcpp-parse.y"
2243 (yyval
.ival
) = - (yyvsp
[(2) - (2)].ival
);
2249 /* Line 1464 of yacc.c */
2250 #line 407 "glcpp/glcpp-parse.y"
2252 (yyval
.ival
) = + (yyvsp
[(2) - (2)].ival
);
2258 /* Line 1464 of yacc.c */
2259 #line 410 "glcpp/glcpp-parse.y"
2261 (yyval
.ival
) = (yyvsp
[(2) - (3)].ival
);
2267 /* Line 1464 of yacc.c */
2268 #line 416 "glcpp/glcpp-parse.y"
2270 (yyval
.string_list
) = _string_list_create (parser
);
2271 _string_list_append_item ((yyval
.string_list
), (yyvsp
[(1) - (1)].str
));
2272 talloc_steal ((yyval
.string_list
), (yyvsp
[(1) - (1)].str
));
2278 /* Line 1464 of yacc.c */
2279 #line 421 "glcpp/glcpp-parse.y"
2281 (yyval
.string_list
) = (yyvsp
[(1) - (3)].string_list
);
2282 _string_list_append_item ((yyval
.string_list
), (yyvsp
[(3) - (3)].str
));
2283 talloc_steal ((yyval
.string_list
), (yyvsp
[(3) - (3)].str
));
2289 /* Line 1464 of yacc.c */
2290 #line 429 "glcpp/glcpp-parse.y"
2291 { (yyval
.token_list
) = NULL
; ;}
2296 /* Line 1464 of yacc.c */
2297 #line 434 "glcpp/glcpp-parse.y"
2299 yyerror (& (yylsp
[(1) - (2)]), parser
, "Invalid tokens after #");
2305 /* Line 1464 of yacc.c */
2306 #line 440 "glcpp/glcpp-parse.y"
2307 { (yyval
.token_list
) = NULL
; ;}
2312 /* Line 1464 of yacc.c */
2313 #line 446 "glcpp/glcpp-parse.y"
2315 glcpp_warning(&(yylsp
[(1) - (1)]), parser
, "extra tokens at end of directive");
2321 /* Line 1464 of yacc.c */
2322 #line 453 "glcpp/glcpp-parse.y"
2324 int v
= hash_table_find (parser
->defines
, (yyvsp
[(2) - (2)].str
)) ? 1 : 0;
2325 (yyval
.token
) = _token_create_ival (parser
, INTEGER
, v
);
2331 /* Line 1464 of yacc.c */
2332 #line 457 "glcpp/glcpp-parse.y"
2334 int v
= hash_table_find (parser
->defines
, (yyvsp
[(3) - (4)].str
)) ? 1 : 0;
2335 (yyval
.token
) = _token_create_ival (parser
, INTEGER
, v
);
2341 /* Line 1464 of yacc.c */
2342 #line 466 "glcpp/glcpp-parse.y"
2344 parser
->space_tokens
= 1;
2345 (yyval
.token_list
) = _token_list_create (parser
);
2346 _token_list_append ((yyval
.token_list
), (yyvsp
[(1) - (1)].token
));
2347 talloc_unlink (parser
, (yyvsp
[(1) - (1)].token
));
2353 /* Line 1464 of yacc.c */
2354 #line 472 "glcpp/glcpp-parse.y"
2356 (yyval
.token_list
) = (yyvsp
[(1) - (2)].token_list
);
2357 _token_list_append ((yyval
.token_list
), (yyvsp
[(2) - (2)].token
));
2358 talloc_unlink (parser
, (yyvsp
[(2) - (2)].token
));
2364 /* Line 1464 of yacc.c */
2365 #line 480 "glcpp/glcpp-parse.y"
2367 parser
->space_tokens
= 1;
2368 (yyval
.token_list
) = _token_list_create (parser
);
2369 _token_list_append ((yyval
.token_list
), (yyvsp
[(1) - (1)].token
));
2370 talloc_unlink (parser
, (yyvsp
[(1) - (1)].token
));
2376 /* Line 1464 of yacc.c */
2377 #line 486 "glcpp/glcpp-parse.y"
2379 (yyval
.token_list
) = (yyvsp
[(1) - (2)].token_list
);
2380 _token_list_append ((yyval
.token_list
), (yyvsp
[(2) - (2)].token
));
2381 talloc_unlink (parser
, (yyvsp
[(2) - (2)].token
));
2387 /* Line 1464 of yacc.c */
2388 #line 494 "glcpp/glcpp-parse.y"
2390 (yyval
.token
) = _token_create_str (parser
, IDENTIFIER
, (yyvsp
[(1) - (1)].str
));
2391 (yyval
.token
)->location
= yylloc
;
2397 /* Line 1464 of yacc.c */
2398 #line 498 "glcpp/glcpp-parse.y"
2400 (yyval
.token
) = _token_create_str (parser
, INTEGER_STRING
, (yyvsp
[(1) - (1)].str
));
2401 (yyval
.token
)->location
= yylloc
;
2407 /* Line 1464 of yacc.c */
2408 #line 502 "glcpp/glcpp-parse.y"
2410 (yyval
.token
) = _token_create_ival (parser
, (yyvsp
[(1) - (1)].ival
), (yyvsp
[(1) - (1)].ival
));
2411 (yyval
.token
)->location
= yylloc
;
2417 /* Line 1464 of yacc.c */
2418 #line 506 "glcpp/glcpp-parse.y"
2420 (yyval
.token
) = _token_create_str (parser
, OTHER
, (yyvsp
[(1) - (1)].str
));
2421 (yyval
.token
)->location
= yylloc
;
2427 /* Line 1464 of yacc.c */
2428 #line 510 "glcpp/glcpp-parse.y"
2430 (yyval
.token
) = _token_create_ival (parser
, SPACE
, SPACE
);
2431 (yyval
.token
)->location
= yylloc
;
2437 /* Line 1464 of yacc.c */
2438 #line 517 "glcpp/glcpp-parse.y"
2439 { (yyval
.ival
) = '['; ;}
2444 /* Line 1464 of yacc.c */
2445 #line 518 "glcpp/glcpp-parse.y"
2446 { (yyval
.ival
) = ']'; ;}
2451 /* Line 1464 of yacc.c */
2452 #line 519 "glcpp/glcpp-parse.y"
2453 { (yyval
.ival
) = '('; ;}
2458 /* Line 1464 of yacc.c */
2459 #line 520 "glcpp/glcpp-parse.y"
2460 { (yyval
.ival
) = ')'; ;}
2465 /* Line 1464 of yacc.c */
2466 #line 521 "glcpp/glcpp-parse.y"
2467 { (yyval
.ival
) = '{'; ;}
2472 /* Line 1464 of yacc.c */
2473 #line 522 "glcpp/glcpp-parse.y"
2474 { (yyval
.ival
) = '}'; ;}
2479 /* Line 1464 of yacc.c */
2480 #line 523 "glcpp/glcpp-parse.y"
2481 { (yyval
.ival
) = '.'; ;}
2486 /* Line 1464 of yacc.c */
2487 #line 524 "glcpp/glcpp-parse.y"
2488 { (yyval
.ival
) = '&'; ;}
2493 /* Line 1464 of yacc.c */
2494 #line 525 "glcpp/glcpp-parse.y"
2495 { (yyval
.ival
) = '*'; ;}
2500 /* Line 1464 of yacc.c */
2501 #line 526 "glcpp/glcpp-parse.y"
2502 { (yyval
.ival
) = '+'; ;}
2507 /* Line 1464 of yacc.c */
2508 #line 527 "glcpp/glcpp-parse.y"
2509 { (yyval
.ival
) = '-'; ;}
2514 /* Line 1464 of yacc.c */
2515 #line 528 "glcpp/glcpp-parse.y"
2516 { (yyval
.ival
) = '~'; ;}
2521 /* Line 1464 of yacc.c */
2522 #line 529 "glcpp/glcpp-parse.y"
2523 { (yyval
.ival
) = '!'; ;}
2528 /* Line 1464 of yacc.c */
2529 #line 530 "glcpp/glcpp-parse.y"
2530 { (yyval
.ival
) = '/'; ;}
2535 /* Line 1464 of yacc.c */
2536 #line 531 "glcpp/glcpp-parse.y"
2537 { (yyval
.ival
) = '%'; ;}
2542 /* Line 1464 of yacc.c */
2543 #line 532 "glcpp/glcpp-parse.y"
2544 { (yyval
.ival
) = LEFT_SHIFT
; ;}
2549 /* Line 1464 of yacc.c */
2550 #line 533 "glcpp/glcpp-parse.y"
2551 { (yyval
.ival
) = RIGHT_SHIFT
; ;}
2556 /* Line 1464 of yacc.c */
2557 #line 534 "glcpp/glcpp-parse.y"
2558 { (yyval
.ival
) = '<'; ;}
2563 /* Line 1464 of yacc.c */
2564 #line 535 "glcpp/glcpp-parse.y"
2565 { (yyval
.ival
) = '>'; ;}
2570 /* Line 1464 of yacc.c */
2571 #line 536 "glcpp/glcpp-parse.y"
2572 { (yyval
.ival
) = LESS_OR_EQUAL
; ;}
2577 /* Line 1464 of yacc.c */
2578 #line 537 "glcpp/glcpp-parse.y"
2579 { (yyval
.ival
) = GREATER_OR_EQUAL
; ;}
2584 /* Line 1464 of yacc.c */
2585 #line 538 "glcpp/glcpp-parse.y"
2586 { (yyval
.ival
) = EQUAL
; ;}
2591 /* Line 1464 of yacc.c */
2592 #line 539 "glcpp/glcpp-parse.y"
2593 { (yyval
.ival
) = NOT_EQUAL
; ;}
2598 /* Line 1464 of yacc.c */
2599 #line 540 "glcpp/glcpp-parse.y"
2600 { (yyval
.ival
) = '^'; ;}
2605 /* Line 1464 of yacc.c */
2606 #line 541 "glcpp/glcpp-parse.y"
2607 { (yyval
.ival
) = '|'; ;}
2612 /* Line 1464 of yacc.c */
2613 #line 542 "glcpp/glcpp-parse.y"
2614 { (yyval
.ival
) = AND
; ;}
2619 /* Line 1464 of yacc.c */
2620 #line 543 "glcpp/glcpp-parse.y"
2621 { (yyval
.ival
) = OR
; ;}
2626 /* Line 1464 of yacc.c */
2627 #line 544 "glcpp/glcpp-parse.y"
2628 { (yyval
.ival
) = ';'; ;}
2633 /* Line 1464 of yacc.c */
2634 #line 545 "glcpp/glcpp-parse.y"
2635 { (yyval
.ival
) = ','; ;}
2640 /* Line 1464 of yacc.c */
2641 #line 546 "glcpp/glcpp-parse.y"
2642 { (yyval
.ival
) = '='; ;}
2647 /* Line 1464 of yacc.c */
2648 #line 547 "glcpp/glcpp-parse.y"
2649 { (yyval
.ival
) = PASTE
; ;}
2654 /* Line 1464 of yacc.c */
2655 #line 2656 "glcpp/glcpp-parse.c"
2658 YY_SYMBOL_PRINT ("-> $$ =", yyr1
[yyn
], &yyval
, &yyloc
);
2662 YY_STACK_PRINT (yyss
, yyssp
);
2667 /* Now `shift' the result of the reduction. Determine what state
2668 that goes to, based on the state we popped back to and the rule
2669 number reduced by. */
2673 yystate
= yypgoto
[yyn
- YYNTOKENS
] + *yyssp
;
2674 if (0 <= yystate
&& yystate
<= YYLAST
&& yycheck
[yystate
] == *yyssp
)
2675 yystate
= yytable
[yystate
];
2677 yystate
= yydefgoto
[yyn
- YYNTOKENS
];
2682 /*------------------------------------.
2683 | yyerrlab -- here on detecting error |
2684 `------------------------------------*/
2686 /* If not already recovering from an error, report this error. */
2690 #if ! YYERROR_VERBOSE
2691 yyerror (&yylloc
, parser
, YY_("syntax error"));
2694 YYSIZE_T yysize
= yysyntax_error (0, yystate
, yychar
);
2695 if (yymsg_alloc
< yysize
&& yymsg_alloc
< YYSTACK_ALLOC_MAXIMUM
)
2697 YYSIZE_T yyalloc
= 2 * yysize
;
2698 if (! (yysize
<= yyalloc
&& yyalloc
<= YYSTACK_ALLOC_MAXIMUM
))
2699 yyalloc
= YYSTACK_ALLOC_MAXIMUM
;
2700 if (yymsg
!= yymsgbuf
)
2701 YYSTACK_FREE (yymsg
);
2702 yymsg
= (char *) YYSTACK_ALLOC (yyalloc
);
2704 yymsg_alloc
= yyalloc
;
2708 yymsg_alloc
= sizeof yymsgbuf
;
2712 if (0 < yysize
&& yysize
<= yymsg_alloc
)
2714 (void) yysyntax_error (yymsg
, yystate
, yychar
);
2715 yyerror (&yylloc
, parser
, yymsg
);
2719 yyerror (&yylloc
, parser
, YY_("syntax error"));
2721 goto yyexhaustedlab
;
2727 yyerror_range
[1] = yylloc
;
2729 if (yyerrstatus
== 3)
2731 /* If just tried and failed to reuse lookahead token after an
2732 error, discard it. */
2734 if (yychar
<= YYEOF
)
2736 /* Return failure if at end of input. */
2737 if (yychar
== YYEOF
)
2742 yydestruct ("Error: discarding",
2743 yytoken
, &yylval
, &yylloc
, parser
);
2748 /* Else will try to reuse lookahead token after shifting the error
2753 /*---------------------------------------------------.
2754 | yyerrorlab -- error raised explicitly by YYERROR. |
2755 `---------------------------------------------------*/
2758 /* Pacify compilers like GCC when the user code never invokes
2759 YYERROR and the label yyerrorlab therefore never appears in user
2761 if (/*CONSTCOND*/ 0)
2764 yyerror_range
[1] = yylsp
[1-yylen
];
2765 /* Do not reclaim the symbols of the rule which action triggered
2769 YY_STACK_PRINT (yyss
, yyssp
);
2774 /*-------------------------------------------------------------.
2775 | yyerrlab1 -- common code for both syntax error and YYERROR. |
2776 `-------------------------------------------------------------*/
2778 yyerrstatus
= 3; /* Each real token shifted decrements this. */
2782 yyn
= yypact
[yystate
];
2783 if (yyn
!= YYPACT_NINF
)
2786 if (0 <= yyn
&& yyn
<= YYLAST
&& yycheck
[yyn
] == YYTERROR
)
2794 /* Pop the current state because it cannot handle the error token. */
2798 yyerror_range
[1] = *yylsp
;
2799 yydestruct ("Error: popping",
2800 yystos
[yystate
], yyvsp
, yylsp
, parser
);
2803 YY_STACK_PRINT (yyss
, yyssp
);
2808 yyerror_range
[2] = yylloc
;
2809 /* Using YYLLOC is tempting, but would change the location of
2810 the lookahead. YYLOC is available though. */
2811 YYLLOC_DEFAULT (yyloc
, yyerror_range
, 2);
2814 /* Shift the error token. */
2815 YY_SYMBOL_PRINT ("Shifting", yystos
[yyn
], yyvsp
, yylsp
);
2821 /*-------------------------------------.
2822 | yyacceptlab -- YYACCEPT comes here. |
2823 `-------------------------------------*/
2828 /*-----------------------------------.
2829 | yyabortlab -- YYABORT comes here. |
2830 `-----------------------------------*/
2835 #if !defined(yyoverflow) || YYERROR_VERBOSE
2836 /*-------------------------------------------------.
2837 | yyexhaustedlab -- memory exhaustion comes here. |
2838 `-------------------------------------------------*/
2840 yyerror (&yylloc
, parser
, YY_("memory exhausted"));
2846 if (yychar
!= YYEMPTY
)
2847 yydestruct ("Cleanup: discarding lookahead",
2848 yytoken
, &yylval
, &yylloc
, parser
);
2849 /* Do not reclaim the symbols of the rule which action triggered
2850 this YYABORT or YYACCEPT. */
2852 YY_STACK_PRINT (yyss
, yyssp
);
2853 while (yyssp
!= yyss
)
2855 yydestruct ("Cleanup: popping",
2856 yystos
[*yyssp
], yyvsp
, yylsp
, parser
);
2861 YYSTACK_FREE (yyss
);
2864 if (yymsg
!= yymsgbuf
)
2865 YYSTACK_FREE (yymsg
);
2867 /* Make sure YYID is used. */
2868 return YYID (yyresult
);
2873 /* Line 1684 of yacc.c */
2874 #line 550 "glcpp/glcpp-parse.y"
2878 _string_list_create (void *ctx
)
2880 string_list_t
*list
;
2882 list
= talloc (ctx
, string_list_t
);
2890 _string_list_append_item (string_list_t
*list
, const char *str
)
2892 string_node_t
*node
;
2894 node
= talloc (list
, string_node_t
);
2895 node
->str
= talloc_strdup (node
, str
);
2899 if (list
->head
== NULL
) {
2902 list
->tail
->next
= node
;
2909 _string_list_contains (string_list_t
*list
, const char *member
, int *index
)
2911 string_node_t
*node
;
2917 for (i
= 0, node
= list
->head
; node
; i
++, node
= node
->next
) {
2918 if (strcmp (node
->str
, member
) == 0) {
2929 _string_list_length (string_list_t
*list
)
2932 string_node_t
*node
;
2937 for (node
= list
->head
; node
; node
= node
->next
)
2944 _string_list_equal (string_list_t
*a
, string_list_t
*b
)
2946 string_node_t
*node_a
, *node_b
;
2948 if (a
== NULL
&& b
== NULL
)
2951 if (a
== NULL
|| b
== NULL
)
2954 for (node_a
= a
->head
, node_b
= b
->head
;
2956 node_a
= node_a
->next
, node_b
= node_b
->next
)
2958 if (strcmp (node_a
->str
, node_b
->str
))
2962 /* Catch the case of lists being different lengths, (which
2963 * would cause the loop above to terminate after the shorter
2965 return node_a
== node_b
;
2969 _argument_list_create (void *ctx
)
2971 argument_list_t
*list
;
2973 list
= talloc (ctx
, argument_list_t
);
2981 _argument_list_append (argument_list_t
*list
, token_list_t
*argument
)
2983 argument_node_t
*node
;
2985 node
= talloc (list
, argument_node_t
);
2986 node
->argument
= argument
;
2990 if (list
->head
== NULL
) {
2993 list
->tail
->next
= node
;
3000 _argument_list_length (argument_list_t
*list
)
3003 argument_node_t
*node
;
3008 for (node
= list
->head
; node
; node
= node
->next
)
3015 _argument_list_member_at (argument_list_t
*list
, int index
)
3017 argument_node_t
*node
;
3024 for (i
= 0; i
< index
; i
++) {
3031 return node
->argument
;
3036 /* Note: This function talloc_steal()s the str pointer. */
3038 _token_create_str (void *ctx
, int type
, char *str
)
3042 token
= talloc (ctx
, token_t
);
3044 token
->value
.str
= talloc_steal (token
, str
);
3050 _token_create_ival (void *ctx
, int type
, int ival
)
3054 token
= talloc (ctx
, token_t
);
3056 token
->value
.ival
= ival
;
3062 _token_list_create (void *ctx
)
3066 list
= talloc (ctx
, token_list_t
);
3069 list
->non_space_tail
= NULL
;
3075 _token_list_append (token_list_t
*list
, token_t
*token
)
3079 node
= talloc (list
, token_node_t
);
3080 node
->token
= talloc_reference (list
, token
);
3084 if (list
->head
== NULL
) {
3087 list
->tail
->next
= node
;
3091 if (token
->type
!= SPACE
)
3092 list
->non_space_tail
= node
;
3096 _token_list_append_list (token_list_t
*list
, token_list_t
*tail
)
3098 if (tail
== NULL
|| tail
->head
== NULL
)
3101 if (list
->head
== NULL
) {
3102 list
->head
= tail
->head
;
3104 list
->tail
->next
= tail
->head
;
3107 list
->tail
= tail
->tail
;
3108 list
->non_space_tail
= tail
->non_space_tail
;
3111 static token_list_t
*
3112 _token_list_copy (void *ctx
, token_list_t
*other
)
3120 copy
= _token_list_create (ctx
);
3121 for (node
= other
->head
; node
; node
= node
->next
)
3122 _token_list_append (copy
, node
->token
);
3128 _token_list_trim_trailing_space (token_list_t
*list
)
3130 token_node_t
*tail
, *next
;
3132 if (list
->non_space_tail
) {
3133 tail
= list
->non_space_tail
->next
;
3134 list
->non_space_tail
->next
= NULL
;
3135 list
->tail
= list
->non_space_tail
;
3146 _token_list_equal_ignoring_space (token_list_t
*a
, token_list_t
*b
)
3148 token_node_t
*node_a
, *node_b
;
3155 if (node_a
== NULL
&& node_b
== NULL
)
3158 if (node_a
== NULL
|| node_b
== NULL
)
3161 if (node_a
->token
->type
== SPACE
) {
3162 node_a
= node_a
->next
;
3166 if (node_b
->token
->type
== SPACE
) {
3167 node_b
= node_b
->next
;
3171 if (node_a
->token
->type
!= node_b
->token
->type
)
3174 switch (node_a
->token
->type
) {
3176 if (node_a
->token
->value
.ival
!=
3177 node_b
->token
->value
.ival
)
3183 case INTEGER_STRING
:
3185 if (strcmp (node_a
->token
->value
.str
,
3186 node_b
->token
->value
.str
))
3193 node_a
= node_a
->next
;
3194 node_b
= node_b
->next
;
3201 _token_print (char **out
, token_t
*token
)
3203 if (token
->type
< 256) {
3204 glcpp_printf (*out
, "%c", token
->type
);
3208 switch (token
->type
) {
3210 glcpp_printf (*out
, "%" PRIiMAX
, token
->value
.ival
);
3213 case INTEGER_STRING
:
3215 glcpp_print (*out
, token
->value
.str
);
3218 glcpp_print (*out
, " ");
3221 glcpp_print (*out
, "<<");
3224 glcpp_print (*out
, ">>");
3227 glcpp_print (*out
, "<=");
3229 case GREATER_OR_EQUAL
:
3230 glcpp_print (*out
, ">=");
3233 glcpp_print (*out
, "==");
3236 glcpp_print (*out
, "!=");
3239 glcpp_print (*out
, "&&");
3242 glcpp_print (*out
, "||");
3245 glcpp_print (*out
, "##");
3248 glcpp_print (*out
, ",");
3251 /* Nothing to print. */
3254 assert(!"Error: Don't know how to print token.");
3259 /* Return a new token (talloc()ed off of 'token') formed by pasting
3260 * 'token' and 'other'. Note that this function may return 'token' or
3261 * 'other' directly rather than allocating anything new.
3263 * Caution: Only very cursory error-checking is performed to see if
3264 * the final result is a valid single token. */
3266 _token_paste (glcpp_parser_t
*parser
, token_t
*token
, token_t
*other
)
3268 token_t
*combined
= NULL
;
3270 /* Pasting a placeholder onto anything makes no change. */
3271 if (other
->type
== PLACEHOLDER
)
3274 /* When 'token' is a placeholder, just return 'other'. */
3275 if (token
->type
== PLACEHOLDER
)
3278 /* A very few single-character punctuators can be combined
3279 * with another to form a multi-character punctuator. */
3280 switch (token
->type
) {
3282 if (other
->type
== '<')
3283 combined
= _token_create_ival (token
, LEFT_SHIFT
, LEFT_SHIFT
);
3284 else if (other
->type
== '=')
3285 combined
= _token_create_ival (token
, LESS_OR_EQUAL
, LESS_OR_EQUAL
);
3288 if (other
->type
== '>')
3289 combined
= _token_create_ival (token
, RIGHT_SHIFT
, RIGHT_SHIFT
);
3290 else if (other
->type
== '=')
3291 combined
= _token_create_ival (token
, GREATER_OR_EQUAL
, GREATER_OR_EQUAL
);
3294 if (other
->type
== '=')
3295 combined
= _token_create_ival (token
, EQUAL
, EQUAL
);
3298 if (other
->type
== '=')
3299 combined
= _token_create_ival (token
, NOT_EQUAL
, NOT_EQUAL
);
3302 if (other
->type
== '&')
3303 combined
= _token_create_ival (token
, AND
, AND
);
3306 if (other
->type
== '|')
3307 combined
= _token_create_ival (token
, OR
, OR
);
3311 if (combined
!= NULL
) {
3312 /* Inherit the location from the first token */
3313 combined
->location
= token
->location
;
3317 /* Two string-valued tokens can usually just be mashed
3320 * XXX: This isn't actually legitimate. Several things here
3321 * should result in a diagnostic since the result cannot be a
3322 * valid, single pre-processing token. For example, pasting
3323 * "123" and "abc" is not legal, but we don't catch that
3325 if ((token
->type
== IDENTIFIER
|| token
->type
== OTHER
|| token
->type
== INTEGER_STRING
) &&
3326 (other
->type
== IDENTIFIER
|| other
->type
== OTHER
|| other
->type
== INTEGER_STRING
))
3330 str
= talloc_asprintf (token
, "%s%s", token
->value
.str
,
3332 combined
= _token_create_str (token
, token
->type
, str
);
3333 combined
->location
= token
->location
;
3337 glcpp_error (&token
->location
, parser
, "");
3338 glcpp_print (parser
->info_log
, "Pasting \"");
3339 _token_print (&parser
->info_log
, token
);
3340 glcpp_print (parser
->info_log
, "\" and \"");
3341 _token_print (&parser
->info_log
, other
);
3342 glcpp_print (parser
->info_log
, "\" does not give a valid preprocessing token.\n");
3348 _token_list_print (glcpp_parser_t
*parser
, token_list_t
*list
)
3355 for (node
= list
->head
; node
; node
= node
->next
)
3356 _token_print (&parser
->output
, node
->token
);
3360 yyerror (YYLTYPE
*locp
, glcpp_parser_t
*parser
, const char *error
)
3362 glcpp_error(locp
, parser
, "%s", error
);
3365 static void add_builtin_define(glcpp_parser_t
*parser
,
3366 const char *name
, int value
)
3371 tok
= _token_create_ival (parser
, INTEGER
, value
);
3373 list
= _token_list_create(parser
);
3374 _token_list_append(list
, tok
);
3375 _define_object_macro(parser
, NULL
, name
, list
);
3377 talloc_unlink(parser
, tok
);
3381 glcpp_parser_create (const struct gl_extensions
*extensions
, int api
)
3383 glcpp_parser_t
*parser
;
3384 int language_version
;
3386 parser
= talloc (NULL
, glcpp_parser_t
);
3388 glcpp_lex_init_extra (parser
, &parser
->scanner
);
3389 parser
->defines
= hash_table_ctor (32, hash_table_string_hash
,
3390 hash_table_string_compare
);
3391 parser
->active
= NULL
;
3392 parser
->lexing_if
= 0;
3393 parser
->space_tokens
= 1;
3394 parser
->newline_as_space
= 0;
3395 parser
->in_control_line
= 0;
3396 parser
->paren_count
= 0;
3398 parser
->skip_stack
= NULL
;
3400 parser
->lex_from_list
= NULL
;
3401 parser
->lex_from_node
= NULL
;
3403 parser
->output
= talloc_strdup(parser
, "");
3404 parser
->info_log
= talloc_strdup(parser
, "");
3407 /* Add pre-defined macros. */
3408 add_builtin_define(parser
, "GL_ARB_draw_buffers", 1);
3409 add_builtin_define(parser
, "GL_ARB_texture_rectangle", 1);
3411 if (api
== API_OPENGLES2
)
3412 add_builtin_define(parser
, "GL_ES", 1);
3414 if (extensions
!= NULL
) {
3415 if (extensions
->EXT_texture_array
) {
3416 add_builtin_define(parser
, "GL_EXT_texture_array", 1);
3419 if (extensions
->ARB_fragment_coord_conventions
)
3420 add_builtin_define(parser
, "GL_ARB_fragment_coord_conventions",
3424 language_version
= 110;
3425 add_builtin_define(parser
, "__VERSION__", language_version
);
3431 glcpp_parser_parse (glcpp_parser_t
*parser
)
3433 return yyparse (parser
);
3437 glcpp_parser_destroy (glcpp_parser_t
*parser
)
3439 glcpp_lex_destroy (parser
->scanner
);
3440 hash_table_dtor (parser
->defines
);
3441 talloc_free (parser
);
3444 typedef enum function_status
3446 FUNCTION_STATUS_SUCCESS
,
3447 FUNCTION_NOT_A_FUNCTION
,
3448 FUNCTION_UNBALANCED_PARENTHESES
3449 } function_status_t
;
3451 /* Find a set of function-like macro arguments by looking for a
3452 * balanced set of parentheses.
3454 * When called, 'node' should be the opening-parenthesis token, (or
3455 * perhaps preceeding SPACE tokens). Upon successful return *last will
3456 * be the last consumed node, (corresponding to the closing right
3461 * FUNCTION_STATUS_SUCCESS:
3463 * Successfully parsed a set of function arguments.
3465 * FUNCTION_NOT_A_FUNCTION:
3467 * Macro name not followed by a '('. This is not an error, but
3468 * simply that the macro name should be treated as a non-macro.
3470 * FUNCTION_UNBALANCED_PARENTHESES
3472 * Macro name is not followed by a balanced set of parentheses.
3474 static function_status_t
3475 _arguments_parse (argument_list_t
*arguments
,
3477 token_node_t
**last
)
3479 token_list_t
*argument
;
3484 /* Ignore whitespace before first parenthesis. */
3485 while (node
&& node
->token
->type
== SPACE
)
3488 if (node
== NULL
|| node
->token
->type
!= '(')
3489 return FUNCTION_NOT_A_FUNCTION
;
3493 argument
= _token_list_create (arguments
);
3494 _argument_list_append (arguments
, argument
);
3496 for (paren_count
= 1; node
; node
= node
->next
) {
3497 if (node
->token
->type
== '(')
3501 else if (node
->token
->type
== ')')
3504 if (paren_count
== 0)
3508 if (node
->token
->type
== ',' &&
3511 _token_list_trim_trailing_space (argument
);
3512 argument
= _token_list_create (arguments
);
3513 _argument_list_append (arguments
, argument
);
3516 if (argument
->head
== NULL
) {
3517 /* Don't treat initial whitespace as
3518 * part of the arguement. */
3519 if (node
->token
->type
== SPACE
)
3522 _token_list_append (argument
, node
->token
);
3527 return FUNCTION_UNBALANCED_PARENTHESES
;
3531 return FUNCTION_STATUS_SUCCESS
;
3534 static token_list_t
*
3535 _token_list_create_with_one_space (void *ctx
)
3540 list
= _token_list_create (ctx
);
3541 space
= _token_create_ival (list
, SPACE
, SPACE
);
3542 _token_list_append (list
, space
);
3548 _glcpp_parser_expand_if (glcpp_parser_t
*parser
, int type
, token_list_t
*list
)
3550 token_list_t
*expanded
;
3553 expanded
= _token_list_create (parser
);
3554 token
= _token_create_ival (parser
, type
, type
);
3555 _token_list_append (expanded
, token
);
3556 _glcpp_parser_expand_token_list (parser
, list
);
3557 _token_list_append_list (expanded
, list
);
3558 glcpp_parser_lex_from (parser
, expanded
);
3561 /* This is a helper function that's essentially part of the
3562 * implementation of _glcpp_parser_expand_node. It shouldn't be called
3563 * except for by that function.
3565 * Returns NULL if node is a simple token with no expansion, (that is,
3566 * although 'node' corresponds to an identifier defined as a
3567 * function-like macro, it is not followed with a parenthesized
3570 * Compute the complete expansion of node (which is a function-like
3571 * macro) and subsequent nodes which are arguments.
3573 * Returns the token list that results from the expansion and sets
3574 * *last to the last node in the list that was consumed by the
3575 * expansion. Specifically, *last will be set as follows: as the
3576 * token of the closing right parenthesis.
3578 static token_list_t
*
3579 _glcpp_parser_expand_function (glcpp_parser_t
*parser
,
3581 token_node_t
**last
)
3585 const char *identifier
;
3586 argument_list_t
*arguments
;
3587 function_status_t status
;
3588 token_list_t
*substituted
;
3589 int parameter_index
;
3591 identifier
= node
->token
->value
.str
;
3593 macro
= hash_table_find (parser
->defines
, identifier
);
3595 assert (macro
->is_function
);
3597 arguments
= _argument_list_create (parser
);
3598 status
= _arguments_parse (arguments
, node
, last
);
3601 case FUNCTION_STATUS_SUCCESS
:
3603 case FUNCTION_NOT_A_FUNCTION
:
3605 case FUNCTION_UNBALANCED_PARENTHESES
:
3606 glcpp_error (&node
->token
->location
, parser
, "Macro %s call has unbalanced parentheses\n", identifier
);
3610 /* Replace a macro defined as empty with a SPACE token. */
3611 if (macro
->replacements
== NULL
) {
3612 talloc_free (arguments
);
3613 return _token_list_create_with_one_space (parser
);
3616 if (! ((_argument_list_length (arguments
) ==
3617 _string_list_length (macro
->parameters
)) ||
3618 (_string_list_length (macro
->parameters
) == 0 &&
3619 _argument_list_length (arguments
) == 1 &&
3620 arguments
->head
->argument
->head
== NULL
)))
3622 glcpp_error (&node
->token
->location
, parser
,
3623 "Error: macro %s invoked with %d arguments (expected %d)\n",
3625 _argument_list_length (arguments
),
3626 _string_list_length (macro
->parameters
));
3630 /* Perform argument substitution on the replacement list. */
3631 substituted
= _token_list_create (arguments
);
3633 for (node
= macro
->replacements
->head
; node
; node
= node
->next
)
3635 if (node
->token
->type
== IDENTIFIER
&&
3636 _string_list_contains (macro
->parameters
,
3637 node
->token
->value
.str
,
3640 token_list_t
*argument
;
3641 argument
= _argument_list_member_at (arguments
,
3643 /* Before substituting, we expand the argument
3644 * tokens, or append a placeholder token for
3645 * an empty argument. */
3646 if (argument
->head
) {
3647 token_list_t
*expanded_argument
;
3648 expanded_argument
= _token_list_copy (parser
,
3650 _glcpp_parser_expand_token_list (parser
,
3652 _token_list_append_list (substituted
,
3657 new_token
= _token_create_ival (substituted
,
3660 _token_list_append (substituted
, new_token
);
3663 _token_list_append (substituted
, node
->token
);
3667 /* After argument substitution, and before further expansion
3668 * below, implement token pasting. */
3670 _token_list_trim_trailing_space (substituted
);
3672 node
= substituted
->head
;
3675 token_node_t
*next_non_space
;
3677 /* Look ahead for a PASTE token, skipping space. */
3678 next_non_space
= node
->next
;
3679 while (next_non_space
&& next_non_space
->token
->type
== SPACE
)
3680 next_non_space
= next_non_space
->next
;
3682 if (next_non_space
== NULL
)
3685 if (next_non_space
->token
->type
!= PASTE
) {
3686 node
= next_non_space
;
3690 /* Now find the next non-space token after the PASTE. */
3691 next_non_space
= next_non_space
->next
;
3692 while (next_non_space
&& next_non_space
->token
->type
== SPACE
)
3693 next_non_space
= next_non_space
->next
;
3695 if (next_non_space
== NULL
) {
3696 yyerror (&node
->token
->location
, parser
, "'##' cannot appear at either end of a macro expansion\n");
3700 node
->token
= _token_paste (parser
, node
->token
, next_non_space
->token
);
3701 node
->next
= next_non_space
->next
;
3702 if (next_non_space
== substituted
->tail
)
3703 substituted
->tail
= node
;
3708 substituted
->non_space_tail
= substituted
->tail
;
3713 /* Compute the complete expansion of node, (and subsequent nodes after
3714 * 'node' in the case that 'node' is a function-like macro and
3715 * subsequent nodes are arguments).
3717 * Returns NULL if node is a simple token with no expansion.
3719 * Otherwise, returns the token list that results from the expansion
3720 * and sets *last to the last node in the list that was consumed by
3721 * the expansion. Specifically, *last will be set as follows:
3723 * As 'node' in the case of object-like macro expansion.
3725 * As the token of the closing right parenthesis in the case of
3726 * function-like macro expansion.
3728 static token_list_t
*
3729 _glcpp_parser_expand_node (glcpp_parser_t
*parser
,
3731 token_node_t
**last
)
3733 token_t
*token
= node
->token
;
3734 const char *identifier
;
3737 /* We only expand identifiers */
3738 if (token
->type
!= IDENTIFIER
) {
3739 /* We change any COMMA into a COMMA_FINAL to prevent
3740 * it being mistaken for an argument separator
3742 if (token
->type
== ',') {
3743 token
->type
= COMMA_FINAL
;
3744 token
->value
.ival
= COMMA_FINAL
;
3750 /* Look up this identifier in the hash table. */
3751 identifier
= token
->value
.str
;
3752 macro
= hash_table_find (parser
->defines
, identifier
);
3754 /* Not a macro, so no expansion needed. */
3758 /* Finally, don't expand this macro if we're already actively
3759 * expanding it, (to avoid infinite recursion). */
3760 if (_active_list_contains (parser
->active
, identifier
)) {
3761 /* We change the token type here from IDENTIFIER to
3762 * OTHER to prevent any future expansion of this
3763 * unexpanded token. */
3765 token_list_t
*expansion
;
3768 str
= talloc_strdup (parser
, token
->value
.str
);
3769 final
= _token_create_str (parser
, OTHER
, str
);
3770 expansion
= _token_list_create (parser
);
3771 _token_list_append (expansion
, final
);
3776 if (! macro
->is_function
)
3780 /* Replace a macro defined as empty with a SPACE token. */
3781 if (macro
->replacements
== NULL
)
3782 return _token_list_create_with_one_space (parser
);
3784 return _token_list_copy (parser
, macro
->replacements
);
3787 return _glcpp_parser_expand_function (parser
, node
, last
);
3790 /* Push a new identifier onto the active list, returning the new list.
3792 * Here, 'marker' is the token node that appears in the list after the
3793 * expansion of 'identifier'. That is, when the list iterator begins
3794 * examinging 'marker', then it is time to pop this node from the
3798 _active_list_push (active_list_t
*list
,
3799 const char *identifier
,
3800 token_node_t
*marker
)
3802 active_list_t
*node
;
3804 node
= talloc (list
, active_list_t
);
3805 node
->identifier
= talloc_strdup (node
, identifier
);
3806 node
->marker
= marker
;
3813 _active_list_pop (active_list_t
*list
)
3815 active_list_t
*node
= list
;
3827 _active_list_contains (active_list_t
*list
, const char *identifier
)
3829 active_list_t
*node
;
3834 for (node
= list
; node
; node
= node
->next
)
3835 if (strcmp (node
->identifier
, identifier
) == 0)
3841 /* Walk over the token list replacing nodes with their expansion.
3842 * Whenever nodes are expanded the walking will walk over the new
3843 * nodes, continuing to expand as necessary. The results are placed in
3847 _glcpp_parser_expand_token_list (glcpp_parser_t
*parser
,
3850 token_node_t
*node_prev
;
3851 token_node_t
*node
, *last
= NULL
;
3852 token_list_t
*expansion
;
3857 _token_list_trim_trailing_space (list
);
3864 while (parser
->active
&& parser
->active
->marker
== node
)
3865 parser
->active
= _active_list_pop (parser
->active
);
3867 /* Find the expansion for node, which will replace all
3868 * nodes from node to last, inclusive. */
3869 expansion
= _glcpp_parser_expand_node (parser
, node
, &last
);
3873 for (n
= node
; n
!= last
->next
; n
= n
->next
)
3874 while (parser
->active
&&
3875 parser
->active
->marker
== n
)
3877 parser
->active
= _active_list_pop (parser
->active
);
3880 parser
->active
= _active_list_push (parser
->active
,
3881 node
->token
->value
.str
,
3884 /* Splice expansion into list, supporting a
3885 * simple deletion if the expansion is
3887 if (expansion
->head
) {
3889 node_prev
->next
= expansion
->head
;
3891 list
->head
= expansion
->head
;
3892 expansion
->tail
->next
= last
->next
;
3893 if (last
== list
->tail
)
3894 list
->tail
= expansion
->tail
;
3897 node_prev
->next
= last
->next
;
3899 list
->head
= last
->next
;
3900 if (last
== list
->tail
)
3906 node
= node_prev
? node_prev
->next
: list
->head
;
3909 while (parser
->active
)
3910 parser
->active
= _active_list_pop (parser
->active
);
3912 list
->non_space_tail
= list
->tail
;
3916 _glcpp_parser_print_expanded_token_list (glcpp_parser_t
*parser
,
3922 _glcpp_parser_expand_token_list (parser
, list
);
3924 _token_list_trim_trailing_space (list
);
3926 _token_list_print (parser
, list
);
3930 _check_for_reserved_macro_name (glcpp_parser_t
*parser
, YYLTYPE
*loc
,
3931 const char *identifier
)
3933 /* According to the GLSL specification, macro names starting with "__"
3934 * or "GL_" are reserved for future use. So, don't allow them.
3936 if (strncmp(identifier
, "__", 2) == 0) {
3937 glcpp_error (loc
, parser
, "Macro names starting with \"__\" are reserved.\n");
3939 if (strncmp(identifier
, "GL_", 3) == 0) {
3940 glcpp_error (loc
, parser
, "Macro names starting with \"GL_\" are reserved.\n");
3945 _macro_equal (macro_t
*a
, macro_t
*b
)
3947 if (a
->is_function
!= b
->is_function
)
3950 if (a
->is_function
) {
3951 if (! _string_list_equal (a
->parameters
, b
->parameters
))
3955 return _token_list_equal_ignoring_space (a
->replacements
,
3960 _define_object_macro (glcpp_parser_t
*parser
,
3962 const char *identifier
,
3963 token_list_t
*replacements
)
3965 macro_t
*macro
, *previous
;
3968 _check_for_reserved_macro_name(parser
, loc
, identifier
);
3970 macro
= talloc (parser
, macro_t
);
3972 macro
->is_function
= 0;
3973 macro
->parameters
= NULL
;
3974 macro
->identifier
= talloc_strdup (macro
, identifier
);
3975 macro
->replacements
= talloc_steal (macro
, replacements
);
3977 previous
= hash_table_find (parser
->defines
, identifier
);
3979 if (_macro_equal (macro
, previous
)) {
3980 talloc_free (macro
);
3983 glcpp_error (loc
, parser
, "Redefinition of macro %s\n",
3987 hash_table_insert (parser
->defines
, macro
, identifier
);
3991 _define_function_macro (glcpp_parser_t
*parser
,
3993 const char *identifier
,
3994 string_list_t
*parameters
,
3995 token_list_t
*replacements
)
3997 macro_t
*macro
, *previous
;
3999 _check_for_reserved_macro_name(parser
, loc
, identifier
);
4001 macro
= talloc (parser
, macro_t
);
4003 macro
->is_function
= 1;
4004 macro
->parameters
= talloc_steal (macro
, parameters
);
4005 macro
->identifier
= talloc_strdup (macro
, identifier
);
4006 macro
->replacements
= talloc_steal (macro
, replacements
);
4008 previous
= hash_table_find (parser
->defines
, identifier
);
4010 if (_macro_equal (macro
, previous
)) {
4011 talloc_free (macro
);
4014 glcpp_error (loc
, parser
, "Redefinition of macro %s\n",
4018 hash_table_insert (parser
->defines
, macro
, identifier
);
4022 glcpp_parser_lex (YYSTYPE
*yylval
, YYLTYPE
*yylloc
, glcpp_parser_t
*parser
)
4027 if (parser
->lex_from_list
== NULL
) {
4028 ret
= glcpp_lex (yylval
, yylloc
, parser
->scanner
);
4030 /* XXX: This ugly block of code exists for the sole
4031 * purpose of converting a NEWLINE token into a SPACE
4032 * token, but only in the case where we have seen a
4033 * function-like macro name, but have not yet seen its
4034 * closing parenthesis.
4036 * There's perhaps a more compact way to do this with
4037 * mid-rule actions in the grammar.
4039 * I'm definitely not pleased with the complexity of
4042 if (parser
->newline_as_space
)
4045 parser
->paren_count
++;
4046 } else if (ret
== ')') {
4047 parser
->paren_count
--;
4048 if (parser
->paren_count
== 0)
4049 parser
->newline_as_space
= 0;
4050 } else if (ret
== NEWLINE
) {
4052 } else if (ret
!= SPACE
) {
4053 if (parser
->paren_count
== 0)
4054 parser
->newline_as_space
= 0;
4057 else if (parser
->in_control_line
)
4060 parser
->in_control_line
= 0;
4062 else if (ret
== HASH_DEFINE_OBJ
|| ret
== HASH_DEFINE_FUNC
||
4063 ret
== HASH_UNDEF
|| ret
== HASH_IF
||
4064 ret
== HASH_IFDEF
|| ret
== HASH_IFNDEF
||
4065 ret
== HASH_ELIF
|| ret
== HASH_ELSE
||
4066 ret
== HASH_ENDIF
|| ret
== HASH
)
4068 parser
->in_control_line
= 1;
4070 else if (ret
== IDENTIFIER
)
4073 macro
= hash_table_find (parser
->defines
,
4075 if (macro
&& macro
->is_function
) {
4076 parser
->newline_as_space
= 1;
4077 parser
->paren_count
= 0;
4084 node
= parser
->lex_from_node
;
4087 talloc_free (parser
->lex_from_list
);
4088 parser
->lex_from_list
= NULL
;
4092 *yylval
= node
->token
->value
;
4093 ret
= node
->token
->type
;
4095 parser
->lex_from_node
= node
->next
;
4101 glcpp_parser_lex_from (glcpp_parser_t
*parser
, token_list_t
*list
)
4105 assert (parser
->lex_from_list
== NULL
);
4107 /* Copy list, eliminating any space tokens. */
4108 parser
->lex_from_list
= _token_list_create (parser
);
4110 for (node
= list
->head
; node
; node
= node
->next
) {
4111 if (node
->token
->type
== SPACE
)
4113 _token_list_append (parser
->lex_from_list
, node
->token
);
4118 parser
->lex_from_node
= parser
->lex_from_list
->head
;
4120 /* It's possible the list consisted of nothing but whitespace. */
4121 if (parser
->lex_from_node
== NULL
) {
4122 talloc_free (parser
->lex_from_list
);
4123 parser
->lex_from_list
= NULL
;
4128 _glcpp_parser_skip_stack_push_if (glcpp_parser_t
*parser
, YYLTYPE
*loc
,
4131 skip_type_t current
= SKIP_NO_SKIP
;
4134 if (parser
->skip_stack
)
4135 current
= parser
->skip_stack
->type
;
4137 node
= talloc (parser
, skip_node_t
);
4140 if (current
== SKIP_NO_SKIP
) {
4142 node
->type
= SKIP_NO_SKIP
;
4144 node
->type
= SKIP_TO_ELSE
;
4146 node
->type
= SKIP_TO_ENDIF
;
4149 node
->next
= parser
->skip_stack
;
4150 parser
->skip_stack
= node
;
4154 _glcpp_parser_skip_stack_change_if (glcpp_parser_t
*parser
, YYLTYPE
*loc
,
4155 const char *type
, int condition
)
4157 if (parser
->skip_stack
== NULL
) {
4158 glcpp_error (loc
, parser
, "%s without #if\n", type
);
4162 if (parser
->skip_stack
->type
== SKIP_TO_ELSE
) {
4164 parser
->skip_stack
->type
= SKIP_NO_SKIP
;
4166 parser
->skip_stack
->type
= SKIP_TO_ENDIF
;
4171 _glcpp_parser_skip_stack_pop (glcpp_parser_t
*parser
, YYLTYPE
*loc
)
4175 if (parser
->skip_stack
== NULL
) {
4176 glcpp_error (loc
, parser
, "#endif without #if\n");
4180 node
= parser
->skip_stack
;
4181 parser
->skip_stack
= node
->next
;