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 */
106 yyerror (YYLTYPE
*locp
, glcpp_parser_t
*parser
, const char *error
);
109 _define_object_macro (glcpp_parser_t
*parser
,
112 token_list_t
*replacements
);
115 _define_function_macro (glcpp_parser_t
*parser
,
118 string_list_t
*parameters
,
119 token_list_t
*replacements
);
121 static string_list_t
*
122 _string_list_create (void *ctx
);
125 _string_list_append_item (string_list_t
*list
, const char *str
);
128 _string_list_contains (string_list_t
*list
, const char *member
, int *index
);
131 _string_list_length (string_list_t
*list
);
134 _string_list_equal (string_list_t
*a
, string_list_t
*b
);
136 static argument_list_t
*
137 _argument_list_create (void *ctx
);
140 _argument_list_append (argument_list_t
*list
, token_list_t
*argument
);
143 _argument_list_length (argument_list_t
*list
);
145 static token_list_t
*
146 _argument_list_member_at (argument_list_t
*list
, int index
);
148 /* Note: This function ralloc_steal()s the str pointer. */
150 _token_create_str (void *ctx
, int type
, char *str
);
153 _token_create_ival (void *ctx
, int type
, int ival
);
155 static token_list_t
*
156 _token_list_create (void *ctx
);
159 _token_list_append (token_list_t
*list
, token_t
*token
);
162 _token_list_append_list (token_list_t
*list
, token_list_t
*tail
);
165 _token_list_equal_ignoring_space (token_list_t
*a
, token_list_t
*b
);
168 _parser_active_list_push (glcpp_parser_t
*parser
,
169 const char *identifier
,
170 token_node_t
*marker
);
173 _parser_active_list_pop (glcpp_parser_t
*parser
);
176 _parser_active_list_contains (glcpp_parser_t
*parser
, const char *identifier
);
179 _glcpp_parser_expand_if (glcpp_parser_t
*parser
, int type
, token_list_t
*list
);
182 _glcpp_parser_expand_token_list (glcpp_parser_t
*parser
,
186 _glcpp_parser_print_expanded_token_list (glcpp_parser_t
*parser
,
190 _glcpp_parser_skip_stack_push_if (glcpp_parser_t
*parser
, YYLTYPE
*loc
,
194 _glcpp_parser_skip_stack_change_if (glcpp_parser_t
*parser
, YYLTYPE
*loc
,
195 const char *type
, int condition
);
198 _glcpp_parser_skip_stack_pop (glcpp_parser_t
*parser
, YYLTYPE
*loc
);
200 #define yylex glcpp_parser_lex
203 glcpp_parser_lex (YYSTYPE
*yylval
, YYLTYPE
*yylloc
, glcpp_parser_t
*parser
);
206 glcpp_parser_lex_from (glcpp_parser_t
*parser
, token_list_t
*list
);
209 add_builtin_define(glcpp_parser_t
*parser
, const char *name
, int value
);
213 /* Line 189 of yacc.c */
214 #line 215 "glcpp/glcpp-parse.c"
216 /* Enabling traces. */
221 /* Enabling verbose error messages. */
222 #ifdef YYERROR_VERBOSE
223 # undef YYERROR_VERBOSE
224 # define YYERROR_VERBOSE 1
226 # define YYERROR_VERBOSE 1
229 /* Enabling the token table. */
230 #ifndef YYTOKEN_TABLE
231 # define YYTOKEN_TABLE 0
238 /* Put the tokens into the symbol table, so that GDB and other debuggers
245 HASH_DEFINE_FUNC
= 262,
246 HASH_DEFINE_OBJ
= 263,
258 INTEGER_STRING
= 275,
268 GREATER_OR_EQUAL
= 285,
278 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
280 # define yystype YYSTYPE /* obsolescent; will be withdrawn */
281 # define YYSTYPE_IS_DECLARED 1
284 #if ! defined YYLTYPE && ! defined YYLTYPE_IS_DECLARED
285 typedef struct YYLTYPE
292 # define yyltype YYLTYPE /* obsolescent; will be withdrawn */
293 # define YYLTYPE_IS_DECLARED 1
294 # define YYLTYPE_IS_TRIVIAL 1
298 /* Copy the second part of user declarations. */
301 /* Line 264 of yacc.c */
302 #line 303 "glcpp/glcpp-parse.c"
309 typedef YYTYPE_UINT8 yytype_uint8
;
311 typedef unsigned char yytype_uint8
;
315 typedef YYTYPE_INT8 yytype_int8
;
316 #elif (defined __STDC__ || defined __C99__FUNC__ \
317 || defined __cplusplus || defined _MSC_VER)
318 typedef signed char yytype_int8
;
320 typedef short int yytype_int8
;
324 typedef YYTYPE_UINT16 yytype_uint16
;
326 typedef unsigned short int yytype_uint16
;
330 typedef YYTYPE_INT16 yytype_int16
;
332 typedef short int yytype_int16
;
336 # ifdef __SIZE_TYPE__
337 # define YYSIZE_T __SIZE_TYPE__
338 # elif defined size_t
339 # define YYSIZE_T size_t
340 # elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \
341 || defined __cplusplus || defined _MSC_VER)
342 # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
343 # define YYSIZE_T size_t
345 # define YYSIZE_T unsigned int
349 #define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
352 # if defined YYENABLE_NLS && YYENABLE_NLS
354 # include <libintl.h> /* INFRINGES ON USER NAME SPACE */
355 # define YY_(msgid) dgettext ("bison-runtime", msgid)
359 # define YY_(msgid) msgid
363 /* Suppress unused-variable warnings by "using" E. */
364 #if ! defined lint || defined __GNUC__
365 # define YYUSE(e) ((void) (e))
367 # define YYUSE(e) /* empty */
370 /* Identity function, used to suppress warnings about constant conditions. */
374 #if (defined __STDC__ || defined __C99__FUNC__ \
375 || defined __cplusplus || defined _MSC_VER)
388 #if ! defined yyoverflow || YYERROR_VERBOSE
390 /* The parser invokes alloca or malloc; define the necessary symbols. */
392 # ifdef YYSTACK_USE_ALLOCA
393 # if YYSTACK_USE_ALLOCA
395 # define YYSTACK_ALLOC __builtin_alloca
396 # elif defined __BUILTIN_VA_ARG_INCR
397 # include <alloca.h> /* INFRINGES ON USER NAME SPACE */
399 # define YYSTACK_ALLOC __alloca
400 # elif defined _MSC_VER
401 # include <malloc.h> /* INFRINGES ON USER NAME SPACE */
402 # define alloca _alloca
404 # define YYSTACK_ALLOC alloca
405 # if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
406 || defined __cplusplus || defined _MSC_VER)
407 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
416 # ifdef YYSTACK_ALLOC
417 /* Pacify GCC's `empty if-body' warning. */
418 # define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0))
419 # ifndef YYSTACK_ALLOC_MAXIMUM
420 /* The OS might guarantee only one guard page at the bottom of the stack,
421 and a page size can be as small as 4096 bytes. So we cannot safely
422 invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
423 to allow for a few compiler-allocated temporary stack slots. */
424 # define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
427 # define YYSTACK_ALLOC YYMALLOC
428 # define YYSTACK_FREE YYFREE
429 # ifndef YYSTACK_ALLOC_MAXIMUM
430 # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
432 # if (defined __cplusplus && ! defined _STDLIB_H \
433 && ! ((defined YYMALLOC || defined malloc) \
434 && (defined YYFREE || defined free)))
435 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
441 # define YYMALLOC malloc
442 # if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
443 || defined __cplusplus || defined _MSC_VER)
444 void *malloc (YYSIZE_T
); /* INFRINGES ON USER NAME SPACE */
449 # if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
450 || defined __cplusplus || defined _MSC_VER)
451 void free (void *); /* INFRINGES ON USER NAME SPACE */
455 #endif /* ! defined yyoverflow || YYERROR_VERBOSE */
458 #if (! defined yyoverflow \
459 && (! defined __cplusplus \
460 || (defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL \
461 && defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
463 /* A type that is properly aligned for any stack member. */
466 yytype_int16 yyss_alloc
;
471 /* The size of the maximum gap between one aligned stack and the next. */
472 # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
474 /* The size of an array large to enough to hold all stacks, each with
476 # define YYSTACK_BYTES(N) \
477 ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE) + sizeof (YYLTYPE)) \
478 + 2 * YYSTACK_GAP_MAXIMUM)
480 /* Copy COUNT objects from FROM to TO. The source and destination do
483 # if defined __GNUC__ && 1 < __GNUC__
484 # define YYCOPY(To, From, Count) \
485 __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
487 # define YYCOPY(To, From, Count) \
491 for (yyi = 0; yyi < (Count); yyi++) \
492 (To)[yyi] = (From)[yyi]; \
498 /* Relocate STACK from its old location to the new one. The
499 local variables YYSIZE and YYSTACKSIZE give the old and new number of
500 elements in the stack, and YYPTR gives the new location of the
501 stack. Advance YYPTR to a properly aligned location for the next
503 # define YYSTACK_RELOCATE(Stack_alloc, Stack) \
506 YYSIZE_T yynewbytes; \
507 YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \
508 Stack = &yyptr->Stack_alloc; \
509 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
510 yyptr += yynewbytes / sizeof (*yyptr); \
516 /* YYFINAL -- State number of the termination state. */
518 /* YYLAST -- Last index in YYTABLE. */
521 /* YYNTOKENS -- Number of terminals. */
523 /* YYNNTS -- Number of nonterminals. */
525 /* YYNRULES -- Number of rules. */
527 /* YYNRULES -- Number of states. */
528 #define YYNSTATES 162
530 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
532 #define YYMAXUTOK 289
534 #define YYTRANSLATE(YYX) \
535 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
537 /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
538 static const yytype_uint8 yytranslate
[] =
540 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
541 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
542 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
543 2, 2, 2, 47, 2, 2, 2, 43, 30, 2,
544 45, 46, 41, 39, 49, 40, 54, 42, 2, 2,
545 2, 2, 2, 2, 2, 2, 2, 2, 2, 55,
546 33, 56, 34, 2, 2, 2, 2, 2, 2, 2,
547 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
548 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
549 2, 50, 2, 51, 29, 2, 2, 2, 2, 2,
550 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
551 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
552 2, 2, 2, 52, 28, 53, 48, 2, 2, 2,
553 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
554 2, 2, 2, 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, 2, 2, 2, 2, 2, 2, 2, 2, 2,
558 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
559 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
560 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
561 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
562 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
563 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
564 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
565 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
566 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
567 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
568 25, 26, 27, 31, 32, 35, 36, 37, 38, 44
572 /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
574 static const yytype_uint16 yyprhs
[] =
576 0, 0, 3, 4, 7, 9, 11, 13, 16, 20,
577 24, 29, 36, 44, 48, 52, 55, 60, 65, 69,
578 72, 75, 78, 82, 85, 87, 89, 91, 95, 99,
579 103, 107, 111, 115, 119, 123, 127, 131, 135, 139,
580 143, 147, 151, 155, 159, 163, 166, 169, 172, 175,
581 179, 181, 185, 187, 190, 193, 194, 196, 197, 199,
582 202, 207, 209, 211, 214, 216, 219, 221, 223, 225,
583 227, 229, 231, 233, 235, 237, 239, 241, 243, 245,
584 247, 249, 251, 253, 255, 257, 259, 261, 263, 265,
585 267, 269, 271, 273, 275, 277, 279, 281, 283, 285,
589 /* YYRHS -- A `-1'-separated list of the rules' RHS. */
590 static const yytype_int8 yyrhs
[] =
592 58, 0, -1, -1, 58, 59, -1, 61, -1, 65,
593 -1, 60, -1, 6, 66, -1, 18, 63, 21, -1,
594 5, 63, 21, -1, 8, 17, 67, 21, -1, 7,
595 17, 45, 46, 67, 21, -1, 7, 17, 45, 64,
596 46, 67, 21, -1, 15, 17, 21, -1, 12, 70,
597 21, -1, 12, 21, -1, 13, 17, 68, 21, -1,
598 14, 17, 68, 21, -1, 9, 70, 21, -1, 9,
599 21, -1, 10, 21, -1, 11, 21, -1, 16, 62,
600 21, -1, 6, 21, -1, 20, -1, 19, -1, 62,
601 -1, 63, 26, 63, -1, 63, 27, 63, -1, 63,
602 28, 63, -1, 63, 29, 63, -1, 63, 30, 63,
603 -1, 63, 31, 63, -1, 63, 32, 63, -1, 63,
604 35, 63, -1, 63, 36, 63, -1, 63, 34, 63,
605 -1, 63, 33, 63, -1, 63, 37, 63, -1, 63,
606 38, 63, -1, 63, 40, 63, -1, 63, 39, 63,
607 -1, 63, 43, 63, -1, 63, 42, 63, -1, 63,
608 41, 63, -1, 47, 63, -1, 48, 63, -1, 40,
609 63, -1, 39, 63, -1, 45, 63, 46, -1, 17,
610 -1, 64, 49, 17, -1, 21, -1, 71, 21, -1,
611 71, 21, -1, -1, 71, -1, -1, 71, -1, 4,
612 17, -1, 4, 45, 17, 46, -1, 72, -1, 69,
613 -1, 70, 69, -1, 72, -1, 71, 72, -1, 17,
614 -1, 20, -1, 73, -1, 22, -1, 24, -1, 50,
615 -1, 51, -1, 45, -1, 46, -1, 52, -1, 53,
616 -1, 54, -1, 30, -1, 41, -1, 39, -1, 40,
617 -1, 48, -1, 47, -1, 42, -1, 43, -1, 38,
618 -1, 37, -1, 33, -1, 34, -1, 36, -1, 35,
619 -1, 32, -1, 31, -1, 29, -1, 28, -1, 27,
620 -1, 26, -1, 55, -1, 49, -1, 56, -1, 25,
624 /* YYRLINE[YYN] -- source line where rule number YYN was defined. */
625 static const yytype_uint16 yyrline
[] =
627 0, 180, 180, 182, 186, 189, 194, 195, 199, 202,
628 208, 211, 214, 217, 225, 244, 254, 259, 264, 283,
629 298, 301, 304, 325, 329, 338, 343, 344, 347, 350,
630 353, 356, 359, 362, 365, 368, 371, 374, 377, 380,
631 383, 386, 389, 397, 405, 408, 411, 414, 417, 420,
632 426, 431, 439, 440, 444, 450, 451, 454, 456, 463,
633 467, 471, 476, 480, 487, 492, 499, 503, 507, 511,
634 515, 522, 523, 524, 525, 526, 527, 528, 529, 530,
635 531, 532, 533, 534, 535, 536, 537, 538, 539, 540,
636 541, 542, 543, 544, 545, 546, 547, 548, 549, 550,
641 #if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
642 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
643 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
644 static const char *const yytname
[] =
646 "$end", "error", "$undefined", "COMMA_FINAL", "DEFINED",
647 "ELIF_EXPANDED", "HASH", "HASH_DEFINE_FUNC", "HASH_DEFINE_OBJ",
648 "HASH_ELIF", "HASH_ELSE", "HASH_ENDIF", "HASH_IF", "HASH_IFDEF",
649 "HASH_IFNDEF", "HASH_UNDEF", "HASH_VERSION", "IDENTIFIER", "IF_EXPANDED",
650 "INTEGER", "INTEGER_STRING", "NEWLINE", "OTHER", "PLACEHOLDER", "SPACE",
651 "PASTE", "OR", "AND", "'|'", "'^'", "'&'", "NOT_EQUAL", "EQUAL", "'<'",
652 "'>'", "GREATER_OR_EQUAL", "LESS_OR_EQUAL", "RIGHT_SHIFT", "LEFT_SHIFT",
653 "'+'", "'-'", "'*'", "'/'", "'%'", "UNARY", "'('", "')'", "'!'", "'~'",
654 "','", "'['", "']'", "'{'", "'}'", "'.'", "';'", "'='", "$accept",
655 "input", "line", "expanded_line", "control_line", "integer_constant",
656 "expression", "identifier_list", "text_line", "non_directive",
657 "replacement_list", "junk", "conditional_token", "conditional_tokens",
658 "pp_tokens", "preprocessing_token", "operator", 0
663 /* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
665 static const yytype_uint16 yytoknum
[] =
667 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
668 265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
669 275, 276, 277, 278, 279, 280, 281, 282, 124, 94,
670 38, 283, 284, 60, 62, 285, 286, 287, 288, 43,
671 45, 42, 47, 37, 289, 40, 41, 33, 126, 44,
672 91, 93, 123, 125, 46, 59, 61
676 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
677 static const yytype_uint8 yyr1
[] =
679 0, 57, 58, 58, 59, 59, 59, 59, 60, 60,
680 61, 61, 61, 61, 61, 61, 61, 61, 61, 61,
681 61, 61, 61, 61, 62, 62, 63, 63, 63, 63,
682 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
683 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
684 64, 64, 65, 65, 66, 67, 67, 68, 68, 69,
685 69, 69, 70, 70, 71, 71, 72, 72, 72, 72,
686 72, 73, 73, 73, 73, 73, 73, 73, 73, 73,
687 73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
688 73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
692 /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
693 static const yytype_uint8 yyr2
[] =
695 0, 2, 0, 2, 1, 1, 1, 2, 3, 3,
696 4, 6, 7, 3, 3, 2, 4, 4, 3, 2,
697 2, 2, 3, 2, 1, 1, 1, 3, 3, 3,
698 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
699 3, 3, 3, 3, 3, 2, 2, 2, 2, 3,
700 1, 3, 1, 2, 2, 0, 1, 0, 1, 2,
701 4, 1, 1, 2, 1, 2, 1, 1, 1, 1,
702 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
703 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
704 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
708 /* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
709 STATE-NUM when YYTABLE doesn't specify something else to do. Zero
710 means the default is an error. */
711 static const yytype_uint8 yydefact
[] =
713 2, 0, 1, 0, 0, 0, 0, 0, 0, 0,
714 0, 0, 0, 0, 0, 66, 0, 67, 52, 69,
715 70, 101, 97, 96, 95, 94, 78, 93, 92, 88,
716 89, 91, 90, 87, 86, 80, 81, 79, 84, 85,
717 73, 74, 83, 82, 99, 71, 72, 75, 76, 77,
718 98, 100, 3, 6, 4, 5, 0, 64, 68, 25,
719 24, 0, 0, 0, 0, 0, 26, 0, 23, 7,
720 0, 0, 55, 0, 19, 62, 0, 61, 20, 21,
721 15, 0, 57, 57, 0, 0, 0, 53, 65, 48,
722 47, 0, 45, 46, 9, 0, 0, 0, 0, 0,
723 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
724 0, 0, 0, 54, 0, 0, 56, 59, 0, 18,
725 63, 14, 0, 58, 0, 13, 22, 8, 49, 27,
726 28, 29, 30, 31, 32, 33, 37, 36, 34, 35,
727 38, 39, 41, 40, 44, 43, 42, 50, 55, 0,
728 10, 0, 16, 17, 0, 55, 0, 60, 11, 0,
732 /* YYDEFGOTO[NTERM-NUM]. */
733 static const yytype_int16 yydefgoto
[] =
735 -1, 1, 52, 53, 54, 66, 67, 149, 55, 69,
736 115, 122, 75, 76, 116, 57, 58
739 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
741 #define YYPACT_NINF -147
742 static const yytype_int16 yypact
[] =
744 -147, 112, -147, 28, -10, 55, 62, 152, -15, 59,
745 192, 85, 86, 87, 51, -147, 28, -147, -147, -147,
746 -147, -147, -147, -147, -147, -147, -147, -147, -147, -147,
747 -147, -147, -147, -147, -147, -147, -147, -147, -147, -147,
748 -147, -147, -147, -147, -147, -147, -147, -147, -147, -147,
749 -147, -147, -147, -147, -147, -147, 312, -147, -147, -147,
750 -147, 28, 28, 28, 28, 28, -147, 428, -147, -147,
751 352, 63, 392, 17, -147, -147, 232, -147, -147, -147,
752 -147, 272, 392, 392, 84, 89, 451, -147, -147, -147,
753 -147, 469, -147, -147, -147, 28, 28, 28, 28, 28,
754 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
755 28, 28, 28, -147, 60, 90, 392, -147, 96, -147,
756 -147, -147, 93, 392, 94, -147, -147, -147, -147, 489,
757 505, 520, 534, 547, 558, 558, 18, 18, 18, 18,
758 563, 563, 23, 23, -147, -147, -147, -147, 392, 32,
759 -147, 61, -147, -147, 110, 392, 118, -147, -147, 149,
763 /* YYPGOTO[NTERM-NUM]. */
764 static const yytype_int16 yypgoto
[] =
766 -147, -147, -147, -147, -147, 157, -11, -147, -147, -147,
767 -146, 92, -68, 200, 0, -7, -147
770 /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
771 positive, shift that token. If negative, reduce the rule which
772 number is the opposite. If zero, do what YYDEFACT says.
773 If YYTABLE_NINF, syntax error. */
774 #define YYTABLE_NINF -1
775 static const yytype_uint8 yytable
[] =
777 77, 56, 154, 77, 70, 86, 78, 15, 120, 159,
778 17, 68, 19, 120, 20, 21, 22, 23, 24, 25,
779 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
780 36, 37, 38, 39, 117, 40, 41, 42, 43, 44,
781 45, 46, 47, 48, 49, 50, 51, 59, 60, 88,
782 89, 90, 91, 92, 93, 106, 107, 108, 109, 110,
783 111, 112, 118, 88, 110, 111, 112, 61, 62, 77,
784 59, 60, 71, 63, 77, 64, 65, 147, 155, 72,
785 79, 156, 123, 123, 129, 130, 131, 132, 133, 134,
786 135, 136, 137, 138, 139, 140, 141, 142, 143, 144,
787 145, 146, 82, 83, 84, 125, 148, 157, 114, 88,
788 126, 150, 2, 151, 152, 153, 88, 3, 4, 5,
789 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
790 16, 158, 17, 18, 19, 160, 20, 21, 22, 23,
791 24, 25, 26, 27, 28, 29, 30, 31, 32, 33,
792 34, 35, 36, 37, 38, 39, 73, 40, 41, 42,
793 43, 44, 45, 46, 47, 48, 49, 50, 51, 15,
794 161, 85, 17, 74, 19, 124, 20, 21, 22, 23,
795 24, 25, 26, 27, 28, 29, 30, 31, 32, 33,
796 34, 35, 36, 37, 38, 39, 73, 40, 41, 42,
797 43, 44, 45, 46, 47, 48, 49, 50, 51, 15,
798 81, 0, 17, 80, 19, 0, 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 0, 0, 17, 119, 19, 0, 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 0, 0, 17, 121, 19, 0, 20, 21, 22, 23,
807 24, 25, 26, 27, 28, 29, 30, 31, 32, 33,
808 34, 35, 36, 37, 38, 39, 0, 40, 41, 42,
809 43, 44, 45, 46, 47, 48, 49, 50, 51, 15,
810 0, 0, 17, 87, 19, 0, 20, 21, 22, 23,
811 24, 25, 26, 27, 28, 29, 30, 31, 32, 33,
812 34, 35, 36, 37, 38, 39, 0, 40, 41, 42,
813 43, 44, 45, 46, 47, 48, 49, 50, 51, 15,
814 0, 0, 17, 113, 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, 0, 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, 94,
822 0, 0, 0, 0, 95, 96, 97, 98, 99, 100,
823 101, 102, 103, 104, 105, 106, 107, 108, 109, 110,
824 111, 112, 127, 0, 0, 0, 0, 95, 96, 97,
825 98, 99, 100, 101, 102, 103, 104, 105, 106, 107,
826 108, 109, 110, 111, 112, 95, 96, 97, 98, 99,
827 100, 101, 102, 103, 104, 105, 106, 107, 108, 109,
828 110, 111, 112, 0, 0, 128, 96, 97, 98, 99,
829 100, 101, 102, 103, 104, 105, 106, 107, 108, 109,
830 110, 111, 112, 97, 98, 99, 100, 101, 102, 103,
831 104, 105, 106, 107, 108, 109, 110, 111, 112, 98,
832 99, 100, 101, 102, 103, 104, 105, 106, 107, 108,
833 109, 110, 111, 112, 99, 100, 101, 102, 103, 104,
834 105, 106, 107, 108, 109, 110, 111, 112, 100, 101,
835 102, 103, 104, 105, 106, 107, 108, 109, 110, 111,
836 112, 102, 103, 104, 105, 106, 107, 108, 109, 110,
837 111, 112, 108, 109, 110, 111, 112
840 static const yytype_int16 yycheck
[] =
842 7, 1, 148, 10, 4, 16, 21, 17, 76, 155,
843 20, 21, 22, 81, 24, 25, 26, 27, 28, 29,
844 30, 31, 32, 33, 34, 35, 36, 37, 38, 39,
845 40, 41, 42, 43, 17, 45, 46, 47, 48, 49,
846 50, 51, 52, 53, 54, 55, 56, 19, 20, 56,
847 61, 62, 63, 64, 65, 37, 38, 39, 40, 41,
848 42, 43, 45, 70, 41, 42, 43, 39, 40, 76,
849 19, 20, 17, 45, 81, 47, 48, 17, 46, 17,
850 21, 49, 82, 83, 95, 96, 97, 98, 99, 100,
851 101, 102, 103, 104, 105, 106, 107, 108, 109, 110,
852 111, 112, 17, 17, 17, 21, 46, 46, 45, 116,
853 21, 21, 0, 17, 21, 21, 123, 5, 6, 7,
854 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
855 18, 21, 20, 21, 22, 17, 24, 25, 26, 27,
856 28, 29, 30, 31, 32, 33, 34, 35, 36, 37,
857 38, 39, 40, 41, 42, 43, 4, 45, 46, 47,
858 48, 49, 50, 51, 52, 53, 54, 55, 56, 17,
859 21, 14, 20, 21, 22, 83, 24, 25, 26, 27,
860 28, 29, 30, 31, 32, 33, 34, 35, 36, 37,
861 38, 39, 40, 41, 42, 43, 4, 45, 46, 47,
862 48, 49, 50, 51, 52, 53, 54, 55, 56, 17,
863 10, -1, 20, 21, 22, -1, 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 -1, -1, 20, 21, 22, -1, 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 -1, -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, -1, 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, -1, 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, -1, 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, 21,
887 -1, -1, -1, -1, 26, 27, 28, 29, 30, 31,
888 32, 33, 34, 35, 36, 37, 38, 39, 40, 41,
889 42, 43, 21, -1, -1, -1, -1, 26, 27, 28,
890 29, 30, 31, 32, 33, 34, 35, 36, 37, 38,
891 39, 40, 41, 42, 43, 26, 27, 28, 29, 30,
892 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
893 41, 42, 43, -1, -1, 46, 27, 28, 29, 30,
894 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
895 41, 42, 43, 28, 29, 30, 31, 32, 33, 34,
896 35, 36, 37, 38, 39, 40, 41, 42, 43, 29,
897 30, 31, 32, 33, 34, 35, 36, 37, 38, 39,
898 40, 41, 42, 43, 30, 31, 32, 33, 34, 35,
899 36, 37, 38, 39, 40, 41, 42, 43, 31, 32,
900 33, 34, 35, 36, 37, 38, 39, 40, 41, 42,
901 43, 33, 34, 35, 36, 37, 38, 39, 40, 41,
902 42, 43, 39, 40, 41, 42, 43
905 /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
906 symbol of state STATE-NUM. */
907 static const yytype_uint8 yystos
[] =
909 0, 58, 0, 5, 6, 7, 8, 9, 10, 11,
910 12, 13, 14, 15, 16, 17, 18, 20, 21, 22,
911 24, 25, 26, 27, 28, 29, 30, 31, 32, 33,
912 34, 35, 36, 37, 38, 39, 40, 41, 42, 43,
913 45, 46, 47, 48, 49, 50, 51, 52, 53, 54,
914 55, 56, 59, 60, 61, 65, 71, 72, 73, 19,
915 20, 39, 40, 45, 47, 48, 62, 63, 21, 66,
916 71, 17, 17, 4, 21, 69, 70, 72, 21, 21,
917 21, 70, 17, 17, 17, 62, 63, 21, 72, 63,
918 63, 63, 63, 63, 21, 26, 27, 28, 29, 30,
919 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
920 41, 42, 43, 21, 45, 67, 71, 17, 45, 21,
921 69, 21, 68, 71, 68, 21, 21, 21, 46, 63,
922 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
923 63, 63, 63, 63, 63, 63, 63, 17, 46, 64,
924 21, 17, 21, 21, 67, 46, 49, 46, 21, 67,
928 #define yyerrok (yyerrstatus = 0)
929 #define yyclearin (yychar = YYEMPTY)
933 #define YYACCEPT goto yyacceptlab
934 #define YYABORT goto yyabortlab
935 #define YYERROR goto yyerrorlab
938 /* Like YYERROR except do call yyerror. This remains here temporarily
939 to ease the transition to the new meaning of YYERROR, for GCC.
940 Once GCC version 2 has supplanted version 1, this can go. However,
941 YYFAIL appears to be in use. Nevertheless, it is formally deprecated
942 in Bison 2.4.2's NEWS entry, where a plan to phase it out is
945 #define YYFAIL goto yyerrlab
947 /* This is here to suppress warnings from the GCC cpp's
948 -Wunused-macros. Normally we don't worry about that warning, but
949 some users do, and we want to make it easy for users to remove
950 YYFAIL uses, which will produce warnings from Bison 2.5. */
953 #define YYRECOVERING() (!!yyerrstatus)
955 #define YYBACKUP(Token, Value) \
957 if (yychar == YYEMPTY && yylen == 1) \
961 yytoken = YYTRANSLATE (yychar); \
967 yyerror (&yylloc, parser, YY_("syntax error: cannot back up")); \
974 #define YYERRCODE 256
977 /* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
978 If N is 0, then set CURRENT to the empty location which ends
979 the previous symbol: RHS[0] (always defined). */
981 #define YYRHSLOC(Rhs, K) ((Rhs)[K])
982 #ifndef YYLLOC_DEFAULT
983 # define YYLLOC_DEFAULT(Current, Rhs, N) \
987 (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
988 (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
989 (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
990 (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
994 (Current).first_line = (Current).last_line = \
995 YYRHSLOC (Rhs, 0).last_line; \
996 (Current).first_column = (Current).last_column = \
997 YYRHSLOC (Rhs, 0).last_column; \
1003 /* YY_LOCATION_PRINT -- Print the location on the stream.
1004 This macro was not mandated originally: define only if we know
1005 we won't break user code: when these are the locations we know. */
1007 #ifndef YY_LOCATION_PRINT
1008 # if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL
1009 # define YY_LOCATION_PRINT(File, Loc) \
1010 fprintf (File, "%d.%d-%d.%d", \
1011 (Loc).first_line, (Loc).first_column, \
1012 (Loc).last_line, (Loc).last_column)
1014 # define YY_LOCATION_PRINT(File, Loc) ((void) 0)
1019 /* YYLEX -- calling `yylex' with the right arguments. */
1022 # define YYLEX yylex (&yylval, &yylloc, YYLEX_PARAM)
1024 # define YYLEX yylex (&yylval, &yylloc, parser)
1027 /* Enable debugging if requested. */
1031 # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
1032 # define YYFPRINTF fprintf
1035 # define YYDPRINTF(Args) \
1041 # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
1045 YYFPRINTF (stderr, "%s ", Title); \
1046 yy_symbol_print (stderr, \
1047 Type, Value, Location, parser); \
1048 YYFPRINTF (stderr, "\n"); \
1053 /*--------------------------------.
1054 | Print this symbol on YYOUTPUT. |
1055 `--------------------------------*/
1058 #if (defined __STDC__ || defined __C99__FUNC__ \
1059 || defined __cplusplus || defined _MSC_VER)
1061 yy_symbol_value_print (FILE *yyoutput
, int yytype
, YYSTYPE
const * const yyvaluep
, YYLTYPE
const * const yylocationp
, glcpp_parser_t
*parser
)
1064 yy_symbol_value_print (yyoutput
, yytype
, yyvaluep
, yylocationp
, parser
)
1067 YYSTYPE
const * const yyvaluep
;
1068 YYLTYPE
const * const yylocationp
;
1069 glcpp_parser_t
*parser
;
1074 YYUSE (yylocationp
);
1077 if (yytype
< YYNTOKENS
)
1078 YYPRINT (yyoutput
, yytoknum
[yytype
], *yyvaluep
);
1090 /*--------------------------------.
1091 | Print this symbol on YYOUTPUT. |
1092 `--------------------------------*/
1094 #if (defined __STDC__ || defined __C99__FUNC__ \
1095 || defined __cplusplus || defined _MSC_VER)
1097 yy_symbol_print (FILE *yyoutput
, int yytype
, YYSTYPE
const * const yyvaluep
, YYLTYPE
const * const yylocationp
, glcpp_parser_t
*parser
)
1100 yy_symbol_print (yyoutput
, yytype
, yyvaluep
, yylocationp
, parser
)
1103 YYSTYPE
const * const yyvaluep
;
1104 YYLTYPE
const * const yylocationp
;
1105 glcpp_parser_t
*parser
;
1108 if (yytype
< YYNTOKENS
)
1109 YYFPRINTF (yyoutput
, "token %s (", yytname
[yytype
]);
1111 YYFPRINTF (yyoutput
, "nterm %s (", yytname
[yytype
]);
1113 YY_LOCATION_PRINT (yyoutput
, *yylocationp
);
1114 YYFPRINTF (yyoutput
, ": ");
1115 yy_symbol_value_print (yyoutput
, yytype
, yyvaluep
, yylocationp
, parser
);
1116 YYFPRINTF (yyoutput
, ")");
1119 /*------------------------------------------------------------------.
1120 | yy_stack_print -- Print the state stack from its BOTTOM up to its |
1122 `------------------------------------------------------------------*/
1124 #if (defined __STDC__ || defined __C99__FUNC__ \
1125 || defined __cplusplus || defined _MSC_VER)
1127 yy_stack_print (yytype_int16
*yybottom
, yytype_int16
*yytop
)
1130 yy_stack_print (yybottom
, yytop
)
1131 yytype_int16
*yybottom
;
1132 yytype_int16
*yytop
;
1135 YYFPRINTF (stderr
, "Stack now");
1136 for (; yybottom
<= yytop
; yybottom
++)
1138 int yybot
= *yybottom
;
1139 YYFPRINTF (stderr
, " %d", yybot
);
1141 YYFPRINTF (stderr
, "\n");
1144 # define YY_STACK_PRINT(Bottom, Top) \
1147 yy_stack_print ((Bottom), (Top)); \
1151 /*------------------------------------------------.
1152 | Report that the YYRULE is going to be reduced. |
1153 `------------------------------------------------*/
1155 #if (defined __STDC__ || defined __C99__FUNC__ \
1156 || defined __cplusplus || defined _MSC_VER)
1158 yy_reduce_print (YYSTYPE
*yyvsp
, YYLTYPE
*yylsp
, int yyrule
, glcpp_parser_t
*parser
)
1161 yy_reduce_print (yyvsp
, yylsp
, yyrule
, parser
)
1165 glcpp_parser_t
*parser
;
1168 int yynrhs
= yyr2
[yyrule
];
1170 unsigned long int yylno
= yyrline
[yyrule
];
1171 YYFPRINTF (stderr
, "Reducing stack by rule %d (line %lu):\n",
1173 /* The symbols being reduced. */
1174 for (yyi
= 0; yyi
< yynrhs
; yyi
++)
1176 YYFPRINTF (stderr
, " $%d = ", yyi
+ 1);
1177 yy_symbol_print (stderr
, yyrhs
[yyprhs
[yyrule
] + yyi
],
1178 &(yyvsp
[(yyi
+ 1) - (yynrhs
)])
1179 , &(yylsp
[(yyi
+ 1) - (yynrhs
)]) , parser
);
1180 YYFPRINTF (stderr
, "\n");
1184 # define YY_REDUCE_PRINT(Rule) \
1187 yy_reduce_print (yyvsp, yylsp, Rule, parser); \
1190 /* Nonzero means print parse trace. It is left uninitialized so that
1191 multiple parsers can coexist. */
1193 #else /* !YYDEBUG */
1194 # define YYDPRINTF(Args)
1195 # define YY_SYMBOL_PRINT(Title, Type, Value, Location)
1196 # define YY_STACK_PRINT(Bottom, Top)
1197 # define YY_REDUCE_PRINT(Rule)
1198 #endif /* !YYDEBUG */
1201 /* YYINITDEPTH -- initial size of the parser's stacks. */
1203 # define YYINITDEPTH 200
1206 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
1207 if the built-in stack extension method is used).
1209 Do not make this value too large; the results are undefined if
1210 YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
1211 evaluated with infinite-precision integer arithmetic. */
1214 # define YYMAXDEPTH 10000
1222 # if defined __GLIBC__ && defined _STRING_H
1223 # define yystrlen strlen
1225 /* Return the length of YYSTR. */
1226 #if (defined __STDC__ || defined __C99__FUNC__ \
1227 || defined __cplusplus || defined _MSC_VER)
1229 yystrlen (const char *yystr
)
1237 for (yylen
= 0; yystr
[yylen
]; yylen
++)
1245 # if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
1246 # define yystpcpy stpcpy
1248 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
1250 #if (defined __STDC__ || defined __C99__FUNC__ \
1251 || defined __cplusplus || defined _MSC_VER)
1253 yystpcpy (char *yydest
, const char *yysrc
)
1256 yystpcpy (yydest
, yysrc
)
1262 const char *yys
= yysrc
;
1264 while ((*yyd
++ = *yys
++) != '\0')
1273 /* Copy to YYRES the contents of YYSTR after stripping away unnecessary
1274 quotes and backslashes, so that it's suitable for yyerror. The
1275 heuristic is that double-quoting is unnecessary unless the string
1276 contains an apostrophe, a comma, or backslash (other than
1277 backslash-backslash). YYSTR is taken from yytname. If YYRES is
1278 null, do not copy; instead, return the length of what the result
1281 yytnamerr (char *yyres
, const char *yystr
)
1286 char const *yyp
= yystr
;
1293 goto do_not_strip_quotes
;
1297 goto do_not_strip_quotes
;
1310 do_not_strip_quotes
: ;
1314 return yystrlen (yystr
);
1316 return yystpcpy (yyres
, yystr
) - yyres
;
1320 /* Copy into YYRESULT an error message about the unexpected token
1321 YYCHAR while in state YYSTATE. Return the number of bytes copied,
1322 including the terminating null byte. If YYRESULT is null, do not
1323 copy anything; just return the number of bytes that would be
1324 copied. As a special case, return 0 if an ordinary "syntax error"
1325 message will do. Return YYSIZE_MAXIMUM if overflow occurs during
1326 size calculation. */
1328 yysyntax_error (char *yyresult
, int yystate
, int yychar
)
1330 int yyn
= yypact
[yystate
];
1332 if (! (YYPACT_NINF
< yyn
&& yyn
<= YYLAST
))
1336 int yytype
= YYTRANSLATE (yychar
);
1337 YYSIZE_T yysize0
= yytnamerr (0, yytname
[yytype
]);
1338 YYSIZE_T yysize
= yysize0
;
1340 int yysize_overflow
= 0;
1341 enum { YYERROR_VERBOSE_ARGS_MAXIMUM
= 5 };
1342 char const *yyarg
[YYERROR_VERBOSE_ARGS_MAXIMUM
];
1346 /* This is so xgettext sees the translatable formats that are
1347 constructed on the fly. */
1348 YY_("syntax error, unexpected %s");
1349 YY_("syntax error, unexpected %s, expecting %s");
1350 YY_("syntax error, unexpected %s, expecting %s or %s");
1351 YY_("syntax error, unexpected %s, expecting %s or %s or %s");
1352 YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s");
1356 static char const yyunexpected
[] = "syntax error, unexpected %s";
1357 static char const yyexpecting
[] = ", expecting %s";
1358 static char const yyor
[] = " or %s";
1359 char yyformat
[sizeof yyunexpected
1360 + sizeof yyexpecting
- 1
1361 + ((YYERROR_VERBOSE_ARGS_MAXIMUM
- 2)
1362 * (sizeof yyor
- 1))];
1363 char const *yyprefix
= yyexpecting
;
1365 /* Start YYX at -YYN if negative to avoid negative indexes in
1367 int yyxbegin
= yyn
< 0 ? -yyn
: 0;
1369 /* Stay within bounds of both yycheck and yytname. */
1370 int yychecklim
= YYLAST
- yyn
+ 1;
1371 int yyxend
= yychecklim
< YYNTOKENS
? yychecklim
: YYNTOKENS
;
1374 yyarg
[0] = yytname
[yytype
];
1375 yyfmt
= yystpcpy (yyformat
, yyunexpected
);
1377 for (yyx
= yyxbegin
; yyx
< yyxend
; ++yyx
)
1378 if (yycheck
[yyx
+ yyn
] == yyx
&& yyx
!= YYTERROR
)
1380 if (yycount
== YYERROR_VERBOSE_ARGS_MAXIMUM
)
1384 yyformat
[sizeof yyunexpected
- 1] = '\0';
1387 yyarg
[yycount
++] = yytname
[yyx
];
1388 yysize1
= yysize
+ yytnamerr (0, yytname
[yyx
]);
1389 yysize_overflow
|= (yysize1
< yysize
);
1391 yyfmt
= yystpcpy (yyfmt
, yyprefix
);
1395 yyf
= YY_(yyformat
);
1396 yysize1
= yysize
+ yystrlen (yyf
);
1397 yysize_overflow
|= (yysize1
< yysize
);
1400 if (yysize_overflow
)
1401 return YYSIZE_MAXIMUM
;
1405 /* Avoid sprintf, as that infringes on the user's name space.
1406 Don't have undefined behavior even if the translation
1407 produced a string with the wrong number of "%s"s. */
1408 char *yyp
= yyresult
;
1410 while ((*yyp
= *yyf
) != '\0')
1412 if (*yyp
== '%' && yyf
[1] == 's' && yyi
< yycount
)
1414 yyp
+= yytnamerr (yyp
, yyarg
[yyi
++]);
1427 #endif /* YYERROR_VERBOSE */
1430 /*-----------------------------------------------.
1431 | Release the memory associated to this symbol. |
1432 `-----------------------------------------------*/
1435 #if (defined __STDC__ || defined __C99__FUNC__ \
1436 || defined __cplusplus || defined _MSC_VER)
1438 yydestruct (const char *yymsg
, int yytype
, YYSTYPE
*yyvaluep
, YYLTYPE
*yylocationp
, glcpp_parser_t
*parser
)
1441 yydestruct (yymsg
, yytype
, yyvaluep
, yylocationp
, parser
)
1445 YYLTYPE
*yylocationp
;
1446 glcpp_parser_t
*parser
;
1450 YYUSE (yylocationp
);
1455 YY_SYMBOL_PRINT (yymsg
, yytype
, yyvaluep
, yylocationp
);
1465 /* Prevent warnings from -Wmissing-prototypes. */
1466 #ifdef YYPARSE_PARAM
1467 #if defined __STDC__ || defined __cplusplus
1468 int yyparse (void *YYPARSE_PARAM
);
1472 #else /* ! YYPARSE_PARAM */
1473 #if defined __STDC__ || defined __cplusplus
1474 int yyparse (glcpp_parser_t
*parser
);
1478 #endif /* ! YYPARSE_PARAM */
1484 /*-------------------------.
1485 | yyparse or yypush_parse. |
1486 `-------------------------*/
1488 #ifdef YYPARSE_PARAM
1489 #if (defined __STDC__ || defined __C99__FUNC__ \
1490 || defined __cplusplus || defined _MSC_VER)
1492 yyparse (void *YYPARSE_PARAM
)
1495 yyparse (YYPARSE_PARAM
)
1496 void *YYPARSE_PARAM
;
1498 #else /* ! YYPARSE_PARAM */
1499 #if (defined __STDC__ || defined __C99__FUNC__ \
1500 || defined __cplusplus || defined _MSC_VER)
1502 yyparse (glcpp_parser_t
*parser
)
1506 glcpp_parser_t
*parser
;
1510 /* The lookahead symbol. */
1513 /* The semantic value of the lookahead symbol. */
1516 /* Location data for the lookahead symbol. */
1519 /* Number of syntax errors so far. */
1523 /* Number of tokens to shift before error messages enabled. */
1526 /* The stacks and their tools:
1527 `yyss': related to states.
1528 `yyvs': related to semantic values.
1529 `yyls': related to locations.
1531 Refer to the stacks thru separate pointers, to allow yyoverflow
1532 to reallocate them elsewhere. */
1534 /* The state stack. */
1535 yytype_int16 yyssa
[YYINITDEPTH
];
1537 yytype_int16
*yyssp
;
1539 /* The semantic value stack. */
1540 YYSTYPE yyvsa
[YYINITDEPTH
];
1544 /* The location stack. */
1545 YYLTYPE yylsa
[YYINITDEPTH
];
1549 /* The locations where the error started and ended. */
1550 YYLTYPE yyerror_range
[3];
1552 YYSIZE_T yystacksize
;
1556 /* Lookahead token as an internal (translated) token number. */
1558 /* The variables used to return semantic value and location from the
1564 /* Buffer for error messages, and its allocated size. */
1566 char *yymsg
= yymsgbuf
;
1567 YYSIZE_T yymsg_alloc
= sizeof yymsgbuf
;
1570 #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N), yylsp -= (N))
1572 /* The number of symbols on the RHS of the reduced rule.
1573 Keep to zero when no symbol should be popped. */
1580 yystacksize
= YYINITDEPTH
;
1582 YYDPRINTF ((stderr
, "Starting parse\n"));
1587 yychar
= YYEMPTY
; /* Cause a token to be read. */
1589 /* Initialize stack pointers.
1590 Waste one element of value and location stack
1591 so that they stay on the same level as the state stack.
1592 The wasted elements are never initialized. */
1597 #if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL
1598 /* Initialize the default location before parsing starts. */
1599 yylloc
.first_line
= yylloc
.last_line
= 1;
1600 yylloc
.first_column
= yylloc
.last_column
= 1;
1603 /* User initialization code. */
1605 /* Line 1251 of yacc.c */
1606 #line 147 "glcpp/glcpp-parse.y"
1608 yylloc
.first_line
= 1;
1609 yylloc
.first_column
= 1;
1610 yylloc
.last_line
= 1;
1611 yylloc
.last_column
= 1;
1615 /* Line 1251 of yacc.c */
1616 #line 1617 "glcpp/glcpp-parse.c"
1621 /*------------------------------------------------------------.
1622 | yynewstate -- Push a new state, which is found in yystate. |
1623 `------------------------------------------------------------*/
1625 /* In all cases, when you get here, the value and location stacks
1626 have just been pushed. So pushing a state here evens the stacks. */
1632 if (yyss
+ yystacksize
- 1 <= yyssp
)
1634 /* Get the current used size of the three stacks, in elements. */
1635 YYSIZE_T yysize
= yyssp
- yyss
+ 1;
1639 /* Give user a chance to reallocate the stack. Use copies of
1640 these so that the &'s don't force the real ones into
1642 YYSTYPE
*yyvs1
= yyvs
;
1643 yytype_int16
*yyss1
= yyss
;
1644 YYLTYPE
*yyls1
= yyls
;
1646 /* Each stack pointer address is followed by the size of the
1647 data in use in that stack, in bytes. This used to be a
1648 conditional around just the two extra args, but that might
1649 be undefined if yyoverflow is a macro. */
1650 yyoverflow (YY_("memory exhausted"),
1651 &yyss1
, yysize
* sizeof (*yyssp
),
1652 &yyvs1
, yysize
* sizeof (*yyvsp
),
1653 &yyls1
, yysize
* sizeof (*yylsp
),
1660 #else /* no yyoverflow */
1661 # ifndef YYSTACK_RELOCATE
1662 goto yyexhaustedlab
;
1664 /* Extend the stack our own way. */
1665 if (YYMAXDEPTH
<= yystacksize
)
1666 goto yyexhaustedlab
;
1668 if (YYMAXDEPTH
< yystacksize
)
1669 yystacksize
= YYMAXDEPTH
;
1672 yytype_int16
*yyss1
= yyss
;
1673 union yyalloc
*yyptr
=
1674 (union yyalloc
*) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize
));
1676 goto yyexhaustedlab
;
1677 YYSTACK_RELOCATE (yyss_alloc
, yyss
);
1678 YYSTACK_RELOCATE (yyvs_alloc
, yyvs
);
1679 YYSTACK_RELOCATE (yyls_alloc
, yyls
);
1680 # undef YYSTACK_RELOCATE
1682 YYSTACK_FREE (yyss1
);
1685 #endif /* no yyoverflow */
1687 yyssp
= yyss
+ yysize
- 1;
1688 yyvsp
= yyvs
+ yysize
- 1;
1689 yylsp
= yyls
+ yysize
- 1;
1691 YYDPRINTF ((stderr
, "Stack size increased to %lu\n",
1692 (unsigned long int) yystacksize
));
1694 if (yyss
+ yystacksize
- 1 <= yyssp
)
1698 YYDPRINTF ((stderr
, "Entering state %d\n", yystate
));
1700 if (yystate
== YYFINAL
)
1710 /* Do appropriate processing given the current state. Read a
1711 lookahead token if we need one and don't already have one. */
1713 /* First try to decide what to do without reference to lookahead token. */
1714 yyn
= yypact
[yystate
];
1715 if (yyn
== YYPACT_NINF
)
1718 /* Not known => get a lookahead token if don't already have one. */
1720 /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */
1721 if (yychar
== YYEMPTY
)
1723 YYDPRINTF ((stderr
, "Reading a token: "));
1727 if (yychar
<= YYEOF
)
1729 yychar
= yytoken
= YYEOF
;
1730 YYDPRINTF ((stderr
, "Now at end of input.\n"));
1734 yytoken
= YYTRANSLATE (yychar
);
1735 YY_SYMBOL_PRINT ("Next token is", yytoken
, &yylval
, &yylloc
);
1738 /* If the proper action on seeing token YYTOKEN is to reduce or to
1739 detect an error, take that action. */
1741 if (yyn
< 0 || YYLAST
< yyn
|| yycheck
[yyn
] != yytoken
)
1746 if (yyn
== 0 || yyn
== YYTABLE_NINF
)
1752 /* Count tokens shifted since error; after three, turn off error
1757 /* Shift the lookahead token. */
1758 YY_SYMBOL_PRINT ("Shifting", yytoken
, &yylval
, &yylloc
);
1760 /* Discard the shifted token. */
1769 /*-----------------------------------------------------------.
1770 | yydefault -- do the default action for the current state. |
1771 `-----------------------------------------------------------*/
1773 yyn
= yydefact
[yystate
];
1779 /*-----------------------------.
1780 | yyreduce -- Do a reduction. |
1781 `-----------------------------*/
1783 /* yyn is the number of a rule to reduce with. */
1786 /* If YYLEN is nonzero, implement the default value of the action:
1789 Otherwise, the following line sets YYVAL to garbage.
1790 This behavior is undocumented and Bison
1791 users should not rely upon it. Assigning to YYVAL
1792 unconditionally makes the parser a bit smaller, and it avoids a
1793 GCC warning that YYVAL may be used uninitialized. */
1794 yyval
= yyvsp
[1-yylen
];
1796 /* Default location. */
1797 YYLLOC_DEFAULT (yyloc
, (yylsp
- yylen
), yylen
);
1798 YY_REDUCE_PRINT (yyn
);
1803 /* Line 1464 of yacc.c */
1804 #line 186 "glcpp/glcpp-parse.y"
1806 ralloc_strcat (&parser
->output
, "\n");
1812 /* Line 1464 of yacc.c */
1813 #line 189 "glcpp/glcpp-parse.y"
1815 _glcpp_parser_print_expanded_token_list (parser
, (yyvsp
[(1) - (1)].token_list
));
1816 ralloc_strcat (&parser
->output
, "\n");
1817 ralloc_free ((yyvsp
[(1) - (1)].token_list
));
1823 /* Line 1464 of yacc.c */
1824 #line 199 "glcpp/glcpp-parse.y"
1826 _glcpp_parser_skip_stack_push_if (parser
, & (yylsp
[(1) - (3)]), (yyvsp
[(2) - (3)].ival
));
1832 /* Line 1464 of yacc.c */
1833 #line 202 "glcpp/glcpp-parse.y"
1835 _glcpp_parser_skip_stack_change_if (parser
, & (yylsp
[(1) - (3)]), "elif", (yyvsp
[(2) - (3)].ival
));
1841 /* Line 1464 of yacc.c */
1842 #line 208 "glcpp/glcpp-parse.y"
1844 _define_object_macro (parser
, & (yylsp
[(2) - (4)]), (yyvsp
[(2) - (4)].str
), (yyvsp
[(3) - (4)].token_list
));
1850 /* Line 1464 of yacc.c */
1851 #line 211 "glcpp/glcpp-parse.y"
1853 _define_function_macro (parser
, & (yylsp
[(2) - (6)]), (yyvsp
[(2) - (6)].str
), NULL
, (yyvsp
[(5) - (6)].token_list
));
1859 /* Line 1464 of yacc.c */
1860 #line 214 "glcpp/glcpp-parse.y"
1862 _define_function_macro (parser
, & (yylsp
[(2) - (7)]), (yyvsp
[(2) - (7)].str
), (yyvsp
[(4) - (7)].string_list
), (yyvsp
[(6) - (7)].token_list
));
1868 /* Line 1464 of yacc.c */
1869 #line 217 "glcpp/glcpp-parse.y"
1871 macro_t
*macro
= hash_table_find (parser
->defines
, (yyvsp
[(2) - (3)].str
));
1873 hash_table_remove (parser
->defines
, (yyvsp
[(2) - (3)].str
));
1874 ralloc_free (macro
);
1876 ralloc_free ((yyvsp
[(2) - (3)].str
));
1882 /* Line 1464 of yacc.c */
1883 #line 225 "glcpp/glcpp-parse.y"
1885 /* Be careful to only evaluate the 'if' expression if
1886 * we are not skipping. When we are skipping, we
1887 * simply push a new 0-valued 'if' onto the skip
1890 * This avoids generating diagnostics for invalid
1891 * expressions that are being skipped. */
1892 if (parser
->skip_stack
== NULL
||
1893 parser
->skip_stack
->type
== SKIP_NO_SKIP
)
1895 _glcpp_parser_expand_if (parser
, IF_EXPANDED
, (yyvsp
[(2) - (3)].token_list
));
1899 _glcpp_parser_skip_stack_push_if (parser
, & (yylsp
[(1) - (3)]), 0);
1900 parser
->skip_stack
->type
= SKIP_TO_ENDIF
;
1907 /* Line 1464 of yacc.c */
1908 #line 244 "glcpp/glcpp-parse.y"
1910 /* #if without an expression is only an error if we
1911 * are not skipping */
1912 if (parser
->skip_stack
== NULL
||
1913 parser
->skip_stack
->type
== SKIP_NO_SKIP
)
1915 glcpp_error(& (yylsp
[(1) - (2)]), parser
, "#if with no expression");
1917 _glcpp_parser_skip_stack_push_if (parser
, & (yylsp
[(1) - (2)]), 0);
1923 /* Line 1464 of yacc.c */
1924 #line 254 "glcpp/glcpp-parse.y"
1926 macro_t
*macro
= hash_table_find (parser
->defines
, (yyvsp
[(2) - (4)].str
));
1927 ralloc_free ((yyvsp
[(2) - (4)].str
));
1928 _glcpp_parser_skip_stack_push_if (parser
, & (yylsp
[(1) - (4)]), macro
!= NULL
);
1934 /* Line 1464 of yacc.c */
1935 #line 259 "glcpp/glcpp-parse.y"
1937 macro_t
*macro
= hash_table_find (parser
->defines
, (yyvsp
[(2) - (4)].str
));
1938 ralloc_free ((yyvsp
[(2) - (4)].str
));
1939 _glcpp_parser_skip_stack_push_if (parser
, & (yylsp
[(1) - (4)]), macro
== NULL
);
1945 /* Line 1464 of yacc.c */
1946 #line 264 "glcpp/glcpp-parse.y"
1948 /* Be careful to only evaluate the 'elif' expression
1949 * if we are not skipping. When we are skipping, we
1950 * simply change to a 0-valued 'elif' on the skip
1953 * This avoids generating diagnostics for invalid
1954 * expressions that are being skipped. */
1955 if (parser
->skip_stack
&&
1956 parser
->skip_stack
->type
== SKIP_TO_ELSE
)
1958 _glcpp_parser_expand_if (parser
, ELIF_EXPANDED
, (yyvsp
[(2) - (3)].token_list
));
1962 _glcpp_parser_skip_stack_change_if (parser
, & (yylsp
[(1) - (3)]),
1970 /* Line 1464 of yacc.c */
1971 #line 283 "glcpp/glcpp-parse.y"
1973 /* #elif without an expression is an error unless we
1975 if (parser
->skip_stack
&&
1976 parser
->skip_stack
->type
== SKIP_TO_ELSE
)
1978 glcpp_error(& (yylsp
[(1) - (2)]), parser
, "#elif with no expression");
1982 _glcpp_parser_skip_stack_change_if (parser
, & (yylsp
[(1) - (2)]),
1984 glcpp_warning(& (yylsp
[(1) - (2)]), parser
, "ignoring illegal #elif without expression");
1991 /* Line 1464 of yacc.c */
1992 #line 298 "glcpp/glcpp-parse.y"
1994 _glcpp_parser_skip_stack_change_if (parser
, & (yylsp
[(1) - (2)]), "else", 1);
2000 /* Line 1464 of yacc.c */
2001 #line 301 "glcpp/glcpp-parse.y"
2003 _glcpp_parser_skip_stack_pop (parser
, & (yylsp
[(1) - (2)]));
2009 /* Line 1464 of yacc.c */
2010 #line 304 "glcpp/glcpp-parse.y"
2012 macro_t
*macro
= hash_table_find (parser
->defines
, "__VERSION__");
2014 hash_table_remove (parser
->defines
, "__VERSION__");
2015 ralloc_free (macro
);
2017 add_builtin_define (parser
, "__VERSION__", (yyvsp
[(2) - (3)].ival
));
2019 if ((yyvsp
[(2) - (3)].ival
) == 100)
2020 add_builtin_define (parser
, "GL_ES", 1);
2022 /* Currently, all ES2 implementations support highp in the
2023 * fragment shader, so we always define this macro in ES2.
2024 * If we ever get a driver that doesn't support highp, we'll
2025 * need to add a flag to the gl_context and check that here.
2027 if ((yyvsp
[(2) - (3)].ival
) >= 130 || (yyvsp
[(2) - (3)].ival
) == 100)
2028 add_builtin_define (parser
, "GL_FRAGMENT_PRECISION_HIGH", 1);
2030 ralloc_asprintf_append (&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 if ((yyvsp
[(3) - (3)].ival
) == 0) {
2199 yyerror (& (yylsp
[(1) - (3)]), parser
,
2200 "zero modulus in preprocessor directive");
2202 (yyval
.ival
) = (yyvsp
[(1) - (3)].ival
) % (yyvsp
[(3) - (3)].ival
);
2209 /* Line 1464 of yacc.c */
2210 #line 397 "glcpp/glcpp-parse.y"
2212 if ((yyvsp
[(3) - (3)].ival
) == 0) {
2213 yyerror (& (yylsp
[(1) - (3)]), parser
,
2214 "division by 0 in preprocessor directive");
2216 (yyval
.ival
) = (yyvsp
[(1) - (3)].ival
) / (yyvsp
[(3) - (3)].ival
);
2223 /* Line 1464 of yacc.c */
2224 #line 405 "glcpp/glcpp-parse.y"
2226 (yyval
.ival
) = (yyvsp
[(1) - (3)].ival
) * (yyvsp
[(3) - (3)].ival
);
2232 /* Line 1464 of yacc.c */
2233 #line 408 "glcpp/glcpp-parse.y"
2235 (yyval
.ival
) = ! (yyvsp
[(2) - (2)].ival
);
2241 /* Line 1464 of yacc.c */
2242 #line 411 "glcpp/glcpp-parse.y"
2244 (yyval
.ival
) = ~ (yyvsp
[(2) - (2)].ival
);
2250 /* Line 1464 of yacc.c */
2251 #line 414 "glcpp/glcpp-parse.y"
2253 (yyval
.ival
) = - (yyvsp
[(2) - (2)].ival
);
2259 /* Line 1464 of yacc.c */
2260 #line 417 "glcpp/glcpp-parse.y"
2262 (yyval
.ival
) = + (yyvsp
[(2) - (2)].ival
);
2268 /* Line 1464 of yacc.c */
2269 #line 420 "glcpp/glcpp-parse.y"
2271 (yyval
.ival
) = (yyvsp
[(2) - (3)].ival
);
2277 /* Line 1464 of yacc.c */
2278 #line 426 "glcpp/glcpp-parse.y"
2280 (yyval
.string_list
) = _string_list_create (parser
);
2281 _string_list_append_item ((yyval
.string_list
), (yyvsp
[(1) - (1)].str
));
2282 ralloc_steal ((yyval
.string_list
), (yyvsp
[(1) - (1)].str
));
2288 /* Line 1464 of yacc.c */
2289 #line 431 "glcpp/glcpp-parse.y"
2291 (yyval
.string_list
) = (yyvsp
[(1) - (3)].string_list
);
2292 _string_list_append_item ((yyval
.string_list
), (yyvsp
[(3) - (3)].str
));
2293 ralloc_steal ((yyval
.string_list
), (yyvsp
[(3) - (3)].str
));
2299 /* Line 1464 of yacc.c */
2300 #line 439 "glcpp/glcpp-parse.y"
2301 { (yyval
.token_list
) = NULL
; ;}
2306 /* Line 1464 of yacc.c */
2307 #line 444 "glcpp/glcpp-parse.y"
2309 yyerror (& (yylsp
[(1) - (2)]), parser
, "Invalid tokens after #");
2315 /* Line 1464 of yacc.c */
2316 #line 450 "glcpp/glcpp-parse.y"
2317 { (yyval
.token_list
) = NULL
; ;}
2322 /* Line 1464 of yacc.c */
2323 #line 456 "glcpp/glcpp-parse.y"
2325 glcpp_warning(&(yylsp
[(1) - (1)]), parser
, "extra tokens at end of directive");
2331 /* Line 1464 of yacc.c */
2332 #line 463 "glcpp/glcpp-parse.y"
2334 int v
= hash_table_find (parser
->defines
, (yyvsp
[(2) - (2)].str
)) ? 1 : 0;
2335 (yyval
.token
) = _token_create_ival (parser
, INTEGER
, v
);
2341 /* Line 1464 of yacc.c */
2342 #line 467 "glcpp/glcpp-parse.y"
2344 int v
= hash_table_find (parser
->defines
, (yyvsp
[(3) - (4)].str
)) ? 1 : 0;
2345 (yyval
.token
) = _token_create_ival (parser
, INTEGER
, v
);
2351 /* Line 1464 of yacc.c */
2352 #line 476 "glcpp/glcpp-parse.y"
2354 (yyval
.token_list
) = _token_list_create (parser
);
2355 _token_list_append ((yyval
.token_list
), (yyvsp
[(1) - (1)].token
));
2361 /* Line 1464 of yacc.c */
2362 #line 480 "glcpp/glcpp-parse.y"
2364 (yyval
.token_list
) = (yyvsp
[(1) - (2)].token_list
);
2365 _token_list_append ((yyval
.token_list
), (yyvsp
[(2) - (2)].token
));
2371 /* Line 1464 of yacc.c */
2372 #line 487 "glcpp/glcpp-parse.y"
2374 parser
->space_tokens
= 1;
2375 (yyval
.token_list
) = _token_list_create (parser
);
2376 _token_list_append ((yyval
.token_list
), (yyvsp
[(1) - (1)].token
));
2382 /* Line 1464 of yacc.c */
2383 #line 492 "glcpp/glcpp-parse.y"
2385 (yyval
.token_list
) = (yyvsp
[(1) - (2)].token_list
);
2386 _token_list_append ((yyval
.token_list
), (yyvsp
[(2) - (2)].token
));
2392 /* Line 1464 of yacc.c */
2393 #line 499 "glcpp/glcpp-parse.y"
2395 (yyval
.token
) = _token_create_str (parser
, IDENTIFIER
, (yyvsp
[(1) - (1)].str
));
2396 (yyval
.token
)->location
= yylloc
;
2402 /* Line 1464 of yacc.c */
2403 #line 503 "glcpp/glcpp-parse.y"
2405 (yyval
.token
) = _token_create_str (parser
, INTEGER_STRING
, (yyvsp
[(1) - (1)].str
));
2406 (yyval
.token
)->location
= yylloc
;
2412 /* Line 1464 of yacc.c */
2413 #line 507 "glcpp/glcpp-parse.y"
2415 (yyval
.token
) = _token_create_ival (parser
, (yyvsp
[(1) - (1)].ival
), (yyvsp
[(1) - (1)].ival
));
2416 (yyval
.token
)->location
= yylloc
;
2422 /* Line 1464 of yacc.c */
2423 #line 511 "glcpp/glcpp-parse.y"
2425 (yyval
.token
) = _token_create_str (parser
, OTHER
, (yyvsp
[(1) - (1)].str
));
2426 (yyval
.token
)->location
= yylloc
;
2432 /* Line 1464 of yacc.c */
2433 #line 515 "glcpp/glcpp-parse.y"
2435 (yyval
.token
) = _token_create_ival (parser
, SPACE
, SPACE
);
2436 (yyval
.token
)->location
= yylloc
;
2442 /* Line 1464 of yacc.c */
2443 #line 522 "glcpp/glcpp-parse.y"
2444 { (yyval
.ival
) = '['; ;}
2449 /* Line 1464 of yacc.c */
2450 #line 523 "glcpp/glcpp-parse.y"
2451 { (yyval
.ival
) = ']'; ;}
2456 /* Line 1464 of yacc.c */
2457 #line 524 "glcpp/glcpp-parse.y"
2458 { (yyval
.ival
) = '('; ;}
2463 /* Line 1464 of yacc.c */
2464 #line 525 "glcpp/glcpp-parse.y"
2465 { (yyval
.ival
) = ')'; ;}
2470 /* Line 1464 of yacc.c */
2471 #line 526 "glcpp/glcpp-parse.y"
2472 { (yyval
.ival
) = '{'; ;}
2477 /* Line 1464 of yacc.c */
2478 #line 527 "glcpp/glcpp-parse.y"
2479 { (yyval
.ival
) = '}'; ;}
2484 /* Line 1464 of yacc.c */
2485 #line 528 "glcpp/glcpp-parse.y"
2486 { (yyval
.ival
) = '.'; ;}
2491 /* Line 1464 of yacc.c */
2492 #line 529 "glcpp/glcpp-parse.y"
2493 { (yyval
.ival
) = '&'; ;}
2498 /* Line 1464 of yacc.c */
2499 #line 530 "glcpp/glcpp-parse.y"
2500 { (yyval
.ival
) = '*'; ;}
2505 /* Line 1464 of yacc.c */
2506 #line 531 "glcpp/glcpp-parse.y"
2507 { (yyval
.ival
) = '+'; ;}
2512 /* Line 1464 of yacc.c */
2513 #line 532 "glcpp/glcpp-parse.y"
2514 { (yyval
.ival
) = '-'; ;}
2519 /* Line 1464 of yacc.c */
2520 #line 533 "glcpp/glcpp-parse.y"
2521 { (yyval
.ival
) = '~'; ;}
2526 /* Line 1464 of yacc.c */
2527 #line 534 "glcpp/glcpp-parse.y"
2528 { (yyval
.ival
) = '!'; ;}
2533 /* Line 1464 of yacc.c */
2534 #line 535 "glcpp/glcpp-parse.y"
2535 { (yyval
.ival
) = '/'; ;}
2540 /* Line 1464 of yacc.c */
2541 #line 536 "glcpp/glcpp-parse.y"
2542 { (yyval
.ival
) = '%'; ;}
2547 /* Line 1464 of yacc.c */
2548 #line 537 "glcpp/glcpp-parse.y"
2549 { (yyval
.ival
) = LEFT_SHIFT
; ;}
2554 /* Line 1464 of yacc.c */
2555 #line 538 "glcpp/glcpp-parse.y"
2556 { (yyval
.ival
) = RIGHT_SHIFT
; ;}
2561 /* Line 1464 of yacc.c */
2562 #line 539 "glcpp/glcpp-parse.y"
2563 { (yyval
.ival
) = '<'; ;}
2568 /* Line 1464 of yacc.c */
2569 #line 540 "glcpp/glcpp-parse.y"
2570 { (yyval
.ival
) = '>'; ;}
2575 /* Line 1464 of yacc.c */
2576 #line 541 "glcpp/glcpp-parse.y"
2577 { (yyval
.ival
) = LESS_OR_EQUAL
; ;}
2582 /* Line 1464 of yacc.c */
2583 #line 542 "glcpp/glcpp-parse.y"
2584 { (yyval
.ival
) = GREATER_OR_EQUAL
; ;}
2589 /* Line 1464 of yacc.c */
2590 #line 543 "glcpp/glcpp-parse.y"
2591 { (yyval
.ival
) = EQUAL
; ;}
2596 /* Line 1464 of yacc.c */
2597 #line 544 "glcpp/glcpp-parse.y"
2598 { (yyval
.ival
) = NOT_EQUAL
; ;}
2603 /* Line 1464 of yacc.c */
2604 #line 545 "glcpp/glcpp-parse.y"
2605 { (yyval
.ival
) = '^'; ;}
2610 /* Line 1464 of yacc.c */
2611 #line 546 "glcpp/glcpp-parse.y"
2612 { (yyval
.ival
) = '|'; ;}
2617 /* Line 1464 of yacc.c */
2618 #line 547 "glcpp/glcpp-parse.y"
2619 { (yyval
.ival
) = AND
; ;}
2624 /* Line 1464 of yacc.c */
2625 #line 548 "glcpp/glcpp-parse.y"
2626 { (yyval
.ival
) = OR
; ;}
2631 /* Line 1464 of yacc.c */
2632 #line 549 "glcpp/glcpp-parse.y"
2633 { (yyval
.ival
) = ';'; ;}
2638 /* Line 1464 of yacc.c */
2639 #line 550 "glcpp/glcpp-parse.y"
2640 { (yyval
.ival
) = ','; ;}
2645 /* Line 1464 of yacc.c */
2646 #line 551 "glcpp/glcpp-parse.y"
2647 { (yyval
.ival
) = '='; ;}
2652 /* Line 1464 of yacc.c */
2653 #line 552 "glcpp/glcpp-parse.y"
2654 { (yyval
.ival
) = PASTE
; ;}
2659 /* Line 1464 of yacc.c */
2660 #line 2661 "glcpp/glcpp-parse.c"
2663 YY_SYMBOL_PRINT ("-> $$ =", yyr1
[yyn
], &yyval
, &yyloc
);
2667 YY_STACK_PRINT (yyss
, yyssp
);
2672 /* Now `shift' the result of the reduction. Determine what state
2673 that goes to, based on the state we popped back to and the rule
2674 number reduced by. */
2678 yystate
= yypgoto
[yyn
- YYNTOKENS
] + *yyssp
;
2679 if (0 <= yystate
&& yystate
<= YYLAST
&& yycheck
[yystate
] == *yyssp
)
2680 yystate
= yytable
[yystate
];
2682 yystate
= yydefgoto
[yyn
- YYNTOKENS
];
2687 /*------------------------------------.
2688 | yyerrlab -- here on detecting error |
2689 `------------------------------------*/
2691 /* If not already recovering from an error, report this error. */
2695 #if ! YYERROR_VERBOSE
2696 yyerror (&yylloc
, parser
, YY_("syntax error"));
2699 YYSIZE_T yysize
= yysyntax_error (0, yystate
, yychar
);
2700 if (yymsg_alloc
< yysize
&& yymsg_alloc
< YYSTACK_ALLOC_MAXIMUM
)
2702 YYSIZE_T yyalloc
= 2 * yysize
;
2703 if (! (yysize
<= yyalloc
&& yyalloc
<= YYSTACK_ALLOC_MAXIMUM
))
2704 yyalloc
= YYSTACK_ALLOC_MAXIMUM
;
2705 if (yymsg
!= yymsgbuf
)
2706 YYSTACK_FREE (yymsg
);
2707 yymsg
= (char *) YYSTACK_ALLOC (yyalloc
);
2709 yymsg_alloc
= yyalloc
;
2713 yymsg_alloc
= sizeof yymsgbuf
;
2717 if (0 < yysize
&& yysize
<= yymsg_alloc
)
2719 (void) yysyntax_error (yymsg
, yystate
, yychar
);
2720 yyerror (&yylloc
, parser
, yymsg
);
2724 yyerror (&yylloc
, parser
, YY_("syntax error"));
2726 goto yyexhaustedlab
;
2732 yyerror_range
[1] = yylloc
;
2734 if (yyerrstatus
== 3)
2736 /* If just tried and failed to reuse lookahead token after an
2737 error, discard it. */
2739 if (yychar
<= YYEOF
)
2741 /* Return failure if at end of input. */
2742 if (yychar
== YYEOF
)
2747 yydestruct ("Error: discarding",
2748 yytoken
, &yylval
, &yylloc
, parser
);
2753 /* Else will try to reuse lookahead token after shifting the error
2758 /*---------------------------------------------------.
2759 | yyerrorlab -- error raised explicitly by YYERROR. |
2760 `---------------------------------------------------*/
2763 /* Pacify compilers like GCC when the user code never invokes
2764 YYERROR and the label yyerrorlab therefore never appears in user
2766 if (/*CONSTCOND*/ 0)
2769 yyerror_range
[1] = yylsp
[1-yylen
];
2770 /* Do not reclaim the symbols of the rule which action triggered
2774 YY_STACK_PRINT (yyss
, yyssp
);
2779 /*-------------------------------------------------------------.
2780 | yyerrlab1 -- common code for both syntax error and YYERROR. |
2781 `-------------------------------------------------------------*/
2783 yyerrstatus
= 3; /* Each real token shifted decrements this. */
2787 yyn
= yypact
[yystate
];
2788 if (yyn
!= YYPACT_NINF
)
2791 if (0 <= yyn
&& yyn
<= YYLAST
&& yycheck
[yyn
] == YYTERROR
)
2799 /* Pop the current state because it cannot handle the error token. */
2803 yyerror_range
[1] = *yylsp
;
2804 yydestruct ("Error: popping",
2805 yystos
[yystate
], yyvsp
, yylsp
, parser
);
2808 YY_STACK_PRINT (yyss
, yyssp
);
2813 yyerror_range
[2] = yylloc
;
2814 /* Using YYLLOC is tempting, but would change the location of
2815 the lookahead. YYLOC is available though. */
2816 YYLLOC_DEFAULT (yyloc
, yyerror_range
, 2);
2819 /* Shift the error token. */
2820 YY_SYMBOL_PRINT ("Shifting", yystos
[yyn
], yyvsp
, yylsp
);
2826 /*-------------------------------------.
2827 | yyacceptlab -- YYACCEPT comes here. |
2828 `-------------------------------------*/
2833 /*-----------------------------------.
2834 | yyabortlab -- YYABORT comes here. |
2835 `-----------------------------------*/
2840 #if !defined(yyoverflow) || YYERROR_VERBOSE
2841 /*-------------------------------------------------.
2842 | yyexhaustedlab -- memory exhaustion comes here. |
2843 `-------------------------------------------------*/
2845 yyerror (&yylloc
, parser
, YY_("memory exhausted"));
2851 if (yychar
!= YYEMPTY
)
2852 yydestruct ("Cleanup: discarding lookahead",
2853 yytoken
, &yylval
, &yylloc
, parser
);
2854 /* Do not reclaim the symbols of the rule which action triggered
2855 this YYABORT or YYACCEPT. */
2857 YY_STACK_PRINT (yyss
, yyssp
);
2858 while (yyssp
!= yyss
)
2860 yydestruct ("Cleanup: popping",
2861 yystos
[*yyssp
], yyvsp
, yylsp
, parser
);
2866 YYSTACK_FREE (yyss
);
2869 if (yymsg
!= yymsgbuf
)
2870 YYSTACK_FREE (yymsg
);
2872 /* Make sure YYID is used. */
2873 return YYID (yyresult
);
2878 /* Line 1684 of yacc.c */
2879 #line 555 "glcpp/glcpp-parse.y"
2883 _string_list_create (void *ctx
)
2885 string_list_t
*list
;
2887 list
= ralloc (ctx
, string_list_t
);
2895 _string_list_append_item (string_list_t
*list
, const char *str
)
2897 string_node_t
*node
;
2899 node
= ralloc (list
, string_node_t
);
2900 node
->str
= ralloc_strdup (node
, str
);
2904 if (list
->head
== NULL
) {
2907 list
->tail
->next
= node
;
2914 _string_list_contains (string_list_t
*list
, const char *member
, int *index
)
2916 string_node_t
*node
;
2922 for (i
= 0, node
= list
->head
; node
; i
++, node
= node
->next
) {
2923 if (strcmp (node
->str
, member
) == 0) {
2934 _string_list_length (string_list_t
*list
)
2937 string_node_t
*node
;
2942 for (node
= list
->head
; node
; node
= node
->next
)
2949 _string_list_equal (string_list_t
*a
, string_list_t
*b
)
2951 string_node_t
*node_a
, *node_b
;
2953 if (a
== NULL
&& b
== NULL
)
2956 if (a
== NULL
|| b
== NULL
)
2959 for (node_a
= a
->head
, node_b
= b
->head
;
2961 node_a
= node_a
->next
, node_b
= node_b
->next
)
2963 if (strcmp (node_a
->str
, node_b
->str
))
2967 /* Catch the case of lists being different lengths, (which
2968 * would cause the loop above to terminate after the shorter
2970 return node_a
== node_b
;
2974 _argument_list_create (void *ctx
)
2976 argument_list_t
*list
;
2978 list
= ralloc (ctx
, argument_list_t
);
2986 _argument_list_append (argument_list_t
*list
, token_list_t
*argument
)
2988 argument_node_t
*node
;
2990 node
= ralloc (list
, argument_node_t
);
2991 node
->argument
= argument
;
2995 if (list
->head
== NULL
) {
2998 list
->tail
->next
= node
;
3005 _argument_list_length (argument_list_t
*list
)
3008 argument_node_t
*node
;
3013 for (node
= list
->head
; node
; node
= node
->next
)
3020 _argument_list_member_at (argument_list_t
*list
, int index
)
3022 argument_node_t
*node
;
3029 for (i
= 0; i
< index
; i
++) {
3036 return node
->argument
;
3041 /* Note: This function ralloc_steal()s the str pointer. */
3043 _token_create_str (void *ctx
, int type
, char *str
)
3047 token
= ralloc (ctx
, token_t
);
3049 token
->value
.str
= str
;
3051 ralloc_steal (token
, str
);
3057 _token_create_ival (void *ctx
, int type
, int ival
)
3061 token
= ralloc (ctx
, token_t
);
3063 token
->value
.ival
= ival
;
3069 _token_list_create (void *ctx
)
3073 list
= ralloc (ctx
, token_list_t
);
3076 list
->non_space_tail
= NULL
;
3082 _token_list_append (token_list_t
*list
, token_t
*token
)
3086 node
= ralloc (list
, token_node_t
);
3087 node
->token
= token
;
3090 if (list
->head
== NULL
) {
3093 list
->tail
->next
= node
;
3097 if (token
->type
!= SPACE
)
3098 list
->non_space_tail
= node
;
3102 _token_list_append_list (token_list_t
*list
, token_list_t
*tail
)
3104 if (tail
== NULL
|| tail
->head
== NULL
)
3107 if (list
->head
== NULL
) {
3108 list
->head
= tail
->head
;
3110 list
->tail
->next
= tail
->head
;
3113 list
->tail
= tail
->tail
;
3114 list
->non_space_tail
= tail
->non_space_tail
;
3117 static token_list_t
*
3118 _token_list_copy (void *ctx
, token_list_t
*other
)
3126 copy
= _token_list_create (ctx
);
3127 for (node
= other
->head
; node
; node
= node
->next
) {
3128 token_t
*new_token
= ralloc (copy
, token_t
);
3129 *new_token
= *node
->token
;
3130 _token_list_append (copy
, new_token
);
3137 _token_list_trim_trailing_space (token_list_t
*list
)
3139 token_node_t
*tail
, *next
;
3141 if (list
->non_space_tail
) {
3142 tail
= list
->non_space_tail
->next
;
3143 list
->non_space_tail
->next
= NULL
;
3144 list
->tail
= list
->non_space_tail
;
3155 _token_list_is_empty_ignoring_space (token_list_t
*l
)
3163 while (n
!= NULL
&& n
->token
->type
== SPACE
)
3170 _token_list_equal_ignoring_space (token_list_t
*a
, token_list_t
*b
)
3172 token_node_t
*node_a
, *node_b
;
3174 if (a
== NULL
|| b
== NULL
) {
3175 int a_empty
= _token_list_is_empty_ignoring_space(a
);
3176 int b_empty
= _token_list_is_empty_ignoring_space(b
);
3177 return a_empty
== b_empty
;
3185 if (node_a
== NULL
&& node_b
== NULL
)
3188 if (node_a
== NULL
|| node_b
== NULL
)
3191 if (node_a
->token
->type
== SPACE
) {
3192 node_a
= node_a
->next
;
3196 if (node_b
->token
->type
== SPACE
) {
3197 node_b
= node_b
->next
;
3201 if (node_a
->token
->type
!= node_b
->token
->type
)
3204 switch (node_a
->token
->type
) {
3206 if (node_a
->token
->value
.ival
!=
3207 node_b
->token
->value
.ival
)
3213 case INTEGER_STRING
:
3215 if (strcmp (node_a
->token
->value
.str
,
3216 node_b
->token
->value
.str
))
3223 node_a
= node_a
->next
;
3224 node_b
= node_b
->next
;
3231 _token_print (char **out
, token_t
*token
)
3233 if (token
->type
< 256) {
3234 ralloc_asprintf_append (out
, "%c", token
->type
);
3238 switch (token
->type
) {
3240 ralloc_asprintf_append (out
, "%" PRIiMAX
, token
->value
.ival
);
3243 case INTEGER_STRING
:
3245 ralloc_strcat (out
, token
->value
.str
);
3248 ralloc_strcat (out
, " ");
3251 ralloc_strcat (out
, "<<");
3254 ralloc_strcat (out
, ">>");
3257 ralloc_strcat (out
, "<=");
3259 case GREATER_OR_EQUAL
:
3260 ralloc_strcat (out
, ">=");
3263 ralloc_strcat (out
, "==");
3266 ralloc_strcat (out
, "!=");
3269 ralloc_strcat (out
, "&&");
3272 ralloc_strcat (out
, "||");
3275 ralloc_strcat (out
, "##");
3278 ralloc_strcat (out
, ",");
3281 /* Nothing to print. */
3284 assert(!"Error: Don't know how to print token.");
3289 /* Return a new token (ralloc()ed off of 'token') formed by pasting
3290 * 'token' and 'other'. Note that this function may return 'token' or
3291 * 'other' directly rather than allocating anything new.
3293 * Caution: Only very cursory error-checking is performed to see if
3294 * the final result is a valid single token. */
3296 _token_paste (glcpp_parser_t
*parser
, token_t
*token
, token_t
*other
)
3298 token_t
*combined
= NULL
;
3300 /* Pasting a placeholder onto anything makes no change. */
3301 if (other
->type
== PLACEHOLDER
)
3304 /* When 'token' is a placeholder, just return 'other'. */
3305 if (token
->type
== PLACEHOLDER
)
3308 /* A very few single-character punctuators can be combined
3309 * with another to form a multi-character punctuator. */
3310 switch (token
->type
) {
3312 if (other
->type
== '<')
3313 combined
= _token_create_ival (token
, LEFT_SHIFT
, LEFT_SHIFT
);
3314 else if (other
->type
== '=')
3315 combined
= _token_create_ival (token
, LESS_OR_EQUAL
, LESS_OR_EQUAL
);
3318 if (other
->type
== '>')
3319 combined
= _token_create_ival (token
, RIGHT_SHIFT
, RIGHT_SHIFT
);
3320 else if (other
->type
== '=')
3321 combined
= _token_create_ival (token
, GREATER_OR_EQUAL
, GREATER_OR_EQUAL
);
3324 if (other
->type
== '=')
3325 combined
= _token_create_ival (token
, EQUAL
, EQUAL
);
3328 if (other
->type
== '=')
3329 combined
= _token_create_ival (token
, NOT_EQUAL
, NOT_EQUAL
);
3332 if (other
->type
== '&')
3333 combined
= _token_create_ival (token
, AND
, AND
);
3336 if (other
->type
== '|')
3337 combined
= _token_create_ival (token
, OR
, OR
);
3341 if (combined
!= NULL
) {
3342 /* Inherit the location from the first token */
3343 combined
->location
= token
->location
;
3347 /* Two string-valued tokens can usually just be mashed
3350 * XXX: This isn't actually legitimate. Several things here
3351 * should result in a diagnostic since the result cannot be a
3352 * valid, single pre-processing token. For example, pasting
3353 * "123" and "abc" is not legal, but we don't catch that
3355 if ((token
->type
== IDENTIFIER
|| token
->type
== OTHER
|| token
->type
== INTEGER_STRING
) &&
3356 (other
->type
== IDENTIFIER
|| other
->type
== OTHER
|| other
->type
== INTEGER_STRING
))
3360 str
= ralloc_asprintf (token
, "%s%s", token
->value
.str
,
3362 combined
= _token_create_str (token
, token
->type
, str
);
3363 combined
->location
= token
->location
;
3367 glcpp_error (&token
->location
, parser
, "");
3368 ralloc_strcat (&parser
->info_log
, "Pasting \"");
3369 _token_print (&parser
->info_log
, token
);
3370 ralloc_strcat (&parser
->info_log
, "\" and \"");
3371 _token_print (&parser
->info_log
, other
);
3372 ralloc_strcat (&parser
->info_log
, "\" does not give a valid preprocessing token.\n");
3378 _token_list_print (glcpp_parser_t
*parser
, token_list_t
*list
)
3385 for (node
= list
->head
; node
; node
= node
->next
)
3386 _token_print (&parser
->output
, node
->token
);
3390 yyerror (YYLTYPE
*locp
, glcpp_parser_t
*parser
, const char *error
)
3392 glcpp_error(locp
, parser
, "%s", error
);
3395 static void add_builtin_define(glcpp_parser_t
*parser
,
3396 const char *name
, int value
)
3401 tok
= _token_create_ival (parser
, INTEGER
, value
);
3403 list
= _token_list_create(parser
);
3404 _token_list_append(list
, tok
);
3405 _define_object_macro(parser
, NULL
, name
, list
);
3409 glcpp_parser_create (const struct gl_extensions
*extensions
)
3411 glcpp_parser_t
*parser
;
3412 int language_version
;
3414 parser
= ralloc (NULL
, glcpp_parser_t
);
3416 glcpp_lex_init_extra (parser
, &parser
->scanner
);
3417 parser
->defines
= hash_table_ctor (32, hash_table_string_hash
,
3418 hash_table_string_compare
);
3419 parser
->active
= NULL
;
3420 parser
->lexing_if
= 0;
3421 parser
->space_tokens
= 1;
3422 parser
->newline_as_space
= 0;
3423 parser
->in_control_line
= 0;
3424 parser
->paren_count
= 0;
3426 parser
->skip_stack
= NULL
;
3428 parser
->lex_from_list
= NULL
;
3429 parser
->lex_from_node
= NULL
;
3431 parser
->output
= ralloc_strdup(parser
, "");
3432 parser
->info_log
= ralloc_strdup(parser
, "");
3435 /* Add pre-defined macros. */
3436 add_builtin_define(parser
, "GL_ARB_draw_buffers", 1);
3438 if (extensions
!= NULL
) {
3440 if (extensions
->ARB_shader_texture_lod
)
3441 add_builtin_define(parser
, "GL_ARB_shader_texture_lod", 1);
3443 if (extensions
->ARB_conservative_depth
) {
3444 add_builtin_define(parser
, "GL_AMD_conservative_depth", 1);
3445 add_builtin_define(parser
, "GL_ARB_conservative_depth", 1);
3449 language_version
= 110;
3450 add_builtin_define(parser
, "__VERSION__", language_version
);
3456 glcpp_parser_parse (glcpp_parser_t
*parser
)
3458 return yyparse (parser
);
3462 glcpp_parser_destroy (glcpp_parser_t
*parser
)
3464 glcpp_lex_destroy (parser
->scanner
);
3465 hash_table_dtor (parser
->defines
);
3466 ralloc_free (parser
);
3469 typedef enum function_status
3471 FUNCTION_STATUS_SUCCESS
,
3472 FUNCTION_NOT_A_FUNCTION
,
3473 FUNCTION_UNBALANCED_PARENTHESES
3474 } function_status_t
;
3476 /* Find a set of function-like macro arguments by looking for a
3477 * balanced set of parentheses.
3479 * When called, 'node' should be the opening-parenthesis token, (or
3480 * perhaps preceeding SPACE tokens). Upon successful return *last will
3481 * be the last consumed node, (corresponding to the closing right
3486 * FUNCTION_STATUS_SUCCESS:
3488 * Successfully parsed a set of function arguments.
3490 * FUNCTION_NOT_A_FUNCTION:
3492 * Macro name not followed by a '('. This is not an error, but
3493 * simply that the macro name should be treated as a non-macro.
3495 * FUNCTION_UNBALANCED_PARENTHESES
3497 * Macro name is not followed by a balanced set of parentheses.
3499 static function_status_t
3500 _arguments_parse (argument_list_t
*arguments
,
3502 token_node_t
**last
)
3504 token_list_t
*argument
;
3509 /* Ignore whitespace before first parenthesis. */
3510 while (node
&& node
->token
->type
== SPACE
)
3513 if (node
== NULL
|| node
->token
->type
!= '(')
3514 return FUNCTION_NOT_A_FUNCTION
;
3518 argument
= _token_list_create (arguments
);
3519 _argument_list_append (arguments
, argument
);
3521 for (paren_count
= 1; node
; node
= node
->next
) {
3522 if (node
->token
->type
== '(')
3526 else if (node
->token
->type
== ')')
3529 if (paren_count
== 0)
3533 if (node
->token
->type
== ',' &&
3536 _token_list_trim_trailing_space (argument
);
3537 argument
= _token_list_create (arguments
);
3538 _argument_list_append (arguments
, argument
);
3541 if (argument
->head
== NULL
) {
3542 /* Don't treat initial whitespace as
3543 * part of the arguement. */
3544 if (node
->token
->type
== SPACE
)
3547 _token_list_append (argument
, node
->token
);
3552 return FUNCTION_UNBALANCED_PARENTHESES
;
3556 return FUNCTION_STATUS_SUCCESS
;
3559 static token_list_t
*
3560 _token_list_create_with_one_space (void *ctx
)
3565 list
= _token_list_create (ctx
);
3566 space
= _token_create_ival (list
, SPACE
, SPACE
);
3567 _token_list_append (list
, space
);
3573 _glcpp_parser_expand_if (glcpp_parser_t
*parser
, int type
, token_list_t
*list
)
3575 token_list_t
*expanded
;
3578 expanded
= _token_list_create (parser
);
3579 token
= _token_create_ival (parser
, type
, type
);
3580 _token_list_append (expanded
, token
);
3581 _glcpp_parser_expand_token_list (parser
, list
);
3582 _token_list_append_list (expanded
, list
);
3583 glcpp_parser_lex_from (parser
, expanded
);
3587 _glcpp_parser_apply_pastes (glcpp_parser_t
*parser
, token_list_t
*list
)
3594 token_node_t
*next_non_space
;
3596 /* Look ahead for a PASTE token, skipping space. */
3597 next_non_space
= node
->next
;
3598 while (next_non_space
&& next_non_space
->token
->type
== SPACE
)
3599 next_non_space
= next_non_space
->next
;
3601 if (next_non_space
== NULL
)
3604 if (next_non_space
->token
->type
!= PASTE
) {
3605 node
= next_non_space
;
3609 /* Now find the next non-space token after the PASTE. */
3610 next_non_space
= next_non_space
->next
;
3611 while (next_non_space
&& next_non_space
->token
->type
== SPACE
)
3612 next_non_space
= next_non_space
->next
;
3614 if (next_non_space
== NULL
) {
3615 yyerror (&node
->token
->location
, parser
, "'##' cannot appear at either end of a macro expansion\n");
3619 node
->token
= _token_paste (parser
, node
->token
, next_non_space
->token
);
3620 node
->next
= next_non_space
->next
;
3621 if (next_non_space
== list
->tail
)
3625 list
->non_space_tail
= list
->tail
;
3628 /* This is a helper function that's essentially part of the
3629 * implementation of _glcpp_parser_expand_node. It shouldn't be called
3630 * except for by that function.
3632 * Returns NULL if node is a simple token with no expansion, (that is,
3633 * although 'node' corresponds to an identifier defined as a
3634 * function-like macro, it is not followed with a parenthesized
3637 * Compute the complete expansion of node (which is a function-like
3638 * macro) and subsequent nodes which are arguments.
3640 * Returns the token list that results from the expansion and sets
3641 * *last to the last node in the list that was consumed by the
3642 * expansion. Specifically, *last will be set as follows: as the
3643 * token of the closing right parenthesis.
3645 static token_list_t
*
3646 _glcpp_parser_expand_function (glcpp_parser_t
*parser
,
3648 token_node_t
**last
)
3652 const char *identifier
;
3653 argument_list_t
*arguments
;
3654 function_status_t status
;
3655 token_list_t
*substituted
;
3656 int parameter_index
;
3658 identifier
= node
->token
->value
.str
;
3660 macro
= hash_table_find (parser
->defines
, identifier
);
3662 assert (macro
->is_function
);
3664 arguments
= _argument_list_create (parser
);
3665 status
= _arguments_parse (arguments
, node
, last
);
3668 case FUNCTION_STATUS_SUCCESS
:
3670 case FUNCTION_NOT_A_FUNCTION
:
3672 case FUNCTION_UNBALANCED_PARENTHESES
:
3673 glcpp_error (&node
->token
->location
, parser
, "Macro %s call has unbalanced parentheses\n", identifier
);
3677 /* Replace a macro defined as empty with a SPACE token. */
3678 if (macro
->replacements
== NULL
) {
3679 ralloc_free (arguments
);
3680 return _token_list_create_with_one_space (parser
);
3683 if (! ((_argument_list_length (arguments
) ==
3684 _string_list_length (macro
->parameters
)) ||
3685 (_string_list_length (macro
->parameters
) == 0 &&
3686 _argument_list_length (arguments
) == 1 &&
3687 arguments
->head
->argument
->head
== NULL
)))
3689 glcpp_error (&node
->token
->location
, parser
,
3690 "Error: macro %s invoked with %d arguments (expected %d)\n",
3692 _argument_list_length (arguments
),
3693 _string_list_length (macro
->parameters
));
3697 /* Perform argument substitution on the replacement list. */
3698 substituted
= _token_list_create (arguments
);
3700 for (node
= macro
->replacements
->head
; node
; node
= node
->next
)
3702 if (node
->token
->type
== IDENTIFIER
&&
3703 _string_list_contains (macro
->parameters
,
3704 node
->token
->value
.str
,
3707 token_list_t
*argument
;
3708 argument
= _argument_list_member_at (arguments
,
3710 /* Before substituting, we expand the argument
3711 * tokens, or append a placeholder token for
3712 * an empty argument. */
3713 if (argument
->head
) {
3714 token_list_t
*expanded_argument
;
3715 expanded_argument
= _token_list_copy (parser
,
3717 _glcpp_parser_expand_token_list (parser
,
3719 _token_list_append_list (substituted
,
3724 new_token
= _token_create_ival (substituted
,
3727 _token_list_append (substituted
, new_token
);
3730 _token_list_append (substituted
, node
->token
);
3734 /* After argument substitution, and before further expansion
3735 * below, implement token pasting. */
3737 _token_list_trim_trailing_space (substituted
);
3739 _glcpp_parser_apply_pastes (parser
, substituted
);
3744 /* Compute the complete expansion of node, (and subsequent nodes after
3745 * 'node' in the case that 'node' is a function-like macro and
3746 * subsequent nodes are arguments).
3748 * Returns NULL if node is a simple token with no expansion.
3750 * Otherwise, returns the token list that results from the expansion
3751 * and sets *last to the last node in the list that was consumed by
3752 * the expansion. Specifically, *last will be set as follows:
3754 * As 'node' in the case of object-like macro expansion.
3756 * As the token of the closing right parenthesis in the case of
3757 * function-like macro expansion.
3759 static token_list_t
*
3760 _glcpp_parser_expand_node (glcpp_parser_t
*parser
,
3762 token_node_t
**last
)
3764 token_t
*token
= node
->token
;
3765 const char *identifier
;
3768 /* We only expand identifiers */
3769 if (token
->type
!= IDENTIFIER
) {
3770 /* We change any COMMA into a COMMA_FINAL to prevent
3771 * it being mistaken for an argument separator
3773 if (token
->type
== ',') {
3774 token
->type
= COMMA_FINAL
;
3775 token
->value
.ival
= COMMA_FINAL
;
3781 /* Look up this identifier in the hash table. */
3782 identifier
= token
->value
.str
;
3783 macro
= hash_table_find (parser
->defines
, identifier
);
3785 /* Not a macro, so no expansion needed. */
3789 /* Finally, don't expand this macro if we're already actively
3790 * expanding it, (to avoid infinite recursion). */
3791 if (_parser_active_list_contains (parser
, identifier
)) {
3792 /* We change the token type here from IDENTIFIER to
3793 * OTHER to prevent any future expansion of this
3794 * unexpanded token. */
3796 token_list_t
*expansion
;
3799 str
= ralloc_strdup (parser
, token
->value
.str
);
3800 final
= _token_create_str (parser
, OTHER
, str
);
3801 expansion
= _token_list_create (parser
);
3802 _token_list_append (expansion
, final
);
3807 if (! macro
->is_function
)
3809 token_list_t
*replacement
;
3812 /* Replace a macro defined as empty with a SPACE token. */
3813 if (macro
->replacements
== NULL
)
3814 return _token_list_create_with_one_space (parser
);
3816 replacement
= _token_list_copy (parser
, macro
->replacements
);
3817 _glcpp_parser_apply_pastes (parser
, replacement
);
3821 return _glcpp_parser_expand_function (parser
, node
, last
);
3824 /* Push a new identifier onto the parser's active list.
3826 * Here, 'marker' is the token node that appears in the list after the
3827 * expansion of 'identifier'. That is, when the list iterator begins
3828 * examining 'marker', then it is time to pop this node from the
3832 _parser_active_list_push (glcpp_parser_t
*parser
,
3833 const char *identifier
,
3834 token_node_t
*marker
)
3836 active_list_t
*node
;
3838 node
= ralloc (parser
->active
, active_list_t
);
3839 node
->identifier
= ralloc_strdup (node
, identifier
);
3840 node
->marker
= marker
;
3841 node
->next
= parser
->active
;
3843 parser
->active
= node
;
3847 _parser_active_list_pop (glcpp_parser_t
*parser
)
3849 active_list_t
*node
= parser
->active
;
3852 parser
->active
= NULL
;
3856 node
= parser
->active
->next
;
3857 ralloc_free (parser
->active
);
3859 parser
->active
= node
;
3863 _parser_active_list_contains (glcpp_parser_t
*parser
, const char *identifier
)
3865 active_list_t
*node
;
3867 if (parser
->active
== NULL
)
3870 for (node
= parser
->active
; node
; node
= node
->next
)
3871 if (strcmp (node
->identifier
, identifier
) == 0)
3877 /* Walk over the token list replacing nodes with their expansion.
3878 * Whenever nodes are expanded the walking will walk over the new
3879 * nodes, continuing to expand as necessary. The results are placed in
3883 _glcpp_parser_expand_token_list (glcpp_parser_t
*parser
,
3886 token_node_t
*node_prev
;
3887 token_node_t
*node
, *last
= NULL
;
3888 token_list_t
*expansion
;
3889 active_list_t
*active_initial
= parser
->active
;
3894 _token_list_trim_trailing_space (list
);
3901 while (parser
->active
&& parser
->active
->marker
== node
)
3902 _parser_active_list_pop (parser
);
3904 expansion
= _glcpp_parser_expand_node (parser
, node
, &last
);
3908 for (n
= node
; n
!= last
->next
; n
= n
->next
)
3909 while (parser
->active
&&
3910 parser
->active
->marker
== n
)
3912 _parser_active_list_pop (parser
);
3915 _parser_active_list_push (parser
,
3916 node
->token
->value
.str
,
3919 /* Splice expansion into list, supporting a
3920 * simple deletion if the expansion is
3922 if (expansion
->head
) {
3924 node_prev
->next
= expansion
->head
;
3926 list
->head
= expansion
->head
;
3927 expansion
->tail
->next
= last
->next
;
3928 if (last
== list
->tail
)
3929 list
->tail
= expansion
->tail
;
3932 node_prev
->next
= last
->next
;
3934 list
->head
= last
->next
;
3935 if (last
== list
->tail
)
3941 node
= node_prev
? node_prev
->next
: list
->head
;
3944 /* Remove any lingering effects of this invocation on the
3945 * active list. That is, pop until the list looks like it did
3946 * at the beginning of this function. */
3947 while (parser
->active
&& parser
->active
!= active_initial
)
3948 _parser_active_list_pop (parser
);
3950 list
->non_space_tail
= list
->tail
;
3954 _glcpp_parser_print_expanded_token_list (glcpp_parser_t
*parser
,
3960 _glcpp_parser_expand_token_list (parser
, list
);
3962 _token_list_trim_trailing_space (list
);
3964 _token_list_print (parser
, list
);
3968 _check_for_reserved_macro_name (glcpp_parser_t
*parser
, YYLTYPE
*loc
,
3969 const char *identifier
)
3971 /* According to the GLSL specification, macro names starting with "__"
3972 * or "GL_" are reserved for future use. So, don't allow them.
3974 if (strstr(identifier
, "__")) {
3975 glcpp_error (loc
, parser
, "Macro names containing \"__\" are reserved.\n");
3977 if (strncmp(identifier
, "GL_", 3) == 0) {
3978 glcpp_error (loc
, parser
, "Macro names starting with \"GL_\" are reserved.\n");
3983 _macro_equal (macro_t
*a
, macro_t
*b
)
3985 if (a
->is_function
!= b
->is_function
)
3988 if (a
->is_function
) {
3989 if (! _string_list_equal (a
->parameters
, b
->parameters
))
3993 return _token_list_equal_ignoring_space (a
->replacements
,
3998 _define_object_macro (glcpp_parser_t
*parser
,
4000 const char *identifier
,
4001 token_list_t
*replacements
)
4003 macro_t
*macro
, *previous
;
4006 _check_for_reserved_macro_name(parser
, loc
, identifier
);
4008 macro
= ralloc (parser
, macro_t
);
4010 macro
->is_function
= 0;
4011 macro
->parameters
= NULL
;
4012 macro
->identifier
= ralloc_strdup (macro
, identifier
);
4013 macro
->replacements
= replacements
;
4014 ralloc_steal (macro
, replacements
);
4016 previous
= hash_table_find (parser
->defines
, identifier
);
4018 if (_macro_equal (macro
, previous
)) {
4019 ralloc_free (macro
);
4022 glcpp_error (loc
, parser
, "Redefinition of macro %s\n",
4026 hash_table_insert (parser
->defines
, macro
, identifier
);
4030 _define_function_macro (glcpp_parser_t
*parser
,
4032 const char *identifier
,
4033 string_list_t
*parameters
,
4034 token_list_t
*replacements
)
4036 macro_t
*macro
, *previous
;
4038 _check_for_reserved_macro_name(parser
, loc
, identifier
);
4040 macro
= ralloc (parser
, macro_t
);
4041 ralloc_steal (macro
, parameters
);
4042 ralloc_steal (macro
, replacements
);
4044 macro
->is_function
= 1;
4045 macro
->parameters
= parameters
;
4046 macro
->identifier
= ralloc_strdup (macro
, identifier
);
4047 macro
->replacements
= replacements
;
4048 previous
= hash_table_find (parser
->defines
, identifier
);
4050 if (_macro_equal (macro
, previous
)) {
4051 ralloc_free (macro
);
4054 glcpp_error (loc
, parser
, "Redefinition of macro %s\n",
4058 hash_table_insert (parser
->defines
, macro
, identifier
);
4062 glcpp_parser_lex (YYSTYPE
*yylval
, YYLTYPE
*yylloc
, glcpp_parser_t
*parser
)
4067 if (parser
->lex_from_list
== NULL
) {
4068 ret
= glcpp_lex (yylval
, yylloc
, parser
->scanner
);
4070 /* XXX: This ugly block of code exists for the sole
4071 * purpose of converting a NEWLINE token into a SPACE
4072 * token, but only in the case where we have seen a
4073 * function-like macro name, but have not yet seen its
4074 * closing parenthesis.
4076 * There's perhaps a more compact way to do this with
4077 * mid-rule actions in the grammar.
4079 * I'm definitely not pleased with the complexity of
4082 if (parser
->newline_as_space
)
4085 parser
->paren_count
++;
4086 } else if (ret
== ')') {
4087 parser
->paren_count
--;
4088 if (parser
->paren_count
== 0)
4089 parser
->newline_as_space
= 0;
4090 } else if (ret
== NEWLINE
) {
4092 } else if (ret
!= SPACE
) {
4093 if (parser
->paren_count
== 0)
4094 parser
->newline_as_space
= 0;
4097 else if (parser
->in_control_line
)
4100 parser
->in_control_line
= 0;
4102 else if (ret
== HASH_DEFINE_OBJ
|| ret
== HASH_DEFINE_FUNC
||
4103 ret
== HASH_UNDEF
|| ret
== HASH_IF
||
4104 ret
== HASH_IFDEF
|| ret
== HASH_IFNDEF
||
4105 ret
== HASH_ELIF
|| ret
== HASH_ELSE
||
4106 ret
== HASH_ENDIF
|| ret
== HASH
)
4108 parser
->in_control_line
= 1;
4110 else if (ret
== IDENTIFIER
)
4113 macro
= hash_table_find (parser
->defines
,
4115 if (macro
&& macro
->is_function
) {
4116 parser
->newline_as_space
= 1;
4117 parser
->paren_count
= 0;
4124 node
= parser
->lex_from_node
;
4127 ralloc_free (parser
->lex_from_list
);
4128 parser
->lex_from_list
= NULL
;
4132 *yylval
= node
->token
->value
;
4133 ret
= node
->token
->type
;
4135 parser
->lex_from_node
= node
->next
;
4141 glcpp_parser_lex_from (glcpp_parser_t
*parser
, token_list_t
*list
)
4145 assert (parser
->lex_from_list
== NULL
);
4147 /* Copy list, eliminating any space tokens. */
4148 parser
->lex_from_list
= _token_list_create (parser
);
4150 for (node
= list
->head
; node
; node
= node
->next
) {
4151 if (node
->token
->type
== SPACE
)
4153 _token_list_append (parser
->lex_from_list
, node
->token
);
4158 parser
->lex_from_node
= parser
->lex_from_list
->head
;
4160 /* It's possible the list consisted of nothing but whitespace. */
4161 if (parser
->lex_from_node
== NULL
) {
4162 ralloc_free (parser
->lex_from_list
);
4163 parser
->lex_from_list
= NULL
;
4168 _glcpp_parser_skip_stack_push_if (glcpp_parser_t
*parser
, YYLTYPE
*loc
,
4171 skip_type_t current
= SKIP_NO_SKIP
;
4174 if (parser
->skip_stack
)
4175 current
= parser
->skip_stack
->type
;
4177 node
= ralloc (parser
, skip_node_t
);
4180 if (current
== SKIP_NO_SKIP
) {
4182 node
->type
= SKIP_NO_SKIP
;
4184 node
->type
= SKIP_TO_ELSE
;
4186 node
->type
= SKIP_TO_ENDIF
;
4189 node
->next
= parser
->skip_stack
;
4190 parser
->skip_stack
= node
;
4194 _glcpp_parser_skip_stack_change_if (glcpp_parser_t
*parser
, YYLTYPE
*loc
,
4195 const char *type
, int condition
)
4197 if (parser
->skip_stack
== NULL
) {
4198 glcpp_error (loc
, parser
, "%s without #if\n", type
);
4202 if (parser
->skip_stack
->type
== SKIP_TO_ELSE
) {
4204 parser
->skip_stack
->type
= SKIP_NO_SKIP
;
4206 parser
->skip_stack
->type
= SKIP_TO_ENDIF
;
4211 _glcpp_parser_skip_stack_pop (glcpp_parser_t
*parser
, YYLTYPE
*loc
)
4215 if (parser
->skip_stack
== NULL
) {
4216 glcpp_error (loc
, parser
, "#endif without #if\n");
4220 node
= parser
->skip_stack
;
4221 parser
->skip_stack
= node
->next
;