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
);
158 /* Note: This function calls ralloc_steal on token. */
160 _token_list_append (token_list_t
*list
, token_t
*token
);
163 _token_list_append_list (token_list_t
*list
, token_list_t
*tail
);
166 _token_list_equal_ignoring_space (token_list_t
*a
, token_list_t
*b
);
169 _parser_active_list_push (glcpp_parser_t
*parser
,
170 const char *identifier
,
171 token_node_t
*marker
);
174 _parser_active_list_pop (glcpp_parser_t
*parser
);
177 _parser_active_list_contains (glcpp_parser_t
*parser
, const char *identifier
);
180 _glcpp_parser_expand_if (glcpp_parser_t
*parser
, int type
, token_list_t
*list
);
183 _glcpp_parser_expand_token_list (glcpp_parser_t
*parser
,
187 _glcpp_parser_print_expanded_token_list (glcpp_parser_t
*parser
,
191 _glcpp_parser_skip_stack_push_if (glcpp_parser_t
*parser
, YYLTYPE
*loc
,
195 _glcpp_parser_skip_stack_change_if (glcpp_parser_t
*parser
, YYLTYPE
*loc
,
196 const char *type
, int condition
);
199 _glcpp_parser_skip_stack_pop (glcpp_parser_t
*parser
, YYLTYPE
*loc
);
201 #define yylex glcpp_parser_lex
204 glcpp_parser_lex (YYSTYPE
*yylval
, YYLTYPE
*yylloc
, glcpp_parser_t
*parser
);
207 glcpp_parser_lex_from (glcpp_parser_t
*parser
, token_list_t
*list
);
210 add_builtin_define(glcpp_parser_t
*parser
, const char *name
, int value
);
214 /* Line 189 of yacc.c */
215 #line 216 "glcpp/glcpp-parse.c"
217 /* Enabling traces. */
222 /* Enabling verbose error messages. */
223 #ifdef YYERROR_VERBOSE
224 # undef YYERROR_VERBOSE
225 # define YYERROR_VERBOSE 1
227 # define YYERROR_VERBOSE 1
230 /* Enabling the token table. */
231 #ifndef YYTOKEN_TABLE
232 # define YYTOKEN_TABLE 0
239 /* Put the tokens into the symbol table, so that GDB and other debuggers
246 HASH_DEFINE_FUNC
= 262,
247 HASH_DEFINE_OBJ
= 263,
259 INTEGER_STRING
= 275,
269 GREATER_OR_EQUAL
= 285,
279 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
281 # define yystype YYSTYPE /* obsolescent; will be withdrawn */
282 # define YYSTYPE_IS_DECLARED 1
285 #if ! defined YYLTYPE && ! defined YYLTYPE_IS_DECLARED
286 typedef struct YYLTYPE
293 # define yyltype YYLTYPE /* obsolescent; will be withdrawn */
294 # define YYLTYPE_IS_DECLARED 1
295 # define YYLTYPE_IS_TRIVIAL 1
299 /* Copy the second part of user declarations. */
302 /* Line 264 of yacc.c */
303 #line 304 "glcpp/glcpp-parse.c"
310 typedef YYTYPE_UINT8 yytype_uint8
;
312 typedef unsigned char yytype_uint8
;
316 typedef YYTYPE_INT8 yytype_int8
;
317 #elif (defined __STDC__ || defined __C99__FUNC__ \
318 || defined __cplusplus || defined _MSC_VER)
319 typedef signed char yytype_int8
;
321 typedef short int yytype_int8
;
325 typedef YYTYPE_UINT16 yytype_uint16
;
327 typedef unsigned short int yytype_uint16
;
331 typedef YYTYPE_INT16 yytype_int16
;
333 typedef short int yytype_int16
;
337 # ifdef __SIZE_TYPE__
338 # define YYSIZE_T __SIZE_TYPE__
339 # elif defined size_t
340 # define YYSIZE_T size_t
341 # elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \
342 || defined __cplusplus || defined _MSC_VER)
343 # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
344 # define YYSIZE_T size_t
346 # define YYSIZE_T unsigned int
350 #define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
353 # if defined YYENABLE_NLS && YYENABLE_NLS
355 # include <libintl.h> /* INFRINGES ON USER NAME SPACE */
356 # define YY_(msgid) dgettext ("bison-runtime", msgid)
360 # define YY_(msgid) msgid
364 /* Suppress unused-variable warnings by "using" E. */
365 #if ! defined lint || defined __GNUC__
366 # define YYUSE(e) ((void) (e))
368 # define YYUSE(e) /* empty */
371 /* Identity function, used to suppress warnings about constant conditions. */
375 #if (defined __STDC__ || defined __C99__FUNC__ \
376 || defined __cplusplus || defined _MSC_VER)
389 #if ! defined yyoverflow || YYERROR_VERBOSE
391 /* The parser invokes alloca or malloc; define the necessary symbols. */
393 # ifdef YYSTACK_USE_ALLOCA
394 # if YYSTACK_USE_ALLOCA
396 # define YYSTACK_ALLOC __builtin_alloca
397 # elif defined __BUILTIN_VA_ARG_INCR
398 # include <alloca.h> /* INFRINGES ON USER NAME SPACE */
400 # define YYSTACK_ALLOC __alloca
401 # elif defined _MSC_VER
402 # include <malloc.h> /* INFRINGES ON USER NAME SPACE */
403 # define alloca _alloca
405 # define YYSTACK_ALLOC alloca
406 # if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
407 || defined __cplusplus || defined _MSC_VER)
408 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
417 # ifdef YYSTACK_ALLOC
418 /* Pacify GCC's `empty if-body' warning. */
419 # define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0))
420 # ifndef YYSTACK_ALLOC_MAXIMUM
421 /* The OS might guarantee only one guard page at the bottom of the stack,
422 and a page size can be as small as 4096 bytes. So we cannot safely
423 invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
424 to allow for a few compiler-allocated temporary stack slots. */
425 # define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
428 # define YYSTACK_ALLOC YYMALLOC
429 # define YYSTACK_FREE YYFREE
430 # ifndef YYSTACK_ALLOC_MAXIMUM
431 # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
433 # if (defined __cplusplus && ! defined _STDLIB_H \
434 && ! ((defined YYMALLOC || defined malloc) \
435 && (defined YYFREE || defined free)))
436 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
442 # define YYMALLOC malloc
443 # if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
444 || defined __cplusplus || defined _MSC_VER)
445 void *malloc (YYSIZE_T
); /* INFRINGES ON USER NAME SPACE */
450 # if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
451 || defined __cplusplus || defined _MSC_VER)
452 void free (void *); /* INFRINGES ON USER NAME SPACE */
456 #endif /* ! defined yyoverflow || YYERROR_VERBOSE */
459 #if (! defined yyoverflow \
460 && (! defined __cplusplus \
461 || (defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL \
462 && defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
464 /* A type that is properly aligned for any stack member. */
467 yytype_int16 yyss_alloc
;
472 /* The size of the maximum gap between one aligned stack and the next. */
473 # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
475 /* The size of an array large to enough to hold all stacks, each with
477 # define YYSTACK_BYTES(N) \
478 ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE) + sizeof (YYLTYPE)) \
479 + 2 * YYSTACK_GAP_MAXIMUM)
481 /* Copy COUNT objects from FROM to TO. The source and destination do
484 # if defined __GNUC__ && 1 < __GNUC__
485 # define YYCOPY(To, From, Count) \
486 __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
488 # define YYCOPY(To, From, Count) \
492 for (yyi = 0; yyi < (Count); yyi++) \
493 (To)[yyi] = (From)[yyi]; \
499 /* Relocate STACK from its old location to the new one. The
500 local variables YYSIZE and YYSTACKSIZE give the old and new number of
501 elements in the stack, and YYPTR gives the new location of the
502 stack. Advance YYPTR to a properly aligned location for the next
504 # define YYSTACK_RELOCATE(Stack_alloc, Stack) \
507 YYSIZE_T yynewbytes; \
508 YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \
509 Stack = &yyptr->Stack_alloc; \
510 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
511 yyptr += yynewbytes / sizeof (*yyptr); \
517 /* YYFINAL -- State number of the termination state. */
519 /* YYLAST -- Last index in YYTABLE. */
522 /* YYNTOKENS -- Number of terminals. */
524 /* YYNNTS -- Number of nonterminals. */
526 /* YYNRULES -- Number of rules. */
528 /* YYNRULES -- Number of states. */
529 #define YYNSTATES 162
531 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
533 #define YYMAXUTOK 289
535 #define YYTRANSLATE(YYX) \
536 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
538 /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
539 static const yytype_uint8 yytranslate
[] =
541 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
542 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
543 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
544 2, 2, 2, 47, 2, 2, 2, 43, 30, 2,
545 45, 46, 41, 39, 49, 40, 54, 42, 2, 2,
546 2, 2, 2, 2, 2, 2, 2, 2, 2, 55,
547 33, 56, 34, 2, 2, 2, 2, 2, 2, 2,
548 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
549 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
550 2, 50, 2, 51, 29, 2, 2, 2, 2, 2,
551 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
552 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
553 2, 2, 2, 52, 28, 53, 48, 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, 2, 2, 2, 2,
566 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
567 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
568 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
569 25, 26, 27, 31, 32, 35, 36, 37, 38, 44
573 /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
575 static const yytype_uint16 yyprhs
[] =
577 0, 0, 3, 4, 7, 9, 11, 13, 16, 20,
578 24, 29, 36, 44, 48, 52, 55, 60, 65, 69,
579 72, 75, 78, 82, 85, 87, 89, 91, 95, 99,
580 103, 107, 111, 115, 119, 123, 127, 131, 135, 139,
581 143, 147, 151, 155, 159, 163, 166, 169, 172, 175,
582 179, 181, 185, 187, 190, 193, 194, 196, 197, 199,
583 202, 207, 209, 211, 214, 216, 219, 221, 223, 225,
584 227, 229, 231, 233, 235, 237, 239, 241, 243, 245,
585 247, 249, 251, 253, 255, 257, 259, 261, 263, 265,
586 267, 269, 271, 273, 275, 277, 279, 281, 283, 285,
590 /* YYRHS -- A `-1'-separated list of the rules' RHS. */
591 static const yytype_int8 yyrhs
[] =
593 58, 0, -1, -1, 58, 59, -1, 61, -1, 65,
594 -1, 60, -1, 6, 66, -1, 18, 63, 21, -1,
595 5, 63, 21, -1, 8, 17, 67, 21, -1, 7,
596 17, 45, 46, 67, 21, -1, 7, 17, 45, 64,
597 46, 67, 21, -1, 15, 17, 21, -1, 12, 70,
598 21, -1, 12, 21, -1, 13, 17, 68, 21, -1,
599 14, 17, 68, 21, -1, 9, 70, 21, -1, 9,
600 21, -1, 10, 21, -1, 11, 21, -1, 16, 62,
601 21, -1, 6, 21, -1, 20, -1, 19, -1, 62,
602 -1, 63, 26, 63, -1, 63, 27, 63, -1, 63,
603 28, 63, -1, 63, 29, 63, -1, 63, 30, 63,
604 -1, 63, 31, 63, -1, 63, 32, 63, -1, 63,
605 35, 63, -1, 63, 36, 63, -1, 63, 34, 63,
606 -1, 63, 33, 63, -1, 63, 37, 63, -1, 63,
607 38, 63, -1, 63, 40, 63, -1, 63, 39, 63,
608 -1, 63, 43, 63, -1, 63, 42, 63, -1, 63,
609 41, 63, -1, 47, 63, -1, 48, 63, -1, 40,
610 63, -1, 39, 63, -1, 45, 63, 46, -1, 17,
611 -1, 64, 49, 17, -1, 21, -1, 71, 21, -1,
612 71, 21, -1, -1, 71, -1, -1, 71, -1, 4,
613 17, -1, 4, 45, 17, 46, -1, 72, -1, 69,
614 -1, 70, 69, -1, 72, -1, 71, 72, -1, 17,
615 -1, 20, -1, 73, -1, 22, -1, 24, -1, 50,
616 -1, 51, -1, 45, -1, 46, -1, 52, -1, 53,
617 -1, 54, -1, 30, -1, 41, -1, 39, -1, 40,
618 -1, 48, -1, 47, -1, 42, -1, 43, -1, 38,
619 -1, 37, -1, 33, -1, 34, -1, 36, -1, 35,
620 -1, 32, -1, 31, -1, 29, -1, 28, -1, 27,
621 -1, 26, -1, 55, -1, 49, -1, 56, -1, 25,
625 /* YYRLINE[YYN] -- source line where rule number YYN was defined. */
626 static const yytype_uint16 yyrline
[] =
628 0, 181, 181, 183, 187, 190, 195, 196, 200, 203,
629 209, 212, 215, 218, 226, 245, 255, 260, 265, 284,
630 299, 302, 305, 326, 330, 339, 344, 345, 348, 351,
631 354, 357, 360, 363, 366, 369, 372, 375, 378, 381,
632 384, 387, 390, 398, 406, 409, 412, 415, 418, 421,
633 427, 432, 440, 441, 445, 451, 452, 455, 457, 464,
634 468, 472, 477, 481, 488, 493, 500, 504, 508, 512,
635 516, 523, 524, 525, 526, 527, 528, 529, 530, 531,
636 532, 533, 534, 535, 536, 537, 538, 539, 540, 541,
637 542, 543, 544, 545, 546, 547, 548, 549, 550, 551,
642 #if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
643 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
644 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
645 static const char *const yytname
[] =
647 "$end", "error", "$undefined", "COMMA_FINAL", "DEFINED",
648 "ELIF_EXPANDED", "HASH", "HASH_DEFINE_FUNC", "HASH_DEFINE_OBJ",
649 "HASH_ELIF", "HASH_ELSE", "HASH_ENDIF", "HASH_IF", "HASH_IFDEF",
650 "HASH_IFNDEF", "HASH_UNDEF", "HASH_VERSION", "IDENTIFIER", "IF_EXPANDED",
651 "INTEGER", "INTEGER_STRING", "NEWLINE", "OTHER", "PLACEHOLDER", "SPACE",
652 "PASTE", "OR", "AND", "'|'", "'^'", "'&'", "NOT_EQUAL", "EQUAL", "'<'",
653 "'>'", "GREATER_OR_EQUAL", "LESS_OR_EQUAL", "RIGHT_SHIFT", "LEFT_SHIFT",
654 "'+'", "'-'", "'*'", "'/'", "'%'", "UNARY", "'('", "')'", "'!'", "'~'",
655 "','", "'['", "']'", "'{'", "'}'", "'.'", "';'", "'='", "$accept",
656 "input", "line", "expanded_line", "control_line", "integer_constant",
657 "expression", "identifier_list", "text_line", "non_directive",
658 "replacement_list", "junk", "conditional_token", "conditional_tokens",
659 "pp_tokens", "preprocessing_token", "operator", 0
664 /* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
666 static const yytype_uint16 yytoknum
[] =
668 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
669 265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
670 275, 276, 277, 278, 279, 280, 281, 282, 124, 94,
671 38, 283, 284, 60, 62, 285, 286, 287, 288, 43,
672 45, 42, 47, 37, 289, 40, 41, 33, 126, 44,
673 91, 93, 123, 125, 46, 59, 61
677 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
678 static const yytype_uint8 yyr1
[] =
680 0, 57, 58, 58, 59, 59, 59, 59, 60, 60,
681 61, 61, 61, 61, 61, 61, 61, 61, 61, 61,
682 61, 61, 61, 61, 62, 62, 63, 63, 63, 63,
683 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
684 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
685 64, 64, 65, 65, 66, 67, 67, 68, 68, 69,
686 69, 69, 70, 70, 71, 71, 72, 72, 72, 72,
687 72, 73, 73, 73, 73, 73, 73, 73, 73, 73,
688 73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
689 73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
693 /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
694 static const yytype_uint8 yyr2
[] =
696 0, 2, 0, 2, 1, 1, 1, 2, 3, 3,
697 4, 6, 7, 3, 3, 2, 4, 4, 3, 2,
698 2, 2, 3, 2, 1, 1, 1, 3, 3, 3,
699 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
700 3, 3, 3, 3, 3, 2, 2, 2, 2, 3,
701 1, 3, 1, 2, 2, 0, 1, 0, 1, 2,
702 4, 1, 1, 2, 1, 2, 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,
705 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
709 /* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
710 STATE-NUM when YYTABLE doesn't specify something else to do. Zero
711 means the default is an error. */
712 static const yytype_uint8 yydefact
[] =
714 2, 0, 1, 0, 0, 0, 0, 0, 0, 0,
715 0, 0, 0, 0, 0, 66, 0, 67, 52, 69,
716 70, 101, 97, 96, 95, 94, 78, 93, 92, 88,
717 89, 91, 90, 87, 86, 80, 81, 79, 84, 85,
718 73, 74, 83, 82, 99, 71, 72, 75, 76, 77,
719 98, 100, 3, 6, 4, 5, 0, 64, 68, 25,
720 24, 0, 0, 0, 0, 0, 26, 0, 23, 7,
721 0, 0, 55, 0, 19, 62, 0, 61, 20, 21,
722 15, 0, 57, 57, 0, 0, 0, 53, 65, 48,
723 47, 0, 45, 46, 9, 0, 0, 0, 0, 0,
724 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
725 0, 0, 0, 54, 0, 0, 56, 59, 0, 18,
726 63, 14, 0, 58, 0, 13, 22, 8, 49, 27,
727 28, 29, 30, 31, 32, 33, 37, 36, 34, 35,
728 38, 39, 41, 40, 44, 43, 42, 50, 55, 0,
729 10, 0, 16, 17, 0, 55, 0, 60, 11, 0,
733 /* YYDEFGOTO[NTERM-NUM]. */
734 static const yytype_int16 yydefgoto
[] =
736 -1, 1, 52, 53, 54, 66, 67, 149, 55, 69,
737 115, 122, 75, 76, 116, 57, 58
740 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
742 #define YYPACT_NINF -147
743 static const yytype_int16 yypact
[] =
745 -147, 112, -147, 28, -10, 55, 62, 152, -15, 59,
746 192, 85, 86, 87, 51, -147, 28, -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, -147, -147, -147, -147,
750 -147, -147, -147, -147, -147, -147, 312, -147, -147, -147,
751 -147, 28, 28, 28, 28, 28, -147, 428, -147, -147,
752 352, 63, 392, 17, -147, -147, 232, -147, -147, -147,
753 -147, 272, 392, 392, 84, 89, 451, -147, -147, -147,
754 -147, 469, -147, -147, -147, 28, 28, 28, 28, 28,
755 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
756 28, 28, 28, -147, 60, 90, 392, -147, 96, -147,
757 -147, -147, 93, 392, 94, -147, -147, -147, -147, 489,
758 505, 520, 534, 547, 558, 558, 18, 18, 18, 18,
759 563, 563, 23, 23, -147, -147, -147, -147, 392, 32,
760 -147, 61, -147, -147, 110, 392, 118, -147, -147, 149,
764 /* YYPGOTO[NTERM-NUM]. */
765 static const yytype_int16 yypgoto
[] =
767 -147, -147, -147, -147, -147, 157, -11, -147, -147, -147,
768 -146, 92, -68, 200, 0, -7, -147
771 /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
772 positive, shift that token. If negative, reduce the rule which
773 number is the opposite. If zero, do what YYDEFACT says.
774 If YYTABLE_NINF, syntax error. */
775 #define YYTABLE_NINF -1
776 static const yytype_uint8 yytable
[] =
778 77, 56, 154, 77, 70, 86, 78, 15, 120, 159,
779 17, 68, 19, 120, 20, 21, 22, 23, 24, 25,
780 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
781 36, 37, 38, 39, 117, 40, 41, 42, 43, 44,
782 45, 46, 47, 48, 49, 50, 51, 59, 60, 88,
783 89, 90, 91, 92, 93, 106, 107, 108, 109, 110,
784 111, 112, 118, 88, 110, 111, 112, 61, 62, 77,
785 59, 60, 71, 63, 77, 64, 65, 147, 155, 72,
786 79, 156, 123, 123, 129, 130, 131, 132, 133, 134,
787 135, 136, 137, 138, 139, 140, 141, 142, 143, 144,
788 145, 146, 82, 83, 84, 125, 148, 157, 114, 88,
789 126, 150, 2, 151, 152, 153, 88, 3, 4, 5,
790 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
791 16, 158, 17, 18, 19, 160, 20, 21, 22, 23,
792 24, 25, 26, 27, 28, 29, 30, 31, 32, 33,
793 34, 35, 36, 37, 38, 39, 73, 40, 41, 42,
794 43, 44, 45, 46, 47, 48, 49, 50, 51, 15,
795 161, 85, 17, 74, 19, 124, 20, 21, 22, 23,
796 24, 25, 26, 27, 28, 29, 30, 31, 32, 33,
797 34, 35, 36, 37, 38, 39, 73, 40, 41, 42,
798 43, 44, 45, 46, 47, 48, 49, 50, 51, 15,
799 81, 0, 17, 80, 19, 0, 20, 21, 22, 23,
800 24, 25, 26, 27, 28, 29, 30, 31, 32, 33,
801 34, 35, 36, 37, 38, 39, 73, 40, 41, 42,
802 43, 44, 45, 46, 47, 48, 49, 50, 51, 15,
803 0, 0, 17, 119, 19, 0, 20, 21, 22, 23,
804 24, 25, 26, 27, 28, 29, 30, 31, 32, 33,
805 34, 35, 36, 37, 38, 39, 73, 40, 41, 42,
806 43, 44, 45, 46, 47, 48, 49, 50, 51, 15,
807 0, 0, 17, 121, 19, 0, 20, 21, 22, 23,
808 24, 25, 26, 27, 28, 29, 30, 31, 32, 33,
809 34, 35, 36, 37, 38, 39, 0, 40, 41, 42,
810 43, 44, 45, 46, 47, 48, 49, 50, 51, 15,
811 0, 0, 17, 87, 19, 0, 20, 21, 22, 23,
812 24, 25, 26, 27, 28, 29, 30, 31, 32, 33,
813 34, 35, 36, 37, 38, 39, 0, 40, 41, 42,
814 43, 44, 45, 46, 47, 48, 49, 50, 51, 15,
815 0, 0, 17, 113, 19, 0, 20, 21, 22, 23,
816 24, 25, 26, 27, 28, 29, 30, 31, 32, 33,
817 34, 35, 36, 37, 38, 39, 0, 40, 41, 42,
818 43, 44, 45, 46, 47, 48, 49, 50, 51, 15,
819 0, 0, 17, 0, 19, 0, 20, 21, 22, 23,
820 24, 25, 26, 27, 28, 29, 30, 31, 32, 33,
821 34, 35, 36, 37, 38, 39, 0, 40, 41, 42,
822 43, 44, 45, 46, 47, 48, 49, 50, 51, 94,
823 0, 0, 0, 0, 95, 96, 97, 98, 99, 100,
824 101, 102, 103, 104, 105, 106, 107, 108, 109, 110,
825 111, 112, 127, 0, 0, 0, 0, 95, 96, 97,
826 98, 99, 100, 101, 102, 103, 104, 105, 106, 107,
827 108, 109, 110, 111, 112, 95, 96, 97, 98, 99,
828 100, 101, 102, 103, 104, 105, 106, 107, 108, 109,
829 110, 111, 112, 0, 0, 128, 96, 97, 98, 99,
830 100, 101, 102, 103, 104, 105, 106, 107, 108, 109,
831 110, 111, 112, 97, 98, 99, 100, 101, 102, 103,
832 104, 105, 106, 107, 108, 109, 110, 111, 112, 98,
833 99, 100, 101, 102, 103, 104, 105, 106, 107, 108,
834 109, 110, 111, 112, 99, 100, 101, 102, 103, 104,
835 105, 106, 107, 108, 109, 110, 111, 112, 100, 101,
836 102, 103, 104, 105, 106, 107, 108, 109, 110, 111,
837 112, 102, 103, 104, 105, 106, 107, 108, 109, 110,
838 111, 112, 108, 109, 110, 111, 112
841 static const yytype_int16 yycheck
[] =
843 7, 1, 148, 10, 4, 16, 21, 17, 76, 155,
844 20, 21, 22, 81, 24, 25, 26, 27, 28, 29,
845 30, 31, 32, 33, 34, 35, 36, 37, 38, 39,
846 40, 41, 42, 43, 17, 45, 46, 47, 48, 49,
847 50, 51, 52, 53, 54, 55, 56, 19, 20, 56,
848 61, 62, 63, 64, 65, 37, 38, 39, 40, 41,
849 42, 43, 45, 70, 41, 42, 43, 39, 40, 76,
850 19, 20, 17, 45, 81, 47, 48, 17, 46, 17,
851 21, 49, 82, 83, 95, 96, 97, 98, 99, 100,
852 101, 102, 103, 104, 105, 106, 107, 108, 109, 110,
853 111, 112, 17, 17, 17, 21, 46, 46, 45, 116,
854 21, 21, 0, 17, 21, 21, 123, 5, 6, 7,
855 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
856 18, 21, 20, 21, 22, 17, 24, 25, 26, 27,
857 28, 29, 30, 31, 32, 33, 34, 35, 36, 37,
858 38, 39, 40, 41, 42, 43, 4, 45, 46, 47,
859 48, 49, 50, 51, 52, 53, 54, 55, 56, 17,
860 21, 14, 20, 21, 22, 83, 24, 25, 26, 27,
861 28, 29, 30, 31, 32, 33, 34, 35, 36, 37,
862 38, 39, 40, 41, 42, 43, 4, 45, 46, 47,
863 48, 49, 50, 51, 52, 53, 54, 55, 56, 17,
864 10, -1, 20, 21, 22, -1, 24, 25, 26, 27,
865 28, 29, 30, 31, 32, 33, 34, 35, 36, 37,
866 38, 39, 40, 41, 42, 43, 4, 45, 46, 47,
867 48, 49, 50, 51, 52, 53, 54, 55, 56, 17,
868 -1, -1, 20, 21, 22, -1, 24, 25, 26, 27,
869 28, 29, 30, 31, 32, 33, 34, 35, 36, 37,
870 38, 39, 40, 41, 42, 43, 4, 45, 46, 47,
871 48, 49, 50, 51, 52, 53, 54, 55, 56, 17,
872 -1, -1, 20, 21, 22, -1, 24, 25, 26, 27,
873 28, 29, 30, 31, 32, 33, 34, 35, 36, 37,
874 38, 39, 40, 41, 42, 43, -1, 45, 46, 47,
875 48, 49, 50, 51, 52, 53, 54, 55, 56, 17,
876 -1, -1, 20, 21, 22, -1, 24, 25, 26, 27,
877 28, 29, 30, 31, 32, 33, 34, 35, 36, 37,
878 38, 39, 40, 41, 42, 43, -1, 45, 46, 47,
879 48, 49, 50, 51, 52, 53, 54, 55, 56, 17,
880 -1, -1, 20, 21, 22, -1, 24, 25, 26, 27,
881 28, 29, 30, 31, 32, 33, 34, 35, 36, 37,
882 38, 39, 40, 41, 42, 43, -1, 45, 46, 47,
883 48, 49, 50, 51, 52, 53, 54, 55, 56, 17,
884 -1, -1, 20, -1, 22, -1, 24, 25, 26, 27,
885 28, 29, 30, 31, 32, 33, 34, 35, 36, 37,
886 38, 39, 40, 41, 42, 43, -1, 45, 46, 47,
887 48, 49, 50, 51, 52, 53, 54, 55, 56, 21,
888 -1, -1, -1, -1, 26, 27, 28, 29, 30, 31,
889 32, 33, 34, 35, 36, 37, 38, 39, 40, 41,
890 42, 43, 21, -1, -1, -1, -1, 26, 27, 28,
891 29, 30, 31, 32, 33, 34, 35, 36, 37, 38,
892 39, 40, 41, 42, 43, 26, 27, 28, 29, 30,
893 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
894 41, 42, 43, -1, -1, 46, 27, 28, 29, 30,
895 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
896 41, 42, 43, 28, 29, 30, 31, 32, 33, 34,
897 35, 36, 37, 38, 39, 40, 41, 42, 43, 29,
898 30, 31, 32, 33, 34, 35, 36, 37, 38, 39,
899 40, 41, 42, 43, 30, 31, 32, 33, 34, 35,
900 36, 37, 38, 39, 40, 41, 42, 43, 31, 32,
901 33, 34, 35, 36, 37, 38, 39, 40, 41, 42,
902 43, 33, 34, 35, 36, 37, 38, 39, 40, 41,
903 42, 43, 39, 40, 41, 42, 43
906 /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
907 symbol of state STATE-NUM. */
908 static const yytype_uint8 yystos
[] =
910 0, 58, 0, 5, 6, 7, 8, 9, 10, 11,
911 12, 13, 14, 15, 16, 17, 18, 20, 21, 22,
912 24, 25, 26, 27, 28, 29, 30, 31, 32, 33,
913 34, 35, 36, 37, 38, 39, 40, 41, 42, 43,
914 45, 46, 47, 48, 49, 50, 51, 52, 53, 54,
915 55, 56, 59, 60, 61, 65, 71, 72, 73, 19,
916 20, 39, 40, 45, 47, 48, 62, 63, 21, 66,
917 71, 17, 17, 4, 21, 69, 70, 72, 21, 21,
918 21, 70, 17, 17, 17, 62, 63, 21, 72, 63,
919 63, 63, 63, 63, 21, 26, 27, 28, 29, 30,
920 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
921 41, 42, 43, 21, 45, 67, 71, 17, 45, 21,
922 69, 21, 68, 71, 68, 21, 21, 21, 46, 63,
923 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
924 63, 63, 63, 63, 63, 63, 63, 17, 46, 64,
925 21, 17, 21, 21, 67, 46, 49, 46, 21, 67,
929 #define yyerrok (yyerrstatus = 0)
930 #define yyclearin (yychar = YYEMPTY)
934 #define YYACCEPT goto yyacceptlab
935 #define YYABORT goto yyabortlab
936 #define YYERROR goto yyerrorlab
939 /* Like YYERROR except do call yyerror. This remains here temporarily
940 to ease the transition to the new meaning of YYERROR, for GCC.
941 Once GCC version 2 has supplanted version 1, this can go. However,
942 YYFAIL appears to be in use. Nevertheless, it is formally deprecated
943 in Bison 2.4.2's NEWS entry, where a plan to phase it out is
946 #define YYFAIL goto yyerrlab
948 /* This is here to suppress warnings from the GCC cpp's
949 -Wunused-macros. Normally we don't worry about that warning, but
950 some users do, and we want to make it easy for users to remove
951 YYFAIL uses, which will produce warnings from Bison 2.5. */
954 #define YYRECOVERING() (!!yyerrstatus)
956 #define YYBACKUP(Token, Value) \
958 if (yychar == YYEMPTY && yylen == 1) \
962 yytoken = YYTRANSLATE (yychar); \
968 yyerror (&yylloc, parser, YY_("syntax error: cannot back up")); \
975 #define YYERRCODE 256
978 /* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
979 If N is 0, then set CURRENT to the empty location which ends
980 the previous symbol: RHS[0] (always defined). */
982 #define YYRHSLOC(Rhs, K) ((Rhs)[K])
983 #ifndef YYLLOC_DEFAULT
984 # define YYLLOC_DEFAULT(Current, Rhs, N) \
988 (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
989 (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
990 (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
991 (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
995 (Current).first_line = (Current).last_line = \
996 YYRHSLOC (Rhs, 0).last_line; \
997 (Current).first_column = (Current).last_column = \
998 YYRHSLOC (Rhs, 0).last_column; \
1004 /* YY_LOCATION_PRINT -- Print the location on the stream.
1005 This macro was not mandated originally: define only if we know
1006 we won't break user code: when these are the locations we know. */
1008 #ifndef YY_LOCATION_PRINT
1009 # if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL
1010 # define YY_LOCATION_PRINT(File, Loc) \
1011 fprintf (File, "%d.%d-%d.%d", \
1012 (Loc).first_line, (Loc).first_column, \
1013 (Loc).last_line, (Loc).last_column)
1015 # define YY_LOCATION_PRINT(File, Loc) ((void) 0)
1020 /* YYLEX -- calling `yylex' with the right arguments. */
1023 # define YYLEX yylex (&yylval, &yylloc, YYLEX_PARAM)
1025 # define YYLEX yylex (&yylval, &yylloc, parser)
1028 /* Enable debugging if requested. */
1032 # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
1033 # define YYFPRINTF fprintf
1036 # define YYDPRINTF(Args) \
1042 # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
1046 YYFPRINTF (stderr, "%s ", Title); \
1047 yy_symbol_print (stderr, \
1048 Type, Value, Location, parser); \
1049 YYFPRINTF (stderr, "\n"); \
1054 /*--------------------------------.
1055 | Print this symbol on YYOUTPUT. |
1056 `--------------------------------*/
1059 #if (defined __STDC__ || defined __C99__FUNC__ \
1060 || defined __cplusplus || defined _MSC_VER)
1062 yy_symbol_value_print (FILE *yyoutput
, int yytype
, YYSTYPE
const * const yyvaluep
, YYLTYPE
const * const yylocationp
, glcpp_parser_t
*parser
)
1065 yy_symbol_value_print (yyoutput
, yytype
, yyvaluep
, yylocationp
, parser
)
1068 YYSTYPE
const * const yyvaluep
;
1069 YYLTYPE
const * const yylocationp
;
1070 glcpp_parser_t
*parser
;
1075 YYUSE (yylocationp
);
1078 if (yytype
< YYNTOKENS
)
1079 YYPRINT (yyoutput
, yytoknum
[yytype
], *yyvaluep
);
1091 /*--------------------------------.
1092 | Print this symbol on YYOUTPUT. |
1093 `--------------------------------*/
1095 #if (defined __STDC__ || defined __C99__FUNC__ \
1096 || defined __cplusplus || defined _MSC_VER)
1098 yy_symbol_print (FILE *yyoutput
, int yytype
, YYSTYPE
const * const yyvaluep
, YYLTYPE
const * const yylocationp
, glcpp_parser_t
*parser
)
1101 yy_symbol_print (yyoutput
, yytype
, yyvaluep
, yylocationp
, parser
)
1104 YYSTYPE
const * const yyvaluep
;
1105 YYLTYPE
const * const yylocationp
;
1106 glcpp_parser_t
*parser
;
1109 if (yytype
< YYNTOKENS
)
1110 YYFPRINTF (yyoutput
, "token %s (", yytname
[yytype
]);
1112 YYFPRINTF (yyoutput
, "nterm %s (", yytname
[yytype
]);
1114 YY_LOCATION_PRINT (yyoutput
, *yylocationp
);
1115 YYFPRINTF (yyoutput
, ": ");
1116 yy_symbol_value_print (yyoutput
, yytype
, yyvaluep
, yylocationp
, parser
);
1117 YYFPRINTF (yyoutput
, ")");
1120 /*------------------------------------------------------------------.
1121 | yy_stack_print -- Print the state stack from its BOTTOM up to its |
1123 `------------------------------------------------------------------*/
1125 #if (defined __STDC__ || defined __C99__FUNC__ \
1126 || defined __cplusplus || defined _MSC_VER)
1128 yy_stack_print (yytype_int16
*yybottom
, yytype_int16
*yytop
)
1131 yy_stack_print (yybottom
, yytop
)
1132 yytype_int16
*yybottom
;
1133 yytype_int16
*yytop
;
1136 YYFPRINTF (stderr
, "Stack now");
1137 for (; yybottom
<= yytop
; yybottom
++)
1139 int yybot
= *yybottom
;
1140 YYFPRINTF (stderr
, " %d", yybot
);
1142 YYFPRINTF (stderr
, "\n");
1145 # define YY_STACK_PRINT(Bottom, Top) \
1148 yy_stack_print ((Bottom), (Top)); \
1152 /*------------------------------------------------.
1153 | Report that the YYRULE is going to be reduced. |
1154 `------------------------------------------------*/
1156 #if (defined __STDC__ || defined __C99__FUNC__ \
1157 || defined __cplusplus || defined _MSC_VER)
1159 yy_reduce_print (YYSTYPE
*yyvsp
, YYLTYPE
*yylsp
, int yyrule
, glcpp_parser_t
*parser
)
1162 yy_reduce_print (yyvsp
, yylsp
, yyrule
, parser
)
1166 glcpp_parser_t
*parser
;
1169 int yynrhs
= yyr2
[yyrule
];
1171 unsigned long int yylno
= yyrline
[yyrule
];
1172 YYFPRINTF (stderr
, "Reducing stack by rule %d (line %lu):\n",
1174 /* The symbols being reduced. */
1175 for (yyi
= 0; yyi
< yynrhs
; yyi
++)
1177 YYFPRINTF (stderr
, " $%d = ", yyi
+ 1);
1178 yy_symbol_print (stderr
, yyrhs
[yyprhs
[yyrule
] + yyi
],
1179 &(yyvsp
[(yyi
+ 1) - (yynrhs
)])
1180 , &(yylsp
[(yyi
+ 1) - (yynrhs
)]) , parser
);
1181 YYFPRINTF (stderr
, "\n");
1185 # define YY_REDUCE_PRINT(Rule) \
1188 yy_reduce_print (yyvsp, yylsp, Rule, parser); \
1191 /* Nonzero means print parse trace. It is left uninitialized so that
1192 multiple parsers can coexist. */
1194 #else /* !YYDEBUG */
1195 # define YYDPRINTF(Args)
1196 # define YY_SYMBOL_PRINT(Title, Type, Value, Location)
1197 # define YY_STACK_PRINT(Bottom, Top)
1198 # define YY_REDUCE_PRINT(Rule)
1199 #endif /* !YYDEBUG */
1202 /* YYINITDEPTH -- initial size of the parser's stacks. */
1204 # define YYINITDEPTH 200
1207 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
1208 if the built-in stack extension method is used).
1210 Do not make this value too large; the results are undefined if
1211 YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
1212 evaluated with infinite-precision integer arithmetic. */
1215 # define YYMAXDEPTH 10000
1223 # if defined __GLIBC__ && defined _STRING_H
1224 # define yystrlen strlen
1226 /* Return the length of YYSTR. */
1227 #if (defined __STDC__ || defined __C99__FUNC__ \
1228 || defined __cplusplus || defined _MSC_VER)
1230 yystrlen (const char *yystr
)
1238 for (yylen
= 0; yystr
[yylen
]; yylen
++)
1246 # if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
1247 # define yystpcpy stpcpy
1249 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
1251 #if (defined __STDC__ || defined __C99__FUNC__ \
1252 || defined __cplusplus || defined _MSC_VER)
1254 yystpcpy (char *yydest
, const char *yysrc
)
1257 yystpcpy (yydest
, yysrc
)
1263 const char *yys
= yysrc
;
1265 while ((*yyd
++ = *yys
++) != '\0')
1274 /* Copy to YYRES the contents of YYSTR after stripping away unnecessary
1275 quotes and backslashes, so that it's suitable for yyerror. The
1276 heuristic is that double-quoting is unnecessary unless the string
1277 contains an apostrophe, a comma, or backslash (other than
1278 backslash-backslash). YYSTR is taken from yytname. If YYRES is
1279 null, do not copy; instead, return the length of what the result
1282 yytnamerr (char *yyres
, const char *yystr
)
1287 char const *yyp
= yystr
;
1294 goto do_not_strip_quotes
;
1298 goto do_not_strip_quotes
;
1311 do_not_strip_quotes
: ;
1315 return yystrlen (yystr
);
1317 return yystpcpy (yyres
, yystr
) - yyres
;
1321 /* Copy into YYRESULT an error message about the unexpected token
1322 YYCHAR while in state YYSTATE. Return the number of bytes copied,
1323 including the terminating null byte. If YYRESULT is null, do not
1324 copy anything; just return the number of bytes that would be
1325 copied. As a special case, return 0 if an ordinary "syntax error"
1326 message will do. Return YYSIZE_MAXIMUM if overflow occurs during
1327 size calculation. */
1329 yysyntax_error (char *yyresult
, int yystate
, int yychar
)
1331 int yyn
= yypact
[yystate
];
1333 if (! (YYPACT_NINF
< yyn
&& yyn
<= YYLAST
))
1337 int yytype
= YYTRANSLATE (yychar
);
1338 YYSIZE_T yysize0
= yytnamerr (0, yytname
[yytype
]);
1339 YYSIZE_T yysize
= yysize0
;
1341 int yysize_overflow
= 0;
1342 enum { YYERROR_VERBOSE_ARGS_MAXIMUM
= 5 };
1343 char const *yyarg
[YYERROR_VERBOSE_ARGS_MAXIMUM
];
1347 /* This is so xgettext sees the translatable formats that are
1348 constructed on the fly. */
1349 YY_("syntax error, unexpected %s");
1350 YY_("syntax error, unexpected %s, expecting %s");
1351 YY_("syntax error, unexpected %s, expecting %s or %s");
1352 YY_("syntax error, unexpected %s, expecting %s or %s or %s");
1353 YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s");
1357 static char const yyunexpected
[] = "syntax error, unexpected %s";
1358 static char const yyexpecting
[] = ", expecting %s";
1359 static char const yyor
[] = " or %s";
1360 char yyformat
[sizeof yyunexpected
1361 + sizeof yyexpecting
- 1
1362 + ((YYERROR_VERBOSE_ARGS_MAXIMUM
- 2)
1363 * (sizeof yyor
- 1))];
1364 char const *yyprefix
= yyexpecting
;
1366 /* Start YYX at -YYN if negative to avoid negative indexes in
1368 int yyxbegin
= yyn
< 0 ? -yyn
: 0;
1370 /* Stay within bounds of both yycheck and yytname. */
1371 int yychecklim
= YYLAST
- yyn
+ 1;
1372 int yyxend
= yychecklim
< YYNTOKENS
? yychecklim
: YYNTOKENS
;
1375 yyarg
[0] = yytname
[yytype
];
1376 yyfmt
= yystpcpy (yyformat
, yyunexpected
);
1378 for (yyx
= yyxbegin
; yyx
< yyxend
; ++yyx
)
1379 if (yycheck
[yyx
+ yyn
] == yyx
&& yyx
!= YYTERROR
)
1381 if (yycount
== YYERROR_VERBOSE_ARGS_MAXIMUM
)
1385 yyformat
[sizeof yyunexpected
- 1] = '\0';
1388 yyarg
[yycount
++] = yytname
[yyx
];
1389 yysize1
= yysize
+ yytnamerr (0, yytname
[yyx
]);
1390 yysize_overflow
|= (yysize1
< yysize
);
1392 yyfmt
= yystpcpy (yyfmt
, yyprefix
);
1396 yyf
= YY_(yyformat
);
1397 yysize1
= yysize
+ yystrlen (yyf
);
1398 yysize_overflow
|= (yysize1
< yysize
);
1401 if (yysize_overflow
)
1402 return YYSIZE_MAXIMUM
;
1406 /* Avoid sprintf, as that infringes on the user's name space.
1407 Don't have undefined behavior even if the translation
1408 produced a string with the wrong number of "%s"s. */
1409 char *yyp
= yyresult
;
1411 while ((*yyp
= *yyf
) != '\0')
1413 if (*yyp
== '%' && yyf
[1] == 's' && yyi
< yycount
)
1415 yyp
+= yytnamerr (yyp
, yyarg
[yyi
++]);
1428 #endif /* YYERROR_VERBOSE */
1431 /*-----------------------------------------------.
1432 | Release the memory associated to this symbol. |
1433 `-----------------------------------------------*/
1436 #if (defined __STDC__ || defined __C99__FUNC__ \
1437 || defined __cplusplus || defined _MSC_VER)
1439 yydestruct (const char *yymsg
, int yytype
, YYSTYPE
*yyvaluep
, YYLTYPE
*yylocationp
, glcpp_parser_t
*parser
)
1442 yydestruct (yymsg
, yytype
, yyvaluep
, yylocationp
, parser
)
1446 YYLTYPE
*yylocationp
;
1447 glcpp_parser_t
*parser
;
1451 YYUSE (yylocationp
);
1456 YY_SYMBOL_PRINT (yymsg
, yytype
, yyvaluep
, yylocationp
);
1466 /* Prevent warnings from -Wmissing-prototypes. */
1467 #ifdef YYPARSE_PARAM
1468 #if defined __STDC__ || defined __cplusplus
1469 int yyparse (void *YYPARSE_PARAM
);
1473 #else /* ! YYPARSE_PARAM */
1474 #if defined __STDC__ || defined __cplusplus
1475 int yyparse (glcpp_parser_t
*parser
);
1479 #endif /* ! YYPARSE_PARAM */
1485 /*-------------------------.
1486 | yyparse or yypush_parse. |
1487 `-------------------------*/
1489 #ifdef YYPARSE_PARAM
1490 #if (defined __STDC__ || defined __C99__FUNC__ \
1491 || defined __cplusplus || defined _MSC_VER)
1493 yyparse (void *YYPARSE_PARAM
)
1496 yyparse (YYPARSE_PARAM
)
1497 void *YYPARSE_PARAM
;
1499 #else /* ! YYPARSE_PARAM */
1500 #if (defined __STDC__ || defined __C99__FUNC__ \
1501 || defined __cplusplus || defined _MSC_VER)
1503 yyparse (glcpp_parser_t
*parser
)
1507 glcpp_parser_t
*parser
;
1511 /* The lookahead symbol. */
1514 /* The semantic value of the lookahead symbol. */
1517 /* Location data for the lookahead symbol. */
1520 /* Number of syntax errors so far. */
1524 /* Number of tokens to shift before error messages enabled. */
1527 /* The stacks and their tools:
1528 `yyss': related to states.
1529 `yyvs': related to semantic values.
1530 `yyls': related to locations.
1532 Refer to the stacks thru separate pointers, to allow yyoverflow
1533 to reallocate them elsewhere. */
1535 /* The state stack. */
1536 yytype_int16 yyssa
[YYINITDEPTH
];
1538 yytype_int16
*yyssp
;
1540 /* The semantic value stack. */
1541 YYSTYPE yyvsa
[YYINITDEPTH
];
1545 /* The location stack. */
1546 YYLTYPE yylsa
[YYINITDEPTH
];
1550 /* The locations where the error started and ended. */
1551 YYLTYPE yyerror_range
[3];
1553 YYSIZE_T yystacksize
;
1557 /* Lookahead token as an internal (translated) token number. */
1559 /* The variables used to return semantic value and location from the
1565 /* Buffer for error messages, and its allocated size. */
1567 char *yymsg
= yymsgbuf
;
1568 YYSIZE_T yymsg_alloc
= sizeof yymsgbuf
;
1571 #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N), yylsp -= (N))
1573 /* The number of symbols on the RHS of the reduced rule.
1574 Keep to zero when no symbol should be popped. */
1581 yystacksize
= YYINITDEPTH
;
1583 YYDPRINTF ((stderr
, "Starting parse\n"));
1588 yychar
= YYEMPTY
; /* Cause a token to be read. */
1590 /* Initialize stack pointers.
1591 Waste one element of value and location stack
1592 so that they stay on the same level as the state stack.
1593 The wasted elements are never initialized. */
1598 #if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL
1599 /* Initialize the default location before parsing starts. */
1600 yylloc
.first_line
= yylloc
.last_line
= 1;
1601 yylloc
.first_column
= yylloc
.last_column
= 1;
1604 /* User initialization code. */
1606 /* Line 1251 of yacc.c */
1607 #line 148 "glcpp/glcpp-parse.y"
1609 yylloc
.first_line
= 1;
1610 yylloc
.first_column
= 1;
1611 yylloc
.last_line
= 1;
1612 yylloc
.last_column
= 1;
1616 /* Line 1251 of yacc.c */
1617 #line 1618 "glcpp/glcpp-parse.c"
1622 /*------------------------------------------------------------.
1623 | yynewstate -- Push a new state, which is found in yystate. |
1624 `------------------------------------------------------------*/
1626 /* In all cases, when you get here, the value and location stacks
1627 have just been pushed. So pushing a state here evens the stacks. */
1633 if (yyss
+ yystacksize
- 1 <= yyssp
)
1635 /* Get the current used size of the three stacks, in elements. */
1636 YYSIZE_T yysize
= yyssp
- yyss
+ 1;
1640 /* Give user a chance to reallocate the stack. Use copies of
1641 these so that the &'s don't force the real ones into
1643 YYSTYPE
*yyvs1
= yyvs
;
1644 yytype_int16
*yyss1
= yyss
;
1645 YYLTYPE
*yyls1
= yyls
;
1647 /* Each stack pointer address is followed by the size of the
1648 data in use in that stack, in bytes. This used to be a
1649 conditional around just the two extra args, but that might
1650 be undefined if yyoverflow is a macro. */
1651 yyoverflow (YY_("memory exhausted"),
1652 &yyss1
, yysize
* sizeof (*yyssp
),
1653 &yyvs1
, yysize
* sizeof (*yyvsp
),
1654 &yyls1
, yysize
* sizeof (*yylsp
),
1661 #else /* no yyoverflow */
1662 # ifndef YYSTACK_RELOCATE
1663 goto yyexhaustedlab
;
1665 /* Extend the stack our own way. */
1666 if (YYMAXDEPTH
<= yystacksize
)
1667 goto yyexhaustedlab
;
1669 if (YYMAXDEPTH
< yystacksize
)
1670 yystacksize
= YYMAXDEPTH
;
1673 yytype_int16
*yyss1
= yyss
;
1674 union yyalloc
*yyptr
=
1675 (union yyalloc
*) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize
));
1677 goto yyexhaustedlab
;
1678 YYSTACK_RELOCATE (yyss_alloc
, yyss
);
1679 YYSTACK_RELOCATE (yyvs_alloc
, yyvs
);
1680 YYSTACK_RELOCATE (yyls_alloc
, yyls
);
1681 # undef YYSTACK_RELOCATE
1683 YYSTACK_FREE (yyss1
);
1686 #endif /* no yyoverflow */
1688 yyssp
= yyss
+ yysize
- 1;
1689 yyvsp
= yyvs
+ yysize
- 1;
1690 yylsp
= yyls
+ yysize
- 1;
1692 YYDPRINTF ((stderr
, "Stack size increased to %lu\n",
1693 (unsigned long int) yystacksize
));
1695 if (yyss
+ yystacksize
- 1 <= yyssp
)
1699 YYDPRINTF ((stderr
, "Entering state %d\n", yystate
));
1701 if (yystate
== YYFINAL
)
1711 /* Do appropriate processing given the current state. Read a
1712 lookahead token if we need one and don't already have one. */
1714 /* First try to decide what to do without reference to lookahead token. */
1715 yyn
= yypact
[yystate
];
1716 if (yyn
== YYPACT_NINF
)
1719 /* Not known => get a lookahead token if don't already have one. */
1721 /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */
1722 if (yychar
== YYEMPTY
)
1724 YYDPRINTF ((stderr
, "Reading a token: "));
1728 if (yychar
<= YYEOF
)
1730 yychar
= yytoken
= YYEOF
;
1731 YYDPRINTF ((stderr
, "Now at end of input.\n"));
1735 yytoken
= YYTRANSLATE (yychar
);
1736 YY_SYMBOL_PRINT ("Next token is", yytoken
, &yylval
, &yylloc
);
1739 /* If the proper action on seeing token YYTOKEN is to reduce or to
1740 detect an error, take that action. */
1742 if (yyn
< 0 || YYLAST
< yyn
|| yycheck
[yyn
] != yytoken
)
1747 if (yyn
== 0 || yyn
== YYTABLE_NINF
)
1753 /* Count tokens shifted since error; after three, turn off error
1758 /* Shift the lookahead token. */
1759 YY_SYMBOL_PRINT ("Shifting", yytoken
, &yylval
, &yylloc
);
1761 /* Discard the shifted token. */
1770 /*-----------------------------------------------------------.
1771 | yydefault -- do the default action for the current state. |
1772 `-----------------------------------------------------------*/
1774 yyn
= yydefact
[yystate
];
1780 /*-----------------------------.
1781 | yyreduce -- Do a reduction. |
1782 `-----------------------------*/
1784 /* yyn is the number of a rule to reduce with. */
1787 /* If YYLEN is nonzero, implement the default value of the action:
1790 Otherwise, the following line sets YYVAL to garbage.
1791 This behavior is undocumented and Bison
1792 users should not rely upon it. Assigning to YYVAL
1793 unconditionally makes the parser a bit smaller, and it avoids a
1794 GCC warning that YYVAL may be used uninitialized. */
1795 yyval
= yyvsp
[1-yylen
];
1797 /* Default location. */
1798 YYLLOC_DEFAULT (yyloc
, (yylsp
- yylen
), yylen
);
1799 YY_REDUCE_PRINT (yyn
);
1804 /* Line 1464 of yacc.c */
1805 #line 187 "glcpp/glcpp-parse.y"
1807 ralloc_strcat (&parser
->output
, "\n");
1813 /* Line 1464 of yacc.c */
1814 #line 190 "glcpp/glcpp-parse.y"
1816 _glcpp_parser_print_expanded_token_list (parser
, (yyvsp
[(1) - (1)].token_list
));
1817 ralloc_strcat (&parser
->output
, "\n");
1818 ralloc_free ((yyvsp
[(1) - (1)].token_list
));
1824 /* Line 1464 of yacc.c */
1825 #line 200 "glcpp/glcpp-parse.y"
1827 _glcpp_parser_skip_stack_push_if (parser
, & (yylsp
[(1) - (3)]), (yyvsp
[(2) - (3)].ival
));
1833 /* Line 1464 of yacc.c */
1834 #line 203 "glcpp/glcpp-parse.y"
1836 _glcpp_parser_skip_stack_change_if (parser
, & (yylsp
[(1) - (3)]), "elif", (yyvsp
[(2) - (3)].ival
));
1842 /* Line 1464 of yacc.c */
1843 #line 209 "glcpp/glcpp-parse.y"
1845 _define_object_macro (parser
, & (yylsp
[(2) - (4)]), (yyvsp
[(2) - (4)].str
), (yyvsp
[(3) - (4)].token_list
));
1851 /* Line 1464 of yacc.c */
1852 #line 212 "glcpp/glcpp-parse.y"
1854 _define_function_macro (parser
, & (yylsp
[(2) - (6)]), (yyvsp
[(2) - (6)].str
), NULL
, (yyvsp
[(5) - (6)].token_list
));
1860 /* Line 1464 of yacc.c */
1861 #line 215 "glcpp/glcpp-parse.y"
1863 _define_function_macro (parser
, & (yylsp
[(2) - (7)]), (yyvsp
[(2) - (7)].str
), (yyvsp
[(4) - (7)].string_list
), (yyvsp
[(6) - (7)].token_list
));
1869 /* Line 1464 of yacc.c */
1870 #line 218 "glcpp/glcpp-parse.y"
1872 macro_t
*macro
= hash_table_find (parser
->defines
, (yyvsp
[(2) - (3)].str
));
1874 hash_table_remove (parser
->defines
, (yyvsp
[(2) - (3)].str
));
1875 ralloc_free (macro
);
1877 ralloc_free ((yyvsp
[(2) - (3)].str
));
1883 /* Line 1464 of yacc.c */
1884 #line 226 "glcpp/glcpp-parse.y"
1886 /* Be careful to only evaluate the 'if' expression if
1887 * we are not skipping. When we are skipping, we
1888 * simply push a new 0-valued 'if' onto the skip
1891 * This avoids generating diagnostics for invalid
1892 * expressions that are being skipped. */
1893 if (parser
->skip_stack
== NULL
||
1894 parser
->skip_stack
->type
== SKIP_NO_SKIP
)
1896 _glcpp_parser_expand_if (parser
, IF_EXPANDED
, (yyvsp
[(2) - (3)].token_list
));
1900 _glcpp_parser_skip_stack_push_if (parser
, & (yylsp
[(1) - (3)]), 0);
1901 parser
->skip_stack
->type
= SKIP_TO_ENDIF
;
1908 /* Line 1464 of yacc.c */
1909 #line 245 "glcpp/glcpp-parse.y"
1911 /* #if without an expression is only an error if we
1912 * are not skipping */
1913 if (parser
->skip_stack
== NULL
||
1914 parser
->skip_stack
->type
== SKIP_NO_SKIP
)
1916 glcpp_error(& (yylsp
[(1) - (2)]), parser
, "#if with no expression");
1918 _glcpp_parser_skip_stack_push_if (parser
, & (yylsp
[(1) - (2)]), 0);
1924 /* Line 1464 of yacc.c */
1925 #line 255 "glcpp/glcpp-parse.y"
1927 macro_t
*macro
= hash_table_find (parser
->defines
, (yyvsp
[(2) - (4)].str
));
1928 ralloc_free ((yyvsp
[(2) - (4)].str
));
1929 _glcpp_parser_skip_stack_push_if (parser
, & (yylsp
[(1) - (4)]), macro
!= NULL
);
1935 /* Line 1464 of yacc.c */
1936 #line 260 "glcpp/glcpp-parse.y"
1938 macro_t
*macro
= hash_table_find (parser
->defines
, (yyvsp
[(2) - (4)].str
));
1939 ralloc_free ((yyvsp
[(2) - (4)].str
));
1940 _glcpp_parser_skip_stack_push_if (parser
, & (yylsp
[(1) - (4)]), macro
== NULL
);
1946 /* Line 1464 of yacc.c */
1947 #line 265 "glcpp/glcpp-parse.y"
1949 /* Be careful to only evaluate the 'elif' expression
1950 * if we are not skipping. When we are skipping, we
1951 * simply change to a 0-valued 'elif' on the skip
1954 * This avoids generating diagnostics for invalid
1955 * expressions that are being skipped. */
1956 if (parser
->skip_stack
&&
1957 parser
->skip_stack
->type
== SKIP_TO_ELSE
)
1959 _glcpp_parser_expand_if (parser
, ELIF_EXPANDED
, (yyvsp
[(2) - (3)].token_list
));
1963 _glcpp_parser_skip_stack_change_if (parser
, & (yylsp
[(1) - (3)]),
1971 /* Line 1464 of yacc.c */
1972 #line 284 "glcpp/glcpp-parse.y"
1974 /* #elif without an expression is an error unless we
1976 if (parser
->skip_stack
&&
1977 parser
->skip_stack
->type
== SKIP_TO_ELSE
)
1979 glcpp_error(& (yylsp
[(1) - (2)]), parser
, "#elif with no expression");
1983 _glcpp_parser_skip_stack_change_if (parser
, & (yylsp
[(1) - (2)]),
1985 glcpp_warning(& (yylsp
[(1) - (2)]), parser
, "ignoring illegal #elif without expression");
1992 /* Line 1464 of yacc.c */
1993 #line 299 "glcpp/glcpp-parse.y"
1995 _glcpp_parser_skip_stack_change_if (parser
, & (yylsp
[(1) - (2)]), "else", 1);
2001 /* Line 1464 of yacc.c */
2002 #line 302 "glcpp/glcpp-parse.y"
2004 _glcpp_parser_skip_stack_pop (parser
, & (yylsp
[(1) - (2)]));
2010 /* Line 1464 of yacc.c */
2011 #line 305 "glcpp/glcpp-parse.y"
2013 macro_t
*macro
= hash_table_find (parser
->defines
, "__VERSION__");
2015 hash_table_remove (parser
->defines
, "__VERSION__");
2016 ralloc_free (macro
);
2018 add_builtin_define (parser
, "__VERSION__", (yyvsp
[(2) - (3)].ival
));
2020 if ((yyvsp
[(2) - (3)].ival
) == 100)
2021 add_builtin_define (parser
, "GL_ES", 1);
2023 /* Currently, all ES2 implementations support highp in the
2024 * fragment shader, so we always define this macro in ES2.
2025 * If we ever get a driver that doesn't support highp, we'll
2026 * need to add a flag to the gl_context and check that here.
2028 if ((yyvsp
[(2) - (3)].ival
) >= 130 || (yyvsp
[(2) - (3)].ival
) == 100)
2029 add_builtin_define (parser
, "GL_FRAGMENT_PRECISION_HIGH", 1);
2031 ralloc_asprintf_append (&parser
->output
, "#version %" PRIiMAX
, (yyvsp
[(2) - (3)].ival
));
2037 /* Line 1464 of yacc.c */
2038 #line 330 "glcpp/glcpp-parse.y"
2040 if (strlen ((yyvsp
[(1) - (1)].str
)) >= 3 && strncmp ((yyvsp
[(1) - (1)].str
), "0x", 2) == 0) {
2041 (yyval
.ival
) = strtoll ((yyvsp
[(1) - (1)].str
) + 2, NULL
, 16);
2042 } else if ((yyvsp
[(1) - (1)].str
)[0] == '0') {
2043 (yyval
.ival
) = strtoll ((yyvsp
[(1) - (1)].str
), NULL
, 8);
2045 (yyval
.ival
) = strtoll ((yyvsp
[(1) - (1)].str
), NULL
, 10);
2052 /* Line 1464 of yacc.c */
2053 #line 339 "glcpp/glcpp-parse.y"
2055 (yyval
.ival
) = (yyvsp
[(1) - (1)].ival
);
2061 /* Line 1464 of yacc.c */
2062 #line 345 "glcpp/glcpp-parse.y"
2064 (yyval
.ival
) = (yyvsp
[(1) - (3)].ival
) || (yyvsp
[(3) - (3)].ival
);
2070 /* Line 1464 of yacc.c */
2071 #line 348 "glcpp/glcpp-parse.y"
2073 (yyval
.ival
) = (yyvsp
[(1) - (3)].ival
) && (yyvsp
[(3) - (3)].ival
);
2079 /* Line 1464 of yacc.c */
2080 #line 351 "glcpp/glcpp-parse.y"
2082 (yyval
.ival
) = (yyvsp
[(1) - (3)].ival
) | (yyvsp
[(3) - (3)].ival
);
2088 /* Line 1464 of yacc.c */
2089 #line 354 "glcpp/glcpp-parse.y"
2091 (yyval
.ival
) = (yyvsp
[(1) - (3)].ival
) ^ (yyvsp
[(3) - (3)].ival
);
2097 /* Line 1464 of yacc.c */
2098 #line 357 "glcpp/glcpp-parse.y"
2100 (yyval
.ival
) = (yyvsp
[(1) - (3)].ival
) & (yyvsp
[(3) - (3)].ival
);
2106 /* Line 1464 of yacc.c */
2107 #line 360 "glcpp/glcpp-parse.y"
2109 (yyval
.ival
) = (yyvsp
[(1) - (3)].ival
) != (yyvsp
[(3) - (3)].ival
);
2115 /* Line 1464 of yacc.c */
2116 #line 363 "glcpp/glcpp-parse.y"
2118 (yyval
.ival
) = (yyvsp
[(1) - (3)].ival
) == (yyvsp
[(3) - (3)].ival
);
2124 /* Line 1464 of yacc.c */
2125 #line 366 "glcpp/glcpp-parse.y"
2127 (yyval
.ival
) = (yyvsp
[(1) - (3)].ival
) >= (yyvsp
[(3) - (3)].ival
);
2133 /* Line 1464 of yacc.c */
2134 #line 369 "glcpp/glcpp-parse.y"
2136 (yyval
.ival
) = (yyvsp
[(1) - (3)].ival
) <= (yyvsp
[(3) - (3)].ival
);
2142 /* Line 1464 of yacc.c */
2143 #line 372 "glcpp/glcpp-parse.y"
2145 (yyval
.ival
) = (yyvsp
[(1) - (3)].ival
) > (yyvsp
[(3) - (3)].ival
);
2151 /* Line 1464 of yacc.c */
2152 #line 375 "glcpp/glcpp-parse.y"
2154 (yyval
.ival
) = (yyvsp
[(1) - (3)].ival
) < (yyvsp
[(3) - (3)].ival
);
2160 /* Line 1464 of yacc.c */
2161 #line 378 "glcpp/glcpp-parse.y"
2163 (yyval
.ival
) = (yyvsp
[(1) - (3)].ival
) >> (yyvsp
[(3) - (3)].ival
);
2169 /* Line 1464 of yacc.c */
2170 #line 381 "glcpp/glcpp-parse.y"
2172 (yyval
.ival
) = (yyvsp
[(1) - (3)].ival
) << (yyvsp
[(3) - (3)].ival
);
2178 /* Line 1464 of yacc.c */
2179 #line 384 "glcpp/glcpp-parse.y"
2181 (yyval
.ival
) = (yyvsp
[(1) - (3)].ival
) - (yyvsp
[(3) - (3)].ival
);
2187 /* Line 1464 of yacc.c */
2188 #line 387 "glcpp/glcpp-parse.y"
2190 (yyval
.ival
) = (yyvsp
[(1) - (3)].ival
) + (yyvsp
[(3) - (3)].ival
);
2196 /* Line 1464 of yacc.c */
2197 #line 390 "glcpp/glcpp-parse.y"
2199 if ((yyvsp
[(3) - (3)].ival
) == 0) {
2200 yyerror (& (yylsp
[(1) - (3)]), parser
,
2201 "zero modulus in preprocessor directive");
2203 (yyval
.ival
) = (yyvsp
[(1) - (3)].ival
) % (yyvsp
[(3) - (3)].ival
);
2210 /* Line 1464 of yacc.c */
2211 #line 398 "glcpp/glcpp-parse.y"
2213 if ((yyvsp
[(3) - (3)].ival
) == 0) {
2214 yyerror (& (yylsp
[(1) - (3)]), parser
,
2215 "division by 0 in preprocessor directive");
2217 (yyval
.ival
) = (yyvsp
[(1) - (3)].ival
) / (yyvsp
[(3) - (3)].ival
);
2224 /* Line 1464 of yacc.c */
2225 #line 406 "glcpp/glcpp-parse.y"
2227 (yyval
.ival
) = (yyvsp
[(1) - (3)].ival
) * (yyvsp
[(3) - (3)].ival
);
2233 /* Line 1464 of yacc.c */
2234 #line 409 "glcpp/glcpp-parse.y"
2236 (yyval
.ival
) = ! (yyvsp
[(2) - (2)].ival
);
2242 /* Line 1464 of yacc.c */
2243 #line 412 "glcpp/glcpp-parse.y"
2245 (yyval
.ival
) = ~ (yyvsp
[(2) - (2)].ival
);
2251 /* Line 1464 of yacc.c */
2252 #line 415 "glcpp/glcpp-parse.y"
2254 (yyval
.ival
) = - (yyvsp
[(2) - (2)].ival
);
2260 /* Line 1464 of yacc.c */
2261 #line 418 "glcpp/glcpp-parse.y"
2263 (yyval
.ival
) = + (yyvsp
[(2) - (2)].ival
);
2269 /* Line 1464 of yacc.c */
2270 #line 421 "glcpp/glcpp-parse.y"
2272 (yyval
.ival
) = (yyvsp
[(2) - (3)].ival
);
2278 /* Line 1464 of yacc.c */
2279 #line 427 "glcpp/glcpp-parse.y"
2281 (yyval
.string_list
) = _string_list_create (parser
);
2282 _string_list_append_item ((yyval
.string_list
), (yyvsp
[(1) - (1)].str
));
2283 ralloc_steal ((yyval
.string_list
), (yyvsp
[(1) - (1)].str
));
2289 /* Line 1464 of yacc.c */
2290 #line 432 "glcpp/glcpp-parse.y"
2292 (yyval
.string_list
) = (yyvsp
[(1) - (3)].string_list
);
2293 _string_list_append_item ((yyval
.string_list
), (yyvsp
[(3) - (3)].str
));
2294 ralloc_steal ((yyval
.string_list
), (yyvsp
[(3) - (3)].str
));
2300 /* Line 1464 of yacc.c */
2301 #line 440 "glcpp/glcpp-parse.y"
2302 { (yyval
.token_list
) = NULL
; ;}
2307 /* Line 1464 of yacc.c */
2308 #line 445 "glcpp/glcpp-parse.y"
2310 yyerror (& (yylsp
[(1) - (2)]), parser
, "Invalid tokens after #");
2316 /* Line 1464 of yacc.c */
2317 #line 451 "glcpp/glcpp-parse.y"
2318 { (yyval
.token_list
) = NULL
; ;}
2323 /* Line 1464 of yacc.c */
2324 #line 457 "glcpp/glcpp-parse.y"
2326 glcpp_warning(&(yylsp
[(1) - (1)]), parser
, "extra tokens at end of directive");
2332 /* Line 1464 of yacc.c */
2333 #line 464 "glcpp/glcpp-parse.y"
2335 int v
= hash_table_find (parser
->defines
, (yyvsp
[(2) - (2)].str
)) ? 1 : 0;
2336 (yyval
.token
) = _token_create_ival (parser
, INTEGER
, v
);
2342 /* Line 1464 of yacc.c */
2343 #line 468 "glcpp/glcpp-parse.y"
2345 int v
= hash_table_find (parser
->defines
, (yyvsp
[(3) - (4)].str
)) ? 1 : 0;
2346 (yyval
.token
) = _token_create_ival (parser
, INTEGER
, v
);
2352 /* Line 1464 of yacc.c */
2353 #line 477 "glcpp/glcpp-parse.y"
2355 (yyval
.token_list
) = _token_list_create (parser
);
2356 _token_list_append ((yyval
.token_list
), (yyvsp
[(1) - (1)].token
));
2362 /* Line 1464 of yacc.c */
2363 #line 481 "glcpp/glcpp-parse.y"
2365 (yyval
.token_list
) = (yyvsp
[(1) - (2)].token_list
);
2366 _token_list_append ((yyval
.token_list
), (yyvsp
[(2) - (2)].token
));
2372 /* Line 1464 of yacc.c */
2373 #line 488 "glcpp/glcpp-parse.y"
2375 parser
->space_tokens
= 1;
2376 (yyval
.token_list
) = _token_list_create (parser
);
2377 _token_list_append ((yyval
.token_list
), (yyvsp
[(1) - (1)].token
));
2383 /* Line 1464 of yacc.c */
2384 #line 493 "glcpp/glcpp-parse.y"
2386 (yyval
.token_list
) = (yyvsp
[(1) - (2)].token_list
);
2387 _token_list_append ((yyval
.token_list
), (yyvsp
[(2) - (2)].token
));
2393 /* Line 1464 of yacc.c */
2394 #line 500 "glcpp/glcpp-parse.y"
2396 (yyval
.token
) = _token_create_str (parser
, IDENTIFIER
, (yyvsp
[(1) - (1)].str
));
2397 (yyval
.token
)->location
= yylloc
;
2403 /* Line 1464 of yacc.c */
2404 #line 504 "glcpp/glcpp-parse.y"
2406 (yyval
.token
) = _token_create_str (parser
, INTEGER_STRING
, (yyvsp
[(1) - (1)].str
));
2407 (yyval
.token
)->location
= yylloc
;
2413 /* Line 1464 of yacc.c */
2414 #line 508 "glcpp/glcpp-parse.y"
2416 (yyval
.token
) = _token_create_ival (parser
, (yyvsp
[(1) - (1)].ival
), (yyvsp
[(1) - (1)].ival
));
2417 (yyval
.token
)->location
= yylloc
;
2423 /* Line 1464 of yacc.c */
2424 #line 512 "glcpp/glcpp-parse.y"
2426 (yyval
.token
) = _token_create_str (parser
, OTHER
, (yyvsp
[(1) - (1)].str
));
2427 (yyval
.token
)->location
= yylloc
;
2433 /* Line 1464 of yacc.c */
2434 #line 516 "glcpp/glcpp-parse.y"
2436 (yyval
.token
) = _token_create_ival (parser
, SPACE
, SPACE
);
2437 (yyval
.token
)->location
= yylloc
;
2443 /* Line 1464 of yacc.c */
2444 #line 523 "glcpp/glcpp-parse.y"
2445 { (yyval
.ival
) = '['; ;}
2450 /* Line 1464 of yacc.c */
2451 #line 524 "glcpp/glcpp-parse.y"
2452 { (yyval
.ival
) = ']'; ;}
2457 /* Line 1464 of yacc.c */
2458 #line 525 "glcpp/glcpp-parse.y"
2459 { (yyval
.ival
) = '('; ;}
2464 /* Line 1464 of yacc.c */
2465 #line 526 "glcpp/glcpp-parse.y"
2466 { (yyval
.ival
) = ')'; ;}
2471 /* Line 1464 of yacc.c */
2472 #line 527 "glcpp/glcpp-parse.y"
2473 { (yyval
.ival
) = '{'; ;}
2478 /* Line 1464 of yacc.c */
2479 #line 528 "glcpp/glcpp-parse.y"
2480 { (yyval
.ival
) = '}'; ;}
2485 /* Line 1464 of yacc.c */
2486 #line 529 "glcpp/glcpp-parse.y"
2487 { (yyval
.ival
) = '.'; ;}
2492 /* Line 1464 of yacc.c */
2493 #line 530 "glcpp/glcpp-parse.y"
2494 { (yyval
.ival
) = '&'; ;}
2499 /* Line 1464 of yacc.c */
2500 #line 531 "glcpp/glcpp-parse.y"
2501 { (yyval
.ival
) = '*'; ;}
2506 /* Line 1464 of yacc.c */
2507 #line 532 "glcpp/glcpp-parse.y"
2508 { (yyval
.ival
) = '+'; ;}
2513 /* Line 1464 of yacc.c */
2514 #line 533 "glcpp/glcpp-parse.y"
2515 { (yyval
.ival
) = '-'; ;}
2520 /* Line 1464 of yacc.c */
2521 #line 534 "glcpp/glcpp-parse.y"
2522 { (yyval
.ival
) = '~'; ;}
2527 /* Line 1464 of yacc.c */
2528 #line 535 "glcpp/glcpp-parse.y"
2529 { (yyval
.ival
) = '!'; ;}
2534 /* Line 1464 of yacc.c */
2535 #line 536 "glcpp/glcpp-parse.y"
2536 { (yyval
.ival
) = '/'; ;}
2541 /* Line 1464 of yacc.c */
2542 #line 537 "glcpp/glcpp-parse.y"
2543 { (yyval
.ival
) = '%'; ;}
2548 /* Line 1464 of yacc.c */
2549 #line 538 "glcpp/glcpp-parse.y"
2550 { (yyval
.ival
) = LEFT_SHIFT
; ;}
2555 /* Line 1464 of yacc.c */
2556 #line 539 "glcpp/glcpp-parse.y"
2557 { (yyval
.ival
) = RIGHT_SHIFT
; ;}
2562 /* Line 1464 of yacc.c */
2563 #line 540 "glcpp/glcpp-parse.y"
2564 { (yyval
.ival
) = '<'; ;}
2569 /* Line 1464 of yacc.c */
2570 #line 541 "glcpp/glcpp-parse.y"
2571 { (yyval
.ival
) = '>'; ;}
2576 /* Line 1464 of yacc.c */
2577 #line 542 "glcpp/glcpp-parse.y"
2578 { (yyval
.ival
) = LESS_OR_EQUAL
; ;}
2583 /* Line 1464 of yacc.c */
2584 #line 543 "glcpp/glcpp-parse.y"
2585 { (yyval
.ival
) = GREATER_OR_EQUAL
; ;}
2590 /* Line 1464 of yacc.c */
2591 #line 544 "glcpp/glcpp-parse.y"
2592 { (yyval
.ival
) = EQUAL
; ;}
2597 /* Line 1464 of yacc.c */
2598 #line 545 "glcpp/glcpp-parse.y"
2599 { (yyval
.ival
) = NOT_EQUAL
; ;}
2604 /* Line 1464 of yacc.c */
2605 #line 546 "glcpp/glcpp-parse.y"
2606 { (yyval
.ival
) = '^'; ;}
2611 /* Line 1464 of yacc.c */
2612 #line 547 "glcpp/glcpp-parse.y"
2613 { (yyval
.ival
) = '|'; ;}
2618 /* Line 1464 of yacc.c */
2619 #line 548 "glcpp/glcpp-parse.y"
2620 { (yyval
.ival
) = AND
; ;}
2625 /* Line 1464 of yacc.c */
2626 #line 549 "glcpp/glcpp-parse.y"
2627 { (yyval
.ival
) = OR
; ;}
2632 /* Line 1464 of yacc.c */
2633 #line 550 "glcpp/glcpp-parse.y"
2634 { (yyval
.ival
) = ';'; ;}
2639 /* Line 1464 of yacc.c */
2640 #line 551 "glcpp/glcpp-parse.y"
2641 { (yyval
.ival
) = ','; ;}
2646 /* Line 1464 of yacc.c */
2647 #line 552 "glcpp/glcpp-parse.y"
2648 { (yyval
.ival
) = '='; ;}
2653 /* Line 1464 of yacc.c */
2654 #line 553 "glcpp/glcpp-parse.y"
2655 { (yyval
.ival
) = PASTE
; ;}
2660 /* Line 1464 of yacc.c */
2661 #line 2662 "glcpp/glcpp-parse.c"
2664 YY_SYMBOL_PRINT ("-> $$ =", yyr1
[yyn
], &yyval
, &yyloc
);
2668 YY_STACK_PRINT (yyss
, yyssp
);
2673 /* Now `shift' the result of the reduction. Determine what state
2674 that goes to, based on the state we popped back to and the rule
2675 number reduced by. */
2679 yystate
= yypgoto
[yyn
- YYNTOKENS
] + *yyssp
;
2680 if (0 <= yystate
&& yystate
<= YYLAST
&& yycheck
[yystate
] == *yyssp
)
2681 yystate
= yytable
[yystate
];
2683 yystate
= yydefgoto
[yyn
- YYNTOKENS
];
2688 /*------------------------------------.
2689 | yyerrlab -- here on detecting error |
2690 `------------------------------------*/
2692 /* If not already recovering from an error, report this error. */
2696 #if ! YYERROR_VERBOSE
2697 yyerror (&yylloc
, parser
, YY_("syntax error"));
2700 YYSIZE_T yysize
= yysyntax_error (0, yystate
, yychar
);
2701 if (yymsg_alloc
< yysize
&& yymsg_alloc
< YYSTACK_ALLOC_MAXIMUM
)
2703 YYSIZE_T yyalloc
= 2 * yysize
;
2704 if (! (yysize
<= yyalloc
&& yyalloc
<= YYSTACK_ALLOC_MAXIMUM
))
2705 yyalloc
= YYSTACK_ALLOC_MAXIMUM
;
2706 if (yymsg
!= yymsgbuf
)
2707 YYSTACK_FREE (yymsg
);
2708 yymsg
= (char *) YYSTACK_ALLOC (yyalloc
);
2710 yymsg_alloc
= yyalloc
;
2714 yymsg_alloc
= sizeof yymsgbuf
;
2718 if (0 < yysize
&& yysize
<= yymsg_alloc
)
2720 (void) yysyntax_error (yymsg
, yystate
, yychar
);
2721 yyerror (&yylloc
, parser
, yymsg
);
2725 yyerror (&yylloc
, parser
, YY_("syntax error"));
2727 goto yyexhaustedlab
;
2733 yyerror_range
[1] = yylloc
;
2735 if (yyerrstatus
== 3)
2737 /* If just tried and failed to reuse lookahead token after an
2738 error, discard it. */
2740 if (yychar
<= YYEOF
)
2742 /* Return failure if at end of input. */
2743 if (yychar
== YYEOF
)
2748 yydestruct ("Error: discarding",
2749 yytoken
, &yylval
, &yylloc
, parser
);
2754 /* Else will try to reuse lookahead token after shifting the error
2759 /*---------------------------------------------------.
2760 | yyerrorlab -- error raised explicitly by YYERROR. |
2761 `---------------------------------------------------*/
2764 /* Pacify compilers like GCC when the user code never invokes
2765 YYERROR and the label yyerrorlab therefore never appears in user
2767 if (/*CONSTCOND*/ 0)
2770 yyerror_range
[1] = yylsp
[1-yylen
];
2771 /* Do not reclaim the symbols of the rule which action triggered
2775 YY_STACK_PRINT (yyss
, yyssp
);
2780 /*-------------------------------------------------------------.
2781 | yyerrlab1 -- common code for both syntax error and YYERROR. |
2782 `-------------------------------------------------------------*/
2784 yyerrstatus
= 3; /* Each real token shifted decrements this. */
2788 yyn
= yypact
[yystate
];
2789 if (yyn
!= YYPACT_NINF
)
2792 if (0 <= yyn
&& yyn
<= YYLAST
&& yycheck
[yyn
] == YYTERROR
)
2800 /* Pop the current state because it cannot handle the error token. */
2804 yyerror_range
[1] = *yylsp
;
2805 yydestruct ("Error: popping",
2806 yystos
[yystate
], yyvsp
, yylsp
, parser
);
2809 YY_STACK_PRINT (yyss
, yyssp
);
2814 yyerror_range
[2] = yylloc
;
2815 /* Using YYLLOC is tempting, but would change the location of
2816 the lookahead. YYLOC is available though. */
2817 YYLLOC_DEFAULT (yyloc
, yyerror_range
, 2);
2820 /* Shift the error token. */
2821 YY_SYMBOL_PRINT ("Shifting", yystos
[yyn
], yyvsp
, yylsp
);
2827 /*-------------------------------------.
2828 | yyacceptlab -- YYACCEPT comes here. |
2829 `-------------------------------------*/
2834 /*-----------------------------------.
2835 | yyabortlab -- YYABORT comes here. |
2836 `-----------------------------------*/
2841 #if !defined(yyoverflow) || YYERROR_VERBOSE
2842 /*-------------------------------------------------.
2843 | yyexhaustedlab -- memory exhaustion comes here. |
2844 `-------------------------------------------------*/
2846 yyerror (&yylloc
, parser
, YY_("memory exhausted"));
2852 if (yychar
!= YYEMPTY
)
2853 yydestruct ("Cleanup: discarding lookahead",
2854 yytoken
, &yylval
, &yylloc
, parser
);
2855 /* Do not reclaim the symbols of the rule which action triggered
2856 this YYABORT or YYACCEPT. */
2858 YY_STACK_PRINT (yyss
, yyssp
);
2859 while (yyssp
!= yyss
)
2861 yydestruct ("Cleanup: popping",
2862 yystos
[*yyssp
], yyvsp
, yylsp
, parser
);
2867 YYSTACK_FREE (yyss
);
2870 if (yymsg
!= yymsgbuf
)
2871 YYSTACK_FREE (yymsg
);
2873 /* Make sure YYID is used. */
2874 return YYID (yyresult
);
2879 /* Line 1684 of yacc.c */
2880 #line 556 "glcpp/glcpp-parse.y"
2884 _string_list_create (void *ctx
)
2886 string_list_t
*list
;
2888 list
= ralloc (ctx
, string_list_t
);
2896 _string_list_append_item (string_list_t
*list
, const char *str
)
2898 string_node_t
*node
;
2900 node
= ralloc (list
, string_node_t
);
2901 node
->str
= ralloc_strdup (node
, str
);
2905 if (list
->head
== NULL
) {
2908 list
->tail
->next
= node
;
2915 _string_list_contains (string_list_t
*list
, const char *member
, int *index
)
2917 string_node_t
*node
;
2923 for (i
= 0, node
= list
->head
; node
; i
++, node
= node
->next
) {
2924 if (strcmp (node
->str
, member
) == 0) {
2935 _string_list_length (string_list_t
*list
)
2938 string_node_t
*node
;
2943 for (node
= list
->head
; node
; node
= node
->next
)
2950 _string_list_equal (string_list_t
*a
, string_list_t
*b
)
2952 string_node_t
*node_a
, *node_b
;
2954 if (a
== NULL
&& b
== NULL
)
2957 if (a
== NULL
|| b
== NULL
)
2960 for (node_a
= a
->head
, node_b
= b
->head
;
2962 node_a
= node_a
->next
, node_b
= node_b
->next
)
2964 if (strcmp (node_a
->str
, node_b
->str
))
2968 /* Catch the case of lists being different lengths, (which
2969 * would cause the loop above to terminate after the shorter
2971 return node_a
== node_b
;
2975 _argument_list_create (void *ctx
)
2977 argument_list_t
*list
;
2979 list
= ralloc (ctx
, argument_list_t
);
2987 _argument_list_append (argument_list_t
*list
, token_list_t
*argument
)
2989 argument_node_t
*node
;
2991 node
= ralloc (list
, argument_node_t
);
2992 node
->argument
= argument
;
2996 if (list
->head
== NULL
) {
2999 list
->tail
->next
= node
;
3006 _argument_list_length (argument_list_t
*list
)
3009 argument_node_t
*node
;
3014 for (node
= list
->head
; node
; node
= node
->next
)
3021 _argument_list_member_at (argument_list_t
*list
, int index
)
3023 argument_node_t
*node
;
3030 for (i
= 0; i
< index
; i
++) {
3037 return node
->argument
;
3042 /* Note: This function ralloc_steal()s the str pointer. */
3044 _token_create_str (void *ctx
, int type
, char *str
)
3048 token
= ralloc (ctx
, token_t
);
3050 token
->value
.str
= str
;
3052 ralloc_steal (token
, str
);
3058 _token_create_ival (void *ctx
, int type
, int ival
)
3062 token
= ralloc (ctx
, token_t
);
3064 token
->value
.ival
= ival
;
3070 _token_list_create (void *ctx
)
3074 list
= ralloc (ctx
, token_list_t
);
3077 list
->non_space_tail
= NULL
;
3083 _token_list_append (token_list_t
*list
, token_t
*token
)
3087 node
= ralloc (list
, token_node_t
);
3088 node
->token
= token
;
3091 ralloc_steal (list
, token
);
3093 if (list
->head
== NULL
) {
3096 list
->tail
->next
= node
;
3100 if (token
->type
!= SPACE
)
3101 list
->non_space_tail
= node
;
3105 _token_list_append_list (token_list_t
*list
, token_list_t
*tail
)
3107 if (tail
== NULL
|| tail
->head
== NULL
)
3110 if (list
->head
== NULL
) {
3111 list
->head
= tail
->head
;
3113 list
->tail
->next
= tail
->head
;
3116 list
->tail
= tail
->tail
;
3117 list
->non_space_tail
= tail
->non_space_tail
;
3120 static token_list_t
*
3121 _token_list_copy (void *ctx
, token_list_t
*other
)
3129 copy
= _token_list_create (ctx
);
3130 for (node
= other
->head
; node
; node
= node
->next
) {
3131 token_t
*new_token
= ralloc (copy
, token_t
);
3132 *new_token
= *node
->token
;
3133 _token_list_append (copy
, new_token
);
3140 _token_list_trim_trailing_space (token_list_t
*list
)
3142 token_node_t
*tail
, *next
;
3144 if (list
->non_space_tail
) {
3145 tail
= list
->non_space_tail
->next
;
3146 list
->non_space_tail
->next
= NULL
;
3147 list
->tail
= list
->non_space_tail
;
3158 _token_list_is_empty_ignoring_space (token_list_t
*l
)
3166 while (n
!= NULL
&& n
->token
->type
== SPACE
)
3173 _token_list_equal_ignoring_space (token_list_t
*a
, token_list_t
*b
)
3175 token_node_t
*node_a
, *node_b
;
3177 if (a
== NULL
|| b
== NULL
) {
3178 int a_empty
= _token_list_is_empty_ignoring_space(a
);
3179 int b_empty
= _token_list_is_empty_ignoring_space(b
);
3180 return a_empty
== b_empty
;
3188 if (node_a
== NULL
&& node_b
== NULL
)
3191 if (node_a
== NULL
|| node_b
== NULL
)
3194 if (node_a
->token
->type
== SPACE
) {
3195 node_a
= node_a
->next
;
3199 if (node_b
->token
->type
== SPACE
) {
3200 node_b
= node_b
->next
;
3204 if (node_a
->token
->type
!= node_b
->token
->type
)
3207 switch (node_a
->token
->type
) {
3209 if (node_a
->token
->value
.ival
!=
3210 node_b
->token
->value
.ival
)
3216 case INTEGER_STRING
:
3218 if (strcmp (node_a
->token
->value
.str
,
3219 node_b
->token
->value
.str
))
3226 node_a
= node_a
->next
;
3227 node_b
= node_b
->next
;
3234 _token_print (char **out
, token_t
*token
)
3236 if (token
->type
< 256) {
3237 ralloc_asprintf_append (out
, "%c", token
->type
);
3241 switch (token
->type
) {
3243 ralloc_asprintf_append (out
, "%" PRIiMAX
, token
->value
.ival
);
3246 case INTEGER_STRING
:
3248 ralloc_strcat (out
, token
->value
.str
);
3251 ralloc_strcat (out
, " ");
3254 ralloc_strcat (out
, "<<");
3257 ralloc_strcat (out
, ">>");
3260 ralloc_strcat (out
, "<=");
3262 case GREATER_OR_EQUAL
:
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 ralloc_strcat (out
, ",");
3284 /* Nothing to print. */
3287 assert(!"Error: Don't know how to print token.");
3292 /* Return a new token (ralloc()ed off of 'token') formed by pasting
3293 * 'token' and 'other'. Note that this function may return 'token' or
3294 * 'other' directly rather than allocating anything new.
3296 * Caution: Only very cursory error-checking is performed to see if
3297 * the final result is a valid single token. */
3299 _token_paste (glcpp_parser_t
*parser
, token_t
*token
, token_t
*other
)
3301 token_t
*combined
= NULL
;
3303 /* Pasting a placeholder onto anything makes no change. */
3304 if (other
->type
== PLACEHOLDER
)
3307 /* When 'token' is a placeholder, just return 'other'. */
3308 if (token
->type
== PLACEHOLDER
)
3311 /* A very few single-character punctuators can be combined
3312 * with another to form a multi-character punctuator. */
3313 switch (token
->type
) {
3315 if (other
->type
== '<')
3316 combined
= _token_create_ival (token
, LEFT_SHIFT
, LEFT_SHIFT
);
3317 else if (other
->type
== '=')
3318 combined
= _token_create_ival (token
, LESS_OR_EQUAL
, LESS_OR_EQUAL
);
3321 if (other
->type
== '>')
3322 combined
= _token_create_ival (token
, RIGHT_SHIFT
, RIGHT_SHIFT
);
3323 else if (other
->type
== '=')
3324 combined
= _token_create_ival (token
, GREATER_OR_EQUAL
, GREATER_OR_EQUAL
);
3327 if (other
->type
== '=')
3328 combined
= _token_create_ival (token
, EQUAL
, EQUAL
);
3331 if (other
->type
== '=')
3332 combined
= _token_create_ival (token
, NOT_EQUAL
, NOT_EQUAL
);
3335 if (other
->type
== '&')
3336 combined
= _token_create_ival (token
, AND
, AND
);
3339 if (other
->type
== '|')
3340 combined
= _token_create_ival (token
, OR
, OR
);
3344 if (combined
!= NULL
) {
3345 /* Inherit the location from the first token */
3346 combined
->location
= token
->location
;
3350 /* Two string-valued tokens can usually just be mashed
3353 * XXX: This isn't actually legitimate. Several things here
3354 * should result in a diagnostic since the result cannot be a
3355 * valid, single pre-processing token. For example, pasting
3356 * "123" and "abc" is not legal, but we don't catch that
3358 if ((token
->type
== IDENTIFIER
|| token
->type
== OTHER
|| token
->type
== INTEGER_STRING
) &&
3359 (other
->type
== IDENTIFIER
|| other
->type
== OTHER
|| other
->type
== INTEGER_STRING
))
3363 str
= ralloc_asprintf (token
, "%s%s", token
->value
.str
,
3365 combined
= _token_create_str (token
, token
->type
, str
);
3366 combined
->location
= token
->location
;
3370 glcpp_error (&token
->location
, parser
, "");
3371 ralloc_strcat (&parser
->info_log
, "Pasting \"");
3372 _token_print (&parser
->info_log
, token
);
3373 ralloc_strcat (&parser
->info_log
, "\" and \"");
3374 _token_print (&parser
->info_log
, other
);
3375 ralloc_strcat (&parser
->info_log
, "\" does not give a valid preprocessing token.\n");
3381 _token_list_print (glcpp_parser_t
*parser
, token_list_t
*list
)
3388 for (node
= list
->head
; node
; node
= node
->next
)
3389 _token_print (&parser
->output
, node
->token
);
3393 yyerror (YYLTYPE
*locp
, glcpp_parser_t
*parser
, const char *error
)
3395 glcpp_error(locp
, parser
, "%s", error
);
3398 static void add_builtin_define(glcpp_parser_t
*parser
,
3399 const char *name
, int value
)
3404 tok
= _token_create_ival (parser
, INTEGER
, value
);
3406 list
= _token_list_create(parser
);
3407 _token_list_append(list
, tok
);
3408 _define_object_macro(parser
, NULL
, name
, list
);
3412 glcpp_parser_create (const struct gl_extensions
*extensions
, int api
)
3414 glcpp_parser_t
*parser
;
3415 int language_version
;
3417 parser
= ralloc (NULL
, glcpp_parser_t
);
3419 glcpp_lex_init_extra (parser
, &parser
->scanner
);
3420 parser
->defines
= hash_table_ctor (32, hash_table_string_hash
,
3421 hash_table_string_compare
);
3422 parser
->active
= NULL
;
3423 parser
->lexing_if
= 0;
3424 parser
->space_tokens
= 1;
3425 parser
->newline_as_space
= 0;
3426 parser
->in_control_line
= 0;
3427 parser
->paren_count
= 0;
3429 parser
->skip_stack
= NULL
;
3431 parser
->lex_from_list
= NULL
;
3432 parser
->lex_from_node
= NULL
;
3434 parser
->output
= ralloc_strdup(parser
, "");
3435 parser
->info_log
= ralloc_strdup(parser
, "");
3438 /* Add pre-defined macros. */
3439 add_builtin_define(parser
, "GL_ARB_draw_buffers", 1);
3440 add_builtin_define(parser
, "GL_ARB_texture_rectangle", 1);
3442 if (api
== API_OPENGLES2
)
3443 add_builtin_define(parser
, "GL_ES", 1);
3445 if (extensions
!= NULL
) {
3446 if (extensions
->EXT_texture_array
) {
3447 add_builtin_define(parser
, "GL_EXT_texture_array", 1);
3450 if (extensions
->ARB_fragment_coord_conventions
)
3451 add_builtin_define(parser
, "GL_ARB_fragment_coord_conventions",
3454 if (extensions
->ARB_explicit_attrib_location
)
3455 add_builtin_define(parser
, "GL_ARB_explicit_attrib_location", 1);
3457 if (extensions
->ARB_shader_texture_lod
)
3458 add_builtin_define(parser
, "GL_ARB_shader_texture_lod", 1);
3460 if (extensions
->AMD_conservative_depth
)
3461 add_builtin_define(parser
, "GL_AMD_conservative_depth", 1);
3464 language_version
= 110;
3465 add_builtin_define(parser
, "__VERSION__", language_version
);
3471 glcpp_parser_parse (glcpp_parser_t
*parser
)
3473 return yyparse (parser
);
3477 glcpp_parser_destroy (glcpp_parser_t
*parser
)
3479 glcpp_lex_destroy (parser
->scanner
);
3480 hash_table_dtor (parser
->defines
);
3481 ralloc_free (parser
);
3484 typedef enum function_status
3486 FUNCTION_STATUS_SUCCESS
,
3487 FUNCTION_NOT_A_FUNCTION
,
3488 FUNCTION_UNBALANCED_PARENTHESES
3489 } function_status_t
;
3491 /* Find a set of function-like macro arguments by looking for a
3492 * balanced set of parentheses.
3494 * When called, 'node' should be the opening-parenthesis token, (or
3495 * perhaps preceeding SPACE tokens). Upon successful return *last will
3496 * be the last consumed node, (corresponding to the closing right
3501 * FUNCTION_STATUS_SUCCESS:
3503 * Successfully parsed a set of function arguments.
3505 * FUNCTION_NOT_A_FUNCTION:
3507 * Macro name not followed by a '('. This is not an error, but
3508 * simply that the macro name should be treated as a non-macro.
3510 * FUNCTION_UNBALANCED_PARENTHESES
3512 * Macro name is not followed by a balanced set of parentheses.
3514 static function_status_t
3515 _arguments_parse (argument_list_t
*arguments
,
3517 token_node_t
**last
)
3519 token_list_t
*argument
;
3524 /* Ignore whitespace before first parenthesis. */
3525 while (node
&& node
->token
->type
== SPACE
)
3528 if (node
== NULL
|| node
->token
->type
!= '(')
3529 return FUNCTION_NOT_A_FUNCTION
;
3533 argument
= _token_list_create (arguments
);
3534 _argument_list_append (arguments
, argument
);
3536 for (paren_count
= 1; node
; node
= node
->next
) {
3537 if (node
->token
->type
== '(')
3541 else if (node
->token
->type
== ')')
3544 if (paren_count
== 0)
3548 if (node
->token
->type
== ',' &&
3551 _token_list_trim_trailing_space (argument
);
3552 argument
= _token_list_create (arguments
);
3553 _argument_list_append (arguments
, argument
);
3556 if (argument
->head
== NULL
) {
3557 /* Don't treat initial whitespace as
3558 * part of the arguement. */
3559 if (node
->token
->type
== SPACE
)
3562 _token_list_append (argument
, node
->token
);
3567 return FUNCTION_UNBALANCED_PARENTHESES
;
3571 return FUNCTION_STATUS_SUCCESS
;
3574 static token_list_t
*
3575 _token_list_create_with_one_space (void *ctx
)
3580 list
= _token_list_create (ctx
);
3581 space
= _token_create_ival (list
, SPACE
, SPACE
);
3582 _token_list_append (list
, space
);
3588 _glcpp_parser_expand_if (glcpp_parser_t
*parser
, int type
, token_list_t
*list
)
3590 token_list_t
*expanded
;
3593 expanded
= _token_list_create (parser
);
3594 token
= _token_create_ival (parser
, type
, type
);
3595 _token_list_append (expanded
, token
);
3596 _glcpp_parser_expand_token_list (parser
, list
);
3597 _token_list_append_list (expanded
, list
);
3598 glcpp_parser_lex_from (parser
, expanded
);
3601 /* This is a helper function that's essentially part of the
3602 * implementation of _glcpp_parser_expand_node. It shouldn't be called
3603 * except for by that function.
3605 * Returns NULL if node is a simple token with no expansion, (that is,
3606 * although 'node' corresponds to an identifier defined as a
3607 * function-like macro, it is not followed with a parenthesized
3610 * Compute the complete expansion of node (which is a function-like
3611 * macro) and subsequent nodes which are arguments.
3613 * Returns the token list that results from the expansion and sets
3614 * *last to the last node in the list that was consumed by the
3615 * expansion. Specifically, *last will be set as follows: as the
3616 * token of the closing right parenthesis.
3618 static token_list_t
*
3619 _glcpp_parser_expand_function (glcpp_parser_t
*parser
,
3621 token_node_t
**last
)
3625 const char *identifier
;
3626 argument_list_t
*arguments
;
3627 function_status_t status
;
3628 token_list_t
*substituted
;
3629 int parameter_index
;
3631 identifier
= node
->token
->value
.str
;
3633 macro
= hash_table_find (parser
->defines
, identifier
);
3635 assert (macro
->is_function
);
3637 arguments
= _argument_list_create (parser
);
3638 status
= _arguments_parse (arguments
, node
, last
);
3641 case FUNCTION_STATUS_SUCCESS
:
3643 case FUNCTION_NOT_A_FUNCTION
:
3645 case FUNCTION_UNBALANCED_PARENTHESES
:
3646 glcpp_error (&node
->token
->location
, parser
, "Macro %s call has unbalanced parentheses\n", identifier
);
3650 /* Replace a macro defined as empty with a SPACE token. */
3651 if (macro
->replacements
== NULL
) {
3652 ralloc_free (arguments
);
3653 return _token_list_create_with_one_space (parser
);
3656 if (! ((_argument_list_length (arguments
) ==
3657 _string_list_length (macro
->parameters
)) ||
3658 (_string_list_length (macro
->parameters
) == 0 &&
3659 _argument_list_length (arguments
) == 1 &&
3660 arguments
->head
->argument
->head
== NULL
)))
3662 glcpp_error (&node
->token
->location
, parser
,
3663 "Error: macro %s invoked with %d arguments (expected %d)\n",
3665 _argument_list_length (arguments
),
3666 _string_list_length (macro
->parameters
));
3670 /* Perform argument substitution on the replacement list. */
3671 substituted
= _token_list_create (arguments
);
3673 for (node
= macro
->replacements
->head
; node
; node
= node
->next
)
3675 if (node
->token
->type
== IDENTIFIER
&&
3676 _string_list_contains (macro
->parameters
,
3677 node
->token
->value
.str
,
3680 token_list_t
*argument
;
3681 argument
= _argument_list_member_at (arguments
,
3683 /* Before substituting, we expand the argument
3684 * tokens, or append a placeholder token for
3685 * an empty argument. */
3686 if (argument
->head
) {
3687 token_list_t
*expanded_argument
;
3688 expanded_argument
= _token_list_copy (parser
,
3690 _glcpp_parser_expand_token_list (parser
,
3692 _token_list_append_list (substituted
,
3697 new_token
= _token_create_ival (substituted
,
3700 _token_list_append (substituted
, new_token
);
3703 _token_list_append (substituted
, node
->token
);
3707 /* After argument substitution, and before further expansion
3708 * below, implement token pasting. */
3710 _token_list_trim_trailing_space (substituted
);
3712 node
= substituted
->head
;
3715 token_node_t
*next_non_space
;
3717 /* Look ahead for a PASTE token, skipping space. */
3718 next_non_space
= node
->next
;
3719 while (next_non_space
&& next_non_space
->token
->type
== SPACE
)
3720 next_non_space
= next_non_space
->next
;
3722 if (next_non_space
== NULL
)
3725 if (next_non_space
->token
->type
!= PASTE
) {
3726 node
= next_non_space
;
3730 /* Now find the next non-space token after the PASTE. */
3731 next_non_space
= next_non_space
->next
;
3732 while (next_non_space
&& next_non_space
->token
->type
== SPACE
)
3733 next_non_space
= next_non_space
->next
;
3735 if (next_non_space
== NULL
) {
3736 yyerror (&node
->token
->location
, parser
, "'##' cannot appear at either end of a macro expansion\n");
3740 node
->token
= _token_paste (parser
, node
->token
, next_non_space
->token
);
3741 node
->next
= next_non_space
->next
;
3742 if (next_non_space
== substituted
->tail
)
3743 substituted
->tail
= node
;
3748 substituted
->non_space_tail
= substituted
->tail
;
3753 /* Compute the complete expansion of node, (and subsequent nodes after
3754 * 'node' in the case that 'node' is a function-like macro and
3755 * subsequent nodes are arguments).
3757 * Returns NULL if node is a simple token with no expansion.
3759 * Otherwise, returns the token list that results from the expansion
3760 * and sets *last to the last node in the list that was consumed by
3761 * the expansion. Specifically, *last will be set as follows:
3763 * As 'node' in the case of object-like macro expansion.
3765 * As the token of the closing right parenthesis in the case of
3766 * function-like macro expansion.
3768 static token_list_t
*
3769 _glcpp_parser_expand_node (glcpp_parser_t
*parser
,
3771 token_node_t
**last
)
3773 token_t
*token
= node
->token
;
3774 const char *identifier
;
3777 /* We only expand identifiers */
3778 if (token
->type
!= IDENTIFIER
) {
3779 /* We change any COMMA into a COMMA_FINAL to prevent
3780 * it being mistaken for an argument separator
3782 if (token
->type
== ',') {
3783 token
->type
= COMMA_FINAL
;
3784 token
->value
.ival
= COMMA_FINAL
;
3790 /* Look up this identifier in the hash table. */
3791 identifier
= token
->value
.str
;
3792 macro
= hash_table_find (parser
->defines
, identifier
);
3794 /* Not a macro, so no expansion needed. */
3798 /* Finally, don't expand this macro if we're already actively
3799 * expanding it, (to avoid infinite recursion). */
3800 if (_parser_active_list_contains (parser
, identifier
)) {
3801 /* We change the token type here from IDENTIFIER to
3802 * OTHER to prevent any future expansion of this
3803 * unexpanded token. */
3805 token_list_t
*expansion
;
3808 str
= ralloc_strdup (parser
, token
->value
.str
);
3809 final
= _token_create_str (parser
, OTHER
, str
);
3810 expansion
= _token_list_create (parser
);
3811 _token_list_append (expansion
, final
);
3816 if (! macro
->is_function
)
3820 /* Replace a macro defined as empty with a SPACE token. */
3821 if (macro
->replacements
== NULL
)
3822 return _token_list_create_with_one_space (parser
);
3824 return _token_list_copy (parser
, macro
->replacements
);
3827 return _glcpp_parser_expand_function (parser
, node
, last
);
3830 /* Push a new identifier onto the parser's active list.
3832 * Here, 'marker' is the token node that appears in the list after the
3833 * expansion of 'identifier'. That is, when the list iterator begins
3834 * examining 'marker', then it is time to pop this node from the
3838 _parser_active_list_push (glcpp_parser_t
*parser
,
3839 const char *identifier
,
3840 token_node_t
*marker
)
3842 active_list_t
*node
;
3844 node
= ralloc (parser
->active
, active_list_t
);
3845 node
->identifier
= ralloc_strdup (node
, identifier
);
3846 node
->marker
= marker
;
3847 node
->next
= parser
->active
;
3849 parser
->active
= node
;
3853 _parser_active_list_pop (glcpp_parser_t
*parser
)
3855 active_list_t
*node
= parser
->active
;
3858 parser
->active
= NULL
;
3862 node
= parser
->active
->next
;
3863 ralloc_free (parser
->active
);
3865 parser
->active
= node
;
3869 _parser_active_list_contains (glcpp_parser_t
*parser
, const char *identifier
)
3871 active_list_t
*node
;
3873 if (parser
->active
== NULL
)
3876 for (node
= parser
->active
; node
; node
= node
->next
)
3877 if (strcmp (node
->identifier
, identifier
) == 0)
3883 /* Walk over the token list replacing nodes with their expansion.
3884 * Whenever nodes are expanded the walking will walk over the new
3885 * nodes, continuing to expand as necessary. The results are placed in
3889 _glcpp_parser_expand_token_list (glcpp_parser_t
*parser
,
3892 token_node_t
*node_prev
;
3893 token_node_t
*node
, *last
= NULL
;
3894 token_list_t
*expansion
;
3895 active_list_t
*active_initial
= parser
->active
;
3900 _token_list_trim_trailing_space (list
);
3907 while (parser
->active
&& parser
->active
->marker
== node
)
3908 _parser_active_list_pop (parser
);
3910 expansion
= _glcpp_parser_expand_node (parser
, node
, &last
);
3914 for (n
= node
; n
!= last
->next
; n
= n
->next
)
3915 while (parser
->active
&&
3916 parser
->active
->marker
== n
)
3918 _parser_active_list_pop (parser
);
3921 _parser_active_list_push (parser
,
3922 node
->token
->value
.str
,
3925 /* Splice expansion into list, supporting a
3926 * simple deletion if the expansion is
3928 if (expansion
->head
) {
3930 node_prev
->next
= expansion
->head
;
3932 list
->head
= expansion
->head
;
3933 expansion
->tail
->next
= last
->next
;
3934 if (last
== list
->tail
)
3935 list
->tail
= expansion
->tail
;
3938 node_prev
->next
= last
->next
;
3940 list
->head
= last
->next
;
3941 if (last
== list
->tail
)
3947 node
= node_prev
? node_prev
->next
: list
->head
;
3950 /* Remove any lingering effects of this invocation on the
3951 * active list. That is, pop until the list looks like it did
3952 * at the beginning of this function. */
3953 while (parser
->active
&& parser
->active
!= active_initial
)
3954 _parser_active_list_pop (parser
);
3956 list
->non_space_tail
= list
->tail
;
3960 _glcpp_parser_print_expanded_token_list (glcpp_parser_t
*parser
,
3966 _glcpp_parser_expand_token_list (parser
, list
);
3968 _token_list_trim_trailing_space (list
);
3970 _token_list_print (parser
, list
);
3974 _check_for_reserved_macro_name (glcpp_parser_t
*parser
, YYLTYPE
*loc
,
3975 const char *identifier
)
3977 /* According to the GLSL specification, macro names starting with "__"
3978 * or "GL_" are reserved for future use. So, don't allow them.
3980 if (strncmp(identifier
, "__", 2) == 0) {
3981 glcpp_error (loc
, parser
, "Macro names starting with \"__\" are reserved.\n");
3983 if (strncmp(identifier
, "GL_", 3) == 0) {
3984 glcpp_error (loc
, parser
, "Macro names starting with \"GL_\" are reserved.\n");
3989 _macro_equal (macro_t
*a
, macro_t
*b
)
3991 if (a
->is_function
!= b
->is_function
)
3994 if (a
->is_function
) {
3995 if (! _string_list_equal (a
->parameters
, b
->parameters
))
3999 return _token_list_equal_ignoring_space (a
->replacements
,
4004 _define_object_macro (glcpp_parser_t
*parser
,
4006 const char *identifier
,
4007 token_list_t
*replacements
)
4009 macro_t
*macro
, *previous
;
4012 _check_for_reserved_macro_name(parser
, loc
, identifier
);
4014 macro
= ralloc (parser
, macro_t
);
4016 macro
->is_function
= 0;
4017 macro
->parameters
= NULL
;
4018 macro
->identifier
= ralloc_strdup (macro
, identifier
);
4019 macro
->replacements
= replacements
;
4020 ralloc_steal (macro
, replacements
);
4022 previous
= hash_table_find (parser
->defines
, identifier
);
4024 if (_macro_equal (macro
, previous
)) {
4025 ralloc_free (macro
);
4028 glcpp_error (loc
, parser
, "Redefinition of macro %s\n",
4032 hash_table_insert (parser
->defines
, macro
, identifier
);
4036 _define_function_macro (glcpp_parser_t
*parser
,
4038 const char *identifier
,
4039 string_list_t
*parameters
,
4040 token_list_t
*replacements
)
4042 macro_t
*macro
, *previous
;
4044 _check_for_reserved_macro_name(parser
, loc
, identifier
);
4046 macro
= ralloc (parser
, macro_t
);
4047 ralloc_steal (macro
, parameters
);
4048 ralloc_steal (macro
, replacements
);
4050 macro
->is_function
= 1;
4051 macro
->parameters
= parameters
;
4052 macro
->identifier
= ralloc_strdup (macro
, identifier
);
4053 macro
->replacements
= replacements
;
4054 previous
= hash_table_find (parser
->defines
, identifier
);
4056 if (_macro_equal (macro
, previous
)) {
4057 ralloc_free (macro
);
4060 glcpp_error (loc
, parser
, "Redefinition of macro %s\n",
4064 hash_table_insert (parser
->defines
, macro
, identifier
);
4068 glcpp_parser_lex (YYSTYPE
*yylval
, YYLTYPE
*yylloc
, glcpp_parser_t
*parser
)
4073 if (parser
->lex_from_list
== NULL
) {
4074 ret
= glcpp_lex (yylval
, yylloc
, parser
->scanner
);
4076 /* XXX: This ugly block of code exists for the sole
4077 * purpose of converting a NEWLINE token into a SPACE
4078 * token, but only in the case where we have seen a
4079 * function-like macro name, but have not yet seen its
4080 * closing parenthesis.
4082 * There's perhaps a more compact way to do this with
4083 * mid-rule actions in the grammar.
4085 * I'm definitely not pleased with the complexity of
4088 if (parser
->newline_as_space
)
4091 parser
->paren_count
++;
4092 } else if (ret
== ')') {
4093 parser
->paren_count
--;
4094 if (parser
->paren_count
== 0)
4095 parser
->newline_as_space
= 0;
4096 } else if (ret
== NEWLINE
) {
4098 } else if (ret
!= SPACE
) {
4099 if (parser
->paren_count
== 0)
4100 parser
->newline_as_space
= 0;
4103 else if (parser
->in_control_line
)
4106 parser
->in_control_line
= 0;
4108 else if (ret
== HASH_DEFINE_OBJ
|| ret
== HASH_DEFINE_FUNC
||
4109 ret
== HASH_UNDEF
|| ret
== HASH_IF
||
4110 ret
== HASH_IFDEF
|| ret
== HASH_IFNDEF
||
4111 ret
== HASH_ELIF
|| ret
== HASH_ELSE
||
4112 ret
== HASH_ENDIF
|| ret
== HASH
)
4114 parser
->in_control_line
= 1;
4116 else if (ret
== IDENTIFIER
)
4119 macro
= hash_table_find (parser
->defines
,
4121 if (macro
&& macro
->is_function
) {
4122 parser
->newline_as_space
= 1;
4123 parser
->paren_count
= 0;
4130 node
= parser
->lex_from_node
;
4133 ralloc_free (parser
->lex_from_list
);
4134 parser
->lex_from_list
= NULL
;
4138 *yylval
= node
->token
->value
;
4139 ret
= node
->token
->type
;
4141 parser
->lex_from_node
= node
->next
;
4147 glcpp_parser_lex_from (glcpp_parser_t
*parser
, token_list_t
*list
)
4151 assert (parser
->lex_from_list
== NULL
);
4153 /* Copy list, eliminating any space tokens. */
4154 parser
->lex_from_list
= _token_list_create (parser
);
4156 for (node
= list
->head
; node
; node
= node
->next
) {
4157 if (node
->token
->type
== SPACE
)
4159 _token_list_append (parser
->lex_from_list
, node
->token
);
4164 parser
->lex_from_node
= parser
->lex_from_list
->head
;
4166 /* It's possible the list consisted of nothing but whitespace. */
4167 if (parser
->lex_from_node
== NULL
) {
4168 ralloc_free (parser
->lex_from_list
);
4169 parser
->lex_from_list
= NULL
;
4174 _glcpp_parser_skip_stack_push_if (glcpp_parser_t
*parser
, YYLTYPE
*loc
,
4177 skip_type_t current
= SKIP_NO_SKIP
;
4180 if (parser
->skip_stack
)
4181 current
= parser
->skip_stack
->type
;
4183 node
= ralloc (parser
, skip_node_t
);
4186 if (current
== SKIP_NO_SKIP
) {
4188 node
->type
= SKIP_NO_SKIP
;
4190 node
->type
= SKIP_TO_ELSE
;
4192 node
->type
= SKIP_TO_ENDIF
;
4195 node
->next
= parser
->skip_stack
;
4196 parser
->skip_stack
= node
;
4200 _glcpp_parser_skip_stack_change_if (glcpp_parser_t
*parser
, YYLTYPE
*loc
,
4201 const char *type
, int condition
)
4203 if (parser
->skip_stack
== NULL
) {
4204 glcpp_error (loc
, parser
, "%s without #if\n", type
);
4208 if (parser
->skip_stack
->type
== SKIP_TO_ELSE
) {
4210 parser
->skip_stack
->type
= SKIP_NO_SKIP
;
4212 parser
->skip_stack
->type
= SKIP_TO_ENDIF
;
4217 _glcpp_parser_skip_stack_pop (glcpp_parser_t
*parser
, YYLTYPE
*loc
)
4221 if (parser
->skip_stack
== NULL
) {
4222 glcpp_error (loc
, parser
, "#endif without #if\n");
4226 node
= parser
->skip_stack
;
4227 parser
->skip_stack
= node
->next
;