• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* A Bison parser, made by GNU Bison 2.5.  */
2 
3 /* Bison implementation for Yacc-like parsers in C
4 
5       Copyright (C) 1984, 1989-1990, 2000-2011 Free Software Foundation, Inc.
6 
7    This program is free software: you can redistribute it and/or modify
8    it under the terms of the GNU General Public License as published by
9    the Free Software Foundation, either version 3 of the License, or
10    (at your option) any later version.
11 
12    This program is distributed in the hope that it will be useful,
13    but WITHOUT ANY WARRANTY; without even the implied warranty of
14    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15    GNU General Public License for more details.
16 
17    You should have received a copy of the GNU General Public License
18    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
19 
20 /* As a special exception, you may create a larger work that contains
21    part or all of the Bison parser skeleton and distribute that work
22    under terms of your choice, so long as that work isn't itself a
23    parser generator using the skeleton or a modified version thereof
24    as a parser skeleton.  Alternatively, if you modify or redistribute
25    the parser skeleton itself, you may (at your option) remove this
26    special exception, which will cause the skeleton and the resulting
27    Bison output files to be licensed under the GNU General Public
28    License without this special exception.
29 
30    This special exception was added by the Free Software Foundation in
31    version 2.2 of Bison.  */
32 
33 /* C LALR(1) parser skeleton written by Richard Stallman, by
34    simplifying the original so-called "semantic" parser.  */
35 
36 /* All symbols defined below should begin with yy or YY, to avoid
37    infringing on user name space.  This should be done even for local
38    variables, as they might otherwise be expanded by user macros.
39    There are some unavoidable exceptions within include files to
40    define necessary library symbols; they are noted "INFRINGES ON
41    USER NAME SPACE" below.  */
42 
43 /* Identify Bison output.  */
44 #define YYBISON 1
45 
46 /* Bison version.  */
47 #define YYBISON_VERSION "2.5"
48 
49 /* Skeleton name.  */
50 #define YYSKELETON_NAME "yacc.c"
51 
52 /* Pure parsers.  */
53 #define YYPURE 1
54 
55 /* Push parsers.  */
56 #define YYPUSH 0
57 
58 /* Pull parsers.  */
59 #define YYPULL 1
60 
61 /* Using locations.  */
62 #define YYLSP_NEEDED 1
63 
64 /* Substitute the variable and function names.  */
65 #define yyparse         glcpp_parser_parse
66 #define yylex           glcpp_parser_lex
67 #define yyerror         glcpp_parser_error
68 #define yylval          glcpp_parser_lval
69 #define yychar          glcpp_parser_char
70 #define yydebug         glcpp_parser_debug
71 #define yynerrs         glcpp_parser_nerrs
72 #define yylloc          glcpp_parser_lloc
73 
74 /* Copy the first part of user declarations.  */
75 
76 /* Line 268 of yacc.c  */
77 #line 1 "src/src/glsl/glcpp/glcpp-parse.y"
78 
79 /*
80  * Copyright © 2010 Intel Corporation
81  *
82  * Permission is hereby granted, free of charge, to any person obtaining a
83  * copy of this software and associated documentation files (the "Software"),
84  * to deal in the Software without restriction, including without limitation
85  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
86  * and/or sell copies of the Software, and to permit persons to whom the
87  * Software is furnished to do so, subject to the following conditions:
88  *
89  * The above copyright notice and this permission notice (including the next
90  * paragraph) shall be included in all copies or substantial portions of the
91  * Software.
92  *
93  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
94  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
95  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
96  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
97  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
98  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
99  * DEALINGS IN THE SOFTWARE.
100  */
101 
102 #include <stdio.h>
103 #include <stdlib.h>
104 #include <string.h>
105 #include <assert.h>
106 #include <inttypes.h>
107 
108 #include "glcpp.h"
109 #include "main/core.h" /* for struct gl_extensions */
110 #include "main/mtypes.h" /* for gl_api enum */
111 
112 static void
113 yyerror (YYLTYPE *locp, glcpp_parser_t *parser, const char *error);
114 
115 static void
116 _define_object_macro (glcpp_parser_t *parser,
117 		      YYLTYPE *loc,
118 		      const char *macro,
119 		      token_list_t *replacements);
120 
121 static void
122 _define_function_macro (glcpp_parser_t *parser,
123 			YYLTYPE *loc,
124 			const char *macro,
125 			string_list_t *parameters,
126 			token_list_t *replacements);
127 
128 static string_list_t *
129 _string_list_create (void *ctx);
130 
131 static void
132 _string_list_append_item (string_list_t *list, const char *str);
133 
134 static int
135 _string_list_contains (string_list_t *list, const char *member, int *index);
136 
137 static int
138 _string_list_length (string_list_t *list);
139 
140 static int
141 _string_list_equal (string_list_t *a, string_list_t *b);
142 
143 static argument_list_t *
144 _argument_list_create (void *ctx);
145 
146 static void
147 _argument_list_append (argument_list_t *list, token_list_t *argument);
148 
149 static int
150 _argument_list_length (argument_list_t *list);
151 
152 static token_list_t *
153 _argument_list_member_at (argument_list_t *list, int index);
154 
155 /* Note: This function ralloc_steal()s the str pointer. */
156 static token_t *
157 _token_create_str (void *ctx, int type, char *str);
158 
159 static token_t *
160 _token_create_ival (void *ctx, int type, int ival);
161 
162 static token_list_t *
163 _token_list_create (void *ctx);
164 
165 static void
166 _token_list_append (token_list_t *list, token_t *token);
167 
168 static void
169 _token_list_append_list (token_list_t *list, token_list_t *tail);
170 
171 static int
172 _token_list_equal_ignoring_space (token_list_t *a, token_list_t *b);
173 
174 static void
175 _parser_active_list_push (glcpp_parser_t *parser,
176 			  const char *identifier,
177 			  token_node_t *marker);
178 
179 static void
180 _parser_active_list_pop (glcpp_parser_t *parser);
181 
182 static int
183 _parser_active_list_contains (glcpp_parser_t *parser, const char *identifier);
184 
185 /* Expand list, and begin lexing from the result (after first
186  * prefixing a token of type 'head_token_type').
187  */
188 static void
189 _glcpp_parser_expand_and_lex_from (glcpp_parser_t *parser,
190 				   int head_token_type,
191 				   token_list_t *list);
192 
193 /* Perform macro expansion in-place on the given list. */
194 static void
195 _glcpp_parser_expand_token_list (glcpp_parser_t *parser,
196 				 token_list_t *list);
197 
198 static void
199 _glcpp_parser_print_expanded_token_list (glcpp_parser_t *parser,
200 					 token_list_t *list);
201 
202 static void
203 _glcpp_parser_skip_stack_push_if (glcpp_parser_t *parser, YYLTYPE *loc,
204 				  int condition);
205 
206 static void
207 _glcpp_parser_skip_stack_change_if (glcpp_parser_t *parser, YYLTYPE *loc,
208 				    const char *type, int condition);
209 
210 static void
211 _glcpp_parser_skip_stack_pop (glcpp_parser_t *parser, YYLTYPE *loc);
212 
213 static int
214 glcpp_parser_lex (YYSTYPE *yylval, YYLTYPE *yylloc, glcpp_parser_t *parser);
215 
216 static void
217 glcpp_parser_lex_from (glcpp_parser_t *parser, token_list_t *list);
218 
219 static void
220 add_builtin_define(glcpp_parser_t *parser, const char *name, int value);
221 
222 
223 
224 /* Line 268 of yacc.c  */
225 #line 226 "src/chromium_gensrc/mesa/glcpp-parse.c"
226 
227 /* Enabling traces.  */
228 #ifndef YYDEBUG
229 # define YYDEBUG 0
230 #endif
231 
232 /* Enabling verbose error messages.  */
233 #ifdef YYERROR_VERBOSE
234 # undef YYERROR_VERBOSE
235 # define YYERROR_VERBOSE 1
236 #else
237 # define YYERROR_VERBOSE 1
238 #endif
239 
240 /* Enabling the token table.  */
241 #ifndef YYTOKEN_TABLE
242 # define YYTOKEN_TABLE 0
243 #endif
244 
245 
246 /* Tokens.  */
247 #ifndef YYTOKENTYPE
248 # define YYTOKENTYPE
249    /* Put the tokens into the symbol table, so that GDB and other debuggers
250       know about them.  */
251    enum yytokentype {
252      COMMA_FINAL = 258,
253      DEFINED = 259,
254      ELIF_EXPANDED = 260,
255      HASH = 261,
256      HASH_DEFINE = 262,
257      FUNC_IDENTIFIER = 263,
258      OBJ_IDENTIFIER = 264,
259      HASH_ELIF = 265,
260      HASH_ELSE = 266,
261      HASH_ENDIF = 267,
262      HASH_IF = 268,
263      HASH_IFDEF = 269,
264      HASH_IFNDEF = 270,
265      HASH_LINE = 271,
266      HASH_UNDEF = 272,
267      HASH_VERSION = 273,
268      IDENTIFIER = 274,
269      IF_EXPANDED = 275,
270      INTEGER = 276,
271      INTEGER_STRING = 277,
272      LINE_EXPANDED = 278,
273      NEWLINE = 279,
274      OTHER = 280,
275      PLACEHOLDER = 281,
276      SPACE = 282,
277      PASTE = 283,
278      OR = 284,
279      AND = 285,
280      NOT_EQUAL = 286,
281      EQUAL = 287,
282      GREATER_OR_EQUAL = 288,
283      LESS_OR_EQUAL = 289,
284      RIGHT_SHIFT = 290,
285      LEFT_SHIFT = 291,
286      UNARY = 292
287    };
288 #endif
289 /* Tokens.  */
290 #define COMMA_FINAL 258
291 #define DEFINED 259
292 #define ELIF_EXPANDED 260
293 #define HASH 261
294 #define HASH_DEFINE 262
295 #define FUNC_IDENTIFIER 263
296 #define OBJ_IDENTIFIER 264
297 #define HASH_ELIF 265
298 #define HASH_ELSE 266
299 #define HASH_ENDIF 267
300 #define HASH_IF 268
301 #define HASH_IFDEF 269
302 #define HASH_IFNDEF 270
303 #define HASH_LINE 271
304 #define HASH_UNDEF 272
305 #define HASH_VERSION 273
306 #define IDENTIFIER 274
307 #define IF_EXPANDED 275
308 #define INTEGER 276
309 #define INTEGER_STRING 277
310 #define LINE_EXPANDED 278
311 #define NEWLINE 279
312 #define OTHER 280
313 #define PLACEHOLDER 281
314 #define SPACE 282
315 #define PASTE 283
316 #define OR 284
317 #define AND 285
318 #define NOT_EQUAL 286
319 #define EQUAL 287
320 #define GREATER_OR_EQUAL 288
321 #define LESS_OR_EQUAL 289
322 #define RIGHT_SHIFT 290
323 #define LEFT_SHIFT 291
324 #define UNARY 292
325 
326 
327 
328 
329 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
330 
331 # define yystype YYSTYPE /* obsolescent; will be withdrawn */
332 # define YYSTYPE_IS_DECLARED 1
333 #endif
334 
335 #if ! defined YYLTYPE && ! defined YYLTYPE_IS_DECLARED
336 typedef struct YYLTYPE
337 {
338   int first_line;
339   int first_column;
340   int last_line;
341   int last_column;
342 } YYLTYPE;
343 # define yyltype YYLTYPE /* obsolescent; will be withdrawn */
344 # define YYLTYPE_IS_DECLARED 1
345 # define YYLTYPE_IS_TRIVIAL 1
346 #endif
347 
348 
349 /* Copy the second part of user declarations.  */
350 
351 
352 /* Line 343 of yacc.c  */
353 #line 354 "src/chromium_gensrc/mesa/glcpp-parse.c"
354 
355 #ifdef short
356 # undef short
357 #endif
358 
359 #ifdef YYTYPE_UINT8
360 typedef YYTYPE_UINT8 yytype_uint8;
361 #else
362 typedef unsigned char yytype_uint8;
363 #endif
364 
365 #ifdef YYTYPE_INT8
366 typedef YYTYPE_INT8 yytype_int8;
367 #elif (defined __STDC__ || defined __C99__FUNC__ \
368      || defined __cplusplus || defined _MSC_VER)
369 typedef signed char yytype_int8;
370 #else
371 typedef short int yytype_int8;
372 #endif
373 
374 #ifdef YYTYPE_UINT16
375 typedef YYTYPE_UINT16 yytype_uint16;
376 #else
377 typedef unsigned short int yytype_uint16;
378 #endif
379 
380 #ifdef YYTYPE_INT16
381 typedef YYTYPE_INT16 yytype_int16;
382 #else
383 typedef short int yytype_int16;
384 #endif
385 
386 #ifndef YYSIZE_T
387 # ifdef __SIZE_TYPE__
388 #  define YYSIZE_T __SIZE_TYPE__
389 # elif defined size_t
390 #  define YYSIZE_T size_t
391 # elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \
392      || defined __cplusplus || defined _MSC_VER)
393 #  include <stddef.h> /* INFRINGES ON USER NAME SPACE */
394 #  define YYSIZE_T size_t
395 # else
396 #  define YYSIZE_T unsigned int
397 # endif
398 #endif
399 
400 #define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
401 
402 #ifndef YY_
403 # if defined YYENABLE_NLS && YYENABLE_NLS
404 #  if ENABLE_NLS
405 #   include <libintl.h> /* INFRINGES ON USER NAME SPACE */
406 #   define YY_(msgid) dgettext ("bison-runtime", msgid)
407 #  endif
408 # endif
409 # ifndef YY_
410 #  define YY_(msgid) msgid
411 # endif
412 #endif
413 
414 /* Suppress unused-variable warnings by "using" E.  */
415 #if ! defined lint || defined __GNUC__
416 # define YYUSE(e) ((void) (e))
417 #else
418 # define YYUSE(e) /* empty */
419 #endif
420 
421 /* Identity function, used to suppress warnings about constant conditions.  */
422 #ifndef lint
423 # define YYID(n) (n)
424 #else
425 #if (defined __STDC__ || defined __C99__FUNC__ \
426      || defined __cplusplus || defined _MSC_VER)
427 static int
YYID(int yyi)428 YYID (int yyi)
429 #else
430 static int
431 YYID (yyi)
432     int yyi;
433 #endif
434 {
435   return yyi;
436 }
437 #endif
438 
439 #if ! defined yyoverflow || YYERROR_VERBOSE
440 
441 /* The parser invokes alloca or malloc; define the necessary symbols.  */
442 
443 # ifdef YYSTACK_USE_ALLOCA
444 #  if YYSTACK_USE_ALLOCA
445 #   ifdef __GNUC__
446 #    define YYSTACK_ALLOC __builtin_alloca
447 #   elif defined __BUILTIN_VA_ARG_INCR
448 #    include <alloca.h> /* INFRINGES ON USER NAME SPACE */
449 #   elif defined _AIX
450 #    define YYSTACK_ALLOC __alloca
451 #   elif defined _MSC_VER
452 #    include <malloc.h> /* INFRINGES ON USER NAME SPACE */
453 #    define alloca _alloca
454 #   else
455 #    define YYSTACK_ALLOC alloca
456 #    if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \
457      || defined __cplusplus || defined _MSC_VER)
458 #     include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
459 #     ifndef EXIT_SUCCESS
460 #      define EXIT_SUCCESS 0
461 #     endif
462 #    endif
463 #   endif
464 #  endif
465 # endif
466 
467 # ifdef YYSTACK_ALLOC
468    /* Pacify GCC's `empty if-body' warning.  */
469 #  define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0))
470 #  ifndef YYSTACK_ALLOC_MAXIMUM
471     /* The OS might guarantee only one guard page at the bottom of the stack,
472        and a page size can be as small as 4096 bytes.  So we cannot safely
473        invoke alloca (N) if N exceeds 4096.  Use a slightly smaller number
474        to allow for a few compiler-allocated temporary stack slots.  */
475 #   define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
476 #  endif
477 # else
478 #  define YYSTACK_ALLOC YYMALLOC
479 #  define YYSTACK_FREE YYFREE
480 #  ifndef YYSTACK_ALLOC_MAXIMUM
481 #   define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
482 #  endif
483 #  if (defined __cplusplus && ! defined EXIT_SUCCESS \
484        && ! ((defined YYMALLOC || defined malloc) \
485 	     && (defined YYFREE || defined free)))
486 #   include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
487 #   ifndef EXIT_SUCCESS
488 #    define EXIT_SUCCESS 0
489 #   endif
490 #  endif
491 #  ifndef YYMALLOC
492 #   define YYMALLOC malloc
493 #   if ! defined malloc && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \
494      || defined __cplusplus || defined _MSC_VER)
495 void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
496 #   endif
497 #  endif
498 #  ifndef YYFREE
499 #   define YYFREE free
500 #   if ! defined free && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \
501      || defined __cplusplus || defined _MSC_VER)
502 void free (void *); /* INFRINGES ON USER NAME SPACE */
503 #   endif
504 #  endif
505 # endif
506 #endif /* ! defined yyoverflow || YYERROR_VERBOSE */
507 
508 
509 #if (! defined yyoverflow \
510      && (! defined __cplusplus \
511 	 || (defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL \
512 	     && defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
513 
514 /* A type that is properly aligned for any stack member.  */
515 union yyalloc
516 {
517   yytype_int16 yyss_alloc;
518   YYSTYPE yyvs_alloc;
519   YYLTYPE yyls_alloc;
520 };
521 
522 /* The size of the maximum gap between one aligned stack and the next.  */
523 # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
524 
525 /* The size of an array large to enough to hold all stacks, each with
526    N elements.  */
527 # define YYSTACK_BYTES(N) \
528      ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE) + sizeof (YYLTYPE)) \
529       + 2 * YYSTACK_GAP_MAXIMUM)
530 
531 # define YYCOPY_NEEDED 1
532 
533 /* Relocate STACK from its old location to the new one.  The
534    local variables YYSIZE and YYSTACKSIZE give the old and new number of
535    elements in the stack, and YYPTR gives the new location of the
536    stack.  Advance YYPTR to a properly aligned location for the next
537    stack.  */
538 # define YYSTACK_RELOCATE(Stack_alloc, Stack)				\
539     do									\
540       {									\
541 	YYSIZE_T yynewbytes;						\
542 	YYCOPY (&yyptr->Stack_alloc, Stack, yysize);			\
543 	Stack = &yyptr->Stack_alloc;					\
544 	yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
545 	yyptr += yynewbytes / sizeof (*yyptr);				\
546       }									\
547     while (YYID (0))
548 
549 #endif
550 
551 #if defined YYCOPY_NEEDED && YYCOPY_NEEDED
552 /* Copy COUNT objects from FROM to TO.  The source and destination do
553    not overlap.  */
554 # ifndef YYCOPY
555 #  if defined __GNUC__ && 1 < __GNUC__
556 #   define YYCOPY(To, From, Count) \
557       __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
558 #  else
559 #   define YYCOPY(To, From, Count)		\
560       do					\
561 	{					\
562 	  YYSIZE_T yyi;				\
563 	  for (yyi = 0; yyi < (Count); yyi++)	\
564 	    (To)[yyi] = (From)[yyi];		\
565 	}					\
566       while (YYID (0))
567 #  endif
568 # endif
569 #endif /* !YYCOPY_NEEDED */
570 
571 /* YYFINAL -- State number of the termination state.  */
572 #define YYFINAL  2
573 /* YYLAST -- Last index in YYTABLE.  */
574 #define YYLAST   670
575 
576 /* YYNTOKENS -- Number of terminals.  */
577 #define YYNTOKENS  60
578 /* YYNNTS -- Number of nonterminals.  */
579 #define YYNNTS  19
580 /* YYNRULES -- Number of rules.  */
581 #define YYNRULES  107
582 /* YYNRULES -- Number of states.  */
583 #define YYNSTATES  172
584 
585 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX.  */
586 #define YYUNDEFTOK  2
587 #define YYMAXUTOK   292
588 
589 #define YYTRANSLATE(YYX)						\
590   ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
591 
592 /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX.  */
593 static const yytype_uint8 yytranslate[] =
594 {
595        0,     2,     2,     2,     2,     2,     2,     2,     2,     2,
596        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
597        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
598        2,     2,     2,    50,     2,     2,     2,    46,    33,     2,
599       48,    49,    44,    42,    52,    43,    57,    45,     2,     2,
600        2,     2,     2,     2,     2,     2,     2,     2,     2,    58,
601       36,    59,    37,     2,     2,     2,     2,     2,     2,     2,
602        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
603        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
604        2,    53,     2,    54,    32,     2,     2,     2,     2,     2,
605        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
606        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
607        2,     2,     2,    55,    31,    56,    51,     2,     2,     2,
608        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
609        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
610        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
611        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
612        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
613        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
614        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
615        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
616        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
617        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
618        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
619        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
620        2,     2,     2,     2,     2,     2,     1,     2,     3,     4,
621        5,     6,     7,     8,     9,    10,    11,    12,    13,    14,
622       15,    16,    17,    18,    19,    20,    21,    22,    23,    24,
623       25,    26,    27,    28,    29,    30,    34,    35,    38,    39,
624       40,    41,    47
625 };
626 
627 #if YYDEBUG
628 /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
629    YYRHS.  */
630 static const yytype_uint16 yyprhs[] =
631 {
632        0,     0,     3,     4,     7,     9,    11,    13,    16,    20,
633       24,    28,    33,    38,    45,    53,    57,    61,    65,    68,
634       73,    78,    82,    85,    86,    90,    91,    95,    99,   102,
635      104,   106,   108,   110,   114,   118,   122,   126,   130,   134,
636      138,   142,   146,   150,   154,   158,   162,   166,   170,   174,
637      178,   182,   185,   188,   191,   194,   198,   200,   204,   206,
638      209,   212,   213,   215,   216,   218,   221,   226,   228,   230,
639      233,   235,   238,   240,   242,   244,   246,   248,   250,   252,
640      254,   256,   258,   260,   262,   264,   266,   268,   270,   272,
641      274,   276,   278,   280,   282,   284,   286,   288,   290,   292,
642      294,   296,   298,   300,   302,   304,   306,   308
643 };
644 
645 /* YYRHS -- A `-1'-separated list of the rules' RHS.  */
646 static const yytype_int8 yyrhs[] =
647 {
648       61,     0,    -1,    -1,    61,    62,    -1,    64,    -1,    70,
649       -1,    63,    -1,     6,    71,    -1,    20,    68,    24,    -1,
650        5,    68,    24,    -1,    23,    67,    24,    -1,    23,    67,
651       67,    24,    -1,     7,     9,    72,    24,    -1,     7,     8,
652       48,    49,    72,    24,    -1,     7,     8,    48,    69,    49,
653       72,    24,    -1,    17,    19,    24,    -1,    16,    76,    24,
654       -1,    13,    75,    24,    -1,    13,    24,    -1,    14,    19,
655       73,    24,    -1,    15,    19,    73,    24,    -1,    10,    75,
656       24,    -1,    10,    24,    -1,    -1,    11,    65,    24,    -1,
657       -1,    12,    66,    24,    -1,    18,    67,    24,    -1,     6,
658       24,    -1,    22,    -1,    21,    -1,    67,    -1,    19,    -1,
659       68,    29,    68,    -1,    68,    30,    68,    -1,    68,    31,
660       68,    -1,    68,    32,    68,    -1,    68,    33,    68,    -1,
661       68,    34,    68,    -1,    68,    35,    68,    -1,    68,    38,
662       68,    -1,    68,    39,    68,    -1,    68,    37,    68,    -1,
663       68,    36,    68,    -1,    68,    40,    68,    -1,    68,    41,
664       68,    -1,    68,    43,    68,    -1,    68,    42,    68,    -1,
665       68,    46,    68,    -1,    68,    45,    68,    -1,    68,    44,
666       68,    -1,    50,    68,    -1,    51,    68,    -1,    43,    68,
667       -1,    42,    68,    -1,    48,    68,    49,    -1,    19,    -1,
668       69,    52,    19,    -1,    24,    -1,    76,    24,    -1,    76,
669       24,    -1,    -1,    76,    -1,    -1,    76,    -1,     4,    19,
670       -1,     4,    48,    19,    49,    -1,    77,    -1,    74,    -1,
671       75,    74,    -1,    77,    -1,    76,    77,    -1,    19,    -1,
672       22,    -1,    78,    -1,    25,    -1,    27,    -1,    53,    -1,
673       54,    -1,    48,    -1,    49,    -1,    55,    -1,    56,    -1,
674       57,    -1,    33,    -1,    44,    -1,    42,    -1,    43,    -1,
675       51,    -1,    50,    -1,    45,    -1,    46,    -1,    41,    -1,
676       40,    -1,    36,    -1,    37,    -1,    39,    -1,    38,    -1,
677       35,    -1,    34,    -1,    32,    -1,    31,    -1,    30,    -1,
678       29,    -1,    58,    -1,    52,    -1,    59,    -1,    28,    -1
679 };
680 
681 /* YYRLINE[YYN] -- source line where rule number YYN was defined.  */
682 static const yytype_uint16 yyrline[] =
683 {
684        0,   184,   184,   186,   190,   193,   198,   199,   203,   206,
685      209,   217,   230,   233,   236,   239,   247,   255,   275,   285,
686      290,   295,   315,   330,   330,   333,   333,   336,   357,   361,
687      370,   375,   376,   379,   382,   385,   388,   391,   394,   397,
688      400,   403,   406,   409,   412,   415,   418,   421,   424,   432,
689      440,   443,   446,   449,   452,   455,   461,   466,   474,   475,
690      479,   485,   486,   489,   491,   498,   502,   506,   511,   515,
691      522,   527,   534,   538,   542,   546,   550,   557,   558,   559,
692      560,   561,   562,   563,   564,   565,   566,   567,   568,   569,
693      570,   571,   572,   573,   574,   575,   576,   577,   578,   579,
694      580,   581,   582,   583,   584,   585,   586,   587
695 };
696 #endif
697 
698 #if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
699 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
700    First, the terminals, then, starting at YYNTOKENS, nonterminals.  */
701 static const char *const yytname[] =
702 {
703   "$end", "error", "$undefined", "COMMA_FINAL", "DEFINED",
704   "ELIF_EXPANDED", "HASH", "HASH_DEFINE", "FUNC_IDENTIFIER",
705   "OBJ_IDENTIFIER", "HASH_ELIF", "HASH_ELSE", "HASH_ENDIF", "HASH_IF",
706   "HASH_IFDEF", "HASH_IFNDEF", "HASH_LINE", "HASH_UNDEF", "HASH_VERSION",
707   "IDENTIFIER", "IF_EXPANDED", "INTEGER", "INTEGER_STRING",
708   "LINE_EXPANDED", "NEWLINE", "OTHER", "PLACEHOLDER", "SPACE", "PASTE",
709   "OR", "AND", "'|'", "'^'", "'&'", "NOT_EQUAL", "EQUAL", "'<'", "'>'",
710   "GREATER_OR_EQUAL", "LESS_OR_EQUAL", "RIGHT_SHIFT", "LEFT_SHIFT", "'+'",
711   "'-'", "'*'", "'/'", "'%'", "UNARY", "'('", "')'", "'!'", "'~'", "','",
712   "'['", "']'", "'{'", "'}'", "'.'", "';'", "'='", "$accept", "input",
713   "line", "expanded_line", "control_line", "$@1", "$@2",
714   "integer_constant", "expression", "identifier_list", "text_line",
715   "non_directive", "replacement_list", "junk", "conditional_token",
716   "conditional_tokens", "pp_tokens", "preprocessing_token", "operator", 0
717 };
718 #endif
719 
720 # ifdef YYPRINT
721 /* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
722    token YYLEX-NUM.  */
723 static const yytype_uint16 yytoknum[] =
724 {
725        0,   256,   257,   258,   259,   260,   261,   262,   263,   264,
726      265,   266,   267,   268,   269,   270,   271,   272,   273,   274,
727      275,   276,   277,   278,   279,   280,   281,   282,   283,   284,
728      285,   124,    94,    38,   286,   287,    60,    62,   288,   289,
729      290,   291,    43,    45,    42,    47,    37,   292,    40,    41,
730       33,   126,    44,    91,    93,   123,   125,    46,    59,    61
731 };
732 # endif
733 
734 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives.  */
735 static const yytype_uint8 yyr1[] =
736 {
737        0,    60,    61,    61,    62,    62,    62,    62,    63,    63,
738       63,    63,    64,    64,    64,    64,    64,    64,    64,    64,
739       64,    64,    64,    65,    64,    66,    64,    64,    64,    67,
740       67,    68,    68,    68,    68,    68,    68,    68,    68,    68,
741       68,    68,    68,    68,    68,    68,    68,    68,    68,    68,
742       68,    68,    68,    68,    68,    68,    69,    69,    70,    70,
743       71,    72,    72,    73,    73,    74,    74,    74,    75,    75,
744       76,    76,    77,    77,    77,    77,    77,    78,    78,    78,
745       78,    78,    78,    78,    78,    78,    78,    78,    78,    78,
746       78,    78,    78,    78,    78,    78,    78,    78,    78,    78,
747       78,    78,    78,    78,    78,    78,    78,    78
748 };
749 
750 /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN.  */
751 static const yytype_uint8 yyr2[] =
752 {
753        0,     2,     0,     2,     1,     1,     1,     2,     3,     3,
754        3,     4,     4,     6,     7,     3,     3,     3,     2,     4,
755        4,     3,     2,     0,     3,     0,     3,     3,     2,     1,
756        1,     1,     1,     3,     3,     3,     3,     3,     3,     3,
757        3,     3,     3,     3,     3,     3,     3,     3,     3,     3,
758        3,     2,     2,     2,     2,     3,     1,     3,     1,     2,
759        2,     0,     1,     0,     1,     2,     4,     1,     1,     2,
760        1,     2,     1,     1,     1,     1,     1,     1,     1,     1,
761        1,     1,     1,     1,     1,     1,     1,     1,     1,     1,
762        1,     1,     1,     1,     1,     1,     1,     1,     1,     1,
763        1,     1,     1,     1,     1,     1,     1,     1
764 };
765 
766 /* YYDEFACT[STATE-NAME] -- Default reduction number in state STATE-NUM.
767    Performed when YYTABLE doesn't specify something else to do.  Zero
768    means the default is an error.  */
769 static const yytype_uint8 yydefact[] =
770 {
771        2,     0,     1,     0,     0,     0,     0,    23,    25,     0,
772        0,     0,     0,     0,     0,    72,     0,    73,     0,    58,
773       75,    76,   107,   103,   102,   101,   100,    84,    99,    98,
774       94,    95,    97,    96,    93,    92,    86,    87,    85,    90,
775       91,    79,    80,    89,    88,   105,    77,    78,    81,    82,
776       83,   104,   106,     3,     6,     4,     5,     0,    70,    74,
777       32,    30,    29,     0,     0,     0,     0,     0,    31,     0,
778       28,     7,     0,     0,    61,     0,    22,    68,     0,    67,
779        0,     0,    18,     0,    63,    63,     0,     0,     0,     0,
780        0,    59,    71,    54,    53,     0,    51,    52,     9,     0,
781        0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
782        0,     0,     0,     0,     0,     0,     0,    60,     0,     0,
783       62,    65,     0,    21,    69,    24,    26,    17,     0,    64,
784        0,    16,    15,    27,     8,    10,     0,    55,    33,    34,
785       35,    36,    37,    38,    39,    43,    42,    40,    41,    44,
786       45,    47,    46,    50,    49,    48,    56,    61,     0,    12,
787        0,    19,    20,    11,     0,    61,     0,    66,    13,     0,
788       57,    14
789 };
790 
791 /* YYDEFGOTO[NTERM-NUM].  */
792 static const yytype_int16 yydefgoto[] =
793 {
794       -1,     1,    53,    54,    55,    80,    81,    68,    69,   158,
795       56,    71,   119,   128,    77,    78,   120,    58,    59
796 };
797 
798 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
799    STATE-NUM.  */
800 #define YYPACT_NINF -149
801 static const yytype_int16 yypact[] =
802 {
803     -149,   115,  -149,   492,    -9,   103,   158,  -149,  -149,   201,
804       -5,    48,   451,    50,    95,  -149,   492,  -149,    95,  -149,
805     -149,  -149,  -149,  -149,  -149,  -149,  -149,  -149,  -149,  -149,
806     -149,  -149,  -149,  -149,  -149,  -149,  -149,  -149,  -149,  -149,
807     -149,  -149,  -149,  -149,  -149,  -149,  -149,  -149,  -149,  -149,
808     -149,  -149,  -149,  -149,  -149,  -149,  -149,   328,  -149,  -149,
809     -149,  -149,  -149,   492,   492,   492,   492,   492,  -149,   515,
810     -149,  -149,   369,    23,   451,    38,  -149,  -149,   244,  -149,
811      -17,    51,  -149,   287,   451,   451,   410,    55,    63,   538,
812       52,  -149,  -149,  -149,  -149,   487,  -149,  -149,  -149,   492,
813      492,   492,   492,   492,   492,   492,   492,   492,   492,   492,
814      492,   492,   492,   492,   492,   492,   492,  -149,    19,    89,
815      451,  -149,    99,  -149,  -149,  -149,  -149,  -149,   100,   451,
816      112,  -149,  -149,  -149,  -149,  -149,   117,  -149,   555,   571,
817      586,   600,   613,   624,   624,    18,    18,    18,    18,    64,
818       64,    37,    37,  -149,  -149,  -149,  -149,   451,   -41,  -149,
819       70,  -149,  -149,  -149,   151,   451,   157,  -149,  -149,   154,
820     -149,  -149
821 };
822 
823 /* YYPGOTO[NTERM-NUM].  */
824 static const yytype_int16 yypgoto[] =
825 {
826     -149,  -149,  -149,  -149,  -149,  -149,  -149,   -12,   -11,  -149,
827     -149,  -149,  -148,    94,   -13,   172,     0,    -6,  -149
828 };
829 
830 /* YYTABLE[YYPACT[STATE-NUM]].  What to do in state STATE-NUM.  If
831    positive, shift that token.  If negative, reduce the rule which
832    number is the opposite.  If YYTABLE_NINF, syntax error.  */
833 #define YYTABLE_NINF -1
834 static const yytype_uint8 yytable[] =
835 {
836       79,    57,    88,    79,    72,    89,    90,   125,   165,   164,
837       15,   166,    86,    17,    84,    70,    20,   169,    21,    22,
838       23,    24,    25,    26,    27,    28,    29,    30,    31,    32,
839       33,    34,    35,    36,    37,    38,    39,    40,   156,    41,
840       42,    43,    44,    45,    46,    47,    48,    49,    50,    51,
841       52,    92,    93,    94,    95,    96,    97,   121,   110,   111,
842      112,   113,   114,   115,   116,   124,    92,    85,   157,    87,
843      124,   118,    79,    61,    62,   126,   135,    79,   136,   132,
844       92,   114,   115,   116,   129,   129,   122,   133,   138,   139,
845      140,   141,   142,   143,   144,   145,   146,   147,   148,   149,
846      150,   151,   152,   153,   154,   155,   112,   113,   114,   115,
847      116,    73,    74,   159,    92,     2,    61,    62,   160,   167,
848        3,     4,     5,    92,   161,     6,     7,     8,     9,    10,
849       11,    12,    13,    14,    15,    16,   162,    17,    18,    19,
850       20,   163,    21,    22,    23,    24,    25,    26,    27,    28,
851       29,    30,    31,    32,    33,    34,    35,    36,    37,    38,
852       39,    40,    75,    41,    42,    43,    44,    45,    46,    47,
853       48,    49,    50,    51,    52,   168,   170,    15,   171,   130,
854       17,    83,    76,    20,     0,    21,    22,    23,    24,    25,
855       26,    27,    28,    29,    30,    31,    32,    33,    34,    35,
856       36,    37,    38,    39,    40,    75,    41,    42,    43,    44,
857       45,    46,    47,    48,    49,    50,    51,    52,     0,     0,
858       15,     0,     0,    17,     0,    82,    20,     0,    21,    22,
859       23,    24,    25,    26,    27,    28,    29,    30,    31,    32,
860       33,    34,    35,    36,    37,    38,    39,    40,    75,    41,
861       42,    43,    44,    45,    46,    47,    48,    49,    50,    51,
862       52,     0,     0,    15,     0,     0,    17,     0,   123,    20,
863        0,    21,    22,    23,    24,    25,    26,    27,    28,    29,
864       30,    31,    32,    33,    34,    35,    36,    37,    38,    39,
865       40,    75,    41,    42,    43,    44,    45,    46,    47,    48,
866       49,    50,    51,    52,     0,     0,    15,     0,     0,    17,
867        0,   127,    20,     0,    21,    22,    23,    24,    25,    26,
868       27,    28,    29,    30,    31,    32,    33,    34,    35,    36,
869       37,    38,    39,    40,     0,    41,    42,    43,    44,    45,
870       46,    47,    48,    49,    50,    51,    52,    15,     0,     0,
871       17,     0,    91,    20,     0,    21,    22,    23,    24,    25,
872       26,    27,    28,    29,    30,    31,    32,    33,    34,    35,
873       36,    37,    38,    39,    40,     0,    41,    42,    43,    44,
874       45,    46,    47,    48,    49,    50,    51,    52,    15,     0,
875        0,    17,     0,   117,    20,     0,    21,    22,    23,    24,
876       25,    26,    27,    28,    29,    30,    31,    32,    33,    34,
877       35,    36,    37,    38,    39,    40,     0,    41,    42,    43,
878       44,    45,    46,    47,    48,    49,    50,    51,    52,    15,
879        0,     0,    17,     0,   131,    20,     0,    21,    22,    23,
880       24,    25,    26,    27,    28,    29,    30,    31,    32,    33,
881       34,    35,    36,    37,    38,    39,    40,     0,    41,    42,
882       43,    44,    45,    46,    47,    48,    49,    50,    51,    52,
883       15,     0,     0,    17,     0,     0,    20,     0,    21,    22,
884       23,    24,    25,    26,    27,    28,    29,    30,    31,    32,
885       33,    34,    35,    36,    37,    38,    39,    40,     0,    41,
886       42,    43,    44,    45,    46,    47,    48,    49,    50,    51,
887       52,    60,     0,    61,    62,     0,    99,   100,   101,   102,
888      103,   104,   105,   106,   107,   108,   109,   110,   111,   112,
889      113,   114,   115,   116,    63,    64,   137,     0,     0,    98,
890       65,     0,    66,    67,    99,   100,   101,   102,   103,   104,
891      105,   106,   107,   108,   109,   110,   111,   112,   113,   114,
892      115,   116,   134,     0,     0,     0,     0,    99,   100,   101,
893      102,   103,   104,   105,   106,   107,   108,   109,   110,   111,
894      112,   113,   114,   115,   116,   100,   101,   102,   103,   104,
895      105,   106,   107,   108,   109,   110,   111,   112,   113,   114,
896      115,   116,   101,   102,   103,   104,   105,   106,   107,   108,
897      109,   110,   111,   112,   113,   114,   115,   116,   102,   103,
898      104,   105,   106,   107,   108,   109,   110,   111,   112,   113,
899      114,   115,   116,   103,   104,   105,   106,   107,   108,   109,
900      110,   111,   112,   113,   114,   115,   116,   104,   105,   106,
901      107,   108,   109,   110,   111,   112,   113,   114,   115,   116,
902      106,   107,   108,   109,   110,   111,   112,   113,   114,   115,
903      116
904 };
905 
906 #define yypact_value_is_default(yystate) \
907   ((yystate) == (-149))
908 
909 #define yytable_value_is_error(yytable_value) \
910   YYID (0)
911 
912 static const yytype_int16 yycheck[] =
913 {
914        6,     1,    14,     9,     4,    16,    18,    24,    49,   157,
915       19,    52,    12,    22,    19,    24,    25,   165,    27,    28,
916       29,    30,    31,    32,    33,    34,    35,    36,    37,    38,
917       39,    40,    41,    42,    43,    44,    45,    46,    19,    48,
918       49,    50,    51,    52,    53,    54,    55,    56,    57,    58,
919       59,    57,    63,    64,    65,    66,    67,    19,    40,    41,
920       42,    43,    44,    45,    46,    78,    72,    19,    49,    19,
921       83,    48,    78,    21,    22,    24,    24,    83,    90,    24,
922       86,    44,    45,    46,    84,    85,    48,    24,    99,   100,
923      101,   102,   103,   104,   105,   106,   107,   108,   109,   110,
924      111,   112,   113,   114,   115,   116,    42,    43,    44,    45,
925       46,     8,     9,    24,   120,     0,    21,    22,    19,    49,
926        5,     6,     7,   129,    24,    10,    11,    12,    13,    14,
927       15,    16,    17,    18,    19,    20,    24,    22,    23,    24,
928       25,    24,    27,    28,    29,    30,    31,    32,    33,    34,
929       35,    36,    37,    38,    39,    40,    41,    42,    43,    44,
930       45,    46,     4,    48,    49,    50,    51,    52,    53,    54,
931       55,    56,    57,    58,    59,    24,    19,    19,    24,    85,
932       22,     9,    24,    25,    -1,    27,    28,    29,    30,    31,
933       32,    33,    34,    35,    36,    37,    38,    39,    40,    41,
934       42,    43,    44,    45,    46,     4,    48,    49,    50,    51,
935       52,    53,    54,    55,    56,    57,    58,    59,    -1,    -1,
936       19,    -1,    -1,    22,    -1,    24,    25,    -1,    27,    28,
937       29,    30,    31,    32,    33,    34,    35,    36,    37,    38,
938       39,    40,    41,    42,    43,    44,    45,    46,     4,    48,
939       49,    50,    51,    52,    53,    54,    55,    56,    57,    58,
940       59,    -1,    -1,    19,    -1,    -1,    22,    -1,    24,    25,
941       -1,    27,    28,    29,    30,    31,    32,    33,    34,    35,
942       36,    37,    38,    39,    40,    41,    42,    43,    44,    45,
943       46,     4,    48,    49,    50,    51,    52,    53,    54,    55,
944       56,    57,    58,    59,    -1,    -1,    19,    -1,    -1,    22,
945       -1,    24,    25,    -1,    27,    28,    29,    30,    31,    32,
946       33,    34,    35,    36,    37,    38,    39,    40,    41,    42,
947       43,    44,    45,    46,    -1,    48,    49,    50,    51,    52,
948       53,    54,    55,    56,    57,    58,    59,    19,    -1,    -1,
949       22,    -1,    24,    25,    -1,    27,    28,    29,    30,    31,
950       32,    33,    34,    35,    36,    37,    38,    39,    40,    41,
951       42,    43,    44,    45,    46,    -1,    48,    49,    50,    51,
952       52,    53,    54,    55,    56,    57,    58,    59,    19,    -1,
953       -1,    22,    -1,    24,    25,    -1,    27,    28,    29,    30,
954       31,    32,    33,    34,    35,    36,    37,    38,    39,    40,
955       41,    42,    43,    44,    45,    46,    -1,    48,    49,    50,
956       51,    52,    53,    54,    55,    56,    57,    58,    59,    19,
957       -1,    -1,    22,    -1,    24,    25,    -1,    27,    28,    29,
958       30,    31,    32,    33,    34,    35,    36,    37,    38,    39,
959       40,    41,    42,    43,    44,    45,    46,    -1,    48,    49,
960       50,    51,    52,    53,    54,    55,    56,    57,    58,    59,
961       19,    -1,    -1,    22,    -1,    -1,    25,    -1,    27,    28,
962       29,    30,    31,    32,    33,    34,    35,    36,    37,    38,
963       39,    40,    41,    42,    43,    44,    45,    46,    -1,    48,
964       49,    50,    51,    52,    53,    54,    55,    56,    57,    58,
965       59,    19,    -1,    21,    22,    -1,    29,    30,    31,    32,
966       33,    34,    35,    36,    37,    38,    39,    40,    41,    42,
967       43,    44,    45,    46,    42,    43,    49,    -1,    -1,    24,
968       48,    -1,    50,    51,    29,    30,    31,    32,    33,    34,
969       35,    36,    37,    38,    39,    40,    41,    42,    43,    44,
970       45,    46,    24,    -1,    -1,    -1,    -1,    29,    30,    31,
971       32,    33,    34,    35,    36,    37,    38,    39,    40,    41,
972       42,    43,    44,    45,    46,    30,    31,    32,    33,    34,
973       35,    36,    37,    38,    39,    40,    41,    42,    43,    44,
974       45,    46,    31,    32,    33,    34,    35,    36,    37,    38,
975       39,    40,    41,    42,    43,    44,    45,    46,    32,    33,
976       34,    35,    36,    37,    38,    39,    40,    41,    42,    43,
977       44,    45,    46,    33,    34,    35,    36,    37,    38,    39,
978       40,    41,    42,    43,    44,    45,    46,    34,    35,    36,
979       37,    38,    39,    40,    41,    42,    43,    44,    45,    46,
980       36,    37,    38,    39,    40,    41,    42,    43,    44,    45,
981       46
982 };
983 
984 /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
985    symbol of state STATE-NUM.  */
986 static const yytype_uint8 yystos[] =
987 {
988        0,    61,     0,     5,     6,     7,    10,    11,    12,    13,
989       14,    15,    16,    17,    18,    19,    20,    22,    23,    24,
990       25,    27,    28,    29,    30,    31,    32,    33,    34,    35,
991       36,    37,    38,    39,    40,    41,    42,    43,    44,    45,
992       46,    48,    49,    50,    51,    52,    53,    54,    55,    56,
993       57,    58,    59,    62,    63,    64,    70,    76,    77,    78,
994       19,    21,    22,    42,    43,    48,    50,    51,    67,    68,
995       24,    71,    76,     8,     9,     4,    24,    74,    75,    77,
996       65,    66,    24,    75,    19,    19,    76,    19,    67,    68,
997       67,    24,    77,    68,    68,    68,    68,    68,    24,    29,
998       30,    31,    32,    33,    34,    35,    36,    37,    38,    39,
999       40,    41,    42,    43,    44,    45,    46,    24,    48,    72,
1000       76,    19,    48,    24,    74,    24,    24,    24,    73,    76,
1001       73,    24,    24,    24,    24,    24,    67,    49,    68,    68,
1002       68,    68,    68,    68,    68,    68,    68,    68,    68,    68,
1003       68,    68,    68,    68,    68,    68,    19,    49,    69,    24,
1004       19,    24,    24,    24,    72,    49,    52,    49,    24,    72,
1005       19,    24
1006 };
1007 
1008 #define yyerrok		(yyerrstatus = 0)
1009 #define yyclearin	(yychar = YYEMPTY)
1010 #define YYEMPTY		(-2)
1011 #define YYEOF		0
1012 
1013 #define YYACCEPT	goto yyacceptlab
1014 #define YYABORT		goto yyabortlab
1015 #define YYERROR		goto yyerrorlab
1016 
1017 
1018 /* Like YYERROR except do call yyerror.  This remains here temporarily
1019    to ease the transition to the new meaning of YYERROR, for GCC.
1020    Once GCC version 2 has supplanted version 1, this can go.  However,
1021    YYFAIL appears to be in use.  Nevertheless, it is formally deprecated
1022    in Bison 2.4.2's NEWS entry, where a plan to phase it out is
1023    discussed.  */
1024 
1025 #define YYFAIL		goto yyerrlab
1026 #if defined YYFAIL
1027   /* This is here to suppress warnings from the GCC cpp's
1028      -Wunused-macros.  Normally we don't worry about that warning, but
1029      some users do, and we want to make it easy for users to remove
1030      YYFAIL uses, which will produce warnings from Bison 2.5.  */
1031 #endif
1032 
1033 #define YYRECOVERING()  (!!yyerrstatus)
1034 
1035 #define YYBACKUP(Token, Value)					\
1036 do								\
1037   if (yychar == YYEMPTY && yylen == 1)				\
1038     {								\
1039       yychar = (Token);						\
1040       yylval = (Value);						\
1041       YYPOPSTACK (1);						\
1042       goto yybackup;						\
1043     }								\
1044   else								\
1045     {								\
1046       yyerror (&yylloc, parser, YY_("syntax error: cannot back up")); \
1047       YYERROR;							\
1048     }								\
1049 while (YYID (0))
1050 
1051 
1052 #define YYTERROR	1
1053 #define YYERRCODE	256
1054 
1055 
1056 /* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
1057    If N is 0, then set CURRENT to the empty location which ends
1058    the previous symbol: RHS[0] (always defined).  */
1059 
1060 #define YYRHSLOC(Rhs, K) ((Rhs)[K])
1061 #ifndef YYLLOC_DEFAULT
1062 # define YYLLOC_DEFAULT(Current, Rhs, N)				\
1063     do									\
1064       if (YYID (N))                                                    \
1065 	{								\
1066 	  (Current).first_line   = YYRHSLOC (Rhs, 1).first_line;	\
1067 	  (Current).first_column = YYRHSLOC (Rhs, 1).first_column;	\
1068 	  (Current).last_line    = YYRHSLOC (Rhs, N).last_line;		\
1069 	  (Current).last_column  = YYRHSLOC (Rhs, N).last_column;	\
1070 	}								\
1071       else								\
1072 	{								\
1073 	  (Current).first_line   = (Current).last_line   =		\
1074 	    YYRHSLOC (Rhs, 0).last_line;				\
1075 	  (Current).first_column = (Current).last_column =		\
1076 	    YYRHSLOC (Rhs, 0).last_column;				\
1077 	}								\
1078     while (YYID (0))
1079 #endif
1080 
1081 
1082 /* YY_LOCATION_PRINT -- Print the location on the stream.
1083    This macro was not mandated originally: define only if we know
1084    we won't break user code: when these are the locations we know.  */
1085 
1086 #ifndef YY_LOCATION_PRINT
1087 # if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL
1088 #  define YY_LOCATION_PRINT(File, Loc)			\
1089      fprintf (File, "%d.%d-%d.%d",			\
1090 	      (Loc).first_line, (Loc).first_column,	\
1091 	      (Loc).last_line,  (Loc).last_column)
1092 # else
1093 #  define YY_LOCATION_PRINT(File, Loc) ((void) 0)
1094 # endif
1095 #endif
1096 
1097 
1098 /* YYLEX -- calling `yylex' with the right arguments.  */
1099 
1100 #ifdef YYLEX_PARAM
1101 # define YYLEX yylex (&yylval, &yylloc, YYLEX_PARAM)
1102 #else
1103 # define YYLEX yylex (&yylval, &yylloc, parser)
1104 #endif
1105 
1106 /* Enable debugging if requested.  */
1107 #if YYDEBUG
1108 
1109 # ifndef YYFPRINTF
1110 #  include <stdio.h> /* INFRINGES ON USER NAME SPACE */
1111 #  define YYFPRINTF fprintf
1112 # endif
1113 
1114 # define YYDPRINTF(Args)			\
1115 do {						\
1116   if (yydebug)					\
1117     YYFPRINTF Args;				\
1118 } while (YYID (0))
1119 
1120 # define YY_SYMBOL_PRINT(Title, Type, Value, Location)			  \
1121 do {									  \
1122   if (yydebug)								  \
1123     {									  \
1124       YYFPRINTF (stderr, "%s ", Title);					  \
1125       yy_symbol_print (stderr,						  \
1126 		  Type, Value, Location, parser); \
1127       YYFPRINTF (stderr, "\n");						  \
1128     }									  \
1129 } while (YYID (0))
1130 
1131 
1132 /*--------------------------------.
1133 | Print this symbol on YYOUTPUT.  |
1134 `--------------------------------*/
1135 
1136 /*ARGSUSED*/
1137 #if (defined __STDC__ || defined __C99__FUNC__ \
1138      || defined __cplusplus || defined _MSC_VER)
1139 static void
yy_symbol_value_print(FILE * yyoutput,int yytype,YYSTYPE const * const yyvaluep,YYLTYPE const * const yylocationp,glcpp_parser_t * parser)1140 yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, YYLTYPE const * const yylocationp, glcpp_parser_t *parser)
1141 #else
1142 static void
1143 yy_symbol_value_print (yyoutput, yytype, yyvaluep, yylocationp, parser)
1144     FILE *yyoutput;
1145     int yytype;
1146     YYSTYPE const * const yyvaluep;
1147     YYLTYPE const * const yylocationp;
1148     glcpp_parser_t *parser;
1149 #endif
1150 {
1151   if (!yyvaluep)
1152     return;
1153   YYUSE (yylocationp);
1154   YYUSE (parser);
1155 # ifdef YYPRINT
1156   if (yytype < YYNTOKENS)
1157     YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
1158 # else
1159   YYUSE (yyoutput);
1160 # endif
1161   switch (yytype)
1162     {
1163       default:
1164 	break;
1165     }
1166 }
1167 
1168 
1169 /*--------------------------------.
1170 | Print this symbol on YYOUTPUT.  |
1171 `--------------------------------*/
1172 
1173 #if (defined __STDC__ || defined __C99__FUNC__ \
1174      || defined __cplusplus || defined _MSC_VER)
1175 static void
yy_symbol_print(FILE * yyoutput,int yytype,YYSTYPE const * const yyvaluep,YYLTYPE const * const yylocationp,glcpp_parser_t * parser)1176 yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, YYLTYPE const * const yylocationp, glcpp_parser_t *parser)
1177 #else
1178 static void
1179 yy_symbol_print (yyoutput, yytype, yyvaluep, yylocationp, parser)
1180     FILE *yyoutput;
1181     int yytype;
1182     YYSTYPE const * const yyvaluep;
1183     YYLTYPE const * const yylocationp;
1184     glcpp_parser_t *parser;
1185 #endif
1186 {
1187   if (yytype < YYNTOKENS)
1188     YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
1189   else
1190     YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
1191 
1192   YY_LOCATION_PRINT (yyoutput, *yylocationp);
1193   YYFPRINTF (yyoutput, ": ");
1194   yy_symbol_value_print (yyoutput, yytype, yyvaluep, yylocationp, parser);
1195   YYFPRINTF (yyoutput, ")");
1196 }
1197 
1198 /*------------------------------------------------------------------.
1199 | yy_stack_print -- Print the state stack from its BOTTOM up to its |
1200 | TOP (included).                                                   |
1201 `------------------------------------------------------------------*/
1202 
1203 #if (defined __STDC__ || defined __C99__FUNC__ \
1204      || defined __cplusplus || defined _MSC_VER)
1205 static void
yy_stack_print(yytype_int16 * yybottom,yytype_int16 * yytop)1206 yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop)
1207 #else
1208 static void
1209 yy_stack_print (yybottom, yytop)
1210     yytype_int16 *yybottom;
1211     yytype_int16 *yytop;
1212 #endif
1213 {
1214   YYFPRINTF (stderr, "Stack now");
1215   for (; yybottom <= yytop; yybottom++)
1216     {
1217       int yybot = *yybottom;
1218       YYFPRINTF (stderr, " %d", yybot);
1219     }
1220   YYFPRINTF (stderr, "\n");
1221 }
1222 
1223 # define YY_STACK_PRINT(Bottom, Top)				\
1224 do {								\
1225   if (yydebug)							\
1226     yy_stack_print ((Bottom), (Top));				\
1227 } while (YYID (0))
1228 
1229 
1230 /*------------------------------------------------.
1231 | Report that the YYRULE is going to be reduced.  |
1232 `------------------------------------------------*/
1233 
1234 #if (defined __STDC__ || defined __C99__FUNC__ \
1235      || defined __cplusplus || defined _MSC_VER)
1236 static void
yy_reduce_print(YYSTYPE * yyvsp,YYLTYPE * yylsp,int yyrule,glcpp_parser_t * parser)1237 yy_reduce_print (YYSTYPE *yyvsp, YYLTYPE *yylsp, int yyrule, glcpp_parser_t *parser)
1238 #else
1239 static void
1240 yy_reduce_print (yyvsp, yylsp, yyrule, parser)
1241     YYSTYPE *yyvsp;
1242     YYLTYPE *yylsp;
1243     int yyrule;
1244     glcpp_parser_t *parser;
1245 #endif
1246 {
1247   int yynrhs = yyr2[yyrule];
1248   int yyi;
1249   unsigned long int yylno = yyrline[yyrule];
1250   YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
1251 	     yyrule - 1, yylno);
1252   /* The symbols being reduced.  */
1253   for (yyi = 0; yyi < yynrhs; yyi++)
1254     {
1255       YYFPRINTF (stderr, "   $%d = ", yyi + 1);
1256       yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
1257 		       &(yyvsp[(yyi + 1) - (yynrhs)])
1258 		       , &(yylsp[(yyi + 1) - (yynrhs)])		       , parser);
1259       YYFPRINTF (stderr, "\n");
1260     }
1261 }
1262 
1263 # define YY_REDUCE_PRINT(Rule)		\
1264 do {					\
1265   if (yydebug)				\
1266     yy_reduce_print (yyvsp, yylsp, Rule, parser); \
1267 } while (YYID (0))
1268 
1269 /* Nonzero means print parse trace.  It is left uninitialized so that
1270    multiple parsers can coexist.  */
1271 int yydebug;
1272 #else /* !YYDEBUG */
1273 # define YYDPRINTF(Args)
1274 # define YY_SYMBOL_PRINT(Title, Type, Value, Location)
1275 # define YY_STACK_PRINT(Bottom, Top)
1276 # define YY_REDUCE_PRINT(Rule)
1277 #endif /* !YYDEBUG */
1278 
1279 
1280 /* YYINITDEPTH -- initial size of the parser's stacks.  */
1281 #ifndef	YYINITDEPTH
1282 # define YYINITDEPTH 200
1283 #endif
1284 
1285 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
1286    if the built-in stack extension method is used).
1287 
1288    Do not make this value too large; the results are undefined if
1289    YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
1290    evaluated with infinite-precision integer arithmetic.  */
1291 
1292 #ifndef YYMAXDEPTH
1293 # define YYMAXDEPTH 10000
1294 #endif
1295 
1296 
1297 #if YYERROR_VERBOSE
1298 
1299 # ifndef yystrlen
1300 #  if defined __GLIBC__ && defined _STRING_H
1301 #   define yystrlen strlen
1302 #  else
1303 /* Return the length of YYSTR.  */
1304 #if (defined __STDC__ || defined __C99__FUNC__ \
1305      || defined __cplusplus || defined _MSC_VER)
1306 static YYSIZE_T
yystrlen(const char * yystr)1307 yystrlen (const char *yystr)
1308 #else
1309 static YYSIZE_T
1310 yystrlen (yystr)
1311     const char *yystr;
1312 #endif
1313 {
1314   YYSIZE_T yylen;
1315   for (yylen = 0; yystr[yylen]; yylen++)
1316     continue;
1317   return yylen;
1318 }
1319 #  endif
1320 # endif
1321 
1322 # ifndef yystpcpy
1323 #  if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
1324 #   define yystpcpy stpcpy
1325 #  else
1326 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
1327    YYDEST.  */
1328 #if (defined __STDC__ || defined __C99__FUNC__ \
1329      || defined __cplusplus || defined _MSC_VER)
1330 static char *
yystpcpy(char * yydest,const char * yysrc)1331 yystpcpy (char *yydest, const char *yysrc)
1332 #else
1333 static char *
1334 yystpcpy (yydest, yysrc)
1335     char *yydest;
1336     const char *yysrc;
1337 #endif
1338 {
1339   char *yyd = yydest;
1340   const char *yys = yysrc;
1341 
1342   while ((*yyd++ = *yys++) != '\0')
1343     continue;
1344 
1345   return yyd - 1;
1346 }
1347 #  endif
1348 # endif
1349 
1350 # ifndef yytnamerr
1351 /* Copy to YYRES the contents of YYSTR after stripping away unnecessary
1352    quotes and backslashes, so that it's suitable for yyerror.  The
1353    heuristic is that double-quoting is unnecessary unless the string
1354    contains an apostrophe, a comma, or backslash (other than
1355    backslash-backslash).  YYSTR is taken from yytname.  If YYRES is
1356    null, do not copy; instead, return the length of what the result
1357    would have been.  */
1358 static YYSIZE_T
yytnamerr(char * yyres,const char * yystr)1359 yytnamerr (char *yyres, const char *yystr)
1360 {
1361   if (*yystr == '"')
1362     {
1363       YYSIZE_T yyn = 0;
1364       char const *yyp = yystr;
1365 
1366       for (;;)
1367 	switch (*++yyp)
1368 	  {
1369 	  case '\'':
1370 	  case ',':
1371 	    goto do_not_strip_quotes;
1372 
1373 	  case '\\':
1374 	    if (*++yyp != '\\')
1375 	      goto do_not_strip_quotes;
1376 	    /* Fall through.  */
1377 	  default:
1378 	    if (yyres)
1379 	      yyres[yyn] = *yyp;
1380 	    yyn++;
1381 	    break;
1382 
1383 	  case '"':
1384 	    if (yyres)
1385 	      yyres[yyn] = '\0';
1386 	    return yyn;
1387 	  }
1388     do_not_strip_quotes: ;
1389     }
1390 
1391   if (! yyres)
1392     return yystrlen (yystr);
1393 
1394   return yystpcpy (yyres, yystr) - yyres;
1395 }
1396 # endif
1397 
1398 /* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message
1399    about the unexpected token YYTOKEN for the state stack whose top is
1400    YYSSP.
1401 
1402    Return 0 if *YYMSG was successfully written.  Return 1 if *YYMSG is
1403    not large enough to hold the message.  In that case, also set
1404    *YYMSG_ALLOC to the required number of bytes.  Return 2 if the
1405    required number of bytes is too large to store.  */
1406 static int
yysyntax_error(YYSIZE_T * yymsg_alloc,char ** yymsg,yytype_int16 * yyssp,int yytoken)1407 yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg,
1408                 yytype_int16 *yyssp, int yytoken)
1409 {
1410   YYSIZE_T yysize0 = yytnamerr (0, yytname[yytoken]);
1411   YYSIZE_T yysize = yysize0;
1412   YYSIZE_T yysize1;
1413   enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
1414   /* Internationalized format string. */
1415   const char *yyformat = 0;
1416   /* Arguments of yyformat. */
1417   char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
1418   /* Number of reported tokens (one for the "unexpected", one per
1419      "expected"). */
1420   int yycount = 0;
1421 
1422   /* There are many possibilities here to consider:
1423      - Assume YYFAIL is not used.  It's too flawed to consider.  See
1424        <http://lists.gnu.org/archive/html/bison-patches/2009-12/msg00024.html>
1425        for details.  YYERROR is fine as it does not invoke this
1426        function.
1427      - If this state is a consistent state with a default action, then
1428        the only way this function was invoked is if the default action
1429        is an error action.  In that case, don't check for expected
1430        tokens because there are none.
1431      - The only way there can be no lookahead present (in yychar) is if
1432        this state is a consistent state with a default action.  Thus,
1433        detecting the absence of a lookahead is sufficient to determine
1434        that there is no unexpected or expected token to report.  In that
1435        case, just report a simple "syntax error".
1436      - Don't assume there isn't a lookahead just because this state is a
1437        consistent state with a default action.  There might have been a
1438        previous inconsistent state, consistent state with a non-default
1439        action, or user semantic action that manipulated yychar.
1440      - Of course, the expected token list depends on states to have
1441        correct lookahead information, and it depends on the parser not
1442        to perform extra reductions after fetching a lookahead from the
1443        scanner and before detecting a syntax error.  Thus, state merging
1444        (from LALR or IELR) and default reductions corrupt the expected
1445        token list.  However, the list is correct for canonical LR with
1446        one exception: it will still contain any token that will not be
1447        accepted due to an error action in a later state.
1448   */
1449   if (yytoken != YYEMPTY)
1450     {
1451       int yyn = yypact[*yyssp];
1452       yyarg[yycount++] = yytname[yytoken];
1453       if (!yypact_value_is_default (yyn))
1454         {
1455           /* Start YYX at -YYN if negative to avoid negative indexes in
1456              YYCHECK.  In other words, skip the first -YYN actions for
1457              this state because they are default actions.  */
1458           int yyxbegin = yyn < 0 ? -yyn : 0;
1459           /* Stay within bounds of both yycheck and yytname.  */
1460           int yychecklim = YYLAST - yyn + 1;
1461           int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
1462           int yyx;
1463 
1464           for (yyx = yyxbegin; yyx < yyxend; ++yyx)
1465             if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR
1466                 && !yytable_value_is_error (yytable[yyx + yyn]))
1467               {
1468                 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
1469                   {
1470                     yycount = 1;
1471                     yysize = yysize0;
1472                     break;
1473                   }
1474                 yyarg[yycount++] = yytname[yyx];
1475                 yysize1 = yysize + yytnamerr (0, yytname[yyx]);
1476                 if (! (yysize <= yysize1
1477                        && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
1478                   return 2;
1479                 yysize = yysize1;
1480               }
1481         }
1482     }
1483 
1484   switch (yycount)
1485     {
1486 # define YYCASE_(N, S)                      \
1487       case N:                               \
1488         yyformat = S;                       \
1489       break
1490       YYCASE_(0, YY_("syntax error"));
1491       YYCASE_(1, YY_("syntax error, unexpected %s"));
1492       YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s"));
1493       YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s"));
1494       YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s"));
1495       YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"));
1496 # undef YYCASE_
1497     }
1498 
1499   yysize1 = yysize + yystrlen (yyformat);
1500   if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
1501     return 2;
1502   yysize = yysize1;
1503 
1504   if (*yymsg_alloc < yysize)
1505     {
1506       *yymsg_alloc = 2 * yysize;
1507       if (! (yysize <= *yymsg_alloc
1508              && *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM))
1509         *yymsg_alloc = YYSTACK_ALLOC_MAXIMUM;
1510       return 1;
1511     }
1512 
1513   /* Avoid sprintf, as that infringes on the user's name space.
1514      Don't have undefined behavior even if the translation
1515      produced a string with the wrong number of "%s"s.  */
1516   {
1517     char *yyp = *yymsg;
1518     int yyi = 0;
1519     while ((*yyp = *yyformat) != '\0')
1520       if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount)
1521         {
1522           yyp += yytnamerr (yyp, yyarg[yyi++]);
1523           yyformat += 2;
1524         }
1525       else
1526         {
1527           yyp++;
1528           yyformat++;
1529         }
1530   }
1531   return 0;
1532 }
1533 #endif /* YYERROR_VERBOSE */
1534 
1535 /*-----------------------------------------------.
1536 | Release the memory associated to this symbol.  |
1537 `-----------------------------------------------*/
1538 
1539 /*ARGSUSED*/
1540 #if (defined __STDC__ || defined __C99__FUNC__ \
1541      || defined __cplusplus || defined _MSC_VER)
1542 static void
yydestruct(const char * yymsg,int yytype,YYSTYPE * yyvaluep,YYLTYPE * yylocationp,glcpp_parser_t * parser)1543 yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, YYLTYPE *yylocationp, glcpp_parser_t *parser)
1544 #else
1545 static void
1546 yydestruct (yymsg, yytype, yyvaluep, yylocationp, parser)
1547     const char *yymsg;
1548     int yytype;
1549     YYSTYPE *yyvaluep;
1550     YYLTYPE *yylocationp;
1551     glcpp_parser_t *parser;
1552 #endif
1553 {
1554   YYUSE (yyvaluep);
1555   YYUSE (yylocationp);
1556   YYUSE (parser);
1557 
1558   if (!yymsg)
1559     yymsg = "Deleting";
1560   YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
1561 
1562   switch (yytype)
1563     {
1564 
1565       default:
1566 	break;
1567     }
1568 }
1569 
1570 
1571 /* Prevent warnings from -Wmissing-prototypes.  */
1572 #ifdef YYPARSE_PARAM
1573 #if defined __STDC__ || defined __cplusplus
1574 int yyparse (void *YYPARSE_PARAM);
1575 #else
1576 int yyparse ();
1577 #endif
1578 #else /* ! YYPARSE_PARAM */
1579 #if defined __STDC__ || defined __cplusplus
1580 int yyparse (glcpp_parser_t *parser);
1581 #else
1582 int yyparse ();
1583 #endif
1584 #endif /* ! YYPARSE_PARAM */
1585 
1586 
1587 /*----------.
1588 | yyparse.  |
1589 `----------*/
1590 
1591 #ifdef YYPARSE_PARAM
1592 #if (defined __STDC__ || defined __C99__FUNC__ \
1593      || defined __cplusplus || defined _MSC_VER)
1594 int
yyparse(void * YYPARSE_PARAM)1595 yyparse (void *YYPARSE_PARAM)
1596 #else
1597 int
1598 yyparse (YYPARSE_PARAM)
1599     void *YYPARSE_PARAM;
1600 #endif
1601 #else /* ! YYPARSE_PARAM */
1602 #if (defined __STDC__ || defined __C99__FUNC__ \
1603      || defined __cplusplus || defined _MSC_VER)
1604 int
1605 yyparse (glcpp_parser_t *parser)
1606 #else
1607 int
1608 yyparse (parser)
1609     glcpp_parser_t *parser;
1610 #endif
1611 #endif
1612 {
1613 /* The lookahead symbol.  */
1614 int yychar;
1615 
1616 /* The semantic value of the lookahead symbol.  */
1617 YYSTYPE yylval;
1618 
1619 /* Location data for the lookahead symbol.  */
1620 YYLTYPE yylloc;
1621 
1622     /* Number of syntax errors so far.  */
1623     int yynerrs;
1624 
1625     int yystate;
1626     /* Number of tokens to shift before error messages enabled.  */
1627     int yyerrstatus;
1628 
1629     /* The stacks and their tools:
1630        `yyss': related to states.
1631        `yyvs': related to semantic values.
1632        `yyls': related to locations.
1633 
1634        Refer to the stacks thru separate pointers, to allow yyoverflow
1635        to reallocate them elsewhere.  */
1636 
1637     /* The state stack.  */
1638     yytype_int16 yyssa[YYINITDEPTH];
1639     yytype_int16 *yyss;
1640     yytype_int16 *yyssp;
1641 
1642     /* The semantic value stack.  */
1643     YYSTYPE yyvsa[YYINITDEPTH];
1644     YYSTYPE *yyvs;
1645     YYSTYPE *yyvsp;
1646 
1647     /* The location stack.  */
1648     YYLTYPE yylsa[YYINITDEPTH];
1649     YYLTYPE *yyls;
1650     YYLTYPE *yylsp;
1651 
1652     /* The locations where the error started and ended.  */
1653     YYLTYPE yyerror_range[3];
1654 
1655     YYSIZE_T yystacksize;
1656 
1657   int yyn;
1658   int yyresult;
1659   /* Lookahead token as an internal (translated) token number.  */
1660   int yytoken;
1661   /* The variables used to return semantic value and location from the
1662      action routines.  */
1663   YYSTYPE yyval;
1664   YYLTYPE yyloc;
1665 
1666 #if YYERROR_VERBOSE
1667   /* Buffer for error messages, and its allocated size.  */
1668   char yymsgbuf[128];
1669   char *yymsg = yymsgbuf;
1670   YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
1671 #endif
1672 
1673 #define YYPOPSTACK(N)   (yyvsp -= (N), yyssp -= (N), yylsp -= (N))
1674 
1675   /* The number of symbols on the RHS of the reduced rule.
1676      Keep to zero when no symbol should be popped.  */
1677   int yylen = 0;
1678 
1679   yytoken = 0;
1680   yyss = yyssa;
1681   yyvs = yyvsa;
1682   yyls = yylsa;
1683   yystacksize = YYINITDEPTH;
1684 
1685   YYDPRINTF ((stderr, "Starting parse\n"));
1686 
1687   yystate = 0;
1688   yyerrstatus = 0;
1689   yynerrs = 0;
1690   yychar = YYEMPTY; /* Cause a token to be read.  */
1691 
1692   /* Initialize stack pointers.
1693      Waste one element of value and location stack
1694      so that they stay on the same level as the state stack.
1695      The wasted elements are never initialized.  */
1696   yyssp = yyss;
1697   yyvsp = yyvs;
1698   yylsp = yyls;
1699 
1700 #if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL
1701   /* Initialize the default location before parsing starts.  */
1702   yylloc.first_line   = yylloc.last_line   = 1;
1703   yylloc.first_column = yylloc.last_column = 1;
1704 #endif
1705 
1706 /* User initialization code.  */
1707 
1708 /* Line 1590 of yacc.c  */
1709 #line 151 "src/src/glsl/glcpp/glcpp-parse.y"
1710 {
1711 	yylloc.first_line = 1;
1712 	yylloc.first_column = 1;
1713 	yylloc.last_line = 1;
1714 	yylloc.last_column = 1;
1715 	yylloc.source = 0;
1716 }
1717 
1718 /* Line 1590 of yacc.c  */
1719 #line 1720 "src/chromium_gensrc/mesa/glcpp-parse.c"
1720   yylsp[0] = yylloc;
1721 
1722   goto yysetstate;
1723 
1724 /*------------------------------------------------------------.
1725 | yynewstate -- Push a new state, which is found in yystate.  |
1726 `------------------------------------------------------------*/
1727  yynewstate:
1728   /* In all cases, when you get here, the value and location stacks
1729      have just been pushed.  So pushing a state here evens the stacks.  */
1730   yyssp++;
1731 
1732  yysetstate:
1733   *yyssp = yystate;
1734 
1735   if (yyss + yystacksize - 1 <= yyssp)
1736     {
1737       /* Get the current used size of the three stacks, in elements.  */
1738       YYSIZE_T yysize = yyssp - yyss + 1;
1739 
1740 #ifdef yyoverflow
1741       {
1742 	/* Give user a chance to reallocate the stack.  Use copies of
1743 	   these so that the &'s don't force the real ones into
1744 	   memory.  */
1745 	YYSTYPE *yyvs1 = yyvs;
1746 	yytype_int16 *yyss1 = yyss;
1747 	YYLTYPE *yyls1 = yyls;
1748 
1749 	/* Each stack pointer address is followed by the size of the
1750 	   data in use in that stack, in bytes.  This used to be a
1751 	   conditional around just the two extra args, but that might
1752 	   be undefined if yyoverflow is a macro.  */
1753 	yyoverflow (YY_("memory exhausted"),
1754 		    &yyss1, yysize * sizeof (*yyssp),
1755 		    &yyvs1, yysize * sizeof (*yyvsp),
1756 		    &yyls1, yysize * sizeof (*yylsp),
1757 		    &yystacksize);
1758 
1759 	yyls = yyls1;
1760 	yyss = yyss1;
1761 	yyvs = yyvs1;
1762       }
1763 #else /* no yyoverflow */
1764 # ifndef YYSTACK_RELOCATE
1765       goto yyexhaustedlab;
1766 # else
1767       /* Extend the stack our own way.  */
1768       if (YYMAXDEPTH <= yystacksize)
1769 	goto yyexhaustedlab;
1770       yystacksize *= 2;
1771       if (YYMAXDEPTH < yystacksize)
1772 	yystacksize = YYMAXDEPTH;
1773 
1774       {
1775 	yytype_int16 *yyss1 = yyss;
1776 	union yyalloc *yyptr =
1777 	  (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
1778 	if (! yyptr)
1779 	  goto yyexhaustedlab;
1780 	YYSTACK_RELOCATE (yyss_alloc, yyss);
1781 	YYSTACK_RELOCATE (yyvs_alloc, yyvs);
1782 	YYSTACK_RELOCATE (yyls_alloc, yyls);
1783 #  undef YYSTACK_RELOCATE
1784 	if (yyss1 != yyssa)
1785 	  YYSTACK_FREE (yyss1);
1786       }
1787 # endif
1788 #endif /* no yyoverflow */
1789 
1790       yyssp = yyss + yysize - 1;
1791       yyvsp = yyvs + yysize - 1;
1792       yylsp = yyls + yysize - 1;
1793 
1794       YYDPRINTF ((stderr, "Stack size increased to %lu\n",
1795 		  (unsigned long int) yystacksize));
1796 
1797       if (yyss + yystacksize - 1 <= yyssp)
1798 	YYABORT;
1799     }
1800 
1801   YYDPRINTF ((stderr, "Entering state %d\n", yystate));
1802 
1803   if (yystate == YYFINAL)
1804     YYACCEPT;
1805 
1806   goto yybackup;
1807 
1808 /*-----------.
1809 | yybackup.  |
1810 `-----------*/
1811 yybackup:
1812 
1813   /* Do appropriate processing given the current state.  Read a
1814      lookahead token if we need one and don't already have one.  */
1815 
1816   /* First try to decide what to do without reference to lookahead token.  */
1817   yyn = yypact[yystate];
1818   if (yypact_value_is_default (yyn))
1819     goto yydefault;
1820 
1821   /* Not known => get a lookahead token if don't already have one.  */
1822 
1823   /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol.  */
1824   if (yychar == YYEMPTY)
1825     {
1826       YYDPRINTF ((stderr, "Reading a token: "));
1827       yychar = YYLEX;
1828     }
1829 
1830   if (yychar <= YYEOF)
1831     {
1832       yychar = yytoken = YYEOF;
1833       YYDPRINTF ((stderr, "Now at end of input.\n"));
1834     }
1835   else
1836     {
1837       yytoken = YYTRANSLATE (yychar);
1838       YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
1839     }
1840 
1841   /* If the proper action on seeing token YYTOKEN is to reduce or to
1842      detect an error, take that action.  */
1843   yyn += yytoken;
1844   if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
1845     goto yydefault;
1846   yyn = yytable[yyn];
1847   if (yyn <= 0)
1848     {
1849       if (yytable_value_is_error (yyn))
1850         goto yyerrlab;
1851       yyn = -yyn;
1852       goto yyreduce;
1853     }
1854 
1855   /* Count tokens shifted since error; after three, turn off error
1856      status.  */
1857   if (yyerrstatus)
1858     yyerrstatus--;
1859 
1860   /* Shift the lookahead token.  */
1861   YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
1862 
1863   /* Discard the shifted token.  */
1864   yychar = YYEMPTY;
1865 
1866   yystate = yyn;
1867   *++yyvsp = yylval;
1868   *++yylsp = yylloc;
1869   goto yynewstate;
1870 
1871 
1872 /*-----------------------------------------------------------.
1873 | yydefault -- do the default action for the current state.  |
1874 `-----------------------------------------------------------*/
1875 yydefault:
1876   yyn = yydefact[yystate];
1877   if (yyn == 0)
1878     goto yyerrlab;
1879   goto yyreduce;
1880 
1881 
1882 /*-----------------------------.
1883 | yyreduce -- Do a reduction.  |
1884 `-----------------------------*/
1885 yyreduce:
1886   /* yyn is the number of a rule to reduce with.  */
1887   yylen = yyr2[yyn];
1888 
1889   /* If YYLEN is nonzero, implement the default value of the action:
1890      `$$ = $1'.
1891 
1892      Otherwise, the following line sets YYVAL to garbage.
1893      This behavior is undocumented and Bison
1894      users should not rely upon it.  Assigning to YYVAL
1895      unconditionally makes the parser a bit smaller, and it avoids a
1896      GCC warning that YYVAL may be used uninitialized.  */
1897   yyval = yyvsp[1-yylen];
1898 
1899   /* Default location.  */
1900   YYLLOC_DEFAULT (yyloc, (yylsp - yylen), yylen);
1901   YY_REDUCE_PRINT (yyn);
1902   switch (yyn)
1903     {
1904         case 4:
1905 
1906 /* Line 1806 of yacc.c  */
1907 #line 190 "src/src/glsl/glcpp/glcpp-parse.y"
1908     {
1909 		ralloc_asprintf_rewrite_tail (&parser->output, &parser->output_length, "\n");
1910 	}
1911     break;
1912 
1913   case 5:
1914 
1915 /* Line 1806 of yacc.c  */
1916 #line 193 "src/src/glsl/glcpp/glcpp-parse.y"
1917     {
1918 		_glcpp_parser_print_expanded_token_list (parser, (yyvsp[(1) - (1)].token_list));
1919 		ralloc_asprintf_rewrite_tail (&parser->output, &parser->output_length, "\n");
1920 		ralloc_free ((yyvsp[(1) - (1)].token_list));
1921 	}
1922     break;
1923 
1924   case 8:
1925 
1926 /* Line 1806 of yacc.c  */
1927 #line 203 "src/src/glsl/glcpp/glcpp-parse.y"
1928     {
1929 		_glcpp_parser_skip_stack_push_if (parser, & (yylsp[(1) - (3)]), (yyvsp[(2) - (3)].ival));
1930 	}
1931     break;
1932 
1933   case 9:
1934 
1935 /* Line 1806 of yacc.c  */
1936 #line 206 "src/src/glsl/glcpp/glcpp-parse.y"
1937     {
1938 		_glcpp_parser_skip_stack_change_if (parser, & (yylsp[(1) - (3)]), "elif", (yyvsp[(2) - (3)].ival));
1939 	}
1940     break;
1941 
1942   case 10:
1943 
1944 /* Line 1806 of yacc.c  */
1945 #line 209 "src/src/glsl/glcpp/glcpp-parse.y"
1946     {
1947 		parser->has_new_line_number = 1;
1948 		parser->new_line_number = (yyvsp[(2) - (3)].ival);
1949 		ralloc_asprintf_rewrite_tail (&parser->output,
1950 					      &parser->output_length,
1951 					      "#line %" PRIiMAX "\n",
1952 					      (yyvsp[(2) - (3)].ival));
1953 	}
1954     break;
1955 
1956   case 11:
1957 
1958 /* Line 1806 of yacc.c  */
1959 #line 217 "src/src/glsl/glcpp/glcpp-parse.y"
1960     {
1961 		parser->has_new_line_number = 1;
1962 		parser->new_line_number = (yyvsp[(2) - (4)].ival);
1963 		parser->has_new_source_number = 1;
1964 		parser->new_source_number = (yyvsp[(3) - (4)].ival);
1965 		ralloc_asprintf_rewrite_tail (&parser->output,
1966 					      &parser->output_length,
1967 					      "#line %" PRIiMAX " %" PRIiMAX "\n",
1968 					      (yyvsp[(2) - (4)].ival), (yyvsp[(3) - (4)].ival));
1969 	}
1970     break;
1971 
1972   case 12:
1973 
1974 /* Line 1806 of yacc.c  */
1975 #line 230 "src/src/glsl/glcpp/glcpp-parse.y"
1976     {
1977 		_define_object_macro (parser, & (yylsp[(2) - (4)]), (yyvsp[(2) - (4)].str), (yyvsp[(3) - (4)].token_list));
1978 	}
1979     break;
1980 
1981   case 13:
1982 
1983 /* Line 1806 of yacc.c  */
1984 #line 233 "src/src/glsl/glcpp/glcpp-parse.y"
1985     {
1986 		_define_function_macro (parser, & (yylsp[(2) - (6)]), (yyvsp[(2) - (6)].str), NULL, (yyvsp[(5) - (6)].token_list));
1987 	}
1988     break;
1989 
1990   case 14:
1991 
1992 /* Line 1806 of yacc.c  */
1993 #line 236 "src/src/glsl/glcpp/glcpp-parse.y"
1994     {
1995 		_define_function_macro (parser, & (yylsp[(2) - (7)]), (yyvsp[(2) - (7)].str), (yyvsp[(4) - (7)].string_list), (yyvsp[(6) - (7)].token_list));
1996 	}
1997     break;
1998 
1999   case 15:
2000 
2001 /* Line 1806 of yacc.c  */
2002 #line 239 "src/src/glsl/glcpp/glcpp-parse.y"
2003     {
2004 		macro_t *macro = hash_table_find (parser->defines, (yyvsp[(2) - (3)].str));
2005 		if (macro) {
2006 			hash_table_remove (parser->defines, (yyvsp[(2) - (3)].str));
2007 			ralloc_free (macro);
2008 		}
2009 		ralloc_free ((yyvsp[(2) - (3)].str));
2010 	}
2011     break;
2012 
2013   case 16:
2014 
2015 /* Line 1806 of yacc.c  */
2016 #line 247 "src/src/glsl/glcpp/glcpp-parse.y"
2017     {
2018 		if (parser->skip_stack == NULL ||
2019 		    parser->skip_stack->type == SKIP_NO_SKIP)
2020 		{
2021 			_glcpp_parser_expand_and_lex_from (parser,
2022 							   LINE_EXPANDED, (yyvsp[(2) - (3)].token_list));
2023 		}
2024 	}
2025     break;
2026 
2027   case 17:
2028 
2029 /* Line 1806 of yacc.c  */
2030 #line 255 "src/src/glsl/glcpp/glcpp-parse.y"
2031     {
2032 		/* Be careful to only evaluate the 'if' expression if
2033 		 * we are not skipping. When we are skipping, we
2034 		 * simply push a new 0-valued 'if' onto the skip
2035 		 * stack.
2036 		 *
2037 		 * This avoids generating diagnostics for invalid
2038 		 * expressions that are being skipped. */
2039 		if (parser->skip_stack == NULL ||
2040 		    parser->skip_stack->type == SKIP_NO_SKIP)
2041 		{
2042 			_glcpp_parser_expand_and_lex_from (parser,
2043 							   IF_EXPANDED, (yyvsp[(2) - (3)].token_list));
2044 		}
2045 		else
2046 		{
2047 			_glcpp_parser_skip_stack_push_if (parser, & (yylsp[(1) - (3)]), 0);
2048 			parser->skip_stack->type = SKIP_TO_ENDIF;
2049 		}
2050 	}
2051     break;
2052 
2053   case 18:
2054 
2055 /* Line 1806 of yacc.c  */
2056 #line 275 "src/src/glsl/glcpp/glcpp-parse.y"
2057     {
2058 		/* #if without an expression is only an error if we
2059 		 *  are not skipping */
2060 		if (parser->skip_stack == NULL ||
2061 		    parser->skip_stack->type == SKIP_NO_SKIP)
2062 		{
2063 			glcpp_error(& (yylsp[(1) - (2)]), parser, "#if with no expression");
2064 		}
2065 		_glcpp_parser_skip_stack_push_if (parser, & (yylsp[(1) - (2)]), 0);
2066 	}
2067     break;
2068 
2069   case 19:
2070 
2071 /* Line 1806 of yacc.c  */
2072 #line 285 "src/src/glsl/glcpp/glcpp-parse.y"
2073     {
2074 		macro_t *macro = hash_table_find (parser->defines, (yyvsp[(2) - (4)].str));
2075 		ralloc_free ((yyvsp[(2) - (4)].str));
2076 		_glcpp_parser_skip_stack_push_if (parser, & (yylsp[(1) - (4)]), macro != NULL);
2077 	}
2078     break;
2079 
2080   case 20:
2081 
2082 /* Line 1806 of yacc.c  */
2083 #line 290 "src/src/glsl/glcpp/glcpp-parse.y"
2084     {
2085 		macro_t *macro = hash_table_find (parser->defines, (yyvsp[(2) - (4)].str));
2086 		ralloc_free ((yyvsp[(2) - (4)].str));
2087 		_glcpp_parser_skip_stack_push_if (parser, & (yylsp[(1) - (4)]), macro == NULL);
2088 	}
2089     break;
2090 
2091   case 21:
2092 
2093 /* Line 1806 of yacc.c  */
2094 #line 295 "src/src/glsl/glcpp/glcpp-parse.y"
2095     {
2096 		/* Be careful to only evaluate the 'elif' expression
2097 		 * if we are not skipping. When we are skipping, we
2098 		 * simply change to a 0-valued 'elif' on the skip
2099 		 * stack.
2100 		 *
2101 		 * This avoids generating diagnostics for invalid
2102 		 * expressions that are being skipped. */
2103 		if (parser->skip_stack &&
2104 		    parser->skip_stack->type == SKIP_TO_ELSE)
2105 		{
2106 			_glcpp_parser_expand_and_lex_from (parser,
2107 							   ELIF_EXPANDED, (yyvsp[(2) - (3)].token_list));
2108 		}
2109 		else
2110 		{
2111 			_glcpp_parser_skip_stack_change_if (parser, & (yylsp[(1) - (3)]),
2112 							    "elif", 0);
2113 		}
2114 	}
2115     break;
2116 
2117   case 22:
2118 
2119 /* Line 1806 of yacc.c  */
2120 #line 315 "src/src/glsl/glcpp/glcpp-parse.y"
2121     {
2122 		/* #elif without an expression is an error unless we
2123 		 * are skipping. */
2124 		if (parser->skip_stack &&
2125 		    parser->skip_stack->type == SKIP_TO_ELSE)
2126 		{
2127 			glcpp_error(& (yylsp[(1) - (2)]), parser, "#elif with no expression");
2128 		}
2129 		else
2130 		{
2131 			_glcpp_parser_skip_stack_change_if (parser, & (yylsp[(1) - (2)]),
2132 							    "elif", 0);
2133 			glcpp_warning(& (yylsp[(1) - (2)]), parser, "ignoring illegal #elif without expression");
2134 		}
2135 	}
2136     break;
2137 
2138   case 23:
2139 
2140 /* Line 1806 of yacc.c  */
2141 #line 330 "src/src/glsl/glcpp/glcpp-parse.y"
2142     {
2143 		_glcpp_parser_skip_stack_change_if (parser, & (yylsp[(1) - (1)]), "else", 1);
2144 	}
2145     break;
2146 
2147   case 25:
2148 
2149 /* Line 1806 of yacc.c  */
2150 #line 333 "src/src/glsl/glcpp/glcpp-parse.y"
2151     {
2152 		_glcpp_parser_skip_stack_pop (parser, & (yylsp[(1) - (1)]));
2153 	}
2154     break;
2155 
2156   case 27:
2157 
2158 /* Line 1806 of yacc.c  */
2159 #line 336 "src/src/glsl/glcpp/glcpp-parse.y"
2160     {
2161 		macro_t *macro = hash_table_find (parser->defines, "__VERSION__");
2162 		if (macro) {
2163 			hash_table_remove (parser->defines, "__VERSION__");
2164 			ralloc_free (macro);
2165 		}
2166 		add_builtin_define (parser, "__VERSION__", (yyvsp[(2) - (3)].ival));
2167 
2168 		if ((yyvsp[(2) - (3)].ival) == 100)
2169 			add_builtin_define (parser, "GL_ES", 1);
2170 
2171 		/* Currently, all ES2 implementations support highp in the
2172 		 * fragment shader, so we always define this macro in ES2.
2173 		 * If we ever get a driver that doesn't support highp, we'll
2174 		 * need to add a flag to the gl_context and check that here.
2175 		 */
2176 		if ((yyvsp[(2) - (3)].ival) >= 130 || (yyvsp[(2) - (3)].ival) == 100)
2177 			add_builtin_define (parser, "GL_FRAGMENT_PRECISION_HIGH", 1);
2178 
2179 		ralloc_asprintf_rewrite_tail (&parser->output, &parser->output_length, "#version %" PRIiMAX, (yyvsp[(2) - (3)].ival));
2180 	}
2181     break;
2182 
2183   case 29:
2184 
2185 /* Line 1806 of yacc.c  */
2186 #line 361 "src/src/glsl/glcpp/glcpp-parse.y"
2187     {
2188 		if (strlen ((yyvsp[(1) - (1)].str)) >= 3 && strncmp ((yyvsp[(1) - (1)].str), "0x", 2) == 0) {
2189 			(yyval.ival) = strtoll ((yyvsp[(1) - (1)].str) + 2, NULL, 16);
2190 		} else if ((yyvsp[(1) - (1)].str)[0] == '0') {
2191 			(yyval.ival) = strtoll ((yyvsp[(1) - (1)].str), NULL, 8);
2192 		} else {
2193 			(yyval.ival) = strtoll ((yyvsp[(1) - (1)].str), NULL, 10);
2194 		}
2195 	}
2196     break;
2197 
2198   case 30:
2199 
2200 /* Line 1806 of yacc.c  */
2201 #line 370 "src/src/glsl/glcpp/glcpp-parse.y"
2202     {
2203 		(yyval.ival) = (yyvsp[(1) - (1)].ival);
2204 	}
2205     break;
2206 
2207   case 32:
2208 
2209 /* Line 1806 of yacc.c  */
2210 #line 376 "src/src/glsl/glcpp/glcpp-parse.y"
2211     {
2212 		(yyval.ival) = 0;
2213 	}
2214     break;
2215 
2216   case 33:
2217 
2218 /* Line 1806 of yacc.c  */
2219 #line 379 "src/src/glsl/glcpp/glcpp-parse.y"
2220     {
2221 		(yyval.ival) = (yyvsp[(1) - (3)].ival) || (yyvsp[(3) - (3)].ival);
2222 	}
2223     break;
2224 
2225   case 34:
2226 
2227 /* Line 1806 of yacc.c  */
2228 #line 382 "src/src/glsl/glcpp/glcpp-parse.y"
2229     {
2230 		(yyval.ival) = (yyvsp[(1) - (3)].ival) && (yyvsp[(3) - (3)].ival);
2231 	}
2232     break;
2233 
2234   case 35:
2235 
2236 /* Line 1806 of yacc.c  */
2237 #line 385 "src/src/glsl/glcpp/glcpp-parse.y"
2238     {
2239 		(yyval.ival) = (yyvsp[(1) - (3)].ival) | (yyvsp[(3) - (3)].ival);
2240 	}
2241     break;
2242 
2243   case 36:
2244 
2245 /* Line 1806 of yacc.c  */
2246 #line 388 "src/src/glsl/glcpp/glcpp-parse.y"
2247     {
2248 		(yyval.ival) = (yyvsp[(1) - (3)].ival) ^ (yyvsp[(3) - (3)].ival);
2249 	}
2250     break;
2251 
2252   case 37:
2253 
2254 /* Line 1806 of yacc.c  */
2255 #line 391 "src/src/glsl/glcpp/glcpp-parse.y"
2256     {
2257 		(yyval.ival) = (yyvsp[(1) - (3)].ival) & (yyvsp[(3) - (3)].ival);
2258 	}
2259     break;
2260 
2261   case 38:
2262 
2263 /* Line 1806 of yacc.c  */
2264 #line 394 "src/src/glsl/glcpp/glcpp-parse.y"
2265     {
2266 		(yyval.ival) = (yyvsp[(1) - (3)].ival) != (yyvsp[(3) - (3)].ival);
2267 	}
2268     break;
2269 
2270   case 39:
2271 
2272 /* Line 1806 of yacc.c  */
2273 #line 397 "src/src/glsl/glcpp/glcpp-parse.y"
2274     {
2275 		(yyval.ival) = (yyvsp[(1) - (3)].ival) == (yyvsp[(3) - (3)].ival);
2276 	}
2277     break;
2278 
2279   case 40:
2280 
2281 /* Line 1806 of yacc.c  */
2282 #line 400 "src/src/glsl/glcpp/glcpp-parse.y"
2283     {
2284 		(yyval.ival) = (yyvsp[(1) - (3)].ival) >= (yyvsp[(3) - (3)].ival);
2285 	}
2286     break;
2287 
2288   case 41:
2289 
2290 /* Line 1806 of yacc.c  */
2291 #line 403 "src/src/glsl/glcpp/glcpp-parse.y"
2292     {
2293 		(yyval.ival) = (yyvsp[(1) - (3)].ival) <= (yyvsp[(3) - (3)].ival);
2294 	}
2295     break;
2296 
2297   case 42:
2298 
2299 /* Line 1806 of yacc.c  */
2300 #line 406 "src/src/glsl/glcpp/glcpp-parse.y"
2301     {
2302 		(yyval.ival) = (yyvsp[(1) - (3)].ival) > (yyvsp[(3) - (3)].ival);
2303 	}
2304     break;
2305 
2306   case 43:
2307 
2308 /* Line 1806 of yacc.c  */
2309 #line 409 "src/src/glsl/glcpp/glcpp-parse.y"
2310     {
2311 		(yyval.ival) = (yyvsp[(1) - (3)].ival) < (yyvsp[(3) - (3)].ival);
2312 	}
2313     break;
2314 
2315   case 44:
2316 
2317 /* Line 1806 of yacc.c  */
2318 #line 412 "src/src/glsl/glcpp/glcpp-parse.y"
2319     {
2320 		(yyval.ival) = (yyvsp[(1) - (3)].ival) >> (yyvsp[(3) - (3)].ival);
2321 	}
2322     break;
2323 
2324   case 45:
2325 
2326 /* Line 1806 of yacc.c  */
2327 #line 415 "src/src/glsl/glcpp/glcpp-parse.y"
2328     {
2329 		(yyval.ival) = (yyvsp[(1) - (3)].ival) << (yyvsp[(3) - (3)].ival);
2330 	}
2331     break;
2332 
2333   case 46:
2334 
2335 /* Line 1806 of yacc.c  */
2336 #line 418 "src/src/glsl/glcpp/glcpp-parse.y"
2337     {
2338 		(yyval.ival) = (yyvsp[(1) - (3)].ival) - (yyvsp[(3) - (3)].ival);
2339 	}
2340     break;
2341 
2342   case 47:
2343 
2344 /* Line 1806 of yacc.c  */
2345 #line 421 "src/src/glsl/glcpp/glcpp-parse.y"
2346     {
2347 		(yyval.ival) = (yyvsp[(1) - (3)].ival) + (yyvsp[(3) - (3)].ival);
2348 	}
2349     break;
2350 
2351   case 48:
2352 
2353 /* Line 1806 of yacc.c  */
2354 #line 424 "src/src/glsl/glcpp/glcpp-parse.y"
2355     {
2356 		if ((yyvsp[(3) - (3)].ival) == 0) {
2357 			yyerror (& (yylsp[(1) - (3)]), parser,
2358 				 "zero modulus in preprocessor directive");
2359 		} else {
2360 			(yyval.ival) = (yyvsp[(1) - (3)].ival) % (yyvsp[(3) - (3)].ival);
2361 		}
2362 	}
2363     break;
2364 
2365   case 49:
2366 
2367 /* Line 1806 of yacc.c  */
2368 #line 432 "src/src/glsl/glcpp/glcpp-parse.y"
2369     {
2370 		if ((yyvsp[(3) - (3)].ival) == 0) {
2371 			yyerror (& (yylsp[(1) - (3)]), parser,
2372 				 "division by 0 in preprocessor directive");
2373 		} else {
2374 			(yyval.ival) = (yyvsp[(1) - (3)].ival) / (yyvsp[(3) - (3)].ival);
2375 		}
2376 	}
2377     break;
2378 
2379   case 50:
2380 
2381 /* Line 1806 of yacc.c  */
2382 #line 440 "src/src/glsl/glcpp/glcpp-parse.y"
2383     {
2384 		(yyval.ival) = (yyvsp[(1) - (3)].ival) * (yyvsp[(3) - (3)].ival);
2385 	}
2386     break;
2387 
2388   case 51:
2389 
2390 /* Line 1806 of yacc.c  */
2391 #line 443 "src/src/glsl/glcpp/glcpp-parse.y"
2392     {
2393 		(yyval.ival) = ! (yyvsp[(2) - (2)].ival);
2394 	}
2395     break;
2396 
2397   case 52:
2398 
2399 /* Line 1806 of yacc.c  */
2400 #line 446 "src/src/glsl/glcpp/glcpp-parse.y"
2401     {
2402 		(yyval.ival) = ~ (yyvsp[(2) - (2)].ival);
2403 	}
2404     break;
2405 
2406   case 53:
2407 
2408 /* Line 1806 of yacc.c  */
2409 #line 449 "src/src/glsl/glcpp/glcpp-parse.y"
2410     {
2411 		(yyval.ival) = - (yyvsp[(2) - (2)].ival);
2412 	}
2413     break;
2414 
2415   case 54:
2416 
2417 /* Line 1806 of yacc.c  */
2418 #line 452 "src/src/glsl/glcpp/glcpp-parse.y"
2419     {
2420 		(yyval.ival) = + (yyvsp[(2) - (2)].ival);
2421 	}
2422     break;
2423 
2424   case 55:
2425 
2426 /* Line 1806 of yacc.c  */
2427 #line 455 "src/src/glsl/glcpp/glcpp-parse.y"
2428     {
2429 		(yyval.ival) = (yyvsp[(2) - (3)].ival);
2430 	}
2431     break;
2432 
2433   case 56:
2434 
2435 /* Line 1806 of yacc.c  */
2436 #line 461 "src/src/glsl/glcpp/glcpp-parse.y"
2437     {
2438 		(yyval.string_list) = _string_list_create (parser);
2439 		_string_list_append_item ((yyval.string_list), (yyvsp[(1) - (1)].str));
2440 		ralloc_steal ((yyval.string_list), (yyvsp[(1) - (1)].str));
2441 	}
2442     break;
2443 
2444   case 57:
2445 
2446 /* Line 1806 of yacc.c  */
2447 #line 466 "src/src/glsl/glcpp/glcpp-parse.y"
2448     {
2449 		(yyval.string_list) = (yyvsp[(1) - (3)].string_list);
2450 		_string_list_append_item ((yyval.string_list), (yyvsp[(3) - (3)].str));
2451 		ralloc_steal ((yyval.string_list), (yyvsp[(3) - (3)].str));
2452 	}
2453     break;
2454 
2455   case 58:
2456 
2457 /* Line 1806 of yacc.c  */
2458 #line 474 "src/src/glsl/glcpp/glcpp-parse.y"
2459     { (yyval.token_list) = NULL; }
2460     break;
2461 
2462   case 60:
2463 
2464 /* Line 1806 of yacc.c  */
2465 #line 479 "src/src/glsl/glcpp/glcpp-parse.y"
2466     {
2467 		yyerror (& (yylsp[(1) - (2)]), parser, "Invalid tokens after #");
2468 	}
2469     break;
2470 
2471   case 61:
2472 
2473 /* Line 1806 of yacc.c  */
2474 #line 485 "src/src/glsl/glcpp/glcpp-parse.y"
2475     { (yyval.token_list) = NULL; }
2476     break;
2477 
2478   case 64:
2479 
2480 /* Line 1806 of yacc.c  */
2481 #line 491 "src/src/glsl/glcpp/glcpp-parse.y"
2482     {
2483 		glcpp_warning(&(yylsp[(1) - (1)]), parser, "extra tokens at end of directive");
2484 	}
2485     break;
2486 
2487   case 65:
2488 
2489 /* Line 1806 of yacc.c  */
2490 #line 498 "src/src/glsl/glcpp/glcpp-parse.y"
2491     {
2492 		int v = hash_table_find (parser->defines, (yyvsp[(2) - (2)].str)) ? 1 : 0;
2493 		(yyval.token) = _token_create_ival (parser, INTEGER, v);
2494 	}
2495     break;
2496 
2497   case 66:
2498 
2499 /* Line 1806 of yacc.c  */
2500 #line 502 "src/src/glsl/glcpp/glcpp-parse.y"
2501     {
2502 		int v = hash_table_find (parser->defines, (yyvsp[(3) - (4)].str)) ? 1 : 0;
2503 		(yyval.token) = _token_create_ival (parser, INTEGER, v);
2504 	}
2505     break;
2506 
2507   case 68:
2508 
2509 /* Line 1806 of yacc.c  */
2510 #line 511 "src/src/glsl/glcpp/glcpp-parse.y"
2511     {
2512 		(yyval.token_list) = _token_list_create (parser);
2513 		_token_list_append ((yyval.token_list), (yyvsp[(1) - (1)].token));
2514 	}
2515     break;
2516 
2517   case 69:
2518 
2519 /* Line 1806 of yacc.c  */
2520 #line 515 "src/src/glsl/glcpp/glcpp-parse.y"
2521     {
2522 		(yyval.token_list) = (yyvsp[(1) - (2)].token_list);
2523 		_token_list_append ((yyval.token_list), (yyvsp[(2) - (2)].token));
2524 	}
2525     break;
2526 
2527   case 70:
2528 
2529 /* Line 1806 of yacc.c  */
2530 #line 522 "src/src/glsl/glcpp/glcpp-parse.y"
2531     {
2532 		parser->space_tokens = 1;
2533 		(yyval.token_list) = _token_list_create (parser);
2534 		_token_list_append ((yyval.token_list), (yyvsp[(1) - (1)].token));
2535 	}
2536     break;
2537 
2538   case 71:
2539 
2540 /* Line 1806 of yacc.c  */
2541 #line 527 "src/src/glsl/glcpp/glcpp-parse.y"
2542     {
2543 		(yyval.token_list) = (yyvsp[(1) - (2)].token_list);
2544 		_token_list_append ((yyval.token_list), (yyvsp[(2) - (2)].token));
2545 	}
2546     break;
2547 
2548   case 72:
2549 
2550 /* Line 1806 of yacc.c  */
2551 #line 534 "src/src/glsl/glcpp/glcpp-parse.y"
2552     {
2553 		(yyval.token) = _token_create_str (parser, IDENTIFIER, (yyvsp[(1) - (1)].str));
2554 		(yyval.token)->location = yylloc;
2555 	}
2556     break;
2557 
2558   case 73:
2559 
2560 /* Line 1806 of yacc.c  */
2561 #line 538 "src/src/glsl/glcpp/glcpp-parse.y"
2562     {
2563 		(yyval.token) = _token_create_str (parser, INTEGER_STRING, (yyvsp[(1) - (1)].str));
2564 		(yyval.token)->location = yylloc;
2565 	}
2566     break;
2567 
2568   case 74:
2569 
2570 /* Line 1806 of yacc.c  */
2571 #line 542 "src/src/glsl/glcpp/glcpp-parse.y"
2572     {
2573 		(yyval.token) = _token_create_ival (parser, (yyvsp[(1) - (1)].ival), (yyvsp[(1) - (1)].ival));
2574 		(yyval.token)->location = yylloc;
2575 	}
2576     break;
2577 
2578   case 75:
2579 
2580 /* Line 1806 of yacc.c  */
2581 #line 546 "src/src/glsl/glcpp/glcpp-parse.y"
2582     {
2583 		(yyval.token) = _token_create_str (parser, OTHER, (yyvsp[(1) - (1)].str));
2584 		(yyval.token)->location = yylloc;
2585 	}
2586     break;
2587 
2588   case 76:
2589 
2590 /* Line 1806 of yacc.c  */
2591 #line 550 "src/src/glsl/glcpp/glcpp-parse.y"
2592     {
2593 		(yyval.token) = _token_create_ival (parser, SPACE, SPACE);
2594 		(yyval.token)->location = yylloc;
2595 	}
2596     break;
2597 
2598   case 77:
2599 
2600 /* Line 1806 of yacc.c  */
2601 #line 557 "src/src/glsl/glcpp/glcpp-parse.y"
2602     { (yyval.ival) = '['; }
2603     break;
2604 
2605   case 78:
2606 
2607 /* Line 1806 of yacc.c  */
2608 #line 558 "src/src/glsl/glcpp/glcpp-parse.y"
2609     { (yyval.ival) = ']'; }
2610     break;
2611 
2612   case 79:
2613 
2614 /* Line 1806 of yacc.c  */
2615 #line 559 "src/src/glsl/glcpp/glcpp-parse.y"
2616     { (yyval.ival) = '('; }
2617     break;
2618 
2619   case 80:
2620 
2621 /* Line 1806 of yacc.c  */
2622 #line 560 "src/src/glsl/glcpp/glcpp-parse.y"
2623     { (yyval.ival) = ')'; }
2624     break;
2625 
2626   case 81:
2627 
2628 /* Line 1806 of yacc.c  */
2629 #line 561 "src/src/glsl/glcpp/glcpp-parse.y"
2630     { (yyval.ival) = '{'; }
2631     break;
2632 
2633   case 82:
2634 
2635 /* Line 1806 of yacc.c  */
2636 #line 562 "src/src/glsl/glcpp/glcpp-parse.y"
2637     { (yyval.ival) = '}'; }
2638     break;
2639 
2640   case 83:
2641 
2642 /* Line 1806 of yacc.c  */
2643 #line 563 "src/src/glsl/glcpp/glcpp-parse.y"
2644     { (yyval.ival) = '.'; }
2645     break;
2646 
2647   case 84:
2648 
2649 /* Line 1806 of yacc.c  */
2650 #line 564 "src/src/glsl/glcpp/glcpp-parse.y"
2651     { (yyval.ival) = '&'; }
2652     break;
2653 
2654   case 85:
2655 
2656 /* Line 1806 of yacc.c  */
2657 #line 565 "src/src/glsl/glcpp/glcpp-parse.y"
2658     { (yyval.ival) = '*'; }
2659     break;
2660 
2661   case 86:
2662 
2663 /* Line 1806 of yacc.c  */
2664 #line 566 "src/src/glsl/glcpp/glcpp-parse.y"
2665     { (yyval.ival) = '+'; }
2666     break;
2667 
2668   case 87:
2669 
2670 /* Line 1806 of yacc.c  */
2671 #line 567 "src/src/glsl/glcpp/glcpp-parse.y"
2672     { (yyval.ival) = '-'; }
2673     break;
2674 
2675   case 88:
2676 
2677 /* Line 1806 of yacc.c  */
2678 #line 568 "src/src/glsl/glcpp/glcpp-parse.y"
2679     { (yyval.ival) = '~'; }
2680     break;
2681 
2682   case 89:
2683 
2684 /* Line 1806 of yacc.c  */
2685 #line 569 "src/src/glsl/glcpp/glcpp-parse.y"
2686     { (yyval.ival) = '!'; }
2687     break;
2688 
2689   case 90:
2690 
2691 /* Line 1806 of yacc.c  */
2692 #line 570 "src/src/glsl/glcpp/glcpp-parse.y"
2693     { (yyval.ival) = '/'; }
2694     break;
2695 
2696   case 91:
2697 
2698 /* Line 1806 of yacc.c  */
2699 #line 571 "src/src/glsl/glcpp/glcpp-parse.y"
2700     { (yyval.ival) = '%'; }
2701     break;
2702 
2703   case 92:
2704 
2705 /* Line 1806 of yacc.c  */
2706 #line 572 "src/src/glsl/glcpp/glcpp-parse.y"
2707     { (yyval.ival) = LEFT_SHIFT; }
2708     break;
2709 
2710   case 93:
2711 
2712 /* Line 1806 of yacc.c  */
2713 #line 573 "src/src/glsl/glcpp/glcpp-parse.y"
2714     { (yyval.ival) = RIGHT_SHIFT; }
2715     break;
2716 
2717   case 94:
2718 
2719 /* Line 1806 of yacc.c  */
2720 #line 574 "src/src/glsl/glcpp/glcpp-parse.y"
2721     { (yyval.ival) = '<'; }
2722     break;
2723 
2724   case 95:
2725 
2726 /* Line 1806 of yacc.c  */
2727 #line 575 "src/src/glsl/glcpp/glcpp-parse.y"
2728     { (yyval.ival) = '>'; }
2729     break;
2730 
2731   case 96:
2732 
2733 /* Line 1806 of yacc.c  */
2734 #line 576 "src/src/glsl/glcpp/glcpp-parse.y"
2735     { (yyval.ival) = LESS_OR_EQUAL; }
2736     break;
2737 
2738   case 97:
2739 
2740 /* Line 1806 of yacc.c  */
2741 #line 577 "src/src/glsl/glcpp/glcpp-parse.y"
2742     { (yyval.ival) = GREATER_OR_EQUAL; }
2743     break;
2744 
2745   case 98:
2746 
2747 /* Line 1806 of yacc.c  */
2748 #line 578 "src/src/glsl/glcpp/glcpp-parse.y"
2749     { (yyval.ival) = EQUAL; }
2750     break;
2751 
2752   case 99:
2753 
2754 /* Line 1806 of yacc.c  */
2755 #line 579 "src/src/glsl/glcpp/glcpp-parse.y"
2756     { (yyval.ival) = NOT_EQUAL; }
2757     break;
2758 
2759   case 100:
2760 
2761 /* Line 1806 of yacc.c  */
2762 #line 580 "src/src/glsl/glcpp/glcpp-parse.y"
2763     { (yyval.ival) = '^'; }
2764     break;
2765 
2766   case 101:
2767 
2768 /* Line 1806 of yacc.c  */
2769 #line 581 "src/src/glsl/glcpp/glcpp-parse.y"
2770     { (yyval.ival) = '|'; }
2771     break;
2772 
2773   case 102:
2774 
2775 /* Line 1806 of yacc.c  */
2776 #line 582 "src/src/glsl/glcpp/glcpp-parse.y"
2777     { (yyval.ival) = AND; }
2778     break;
2779 
2780   case 103:
2781 
2782 /* Line 1806 of yacc.c  */
2783 #line 583 "src/src/glsl/glcpp/glcpp-parse.y"
2784     { (yyval.ival) = OR; }
2785     break;
2786 
2787   case 104:
2788 
2789 /* Line 1806 of yacc.c  */
2790 #line 584 "src/src/glsl/glcpp/glcpp-parse.y"
2791     { (yyval.ival) = ';'; }
2792     break;
2793 
2794   case 105:
2795 
2796 /* Line 1806 of yacc.c  */
2797 #line 585 "src/src/glsl/glcpp/glcpp-parse.y"
2798     { (yyval.ival) = ','; }
2799     break;
2800 
2801   case 106:
2802 
2803 /* Line 1806 of yacc.c  */
2804 #line 586 "src/src/glsl/glcpp/glcpp-parse.y"
2805     { (yyval.ival) = '='; }
2806     break;
2807 
2808   case 107:
2809 
2810 /* Line 1806 of yacc.c  */
2811 #line 587 "src/src/glsl/glcpp/glcpp-parse.y"
2812     { (yyval.ival) = PASTE; }
2813     break;
2814 
2815 
2816 
2817 /* Line 1806 of yacc.c  */
2818 #line 2819 "src/chromium_gensrc/mesa/glcpp-parse.c"
2819       default: break;
2820     }
2821   /* User semantic actions sometimes alter yychar, and that requires
2822      that yytoken be updated with the new translation.  We take the
2823      approach of translating immediately before every use of yytoken.
2824      One alternative is translating here after every semantic action,
2825      but that translation would be missed if the semantic action invokes
2826      YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or
2827      if it invokes YYBACKUP.  In the case of YYABORT or YYACCEPT, an
2828      incorrect destructor might then be invoked immediately.  In the
2829      case of YYERROR or YYBACKUP, subsequent parser actions might lead
2830      to an incorrect destructor call or verbose syntax error message
2831      before the lookahead is translated.  */
2832   YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
2833 
2834   YYPOPSTACK (yylen);
2835   yylen = 0;
2836   YY_STACK_PRINT (yyss, yyssp);
2837 
2838   *++yyvsp = yyval;
2839   *++yylsp = yyloc;
2840 
2841   /* Now `shift' the result of the reduction.  Determine what state
2842      that goes to, based on the state we popped back to and the rule
2843      number reduced by.  */
2844 
2845   yyn = yyr1[yyn];
2846 
2847   yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
2848   if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
2849     yystate = yytable[yystate];
2850   else
2851     yystate = yydefgoto[yyn - YYNTOKENS];
2852 
2853   goto yynewstate;
2854 
2855 
2856 /*------------------------------------.
2857 | yyerrlab -- here on detecting error |
2858 `------------------------------------*/
2859 yyerrlab:
2860   /* Make sure we have latest lookahead translation.  See comments at
2861      user semantic actions for why this is necessary.  */
2862   yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE (yychar);
2863 
2864   /* If not already recovering from an error, report this error.  */
2865   if (!yyerrstatus)
2866     {
2867       ++yynerrs;
2868 #if ! YYERROR_VERBOSE
2869       yyerror (&yylloc, parser, YY_("syntax error"));
2870 #else
2871 # define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \
2872                                         yyssp, yytoken)
2873       {
2874         char const *yymsgp = YY_("syntax error");
2875         int yysyntax_error_status;
2876         yysyntax_error_status = YYSYNTAX_ERROR;
2877         if (yysyntax_error_status == 0)
2878           yymsgp = yymsg;
2879         else if (yysyntax_error_status == 1)
2880           {
2881             if (yymsg != yymsgbuf)
2882               YYSTACK_FREE (yymsg);
2883             yymsg = (char *) YYSTACK_ALLOC (yymsg_alloc);
2884             if (!yymsg)
2885               {
2886                 yymsg = yymsgbuf;
2887                 yymsg_alloc = sizeof yymsgbuf;
2888                 yysyntax_error_status = 2;
2889               }
2890             else
2891               {
2892                 yysyntax_error_status = YYSYNTAX_ERROR;
2893                 yymsgp = yymsg;
2894               }
2895           }
2896         yyerror (&yylloc, parser, yymsgp);
2897         if (yysyntax_error_status == 2)
2898           goto yyexhaustedlab;
2899       }
2900 # undef YYSYNTAX_ERROR
2901 #endif
2902     }
2903 
2904   yyerror_range[1] = yylloc;
2905 
2906   if (yyerrstatus == 3)
2907     {
2908       /* If just tried and failed to reuse lookahead token after an
2909 	 error, discard it.  */
2910 
2911       if (yychar <= YYEOF)
2912 	{
2913 	  /* Return failure if at end of input.  */
2914 	  if (yychar == YYEOF)
2915 	    YYABORT;
2916 	}
2917       else
2918 	{
2919 	  yydestruct ("Error: discarding",
2920 		      yytoken, &yylval, &yylloc, parser);
2921 	  yychar = YYEMPTY;
2922 	}
2923     }
2924 
2925   /* Else will try to reuse lookahead token after shifting the error
2926      token.  */
2927   goto yyerrlab1;
2928 
2929 
2930 /*---------------------------------------------------.
2931 | yyerrorlab -- error raised explicitly by YYERROR.  |
2932 `---------------------------------------------------*/
2933 yyerrorlab:
2934 
2935   /* Pacify compilers like GCC when the user code never invokes
2936      YYERROR and the label yyerrorlab therefore never appears in user
2937      code.  */
2938   if (/*CONSTCOND*/ 0)
2939      goto yyerrorlab;
2940 
2941   yyerror_range[1] = yylsp[1-yylen];
2942   /* Do not reclaim the symbols of the rule which action triggered
2943      this YYERROR.  */
2944   YYPOPSTACK (yylen);
2945   yylen = 0;
2946   YY_STACK_PRINT (yyss, yyssp);
2947   yystate = *yyssp;
2948   goto yyerrlab1;
2949 
2950 
2951 /*-------------------------------------------------------------.
2952 | yyerrlab1 -- common code for both syntax error and YYERROR.  |
2953 `-------------------------------------------------------------*/
2954 yyerrlab1:
2955   yyerrstatus = 3;	/* Each real token shifted decrements this.  */
2956 
2957   for (;;)
2958     {
2959       yyn = yypact[yystate];
2960       if (!yypact_value_is_default (yyn))
2961 	{
2962 	  yyn += YYTERROR;
2963 	  if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
2964 	    {
2965 	      yyn = yytable[yyn];
2966 	      if (0 < yyn)
2967 		break;
2968 	    }
2969 	}
2970 
2971       /* Pop the current state because it cannot handle the error token.  */
2972       if (yyssp == yyss)
2973 	YYABORT;
2974 
2975       yyerror_range[1] = *yylsp;
2976       yydestruct ("Error: popping",
2977 		  yystos[yystate], yyvsp, yylsp, parser);
2978       YYPOPSTACK (1);
2979       yystate = *yyssp;
2980       YY_STACK_PRINT (yyss, yyssp);
2981     }
2982 
2983   *++yyvsp = yylval;
2984 
2985   yyerror_range[2] = yylloc;
2986   /* Using YYLLOC is tempting, but would change the location of
2987      the lookahead.  YYLOC is available though.  */
2988   YYLLOC_DEFAULT (yyloc, yyerror_range, 2);
2989   *++yylsp = yyloc;
2990 
2991   /* Shift the error token.  */
2992   YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
2993 
2994   yystate = yyn;
2995   goto yynewstate;
2996 
2997 
2998 /*-------------------------------------.
2999 | yyacceptlab -- YYACCEPT comes here.  |
3000 `-------------------------------------*/
3001 yyacceptlab:
3002   yyresult = 0;
3003   goto yyreturn;
3004 
3005 /*-----------------------------------.
3006 | yyabortlab -- YYABORT comes here.  |
3007 `-----------------------------------*/
3008 yyabortlab:
3009   yyresult = 1;
3010   goto yyreturn;
3011 
3012 #if !defined(yyoverflow) || YYERROR_VERBOSE
3013 /*-------------------------------------------------.
3014 | yyexhaustedlab -- memory exhaustion comes here.  |
3015 `-------------------------------------------------*/
3016 yyexhaustedlab:
3017   yyerror (&yylloc, parser, YY_("memory exhausted"));
3018   yyresult = 2;
3019   /* Fall through.  */
3020 #endif
3021 
3022 yyreturn:
3023   if (yychar != YYEMPTY)
3024     {
3025       /* Make sure we have latest lookahead translation.  See comments at
3026          user semantic actions for why this is necessary.  */
3027       yytoken = YYTRANSLATE (yychar);
3028       yydestruct ("Cleanup: discarding lookahead",
3029                   yytoken, &yylval, &yylloc, parser);
3030     }
3031   /* Do not reclaim the symbols of the rule which action triggered
3032      this YYABORT or YYACCEPT.  */
3033   YYPOPSTACK (yylen);
3034   YY_STACK_PRINT (yyss, yyssp);
3035   while (yyssp != yyss)
3036     {
3037       yydestruct ("Cleanup: popping",
3038 		  yystos[*yyssp], yyvsp, yylsp, parser);
3039       YYPOPSTACK (1);
3040     }
3041 #ifndef yyoverflow
3042   if (yyss != yyssa)
3043     YYSTACK_FREE (yyss);
3044 #endif
3045 #if YYERROR_VERBOSE
3046   if (yymsg != yymsgbuf)
3047     YYSTACK_FREE (yymsg);
3048 #endif
3049   /* Make sure YYID is used.  */
3050   return YYID (yyresult);
3051 }
3052 
3053 
3054 
3055 /* Line 2067 of yacc.c  */
3056 #line 590 "src/src/glsl/glcpp/glcpp-parse.y"
3057 
3058 
3059 string_list_t *
_string_list_create(void * ctx)3060 _string_list_create (void *ctx)
3061 {
3062 	string_list_t *list;
3063 
3064 	list = ralloc (ctx, string_list_t);
3065 	list->head = NULL;
3066 	list->tail = NULL;
3067 
3068 	return list;
3069 }
3070 
3071 void
_string_list_append_item(string_list_t * list,const char * str)3072 _string_list_append_item (string_list_t *list, const char *str)
3073 {
3074 	string_node_t *node;
3075 
3076 	node = ralloc (list, string_node_t);
3077 	node->str = ralloc_strdup (node, str);
3078 
3079 	node->next = NULL;
3080 
3081 	if (list->head == NULL) {
3082 		list->head = node;
3083 	} else {
3084 		list->tail->next = node;
3085 	}
3086 
3087 	list->tail = node;
3088 }
3089 
3090 int
_string_list_contains(string_list_t * list,const char * member,int * index)3091 _string_list_contains (string_list_t *list, const char *member, int *index)
3092 {
3093 	string_node_t *node;
3094 	int i;
3095 
3096 	if (list == NULL)
3097 		return 0;
3098 
3099 	for (i = 0, node = list->head; node; i++, node = node->next) {
3100 		if (strcmp (node->str, member) == 0) {
3101 			if (index)
3102 				*index = i;
3103 			return 1;
3104 		}
3105 	}
3106 
3107 	return 0;
3108 }
3109 
3110 int
_string_list_length(string_list_t * list)3111 _string_list_length (string_list_t *list)
3112 {
3113 	int length = 0;
3114 	string_node_t *node;
3115 
3116 	if (list == NULL)
3117 		return 0;
3118 
3119 	for (node = list->head; node; node = node->next)
3120 		length++;
3121 
3122 	return length;
3123 }
3124 
3125 int
_string_list_equal(string_list_t * a,string_list_t * b)3126 _string_list_equal (string_list_t *a, string_list_t *b)
3127 {
3128 	string_node_t *node_a, *node_b;
3129 
3130 	if (a == NULL && b == NULL)
3131 		return 1;
3132 
3133 	if (a == NULL || b == NULL)
3134 		return 0;
3135 
3136 	for (node_a = a->head, node_b = b->head;
3137 	     node_a && node_b;
3138 	     node_a = node_a->next, node_b = node_b->next)
3139 	{
3140 		if (strcmp (node_a->str, node_b->str))
3141 			return 0;
3142 	}
3143 
3144 	/* Catch the case of lists being different lengths, (which
3145 	 * would cause the loop above to terminate after the shorter
3146 	 * list). */
3147 	return node_a == node_b;
3148 }
3149 
3150 argument_list_t *
_argument_list_create(void * ctx)3151 _argument_list_create (void *ctx)
3152 {
3153 	argument_list_t *list;
3154 
3155 	list = ralloc (ctx, argument_list_t);
3156 	list->head = NULL;
3157 	list->tail = NULL;
3158 
3159 	return list;
3160 }
3161 
3162 void
_argument_list_append(argument_list_t * list,token_list_t * argument)3163 _argument_list_append (argument_list_t *list, token_list_t *argument)
3164 {
3165 	argument_node_t *node;
3166 
3167 	node = ralloc (list, argument_node_t);
3168 	node->argument = argument;
3169 
3170 	node->next = NULL;
3171 
3172 	if (list->head == NULL) {
3173 		list->head = node;
3174 	} else {
3175 		list->tail->next = node;
3176 	}
3177 
3178 	list->tail = node;
3179 }
3180 
3181 int
_argument_list_length(argument_list_t * list)3182 _argument_list_length (argument_list_t *list)
3183 {
3184 	int length = 0;
3185 	argument_node_t *node;
3186 
3187 	if (list == NULL)
3188 		return 0;
3189 
3190 	for (node = list->head; node; node = node->next)
3191 		length++;
3192 
3193 	return length;
3194 }
3195 
3196 token_list_t *
_argument_list_member_at(argument_list_t * list,int index)3197 _argument_list_member_at (argument_list_t *list, int index)
3198 {
3199 	argument_node_t *node;
3200 	int i;
3201 
3202 	if (list == NULL)
3203 		return NULL;
3204 
3205 	node = list->head;
3206 	for (i = 0; i < index; i++) {
3207 		node = node->next;
3208 		if (node == NULL)
3209 			break;
3210 	}
3211 
3212 	if (node)
3213 		return node->argument;
3214 
3215 	return NULL;
3216 }
3217 
3218 /* Note: This function ralloc_steal()s the str pointer. */
3219 token_t *
_token_create_str(void * ctx,int type,char * str)3220 _token_create_str (void *ctx, int type, char *str)
3221 {
3222 	token_t *token;
3223 
3224 	token = ralloc (ctx, token_t);
3225 	token->type = type;
3226 	token->value.str = str;
3227 
3228 	ralloc_steal (token, str);
3229 
3230 	return token;
3231 }
3232 
3233 token_t *
_token_create_ival(void * ctx,int type,int ival)3234 _token_create_ival (void *ctx, int type, int ival)
3235 {
3236 	token_t *token;
3237 
3238 	token = ralloc (ctx, token_t);
3239 	token->type = type;
3240 	token->value.ival = ival;
3241 
3242 	return token;
3243 }
3244 
3245 token_list_t *
_token_list_create(void * ctx)3246 _token_list_create (void *ctx)
3247 {
3248 	token_list_t *list;
3249 
3250 	list = ralloc (ctx, token_list_t);
3251 	list->head = NULL;
3252 	list->tail = NULL;
3253 	list->non_space_tail = NULL;
3254 
3255 	return list;
3256 }
3257 
3258 void
_token_list_append(token_list_t * list,token_t * token)3259 _token_list_append (token_list_t *list, token_t *token)
3260 {
3261 	token_node_t *node;
3262 
3263 	node = ralloc (list, token_node_t);
3264 	node->token = token;
3265 	node->next = NULL;
3266 
3267 	if (list->head == NULL) {
3268 		list->head = node;
3269 	} else {
3270 		list->tail->next = node;
3271 	}
3272 
3273 	list->tail = node;
3274 	if (token->type != SPACE)
3275 		list->non_space_tail = node;
3276 }
3277 
3278 void
_token_list_append_list(token_list_t * list,token_list_t * tail)3279 _token_list_append_list (token_list_t *list, token_list_t *tail)
3280 {
3281 	if (tail == NULL || tail->head == NULL)
3282 		return;
3283 
3284 	if (list->head == NULL) {
3285 		list->head = tail->head;
3286 	} else {
3287 		list->tail->next = tail->head;
3288 	}
3289 
3290 	list->tail = tail->tail;
3291 	list->non_space_tail = tail->non_space_tail;
3292 }
3293 
3294 static token_list_t *
_token_list_copy(void * ctx,token_list_t * other)3295 _token_list_copy (void *ctx, token_list_t *other)
3296 {
3297 	token_list_t *copy;
3298 	token_node_t *node;
3299 
3300 	if (other == NULL)
3301 		return NULL;
3302 
3303 	copy = _token_list_create (ctx);
3304 	for (node = other->head; node; node = node->next) {
3305 		token_t *new_token = ralloc (copy, token_t);
3306 		*new_token = *node->token;
3307 		_token_list_append (copy, new_token);
3308 	}
3309 
3310 	return copy;
3311 }
3312 
3313 static void
_token_list_trim_trailing_space(token_list_t * list)3314 _token_list_trim_trailing_space (token_list_t *list)
3315 {
3316 	token_node_t *tail, *next;
3317 
3318 	if (list->non_space_tail) {
3319 		tail = list->non_space_tail->next;
3320 		list->non_space_tail->next = NULL;
3321 		list->tail = list->non_space_tail;
3322 
3323 		while (tail) {
3324 			next = tail->next;
3325 			ralloc_free (tail);
3326 			tail = next;
3327 		}
3328 	}
3329 }
3330 
3331 static int
_token_list_is_empty_ignoring_space(token_list_t * l)3332 _token_list_is_empty_ignoring_space (token_list_t *l)
3333 {
3334 	token_node_t *n;
3335 
3336 	if (l == NULL)
3337 		return 1;
3338 
3339 	n = l->head;
3340 	while (n != NULL && n->token->type == SPACE)
3341 		n = n->next;
3342 
3343 	return n == NULL;
3344 }
3345 
3346 int
_token_list_equal_ignoring_space(token_list_t * a,token_list_t * b)3347 _token_list_equal_ignoring_space (token_list_t *a, token_list_t *b)
3348 {
3349 	token_node_t *node_a, *node_b;
3350 
3351 	if (a == NULL || b == NULL) {
3352 		int a_empty = _token_list_is_empty_ignoring_space(a);
3353 		int b_empty = _token_list_is_empty_ignoring_space(b);
3354 		return a_empty == b_empty;
3355 	}
3356 
3357 	node_a = a->head;
3358 	node_b = b->head;
3359 
3360 	while (1)
3361 	{
3362 		if (node_a == NULL && node_b == NULL)
3363 			break;
3364 
3365 		if (node_a == NULL || node_b == NULL)
3366 			return 0;
3367 
3368 		if (node_a->token->type == SPACE) {
3369 			node_a = node_a->next;
3370 			continue;
3371 		}
3372 
3373 		if (node_b->token->type == SPACE) {
3374 			node_b = node_b->next;
3375 			continue;
3376 		}
3377 
3378 		if (node_a->token->type != node_b->token->type)
3379 			return 0;
3380 
3381 		switch (node_a->token->type) {
3382 		case INTEGER:
3383 			if (node_a->token->value.ival !=
3384 			    node_b->token->value.ival)
3385 			{
3386 				return 0;
3387 			}
3388 			break;
3389 		case IDENTIFIER:
3390 		case INTEGER_STRING:
3391 		case OTHER:
3392 			if (strcmp (node_a->token->value.str,
3393 				    node_b->token->value.str))
3394 			{
3395 				return 0;
3396 			}
3397 			break;
3398 		}
3399 
3400 		node_a = node_a->next;
3401 		node_b = node_b->next;
3402 	}
3403 
3404 	return 1;
3405 }
3406 
3407 static void
_token_print(char ** out,size_t * len,token_t * token)3408 _token_print (char **out, size_t *len, token_t *token)
3409 {
3410 	if (token->type < 256) {
3411 		ralloc_asprintf_rewrite_tail (out, len, "%c", token->type);
3412 		return;
3413 	}
3414 
3415 	switch (token->type) {
3416 	case INTEGER:
3417 		ralloc_asprintf_rewrite_tail (out, len, "%" PRIiMAX, token->value.ival);
3418 		break;
3419 	case IDENTIFIER:
3420 	case INTEGER_STRING:
3421 	case OTHER:
3422 		ralloc_asprintf_rewrite_tail (out, len, "%s", token->value.str);
3423 		break;
3424 	case SPACE:
3425 		ralloc_asprintf_rewrite_tail (out, len, " ");
3426 		break;
3427 	case LEFT_SHIFT:
3428 		ralloc_asprintf_rewrite_tail (out, len, "<<");
3429 		break;
3430 	case RIGHT_SHIFT:
3431 		ralloc_asprintf_rewrite_tail (out, len, ">>");
3432 		break;
3433 	case LESS_OR_EQUAL:
3434 		ralloc_asprintf_rewrite_tail (out, len, "<=");
3435 		break;
3436 	case GREATER_OR_EQUAL:
3437 		ralloc_asprintf_rewrite_tail (out, len, ">=");
3438 		break;
3439 	case EQUAL:
3440 		ralloc_asprintf_rewrite_tail (out, len, "==");
3441 		break;
3442 	case NOT_EQUAL:
3443 		ralloc_asprintf_rewrite_tail (out, len, "!=");
3444 		break;
3445 	case AND:
3446 		ralloc_asprintf_rewrite_tail (out, len, "&&");
3447 		break;
3448 	case OR:
3449 		ralloc_asprintf_rewrite_tail (out, len, "||");
3450 		break;
3451 	case PASTE:
3452 		ralloc_asprintf_rewrite_tail (out, len, "##");
3453 		break;
3454 	case COMMA_FINAL:
3455 		ralloc_asprintf_rewrite_tail (out, len, ",");
3456 		break;
3457 	case PLACEHOLDER:
3458 		/* Nothing to print. */
3459 		break;
3460 	default:
3461 		assert(!"Error: Don't know how to print token.");
3462 		break;
3463 	}
3464 }
3465 
3466 /* Return a new token (ralloc()ed off of 'token') formed by pasting
3467  * 'token' and 'other'. Note that this function may return 'token' or
3468  * 'other' directly rather than allocating anything new.
3469  *
3470  * Caution: Only very cursory error-checking is performed to see if
3471  * the final result is a valid single token. */
3472 static token_t *
_token_paste(glcpp_parser_t * parser,token_t * token,token_t * other)3473 _token_paste (glcpp_parser_t *parser, token_t *token, token_t *other)
3474 {
3475 	token_t *combined = NULL;
3476 
3477 	/* Pasting a placeholder onto anything makes no change. */
3478 	if (other->type == PLACEHOLDER)
3479 		return token;
3480 
3481 	/* When 'token' is a placeholder, just return 'other'. */
3482 	if (token->type == PLACEHOLDER)
3483 		return other;
3484 
3485 	/* A very few single-character punctuators can be combined
3486 	 * with another to form a multi-character punctuator. */
3487 	switch (token->type) {
3488 	case '<':
3489 		if (other->type == '<')
3490 			combined = _token_create_ival (token, LEFT_SHIFT, LEFT_SHIFT);
3491 		else if (other->type == '=')
3492 			combined = _token_create_ival (token, LESS_OR_EQUAL, LESS_OR_EQUAL);
3493 		break;
3494 	case '>':
3495 		if (other->type == '>')
3496 			combined = _token_create_ival (token, RIGHT_SHIFT, RIGHT_SHIFT);
3497 		else if (other->type == '=')
3498 			combined = _token_create_ival (token, GREATER_OR_EQUAL, GREATER_OR_EQUAL);
3499 		break;
3500 	case '=':
3501 		if (other->type == '=')
3502 			combined = _token_create_ival (token, EQUAL, EQUAL);
3503 		break;
3504 	case '!':
3505 		if (other->type == '=')
3506 			combined = _token_create_ival (token, NOT_EQUAL, NOT_EQUAL);
3507 		break;
3508 	case '&':
3509 		if (other->type == '&')
3510 			combined = _token_create_ival (token, AND, AND);
3511 		break;
3512 	case '|':
3513 		if (other->type == '|')
3514 			combined = _token_create_ival (token, OR, OR);
3515 		break;
3516 	}
3517 
3518 	if (combined != NULL) {
3519 		/* Inherit the location from the first token */
3520 		combined->location = token->location;
3521 		return combined;
3522 	}
3523 
3524 	/* Two string-valued tokens can usually just be mashed
3525 	 * together.
3526 	 *
3527 	 * XXX: This isn't actually legitimate. Several things here
3528 	 * should result in a diagnostic since the result cannot be a
3529 	 * valid, single pre-processing token. For example, pasting
3530 	 * "123" and "abc" is not legal, but we don't catch that
3531 	 * here. */
3532 	if ((token->type == IDENTIFIER || token->type == OTHER || token->type == INTEGER_STRING) &&
3533 	    (other->type == IDENTIFIER || other->type == OTHER || other->type == INTEGER_STRING))
3534 	{
3535 		char *str;
3536 
3537 		str = ralloc_asprintf (token, "%s%s", token->value.str,
3538 				       other->value.str);
3539 		combined = _token_create_str (token, token->type, str);
3540 		combined->location = token->location;
3541 		return combined;
3542 	}
3543 
3544 	glcpp_error (&token->location, parser, "");
3545 	ralloc_asprintf_rewrite_tail (&parser->info_log, &parser->info_log_length, "Pasting \"");
3546 	_token_print (&parser->info_log, &parser->info_log_length, token);
3547 	ralloc_asprintf_rewrite_tail (&parser->info_log, &parser->info_log_length, "\" and \"");
3548 	_token_print (&parser->info_log, &parser->info_log_length, other);
3549 	ralloc_asprintf_rewrite_tail (&parser->info_log, &parser->info_log_length, "\" does not give a valid preprocessing token.\n");
3550 
3551 	return token;
3552 }
3553 
3554 static void
_token_list_print(glcpp_parser_t * parser,token_list_t * list)3555 _token_list_print (glcpp_parser_t *parser, token_list_t *list)
3556 {
3557 	token_node_t *node;
3558 
3559 	if (list == NULL)
3560 		return;
3561 
3562 	for (node = list->head; node; node = node->next)
3563 		_token_print (&parser->output, &parser->output_length, node->token);
3564 }
3565 
3566 void
yyerror(YYLTYPE * locp,glcpp_parser_t * parser,const char * error)3567 yyerror (YYLTYPE *locp, glcpp_parser_t *parser, const char *error)
3568 {
3569 	glcpp_error(locp, parser, "%s", error);
3570 }
3571 
add_builtin_define(glcpp_parser_t * parser,const char * name,int value)3572 static void add_builtin_define(glcpp_parser_t *parser,
3573 			       const char *name, int value)
3574 {
3575    token_t *tok;
3576    token_list_t *list;
3577 
3578    tok = _token_create_ival (parser, INTEGER, value);
3579 
3580    list = _token_list_create(parser);
3581    _token_list_append(list, tok);
3582    _define_object_macro(parser, NULL, name, list);
3583 }
3584 
3585 glcpp_parser_t *
glcpp_parser_create(const struct gl_extensions * extensions,int api)3586 glcpp_parser_create (const struct gl_extensions *extensions, int api)
3587 {
3588 	glcpp_parser_t *parser;
3589 	int language_version;
3590 
3591 	parser = ralloc (NULL, glcpp_parser_t);
3592 
3593 	glcpp_lex_init_extra (parser, &parser->scanner);
3594 	parser->defines = hash_table_ctor (32, hash_table_string_hash,
3595 					   hash_table_string_compare);
3596 	parser->active = NULL;
3597 	parser->lexing_if = 0;
3598 	parser->space_tokens = 1;
3599 	parser->newline_as_space = 0;
3600 	parser->in_control_line = 0;
3601 	parser->paren_count = 0;
3602 
3603 	parser->skip_stack = NULL;
3604 
3605 	parser->lex_from_list = NULL;
3606 	parser->lex_from_node = NULL;
3607 
3608 	parser->output = ralloc_strdup(parser, "");
3609 	parser->output_length = 0;
3610 	parser->info_log = ralloc_strdup(parser, "");
3611 	parser->info_log_length = 0;
3612 	parser->error = 0;
3613 
3614 	parser->has_new_line_number = 0;
3615 	parser->new_line_number = 1;
3616 	parser->has_new_source_number = 0;
3617 	parser->new_source_number = 0;
3618 
3619 	/* Add pre-defined macros. */
3620 	add_builtin_define(parser, "GL_ARB_draw_buffers", 1);
3621 	add_builtin_define(parser, "GL_ARB_texture_rectangle", 1);
3622 
3623 	if (api == API_OPENGLES2)
3624 		add_builtin_define(parser, "GL_ES", 1);
3625 
3626 	if (extensions != NULL) {
3627 	   if (extensions->EXT_texture_array) {
3628 	      add_builtin_define(parser, "GL_EXT_texture_array", 1);
3629 	   }
3630 
3631 	   if (extensions->ARB_fragment_coord_conventions)
3632 	      add_builtin_define(parser, "GL_ARB_fragment_coord_conventions",
3633 				 1);
3634 
3635 	   if (extensions->ARB_explicit_attrib_location)
3636 	      add_builtin_define(parser, "GL_ARB_explicit_attrib_location", 1);
3637 
3638 	   if (extensions->ARB_shader_texture_lod)
3639 	      add_builtin_define(parser, "GL_ARB_shader_texture_lod", 1);
3640 
3641 	   if (extensions->ARB_draw_instanced)
3642 	      add_builtin_define(parser, "GL_ARB_draw_instanced", 1);
3643 
3644 	   if (extensions->ARB_conservative_depth) {
3645 	      add_builtin_define(parser, "GL_AMD_conservative_depth", 1);
3646 	      add_builtin_define(parser, "GL_ARB_conservative_depth", 1);
3647 	   }
3648 
3649 	   if (extensions->OES_EGL_image_external)
3650 	      add_builtin_define(parser, "GL_OES_EGL_image_external", 1);
3651 
3652 	   if (extensions->ARB_shader_bit_encoding)
3653 	      add_builtin_define(parser, "GL_ARB_shader_bit_encoding", 1);
3654 
3655 	   if (extensions->ARB_uniform_buffer_object)
3656 	      add_builtin_define(parser, "GL_ARB_uniform_buffer_object", 1);
3657 	}
3658 
3659 	language_version = 110;
3660 	add_builtin_define(parser, "__VERSION__", language_version);
3661 
3662 	return parser;
3663 }
3664 
3665 void
glcpp_parser_destroy(glcpp_parser_t * parser)3666 glcpp_parser_destroy (glcpp_parser_t *parser)
3667 {
3668 	glcpp_lex_destroy (parser->scanner);
3669 	hash_table_dtor (parser->defines);
3670 	ralloc_free (parser);
3671 }
3672 
3673 typedef enum function_status
3674 {
3675 	FUNCTION_STATUS_SUCCESS,
3676 	FUNCTION_NOT_A_FUNCTION,
3677 	FUNCTION_UNBALANCED_PARENTHESES
3678 } function_status_t;
3679 
3680 /* Find a set of function-like macro arguments by looking for a
3681  * balanced set of parentheses.
3682  *
3683  * When called, 'node' should be the opening-parenthesis token, (or
3684  * perhaps preceeding SPACE tokens). Upon successful return *last will
3685  * be the last consumed node, (corresponding to the closing right
3686  * parenthesis).
3687  *
3688  * Return values:
3689  *
3690  *   FUNCTION_STATUS_SUCCESS:
3691  *
3692  *	Successfully parsed a set of function arguments.
3693  *
3694  *   FUNCTION_NOT_A_FUNCTION:
3695  *
3696  *	Macro name not followed by a '('. This is not an error, but
3697  *	simply that the macro name should be treated as a non-macro.
3698  *
3699  *   FUNCTION_UNBALANCED_PARENTHESES
3700  *
3701  *	Macro name is not followed by a balanced set of parentheses.
3702  */
3703 static function_status_t
_arguments_parse(argument_list_t * arguments,token_node_t * node,token_node_t ** last)3704 _arguments_parse (argument_list_t *arguments,
3705 		  token_node_t *node,
3706 		  token_node_t **last)
3707 {
3708 	token_list_t *argument;
3709 	int paren_count;
3710 
3711 	node = node->next;
3712 
3713 	/* Ignore whitespace before first parenthesis. */
3714 	while (node && node->token->type == SPACE)
3715 		node = node->next;
3716 
3717 	if (node == NULL || node->token->type != '(')
3718 		return FUNCTION_NOT_A_FUNCTION;
3719 
3720 	node = node->next;
3721 
3722 	argument = _token_list_create (arguments);
3723 	_argument_list_append (arguments, argument);
3724 
3725 	for (paren_count = 1; node; node = node->next) {
3726 		if (node->token->type == '(')
3727 		{
3728 			paren_count++;
3729 		}
3730 		else if (node->token->type == ')')
3731 		{
3732 			paren_count--;
3733 			if (paren_count == 0)
3734 				break;
3735 		}
3736 
3737 		if (node->token->type == ',' &&
3738 			 paren_count == 1)
3739 		{
3740 			_token_list_trim_trailing_space (argument);
3741 			argument = _token_list_create (arguments);
3742 			_argument_list_append (arguments, argument);
3743 		}
3744 		else {
3745 			if (argument->head == NULL) {
3746 				/* Don't treat initial whitespace as
3747 				 * part of the arguement. */
3748 				if (node->token->type == SPACE)
3749 					continue;
3750 			}
3751 			_token_list_append (argument, node->token);
3752 		}
3753 	}
3754 
3755 	if (paren_count)
3756 		return FUNCTION_UNBALANCED_PARENTHESES;
3757 
3758 	*last = node;
3759 
3760 	return FUNCTION_STATUS_SUCCESS;
3761 }
3762 
3763 static token_list_t *
_token_list_create_with_one_space(void * ctx)3764 _token_list_create_with_one_space (void *ctx)
3765 {
3766 	token_list_t *list;
3767 	token_t *space;
3768 
3769 	list = _token_list_create (ctx);
3770 	space = _token_create_ival (list, SPACE, SPACE);
3771 	_token_list_append (list, space);
3772 
3773 	return list;
3774 }
3775 
3776 /* Perform macro expansion on 'list', placing the resulting tokens
3777  * into a new list which is initialized with a first token of type
3778  * 'head_token_type'. Then begin lexing from the resulting list,
3779  * (return to the current lexing source when this list is exhausted).
3780  */
3781 static void
_glcpp_parser_expand_and_lex_from(glcpp_parser_t * parser,int head_token_type,token_list_t * list)3782 _glcpp_parser_expand_and_lex_from (glcpp_parser_t *parser,
3783 				   int head_token_type,
3784 				   token_list_t *list)
3785 {
3786 	token_list_t *expanded;
3787 	token_t *token;
3788 
3789 	expanded = _token_list_create (parser);
3790 	token = _token_create_ival (parser, head_token_type, head_token_type);
3791 	_token_list_append (expanded, token);
3792 	_glcpp_parser_expand_token_list (parser, list);
3793 	_token_list_append_list (expanded, list);
3794 	glcpp_parser_lex_from (parser, expanded);
3795 }
3796 
3797 static void
_glcpp_parser_apply_pastes(glcpp_parser_t * parser,token_list_t * list)3798 _glcpp_parser_apply_pastes (glcpp_parser_t *parser, token_list_t *list)
3799 {
3800 	token_node_t *node;
3801 
3802 	node = list->head;
3803 	while (node)
3804 	{
3805 		token_node_t *next_non_space;
3806 
3807 		/* Look ahead for a PASTE token, skipping space. */
3808 		next_non_space = node->next;
3809 		while (next_non_space && next_non_space->token->type == SPACE)
3810 			next_non_space = next_non_space->next;
3811 
3812 		if (next_non_space == NULL)
3813 			break;
3814 
3815 		if (next_non_space->token->type != PASTE) {
3816 			node = next_non_space;
3817 			continue;
3818 		}
3819 
3820 		/* Now find the next non-space token after the PASTE. */
3821 		next_non_space = next_non_space->next;
3822 		while (next_non_space && next_non_space->token->type == SPACE)
3823 			next_non_space = next_non_space->next;
3824 
3825 		if (next_non_space == NULL) {
3826 			yyerror (&node->token->location, parser, "'##' cannot appear at either end of a macro expansion\n");
3827 			return;
3828 		}
3829 
3830 		node->token = _token_paste (parser, node->token, next_non_space->token);
3831 		node->next = next_non_space->next;
3832 		if (next_non_space == list->tail)
3833 			list->tail = node;
3834 	}
3835 
3836 	list->non_space_tail = list->tail;
3837 }
3838 
3839 /* This is a helper function that's essentially part of the
3840  * implementation of _glcpp_parser_expand_node. It shouldn't be called
3841  * except for by that function.
3842  *
3843  * Returns NULL if node is a simple token with no expansion, (that is,
3844  * although 'node' corresponds to an identifier defined as a
3845  * function-like macro, it is not followed with a parenthesized
3846  * argument list).
3847  *
3848  * Compute the complete expansion of node (which is a function-like
3849  * macro) and subsequent nodes which are arguments.
3850  *
3851  * Returns the token list that results from the expansion and sets
3852  * *last to the last node in the list that was consumed by the
3853  * expansion. Specifically, *last will be set as follows: as the
3854  * token of the closing right parenthesis.
3855  */
3856 static token_list_t *
_glcpp_parser_expand_function(glcpp_parser_t * parser,token_node_t * node,token_node_t ** last)3857 _glcpp_parser_expand_function (glcpp_parser_t *parser,
3858 			       token_node_t *node,
3859 			       token_node_t **last)
3860 
3861 {
3862 	macro_t *macro;
3863 	const char *identifier;
3864 	argument_list_t *arguments;
3865 	function_status_t status;
3866 	token_list_t *substituted;
3867 	int parameter_index;
3868 
3869 	identifier = node->token->value.str;
3870 
3871 	macro = hash_table_find (parser->defines, identifier);
3872 
3873 	assert (macro->is_function);
3874 
3875 	arguments = _argument_list_create (parser);
3876 	status = _arguments_parse (arguments, node, last);
3877 
3878 	switch (status) {
3879 	case FUNCTION_STATUS_SUCCESS:
3880 		break;
3881 	case FUNCTION_NOT_A_FUNCTION:
3882 		return NULL;
3883 	case FUNCTION_UNBALANCED_PARENTHESES:
3884 		glcpp_error (&node->token->location, parser, "Macro %s call has unbalanced parentheses\n", identifier);
3885 		return NULL;
3886 	}
3887 
3888 	/* Replace a macro defined as empty with a SPACE token. */
3889 	if (macro->replacements == NULL) {
3890 		ralloc_free (arguments);
3891 		return _token_list_create_with_one_space (parser);
3892 	}
3893 
3894 	if (! ((_argument_list_length (arguments) ==
3895 		_string_list_length (macro->parameters)) ||
3896 	       (_string_list_length (macro->parameters) == 0 &&
3897 		_argument_list_length (arguments) == 1 &&
3898 		arguments->head->argument->head == NULL)))
3899 	{
3900 		glcpp_error (&node->token->location, parser,
3901 			      "Error: macro %s invoked with %d arguments (expected %d)\n",
3902 			      identifier,
3903 			      _argument_list_length (arguments),
3904 			      _string_list_length (macro->parameters));
3905 		return NULL;
3906 	}
3907 
3908 	/* Perform argument substitution on the replacement list. */
3909 	substituted = _token_list_create (arguments);
3910 
3911 	for (node = macro->replacements->head; node; node = node->next)
3912 	{
3913 		if (node->token->type == IDENTIFIER &&
3914 		    _string_list_contains (macro->parameters,
3915 					   node->token->value.str,
3916 					   &parameter_index))
3917 		{
3918 			token_list_t *argument;
3919 			argument = _argument_list_member_at (arguments,
3920 							     parameter_index);
3921 			/* Before substituting, we expand the argument
3922 			 * tokens, or append a placeholder token for
3923 			 * an empty argument. */
3924 			if (argument->head) {
3925 				token_list_t *expanded_argument;
3926 				expanded_argument = _token_list_copy (parser,
3927 								      argument);
3928 				_glcpp_parser_expand_token_list (parser,
3929 								 expanded_argument);
3930 				_token_list_append_list (substituted,
3931 							 expanded_argument);
3932 			} else {
3933 				token_t *new_token;
3934 
3935 				new_token = _token_create_ival (substituted,
3936 								PLACEHOLDER,
3937 								PLACEHOLDER);
3938 				_token_list_append (substituted, new_token);
3939 			}
3940 		} else {
3941 			_token_list_append (substituted, node->token);
3942 		}
3943 	}
3944 
3945 	/* After argument substitution, and before further expansion
3946 	 * below, implement token pasting. */
3947 
3948 	_token_list_trim_trailing_space (substituted);
3949 
3950 	_glcpp_parser_apply_pastes (parser, substituted);
3951 
3952 	return substituted;
3953 }
3954 
3955 /* Compute the complete expansion of node, (and subsequent nodes after
3956  * 'node' in the case that 'node' is a function-like macro and
3957  * subsequent nodes are arguments).
3958  *
3959  * Returns NULL if node is a simple token with no expansion.
3960  *
3961  * Otherwise, returns the token list that results from the expansion
3962  * and sets *last to the last node in the list that was consumed by
3963  * the expansion. Specifically, *last will be set as follows:
3964  *
3965  *	As 'node' in the case of object-like macro expansion.
3966  *
3967  *	As the token of the closing right parenthesis in the case of
3968  *	function-like macro expansion.
3969  */
3970 static token_list_t *
_glcpp_parser_expand_node(glcpp_parser_t * parser,token_node_t * node,token_node_t ** last)3971 _glcpp_parser_expand_node (glcpp_parser_t *parser,
3972 			   token_node_t *node,
3973 			   token_node_t **last)
3974 {
3975 	token_t *token = node->token;
3976 	const char *identifier;
3977 	macro_t *macro;
3978 
3979 	/* We only expand identifiers */
3980 	if (token->type != IDENTIFIER) {
3981 		/* We change any COMMA into a COMMA_FINAL to prevent
3982 		 * it being mistaken for an argument separator
3983 		 * later. */
3984 		if (token->type == ',') {
3985 			token->type = COMMA_FINAL;
3986 			token->value.ival = COMMA_FINAL;
3987 		}
3988 
3989 		return NULL;
3990 	}
3991 
3992 	/* Look up this identifier in the hash table. */
3993 	identifier = token->value.str;
3994 	macro = hash_table_find (parser->defines, identifier);
3995 
3996 	/* Not a macro, so no expansion needed. */
3997 	if (macro == NULL)
3998 		return NULL;
3999 
4000 	/* Finally, don't expand this macro if we're already actively
4001 	 * expanding it, (to avoid infinite recursion). */
4002 	if (_parser_active_list_contains (parser, identifier)) {
4003 		/* We change the token type here from IDENTIFIER to
4004 		 * OTHER to prevent any future expansion of this
4005 		 * unexpanded token. */
4006 		char *str;
4007 		token_list_t *expansion;
4008 		token_t *final;
4009 
4010 		str = ralloc_strdup (parser, token->value.str);
4011 		final = _token_create_str (parser, OTHER, str);
4012 		expansion = _token_list_create (parser);
4013 		_token_list_append (expansion, final);
4014 		*last = node;
4015 		return expansion;
4016 	}
4017 
4018 	if (! macro->is_function)
4019 	{
4020 		token_list_t *replacement;
4021 		*last = node;
4022 
4023 		/* Replace a macro defined as empty with a SPACE token. */
4024 		if (macro->replacements == NULL)
4025 			return _token_list_create_with_one_space (parser);
4026 
4027 		replacement = _token_list_copy (parser, macro->replacements);
4028 		_glcpp_parser_apply_pastes (parser, replacement);
4029 		return replacement;
4030 	}
4031 
4032 	return _glcpp_parser_expand_function (parser, node, last);
4033 }
4034 
4035 /* Push a new identifier onto the parser's active list.
4036  *
4037  * Here, 'marker' is the token node that appears in the list after the
4038  * expansion of 'identifier'. That is, when the list iterator begins
4039  * examining 'marker', then it is time to pop this node from the
4040  * active stack.
4041  */
4042 static void
_parser_active_list_push(glcpp_parser_t * parser,const char * identifier,token_node_t * marker)4043 _parser_active_list_push (glcpp_parser_t *parser,
4044 			  const char *identifier,
4045 			  token_node_t *marker)
4046 {
4047 	active_list_t *node;
4048 
4049 	node = ralloc (parser->active, active_list_t);
4050 	node->identifier = ralloc_strdup (node, identifier);
4051 	node->marker = marker;
4052 	node->next = parser->active;
4053 
4054 	parser->active = node;
4055 }
4056 
4057 static void
_parser_active_list_pop(glcpp_parser_t * parser)4058 _parser_active_list_pop (glcpp_parser_t *parser)
4059 {
4060 	active_list_t *node = parser->active;
4061 
4062 	if (node == NULL) {
4063 		parser->active = NULL;
4064 		return;
4065 	}
4066 
4067 	node = parser->active->next;
4068 	ralloc_free (parser->active);
4069 
4070 	parser->active = node;
4071 }
4072 
4073 static int
_parser_active_list_contains(glcpp_parser_t * parser,const char * identifier)4074 _parser_active_list_contains (glcpp_parser_t *parser, const char *identifier)
4075 {
4076 	active_list_t *node;
4077 
4078 	if (parser->active == NULL)
4079 		return 0;
4080 
4081 	for (node = parser->active; node; node = node->next)
4082 		if (strcmp (node->identifier, identifier) == 0)
4083 			return 1;
4084 
4085 	return 0;
4086 }
4087 
4088 /* Walk over the token list replacing nodes with their expansion.
4089  * Whenever nodes are expanded the walking will walk over the new
4090  * nodes, continuing to expand as necessary. The results are placed in
4091  * 'list' itself;
4092  */
4093 static void
_glcpp_parser_expand_token_list(glcpp_parser_t * parser,token_list_t * list)4094 _glcpp_parser_expand_token_list (glcpp_parser_t *parser,
4095 				 token_list_t *list)
4096 {
4097 	token_node_t *node_prev;
4098 	token_node_t *node, *last = NULL;
4099 	token_list_t *expansion;
4100 	active_list_t *active_initial = parser->active;
4101 
4102 	if (list == NULL)
4103 		return;
4104 
4105 	_token_list_trim_trailing_space (list);
4106 
4107 	node_prev = NULL;
4108 	node = list->head;
4109 
4110 	while (node) {
4111 
4112 		while (parser->active && parser->active->marker == node)
4113 			_parser_active_list_pop (parser);
4114 
4115 		expansion = _glcpp_parser_expand_node (parser, node, &last);
4116 		if (expansion) {
4117 			token_node_t *n;
4118 
4119 			for (n = node; n != last->next; n = n->next)
4120 				while (parser->active &&
4121 				       parser->active->marker == n)
4122 				{
4123 					_parser_active_list_pop (parser);
4124 				}
4125 
4126 			_parser_active_list_push (parser,
4127 						  node->token->value.str,
4128 						  last->next);
4129 
4130 			/* Splice expansion into list, supporting a
4131 			 * simple deletion if the expansion is
4132 			 * empty. */
4133 			if (expansion->head) {
4134 				if (node_prev)
4135 					node_prev->next = expansion->head;
4136 				else
4137 					list->head = expansion->head;
4138 				expansion->tail->next = last->next;
4139 				if (last == list->tail)
4140 					list->tail = expansion->tail;
4141 			} else {
4142 				if (node_prev)
4143 					node_prev->next = last->next;
4144 				else
4145 					list->head = last->next;
4146 				if (last == list->tail)
4147 					list->tail = NULL;
4148 			}
4149 		} else {
4150 			node_prev = node;
4151 		}
4152 		node = node_prev ? node_prev->next : list->head;
4153 	}
4154 
4155 	/* Remove any lingering effects of this invocation on the
4156 	 * active list. That is, pop until the list looks like it did
4157 	 * at the beginning of this function. */
4158 	while (parser->active && parser->active != active_initial)
4159 		_parser_active_list_pop (parser);
4160 
4161 	list->non_space_tail = list->tail;
4162 }
4163 
4164 void
_glcpp_parser_print_expanded_token_list(glcpp_parser_t * parser,token_list_t * list)4165 _glcpp_parser_print_expanded_token_list (glcpp_parser_t *parser,
4166 					 token_list_t *list)
4167 {
4168 	if (list == NULL)
4169 		return;
4170 
4171 	_glcpp_parser_expand_token_list (parser, list);
4172 
4173 	_token_list_trim_trailing_space (list);
4174 
4175 	_token_list_print (parser, list);
4176 }
4177 
4178 static void
_check_for_reserved_macro_name(glcpp_parser_t * parser,YYLTYPE * loc,const char * identifier)4179 _check_for_reserved_macro_name (glcpp_parser_t *parser, YYLTYPE *loc,
4180 				const char *identifier)
4181 {
4182 	/* According to the GLSL specification, macro names starting with "__"
4183 	 * or "GL_" are reserved for future use.  So, don't allow them.
4184 	 */
4185 	if (strstr(identifier, "__")) {
4186 		glcpp_error (loc, parser, "Macro names containing \"__\" are reserved.\n");
4187 	}
4188 	if (strncmp(identifier, "GL_", 3) == 0) {
4189 		glcpp_error (loc, parser, "Macro names starting with \"GL_\" are reserved.\n");
4190 	}
4191 }
4192 
4193 static int
_macro_equal(macro_t * a,macro_t * b)4194 _macro_equal (macro_t *a, macro_t *b)
4195 {
4196 	if (a->is_function != b->is_function)
4197 		return 0;
4198 
4199 	if (a->is_function) {
4200 		if (! _string_list_equal (a->parameters, b->parameters))
4201 			return 0;
4202 	}
4203 
4204 	return _token_list_equal_ignoring_space (a->replacements,
4205 						 b->replacements);
4206 }
4207 
4208 void
_define_object_macro(glcpp_parser_t * parser,YYLTYPE * loc,const char * identifier,token_list_t * replacements)4209 _define_object_macro (glcpp_parser_t *parser,
4210 		      YYLTYPE *loc,
4211 		      const char *identifier,
4212 		      token_list_t *replacements)
4213 {
4214 	macro_t *macro, *previous;
4215 
4216 	if (loc != NULL)
4217 		_check_for_reserved_macro_name(parser, loc, identifier);
4218 
4219 	macro = ralloc (parser, macro_t);
4220 
4221 	macro->is_function = 0;
4222 	macro->parameters = NULL;
4223 	macro->identifier = ralloc_strdup (macro, identifier);
4224 	macro->replacements = replacements;
4225 	ralloc_steal (macro, replacements);
4226 
4227 	previous = hash_table_find (parser->defines, identifier);
4228 	if (previous) {
4229 		if (_macro_equal (macro, previous)) {
4230 			ralloc_free (macro);
4231 			return;
4232 		}
4233 		glcpp_error (loc, parser, "Redefinition of macro %s\n",
4234 			     identifier);
4235 	}
4236 
4237 	hash_table_insert (parser->defines, macro, identifier);
4238 }
4239 
4240 void
_define_function_macro(glcpp_parser_t * parser,YYLTYPE * loc,const char * identifier,string_list_t * parameters,token_list_t * replacements)4241 _define_function_macro (glcpp_parser_t *parser,
4242 			YYLTYPE *loc,
4243 			const char *identifier,
4244 			string_list_t *parameters,
4245 			token_list_t *replacements)
4246 {
4247 	macro_t *macro, *previous;
4248 
4249 	_check_for_reserved_macro_name(parser, loc, identifier);
4250 
4251 	macro = ralloc (parser, macro_t);
4252 	ralloc_steal (macro, parameters);
4253 	ralloc_steal (macro, replacements);
4254 
4255 	macro->is_function = 1;
4256 	macro->parameters = parameters;
4257 	macro->identifier = ralloc_strdup (macro, identifier);
4258 	macro->replacements = replacements;
4259 	previous = hash_table_find (parser->defines, identifier);
4260 	if (previous) {
4261 		if (_macro_equal (macro, previous)) {
4262 			ralloc_free (macro);
4263 			return;
4264 		}
4265 		glcpp_error (loc, parser, "Redefinition of macro %s\n",
4266 			     identifier);
4267 	}
4268 
4269 	hash_table_insert (parser->defines, macro, identifier);
4270 }
4271 
4272 static int
glcpp_parser_lex(YYSTYPE * yylval,YYLTYPE * yylloc,glcpp_parser_t * parser)4273 glcpp_parser_lex (YYSTYPE *yylval, YYLTYPE *yylloc, glcpp_parser_t *parser)
4274 {
4275 	token_node_t *node;
4276 	int ret;
4277 
4278 	if (parser->lex_from_list == NULL) {
4279 		ret = glcpp_lex (yylval, yylloc, parser->scanner);
4280 
4281 		/* XXX: This ugly block of code exists for the sole
4282 		 * purpose of converting a NEWLINE token into a SPACE
4283 		 * token, but only in the case where we have seen a
4284 		 * function-like macro name, but have not yet seen its
4285 		 * closing parenthesis.
4286 		 *
4287 		 * There's perhaps a more compact way to do this with
4288 		 * mid-rule actions in the grammar.
4289 		 *
4290 		 * I'm definitely not pleased with the complexity of
4291 		 * this code here.
4292 		 */
4293 		if (parser->newline_as_space)
4294 		{
4295 			if (ret == '(') {
4296 				parser->paren_count++;
4297 			} else if (ret == ')') {
4298 				parser->paren_count--;
4299 				if (parser->paren_count == 0)
4300 					parser->newline_as_space = 0;
4301 			} else if (ret == NEWLINE) {
4302 				ret = SPACE;
4303 			} else if (ret != SPACE) {
4304 				if (parser->paren_count == 0)
4305 					parser->newline_as_space = 0;
4306 			}
4307 		}
4308 		else if (parser->in_control_line)
4309 		{
4310 			if (ret == NEWLINE)
4311 				parser->in_control_line = 0;
4312 		}
4313 		else if (ret == HASH_DEFINE ||
4314 			   ret == HASH_UNDEF || ret == HASH_IF ||
4315 			   ret == HASH_IFDEF || ret == HASH_IFNDEF ||
4316 			   ret == HASH_ELIF || ret == HASH_ELSE ||
4317 			   ret == HASH_ENDIF || ret == HASH)
4318 		{
4319 			parser->in_control_line = 1;
4320 		}
4321 		else if (ret == IDENTIFIER)
4322 		{
4323 			macro_t *macro;
4324 			macro = hash_table_find (parser->defines,
4325 						 yylval->str);
4326 			if (macro && macro->is_function) {
4327 				parser->newline_as_space = 1;
4328 				parser->paren_count = 0;
4329 			}
4330 		}
4331 
4332 		return ret;
4333 	}
4334 
4335 	node = parser->lex_from_node;
4336 
4337 	if (node == NULL) {
4338 		ralloc_free (parser->lex_from_list);
4339 		parser->lex_from_list = NULL;
4340 		return NEWLINE;
4341 	}
4342 
4343 	*yylval = node->token->value;
4344 	ret = node->token->type;
4345 
4346 	parser->lex_from_node = node->next;
4347 
4348 	return ret;
4349 }
4350 
4351 static void
glcpp_parser_lex_from(glcpp_parser_t * parser,token_list_t * list)4352 glcpp_parser_lex_from (glcpp_parser_t *parser, token_list_t *list)
4353 {
4354 	token_node_t *node;
4355 
4356 	assert (parser->lex_from_list == NULL);
4357 
4358 	/* Copy list, eliminating any space tokens. */
4359 	parser->lex_from_list = _token_list_create (parser);
4360 
4361 	for (node = list->head; node; node = node->next) {
4362 		if (node->token->type == SPACE)
4363 			continue;
4364 		_token_list_append (parser->lex_from_list, node->token);
4365 	}
4366 
4367 	ralloc_free (list);
4368 
4369 	parser->lex_from_node = parser->lex_from_list->head;
4370 
4371 	/* It's possible the list consisted of nothing but whitespace. */
4372 	if (parser->lex_from_node == NULL) {
4373 		ralloc_free (parser->lex_from_list);
4374 		parser->lex_from_list = NULL;
4375 	}
4376 }
4377 
4378 static void
_glcpp_parser_skip_stack_push_if(glcpp_parser_t * parser,YYLTYPE * loc,int condition)4379 _glcpp_parser_skip_stack_push_if (glcpp_parser_t *parser, YYLTYPE *loc,
4380 				  int condition)
4381 {
4382 	skip_type_t current = SKIP_NO_SKIP;
4383 	skip_node_t *node;
4384 
4385 	if (parser->skip_stack)
4386 		current = parser->skip_stack->type;
4387 
4388 	node = ralloc (parser, skip_node_t);
4389 	node->loc = *loc;
4390 
4391 	if (current == SKIP_NO_SKIP) {
4392 		if (condition)
4393 			node->type = SKIP_NO_SKIP;
4394 		else
4395 			node->type = SKIP_TO_ELSE;
4396 	} else {
4397 		node->type = SKIP_TO_ENDIF;
4398 	}
4399 
4400 	node->next = parser->skip_stack;
4401 	parser->skip_stack = node;
4402 }
4403 
4404 static void
_glcpp_parser_skip_stack_change_if(glcpp_parser_t * parser,YYLTYPE * loc,const char * type,int condition)4405 _glcpp_parser_skip_stack_change_if (glcpp_parser_t *parser, YYLTYPE *loc,
4406 				    const char *type, int condition)
4407 {
4408 	if (parser->skip_stack == NULL) {
4409 		glcpp_error (loc, parser, "%s without #if\n", type);
4410 		return;
4411 	}
4412 
4413 	if (parser->skip_stack->type == SKIP_TO_ELSE) {
4414 		if (condition)
4415 			parser->skip_stack->type = SKIP_NO_SKIP;
4416 	} else {
4417 		parser->skip_stack->type = SKIP_TO_ENDIF;
4418 	}
4419 }
4420 
4421 static void
_glcpp_parser_skip_stack_pop(glcpp_parser_t * parser,YYLTYPE * loc)4422 _glcpp_parser_skip_stack_pop (glcpp_parser_t *parser, YYLTYPE *loc)
4423 {
4424 	skip_node_t *node;
4425 
4426 	if (parser->skip_stack == NULL) {
4427 		glcpp_error (loc, parser, "#endif without #if\n");
4428 		return;
4429 	}
4430 
4431 	node = parser->skip_stack;
4432 	parser->skip_stack = node->next;
4433 	ralloc_free (node);
4434 }
4435 
4436