blob: 2ef00a0c8d7bc9f89b8399ba1e0b2d1188f8708a [file] [log] [blame]
Carl Worthe29cd392010-08-10 16:59:20 -07001
2/* A Bison parser, made by GNU Bison 2.4.1. */
Carl Worth667173e2010-07-28 12:33:56 -07003
4/* Skeleton implementation for Bison's Yacc-like parsers in C
5
Carl Worthe29cd392010-08-10 16:59:20 -07006 Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
7 Free Software Foundation, Inc.
Carl Worth667173e2010-07-28 12:33:56 -07008
9 This program is free software: you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation, either version 3 of the License, or
12 (at your option) any later version.
13
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with this program. If not, see <http://www.gnu.org/licenses/>. */
21
22/* As a special exception, you may create a larger work that contains
23 part or all of the Bison parser skeleton and distribute that work
24 under terms of your choice, so long as that work isn't itself a
25 parser generator using the skeleton or a modified version thereof
26 as a parser skeleton. Alternatively, if you modify or redistribute
27 the parser skeleton itself, you may (at your option) remove this
28 special exception, which will cause the skeleton and the resulting
29 Bison output files to be licensed under the GNU General Public
30 License without this special exception.
31
32 This special exception was added by the Free Software Foundation in
33 version 2.2 of Bison. */
34
35/* C LALR(1) parser skeleton written by Richard Stallman, by
36 simplifying the original so-called "semantic" parser. */
37
38/* All symbols defined below should begin with yy or YY, to avoid
39 infringing on user name space. This should be done even for local
40 variables, as they might otherwise be expanded by user macros.
41 There are some unavoidable exceptions within include files to
42 define necessary library symbols; they are noted "INFRINGES ON
43 USER NAME SPACE" below. */
44
45/* Identify Bison output. */
46#define YYBISON 1
47
48/* Bison version. */
Carl Worthe29cd392010-08-10 16:59:20 -070049#define YYBISON_VERSION "2.4.1"
Carl Worth667173e2010-07-28 12:33:56 -070050
51/* Skeleton name. */
52#define YYSKELETON_NAME "yacc.c"
53
54/* Pure parsers. */
55#define YYPURE 1
56
57/* Push parsers. */
58#define YYPUSH 0
59
60/* Pull parsers. */
61#define YYPULL 1
62
63/* Using locations. */
64#define YYLSP_NEEDED 1
65
66
67
68/* Copy the first part of user declarations. */
69
70/* Line 189 of yacc.c */
71#line 1 "glcpp/glcpp-parse.y"
72
73/*
74 * Copyright © 2010 Intel Corporation
75 *
76 * Permission is hereby granted, free of charge, to any person obtaining a
77 * copy of this software and associated documentation files (the "Software"),
78 * to deal in the Software without restriction, including without limitation
79 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
80 * and/or sell copies of the Software, and to permit persons to whom the
81 * Software is furnished to do so, subject to the following conditions:
82 *
83 * The above copyright notice and this permission notice (including the next
84 * paragraph) shall be included in all copies or substantial portions of the
85 * Software.
86 *
87 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
88 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
89 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
90 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
91 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
92 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
93 * DEALINGS IN THE SOFTWARE.
94 */
95
96#include <stdio.h>
97#include <stdlib.h>
98#include <assert.h>
99#include <inttypes.h>
100
101#include "glcpp.h"
102#include "main/mtypes.h"
103
104#define glcpp_print(stream, str) stream = talloc_strdup_append(stream, str)
105#define glcpp_printf(stream, fmt, args...) \
106 stream = talloc_asprintf_append(stream, fmt, args)
107
108static void
109yyerror (YYLTYPE *locp, glcpp_parser_t *parser, const char *error);
110
111static void
112_define_object_macro (glcpp_parser_t *parser,
113 YYLTYPE *loc,
114 const char *macro,
115 token_list_t *replacements);
116
117static void
118_define_function_macro (glcpp_parser_t *parser,
119 YYLTYPE *loc,
120 const char *macro,
121 string_list_t *parameters,
122 token_list_t *replacements);
123
124static string_list_t *
125_string_list_create (void *ctx);
126
127static void
128_string_list_append_item (string_list_t *list, const char *str);
129
130static int
131_string_list_contains (string_list_t *list, const char *member, int *index);
132
133static int
134_string_list_length (string_list_t *list);
135
136static argument_list_t *
137_argument_list_create (void *ctx);
138
139static void
140_argument_list_append (argument_list_t *list, token_list_t *argument);
141
142static int
143_argument_list_length (argument_list_t *list);
144
145static token_list_t *
146_argument_list_member_at (argument_list_t *list, int index);
147
148/* Note: This function talloc_steal()s the str pointer. */
149static token_t *
150_token_create_str (void *ctx, int type, char *str);
151
152static token_t *
153_token_create_ival (void *ctx, int type, int ival);
154
155static token_list_t *
156_token_list_create (void *ctx);
157
158/* Note: This function adds a talloc_reference() to token.
159 *
160 * You may want to talloc_unlink any current reference if you no
161 * longer need it. */
162static void
163_token_list_append (token_list_t *list, token_t *token);
164
165static void
166_token_list_append_list (token_list_t *list, token_list_t *tail);
167
168static active_list_t *
169_active_list_push (active_list_t *list,
170 const char *identifier,
171 token_node_t *marker);
172
173static active_list_t *
174_active_list_pop (active_list_t *list);
175
176int
177_active_list_contains (active_list_t *list, const char *identifier);
178
179static void
Kenneth Graunke16b4eed2010-08-04 16:10:03 -0700180_glcpp_parser_expand_if (glcpp_parser_t *parser, int type, token_list_t *list);
181
182static void
Carl Worth667173e2010-07-28 12:33:56 -0700183_glcpp_parser_expand_token_list (glcpp_parser_t *parser,
184 token_list_t *list);
185
186static void
187_glcpp_parser_print_expanded_token_list (glcpp_parser_t *parser,
188 token_list_t *list);
189
190static void
191_glcpp_parser_skip_stack_push_if (glcpp_parser_t *parser, YYLTYPE *loc,
192 int condition);
193
194static void
195_glcpp_parser_skip_stack_change_if (glcpp_parser_t *parser, YYLTYPE *loc,
196 const char *type, int condition);
197
198static void
199_glcpp_parser_skip_stack_pop (glcpp_parser_t *parser, YYLTYPE *loc);
200
201#define yylex glcpp_parser_lex
202
203static int
204glcpp_parser_lex (YYSTYPE *yylval, YYLTYPE *yylloc, glcpp_parser_t *parser);
205
206static void
207glcpp_parser_lex_from (glcpp_parser_t *parser, token_list_t *list);
208
Eric Anholtd4a04f32010-07-28 16:58:39 -0700209static void
210add_builtin_define(glcpp_parser_t *parser, const char *name, int value);
211
Carl Worth667173e2010-07-28 12:33:56 -0700212
213
214/* Line 189 of yacc.c */
Carl Worthe29cd392010-08-10 16:59:20 -0700215#line 216 "glcpp/glcpp-parse.c"
Carl Worth667173e2010-07-28 12:33:56 -0700216
217/* Enabling traces. */
218#ifndef YYDEBUG
219# define YYDEBUG 0
220#endif
221
222/* Enabling verbose error messages. */
223#ifdef YYERROR_VERBOSE
224# undef YYERROR_VERBOSE
225# define YYERROR_VERBOSE 1
226#else
227# define YYERROR_VERBOSE 1
228#endif
229
230/* Enabling the token table. */
231#ifndef YYTOKEN_TABLE
232# define YYTOKEN_TABLE 0
233#endif
234
235
236/* Tokens. */
237#ifndef YYTOKENTYPE
238# define YYTOKENTYPE
239 /* Put the tokens into the symbol table, so that GDB and other debuggers
240 know about them. */
241 enum yytokentype {
242 COMMA_FINAL = 258,
243 DEFINED = 259,
244 ELIF_EXPANDED = 260,
245 HASH = 261,
246 HASH_DEFINE_FUNC = 262,
247 HASH_DEFINE_OBJ = 263,
248 HASH_ELIF = 264,
249 HASH_ELSE = 265,
250 HASH_ENDIF = 266,
251 HASH_IF = 267,
252 HASH_IFDEF = 268,
253 HASH_IFNDEF = 269,
254 HASH_UNDEF = 270,
Eric Anholtd4a04f32010-07-28 16:58:39 -0700255 HASH_VERSION = 271,
256 IDENTIFIER = 272,
257 IF_EXPANDED = 273,
258 INTEGER = 274,
259 INTEGER_STRING = 275,
260 NEWLINE = 276,
261 OTHER = 277,
262 PLACEHOLDER = 278,
263 SPACE = 279,
264 PASTE = 280,
265 OR = 281,
266 AND = 282,
267 NOT_EQUAL = 283,
268 EQUAL = 284,
269 GREATER_OR_EQUAL = 285,
270 LESS_OR_EQUAL = 286,
271 RIGHT_SHIFT = 287,
272 LEFT_SHIFT = 288,
273 UNARY = 289
Carl Worth667173e2010-07-28 12:33:56 -0700274 };
275#endif
276
277
278
279#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
280
281# define yystype YYSTYPE /* obsolescent; will be withdrawn */
282# define YYSTYPE_IS_DECLARED 1
283#endif
284
285#if ! defined YYLTYPE && ! defined YYLTYPE_IS_DECLARED
286typedef struct YYLTYPE
287{
288 int first_line;
289 int first_column;
290 int last_line;
291 int last_column;
292} YYLTYPE;
293# define yyltype YYLTYPE /* obsolescent; will be withdrawn */
294# define YYLTYPE_IS_DECLARED 1
295# define YYLTYPE_IS_TRIVIAL 1
296#endif
297
298
299/* Copy the second part of user declarations. */
300
301
302/* Line 264 of yacc.c */
Carl Worthe29cd392010-08-10 16:59:20 -0700303#line 304 "glcpp/glcpp-parse.c"
Carl Worth667173e2010-07-28 12:33:56 -0700304
305#ifdef short
306# undef short
307#endif
308
309#ifdef YYTYPE_UINT8
310typedef YYTYPE_UINT8 yytype_uint8;
311#else
312typedef unsigned char yytype_uint8;
313#endif
314
315#ifdef YYTYPE_INT8
316typedef YYTYPE_INT8 yytype_int8;
317#elif (defined __STDC__ || defined __C99__FUNC__ \
318 || defined __cplusplus || defined _MSC_VER)
319typedef signed char yytype_int8;
320#else
321typedef short int yytype_int8;
322#endif
323
324#ifdef YYTYPE_UINT16
325typedef YYTYPE_UINT16 yytype_uint16;
326#else
327typedef unsigned short int yytype_uint16;
328#endif
329
330#ifdef YYTYPE_INT16
331typedef YYTYPE_INT16 yytype_int16;
332#else
333typedef short int yytype_int16;
334#endif
335
336#ifndef YYSIZE_T
337# ifdef __SIZE_TYPE__
338# define YYSIZE_T __SIZE_TYPE__
339# elif defined size_t
340# define YYSIZE_T size_t
341# elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \
342 || defined __cplusplus || defined _MSC_VER)
343# include <stddef.h> /* INFRINGES ON USER NAME SPACE */
344# define YYSIZE_T size_t
345# else
346# define YYSIZE_T unsigned int
347# endif
348#endif
349
350#define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
351
352#ifndef YY_
Carl Worthe29cd392010-08-10 16:59:20 -0700353# if YYENABLE_NLS
Carl Worth667173e2010-07-28 12:33:56 -0700354# if ENABLE_NLS
355# include <libintl.h> /* INFRINGES ON USER NAME SPACE */
356# define YY_(msgid) dgettext ("bison-runtime", msgid)
357# endif
358# endif
359# ifndef YY_
360# define YY_(msgid) msgid
361# endif
362#endif
363
364/* Suppress unused-variable warnings by "using" E. */
365#if ! defined lint || defined __GNUC__
366# define YYUSE(e) ((void) (e))
367#else
368# define YYUSE(e) /* empty */
369#endif
370
371/* Identity function, used to suppress warnings about constant conditions. */
372#ifndef lint
373# define YYID(n) (n)
374#else
375#if (defined __STDC__ || defined __C99__FUNC__ \
376 || defined __cplusplus || defined _MSC_VER)
377static int
378YYID (int yyi)
379#else
380static int
381YYID (yyi)
382 int yyi;
383#endif
384{
385 return yyi;
386}
387#endif
388
389#if ! defined yyoverflow || YYERROR_VERBOSE
390
391/* The parser invokes alloca or malloc; define the necessary symbols. */
392
393# ifdef YYSTACK_USE_ALLOCA
394# if YYSTACK_USE_ALLOCA
395# ifdef __GNUC__
396# define YYSTACK_ALLOC __builtin_alloca
397# elif defined __BUILTIN_VA_ARG_INCR
398# include <alloca.h> /* INFRINGES ON USER NAME SPACE */
399# elif defined _AIX
400# define YYSTACK_ALLOC __alloca
401# elif defined _MSC_VER
402# include <malloc.h> /* INFRINGES ON USER NAME SPACE */
403# define alloca _alloca
404# else
405# define YYSTACK_ALLOC alloca
406# if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
407 || defined __cplusplus || defined _MSC_VER)
408# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
409# ifndef _STDLIB_H
410# define _STDLIB_H 1
411# endif
412# endif
413# endif
414# endif
415# endif
416
417# ifdef YYSTACK_ALLOC
418 /* Pacify GCC's `empty if-body' warning. */
419# define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0))
420# ifndef YYSTACK_ALLOC_MAXIMUM
421 /* The OS might guarantee only one guard page at the bottom of the stack,
422 and a page size can be as small as 4096 bytes. So we cannot safely
423 invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
424 to allow for a few compiler-allocated temporary stack slots. */
425# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
426# endif
427# else
428# define YYSTACK_ALLOC YYMALLOC
429# define YYSTACK_FREE YYFREE
430# ifndef YYSTACK_ALLOC_MAXIMUM
431# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
432# endif
433# if (defined __cplusplus && ! defined _STDLIB_H \
434 && ! ((defined YYMALLOC || defined malloc) \
435 && (defined YYFREE || defined free)))
436# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
437# ifndef _STDLIB_H
438# define _STDLIB_H 1
439# endif
440# endif
441# ifndef YYMALLOC
442# define YYMALLOC malloc
443# if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
444 || defined __cplusplus || defined _MSC_VER)
445void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
446# endif
447# endif
448# ifndef YYFREE
449# define YYFREE free
450# if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
451 || defined __cplusplus || defined _MSC_VER)
452void free (void *); /* INFRINGES ON USER NAME SPACE */
453# endif
454# endif
455# endif
456#endif /* ! defined yyoverflow || YYERROR_VERBOSE */
457
458
459#if (! defined yyoverflow \
460 && (! defined __cplusplus \
461 || (defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL \
462 && defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
463
464/* A type that is properly aligned for any stack member. */
465union yyalloc
466{
467 yytype_int16 yyss_alloc;
468 YYSTYPE yyvs_alloc;
469 YYLTYPE yyls_alloc;
470};
471
472/* The size of the maximum gap between one aligned stack and the next. */
473# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
474
475/* The size of an array large to enough to hold all stacks, each with
476 N elements. */
477# define YYSTACK_BYTES(N) \
478 ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE) + sizeof (YYLTYPE)) \
479 + 2 * YYSTACK_GAP_MAXIMUM)
480
481/* Copy COUNT objects from FROM to TO. The source and destination do
482 not overlap. */
483# ifndef YYCOPY
484# if defined __GNUC__ && 1 < __GNUC__
485# define YYCOPY(To, From, Count) \
486 __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
487# else
488# define YYCOPY(To, From, Count) \
489 do \
490 { \
491 YYSIZE_T yyi; \
492 for (yyi = 0; yyi < (Count); yyi++) \
493 (To)[yyi] = (From)[yyi]; \
494 } \
495 while (YYID (0))
496# endif
497# endif
498
499/* Relocate STACK from its old location to the new one. The
500 local variables YYSIZE and YYSTACKSIZE give the old and new number of
501 elements in the stack, and YYPTR gives the new location of the
502 stack. Advance YYPTR to a properly aligned location for the next
503 stack. */
504# define YYSTACK_RELOCATE(Stack_alloc, Stack) \
505 do \
506 { \
507 YYSIZE_T yynewbytes; \
508 YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \
509 Stack = &yyptr->Stack_alloc; \
510 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
511 yyptr += yynewbytes / sizeof (*yyptr); \
512 } \
513 while (YYID (0))
514
515#endif
516
517/* YYFINAL -- State number of the termination state. */
518#define YYFINAL 2
519/* YYLAST -- Last index in YYTABLE. */
Eric Anholtd4a04f32010-07-28 16:58:39 -0700520#define YYLAST 604
Carl Worth667173e2010-07-28 12:33:56 -0700521
522/* YYNTOKENS -- Number of terminals. */
Eric Anholtd4a04f32010-07-28 16:58:39 -0700523#define YYNTOKENS 57
Carl Worth667173e2010-07-28 12:33:56 -0700524/* YYNNTS -- Number of nonterminals. */
Eric Anholtd4a04f32010-07-28 16:58:39 -0700525#define YYNNTS 17
Carl Worth667173e2010-07-28 12:33:56 -0700526/* YYNRULES -- Number of rules. */
Eric Anholtd4a04f32010-07-28 16:58:39 -0700527#define YYNRULES 100
Carl Worth667173e2010-07-28 12:33:56 -0700528/* YYNRULES -- Number of states. */
Eric Anholtd4a04f32010-07-28 16:58:39 -0700529#define YYNSTATES 161
Carl Worth667173e2010-07-28 12:33:56 -0700530
531/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
532#define YYUNDEFTOK 2
Eric Anholtd4a04f32010-07-28 16:58:39 -0700533#define YYMAXUTOK 289
Carl Worth667173e2010-07-28 12:33:56 -0700534
535#define YYTRANSLATE(YYX) \
536 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
537
538/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
539static const yytype_uint8 yytranslate[] =
540{
541 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
542 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
543 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
Eric Anholtd4a04f32010-07-28 16:58:39 -0700544 2, 2, 2, 47, 2, 2, 2, 43, 30, 2,
545 45, 46, 41, 39, 49, 40, 54, 42, 2, 2,
546 2, 2, 2, 2, 2, 2, 2, 2, 2, 55,
547 33, 56, 34, 2, 2, 2, 2, 2, 2, 2,
Carl Worth667173e2010-07-28 12:33:56 -0700548 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
549 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
Eric Anholtd4a04f32010-07-28 16:58:39 -0700550 2, 50, 2, 51, 29, 2, 2, 2, 2, 2,
Carl Worth667173e2010-07-28 12:33:56 -0700551 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
552 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
Eric Anholtd4a04f32010-07-28 16:58:39 -0700553 2, 2, 2, 52, 28, 53, 48, 2, 2, 2,
Carl Worth667173e2010-07-28 12:33:56 -0700554 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
555 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
556 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
557 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
558 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
559 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
560 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
561 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
562 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
563 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
564 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
565 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
566 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
567 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
568 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
Eric Anholtd4a04f32010-07-28 16:58:39 -0700569 25, 26, 27, 31, 32, 35, 36, 37, 38, 44
Carl Worth667173e2010-07-28 12:33:56 -0700570};
571
572#if YYDEBUG
573/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
574 YYRHS. */
575static const yytype_uint16 yyprhs[] =
576{
577 0, 0, 3, 4, 7, 9, 11, 13, 16, 20,
578 24, 29, 36, 44, 48, 52, 57, 62, 66, 69,
Eric Anholtd4a04f32010-07-28 16:58:39 -0700579 72, 75, 79, 82, 84, 86, 88, 92, 96, 100,
580 104, 108, 112, 116, 120, 124, 128, 132, 136, 140,
581 144, 148, 152, 156, 160, 163, 166, 169, 172, 176,
582 178, 182, 184, 187, 190, 191, 193, 194, 196, 199,
583 204, 206, 208, 211, 213, 216, 218, 220, 222, 224,
584 226, 228, 230, 232, 234, 236, 238, 240, 242, 244,
585 246, 248, 250, 252, 254, 256, 258, 260, 262, 264,
586 266, 268, 270, 272, 274, 276, 278, 280, 282, 284,
587 286
Carl Worth667173e2010-07-28 12:33:56 -0700588};
589
590/* YYRHS -- A `-1'-separated list of the rules' RHS. */
591static const yytype_int8 yyrhs[] =
592{
Eric Anholtd4a04f32010-07-28 16:58:39 -0700593 58, 0, -1, -1, 58, 59, -1, 61, -1, 65,
594 -1, 60, -1, 6, 66, -1, 18, 63, 21, -1,
595 5, 63, 21, -1, 8, 17, 67, 21, -1, 7,
596 17, 45, 46, 67, 21, -1, 7, 17, 45, 64,
597 46, 67, 21, -1, 15, 17, 21, -1, 12, 70,
598 21, -1, 13, 17, 68, 21, -1, 14, 17, 68,
599 21, -1, 9, 70, 21, -1, 9, 21, -1, 10,
600 21, -1, 11, 21, -1, 16, 62, 21, -1, 6,
601 21, -1, 20, -1, 19, -1, 62, -1, 63, 26,
602 63, -1, 63, 27, 63, -1, 63, 28, 63, -1,
603 63, 29, 63, -1, 63, 30, 63, -1, 63, 31,
604 63, -1, 63, 32, 63, -1, 63, 35, 63, -1,
605 63, 36, 63, -1, 63, 34, 63, -1, 63, 33,
606 63, -1, 63, 37, 63, -1, 63, 38, 63, -1,
607 63, 40, 63, -1, 63, 39, 63, -1, 63, 43,
608 63, -1, 63, 42, 63, -1, 63, 41, 63, -1,
609 47, 63, -1, 48, 63, -1, 40, 63, -1, 39,
610 63, -1, 45, 63, 46, -1, 17, -1, 64, 49,
611 17, -1, 21, -1, 71, 21, -1, 71, 21, -1,
612 -1, 71, -1, -1, 71, -1, 4, 17, -1, 4,
613 45, 17, 46, -1, 72, -1, 69, -1, 70, 69,
614 -1, 72, -1, 71, 72, -1, 17, -1, 20, -1,
615 73, -1, 22, -1, 24, -1, 50, -1, 51, -1,
616 45, -1, 46, -1, 52, -1, 53, -1, 54, -1,
617 30, -1, 41, -1, 39, -1, 40, -1, 48, -1,
618 47, -1, 42, -1, 43, -1, 38, -1, 37, -1,
619 33, -1, 34, -1, 36, -1, 35, -1, 32, -1,
620 31, -1, 29, -1, 28, -1, 27, -1, 26, -1,
621 55, -1, 49, -1, 56, -1, 25, -1
Carl Worth667173e2010-07-28 12:33:56 -0700622};
623
624/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
625static const yytype_uint16 yyrline[] =
626{
Carl Worthe29cd392010-08-10 16:59:20 -0700627 0, 180, 180, 182, 186, 189, 194, 195, 199, 202,
628 208, 211, 214, 217, 225, 236, 241, 246, 255, 266,
629 269, 272, 281, 285, 294, 299, 300, 303, 306, 309,
630 312, 315, 318, 321, 324, 327, 330, 333, 336, 339,
631 342, 345, 348, 351, 354, 357, 360, 363, 366, 372,
632 377, 385, 386, 390, 396, 397, 400, 402, 409, 413,
633 417, 422, 428, 436, 442, 450, 454, 458, 462, 466,
634 473, 474, 475, 476, 477, 478, 479, 480, 481, 482,
635 483, 484, 485, 486, 487, 488, 489, 490, 491, 492,
636 493, 494, 495, 496, 497, 498, 499, 500, 501, 502,
637 503
Carl Worth667173e2010-07-28 12:33:56 -0700638};
639#endif
640
641#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
642/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
643 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
644static const char *const yytname[] =
645{
646 "$end", "error", "$undefined", "COMMA_FINAL", "DEFINED",
647 "ELIF_EXPANDED", "HASH", "HASH_DEFINE_FUNC", "HASH_DEFINE_OBJ",
648 "HASH_ELIF", "HASH_ELSE", "HASH_ENDIF", "HASH_IF", "HASH_IFDEF",
Eric Anholtd4a04f32010-07-28 16:58:39 -0700649 "HASH_IFNDEF", "HASH_UNDEF", "HASH_VERSION", "IDENTIFIER", "IF_EXPANDED",
650 "INTEGER", "INTEGER_STRING", "NEWLINE", "OTHER", "PLACEHOLDER", "SPACE",
651 "PASTE", "OR", "AND", "'|'", "'^'", "'&'", "NOT_EQUAL", "EQUAL", "'<'",
652 "'>'", "GREATER_OR_EQUAL", "LESS_OR_EQUAL", "RIGHT_SHIFT", "LEFT_SHIFT",
653 "'+'", "'-'", "'*'", "'/'", "'%'", "UNARY", "'('", "')'", "'!'", "'~'",
654 "','", "'['", "']'", "'{'", "'}'", "'.'", "';'", "'='", "$accept",
655 "input", "line", "expanded_line", "control_line", "integer_constant",
656 "expression", "identifier_list", "text_line", "non_directive",
657 "replacement_list", "junk", "conditional_token", "conditional_tokens",
658 "pp_tokens", "preprocessing_token", "operator", 0
Carl Worth667173e2010-07-28 12:33:56 -0700659};
660#endif
661
662# ifdef YYPRINT
663/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
664 token YYLEX-NUM. */
665static const yytype_uint16 yytoknum[] =
666{
667 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
668 265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
Eric Anholtd4a04f32010-07-28 16:58:39 -0700669 275, 276, 277, 278, 279, 280, 281, 282, 124, 94,
670 38, 283, 284, 60, 62, 285, 286, 287, 288, 43,
671 45, 42, 47, 37, 289, 40, 41, 33, 126, 44,
672 91, 93, 123, 125, 46, 59, 61
Carl Worth667173e2010-07-28 12:33:56 -0700673};
674# endif
675
676/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
677static const yytype_uint8 yyr1[] =
678{
Eric Anholtd4a04f32010-07-28 16:58:39 -0700679 0, 57, 58, 58, 59, 59, 59, 59, 60, 60,
Carl Worth667173e2010-07-28 12:33:56 -0700680 61, 61, 61, 61, 61, 61, 61, 61, 61, 61,
Eric Anholtd4a04f32010-07-28 16:58:39 -0700681 61, 61, 61, 62, 62, 63, 63, 63, 63, 63,
682 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
683 63, 63, 63, 63, 63, 63, 63, 63, 63, 64,
684 64, 65, 65, 66, 67, 67, 68, 68, 69, 69,
685 69, 70, 70, 71, 71, 72, 72, 72, 72, 72,
686 73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
687 73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
688 73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
689 73
Carl Worth667173e2010-07-28 12:33:56 -0700690};
691
692/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
693static const yytype_uint8 yyr2[] =
694{
695 0, 2, 0, 2, 1, 1, 1, 2, 3, 3,
696 4, 6, 7, 3, 3, 4, 4, 3, 2, 2,
Eric Anholtd4a04f32010-07-28 16:58:39 -0700697 2, 3, 2, 1, 1, 1, 3, 3, 3, 3,
Carl Worth667173e2010-07-28 12:33:56 -0700698 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
Eric Anholtd4a04f32010-07-28 16:58:39 -0700699 3, 3, 3, 3, 2, 2, 2, 2, 3, 1,
700 3, 1, 2, 2, 0, 1, 0, 1, 2, 4,
701 1, 1, 2, 1, 2, 1, 1, 1, 1, 1,
Carl Worth667173e2010-07-28 12:33:56 -0700702 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
703 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
Eric Anholtd4a04f32010-07-28 16:58:39 -0700704 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
705 1
Carl Worth667173e2010-07-28 12:33:56 -0700706};
707
708/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
709 STATE-NUM when YYTABLE doesn't specify something else to do. Zero
710 means the default is an error. */
711static const yytype_uint8 yydefact[] =
712{
713 2, 0, 1, 0, 0, 0, 0, 0, 0, 0,
Eric Anholtd4a04f32010-07-28 16:58:39 -0700714 0, 0, 0, 0, 0, 65, 0, 66, 51, 68,
715 69, 100, 96, 95, 94, 93, 77, 92, 91, 87,
716 88, 90, 89, 86, 85, 79, 80, 78, 83, 84,
717 72, 73, 82, 81, 98, 70, 71, 74, 75, 76,
718 97, 99, 3, 6, 4, 5, 0, 63, 67, 24,
719 23, 0, 0, 0, 0, 0, 25, 0, 22, 7,
720 0, 0, 54, 0, 18, 61, 0, 60, 19, 20,
721 0, 56, 56, 0, 0, 0, 52, 64, 47, 46,
722 0, 44, 45, 9, 0, 0, 0, 0, 0, 0,
723 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
724 0, 0, 53, 0, 0, 55, 58, 0, 17, 62,
725 14, 0, 57, 0, 13, 21, 8, 48, 26, 27,
726 28, 29, 30, 31, 32, 36, 35, 33, 34, 37,
727 38, 40, 39, 43, 42, 41, 49, 54, 0, 10,
728 0, 15, 16, 0, 54, 0, 59, 11, 0, 50,
729 12
Carl Worth667173e2010-07-28 12:33:56 -0700730};
731
732/* YYDEFGOTO[NTERM-NUM]. */
733static const yytype_int16 yydefgoto[] =
734{
Eric Anholtd4a04f32010-07-28 16:58:39 -0700735 -1, 1, 52, 53, 54, 66, 67, 148, 55, 69,
736 114, 121, 75, 76, 115, 57, 58
Carl Worth667173e2010-07-28 12:33:56 -0700737};
738
739/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
740 STATE-NUM. */
Eric Anholtd4a04f32010-07-28 16:58:39 -0700741#define YYPACT_NINF -146
Carl Worth667173e2010-07-28 12:33:56 -0700742static const yytype_int16 yypact[] =
743{
Eric Anholtd4a04f32010-07-28 16:58:39 -0700744 -146, 111, -146, 429, -10, -9, -4, 151, -15, 27,
745 271, 54, 63, 86, 82, -146, 429, -146, -146, -146,
746 -146, -146, -146, -146, -146, -146, -146, -146, -146, -146,
747 -146, -146, -146, -146, -146, -146, -146, -146, -146, -146,
748 -146, -146, -146, -146, -146, -146, -146, -146, -146, -146,
749 -146, -146, -146, -146, -146, -146, 311, -146, -146, -146,
750 -146, 429, 429, 429, 429, 429, -146, 452, -146, -146,
751 351, 59, 391, 17, -146, -146, 191, -146, -146, -146,
752 231, 391, 391, 84, 85, 475, -146, -146, -146, -146,
753 424, -146, -146, -146, 429, 429, 429, 429, 429, 429,
754 429, 429, 429, 429, 429, 429, 429, 429, 429, 429,
755 429, 429, -146, 30, 88, 391, -146, 90, -146, -146,
756 -146, 89, 391, 91, -146, -146, -146, -146, 492, 508,
757 523, 537, 550, 561, 561, 18, 18, 18, 18, 25,
758 25, 36, 36, -146, -146, -146, -146, 391, 26, -146,
759 67, -146, -146, 93, 391, 113, -146, -146, 148, -146,
760 -146
Carl Worth667173e2010-07-28 12:33:56 -0700761};
762
763/* YYPGOTO[NTERM-NUM]. */
Eric Anholtd4a04f32010-07-28 16:58:39 -0700764static const yytype_int16 yypgoto[] =
Carl Worth667173e2010-07-28 12:33:56 -0700765{
Eric Anholtd4a04f32010-07-28 16:58:39 -0700766 -146, -146, -146, -146, -146, 120, -11, -146, -146, -146,
767 -145, 92, -6, 160, 0, -7, -146
Carl Worth667173e2010-07-28 12:33:56 -0700768};
769
770/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
771 positive, shift that token. If negative, reduce the rule which
772 number is the opposite. If zero, do what YYDEFACT says.
773 If YYTABLE_NINF, syntax error. */
774#define YYTABLE_NINF -1
775static const yytype_uint8 yytable[] =
776{
Eric Anholtd4a04f32010-07-28 16:58:39 -0700777 77, 56, 153, 77, 70, 85, 78, 15, 71, 158,
778 17, 68, 19, 72, 20, 21, 22, 23, 24, 25,
Carl Worth667173e2010-07-28 12:33:56 -0700779 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
Eric Anholtd4a04f32010-07-28 16:58:39 -0700780 36, 37, 38, 39, 116, 40, 41, 42, 43, 44,
781 45, 46, 47, 48, 49, 50, 51, 146, 79, 87,
782 88, 89, 90, 91, 92, 105, 106, 107, 108, 109,
783 110, 111, 117, 87, 107, 108, 109, 110, 111, 77,
784 119, 81, 154, 77, 119, 155, 147, 109, 110, 111,
785 82, 122, 122, 128, 129, 130, 131, 132, 133, 134,
786 135, 136, 137, 138, 139, 140, 141, 142, 143, 144,
787 145, 59, 60, 83, 113, 124, 125, 150, 87, 149,
788 151, 2, 152, 156, 157, 87, 3, 4, 5, 6,
789 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
790 159, 17, 18, 19, 84, 20, 21, 22, 23, 24,
791 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
792 35, 36, 37, 38, 39, 73, 40, 41, 42, 43,
793 44, 45, 46, 47, 48, 49, 50, 51, 15, 160,
794 80, 17, 74, 19, 123, 20, 21, 22, 23, 24,
795 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
796 35, 36, 37, 38, 39, 73, 40, 41, 42, 43,
797 44, 45, 46, 47, 48, 49, 50, 51, 15, 0,
798 0, 17, 118, 19, 0, 20, 21, 22, 23, 24,
799 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
800 35, 36, 37, 38, 39, 73, 40, 41, 42, 43,
801 44, 45, 46, 47, 48, 49, 50, 51, 15, 0,
802 0, 17, 120, 19, 0, 20, 21, 22, 23, 24,
803 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
804 35, 36, 37, 38, 39, 73, 40, 41, 42, 43,
805 44, 45, 46, 47, 48, 49, 50, 51, 15, 0,
806 0, 17, 0, 19, 0, 20, 21, 22, 23, 24,
807 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
808 35, 36, 37, 38, 39, 0, 40, 41, 42, 43,
809 44, 45, 46, 47, 48, 49, 50, 51, 15, 0,
810 0, 17, 86, 19, 0, 20, 21, 22, 23, 24,
811 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
812 35, 36, 37, 38, 39, 0, 40, 41, 42, 43,
813 44, 45, 46, 47, 48, 49, 50, 51, 15, 0,
814 0, 17, 112, 19, 0, 20, 21, 22, 23, 24,
815 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
816 35, 36, 37, 38, 39, 0, 40, 41, 42, 43,
817 44, 45, 46, 47, 48, 49, 50, 51, 15, 0,
818 0, 17, 0, 19, 0, 20, 21, 22, 23, 24,
819 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
820 35, 36, 37, 38, 39, 0, 40, 41, 42, 43,
821 44, 45, 46, 47, 48, 49, 50, 51, 59, 60,
Carl Worth667173e2010-07-28 12:33:56 -0700822 94, 95, 96, 97, 98, 99, 100, 101, 102, 103,
Eric Anholtd4a04f32010-07-28 16:58:39 -0700823 104, 105, 106, 107, 108, 109, 110, 111, 61, 62,
824 127, 0, 0, 93, 63, 0, 64, 65, 94, 95,
825 96, 97, 98, 99, 100, 101, 102, 103, 104, 105,
826 106, 107, 108, 109, 110, 111, 126, 0, 0, 0,
827 0, 94, 95, 96, 97, 98, 99, 100, 101, 102,
828 103, 104, 105, 106, 107, 108, 109, 110, 111, 95,
829 96, 97, 98, 99, 100, 101, 102, 103, 104, 105,
830 106, 107, 108, 109, 110, 111, 96, 97, 98, 99,
831 100, 101, 102, 103, 104, 105, 106, 107, 108, 109,
832 110, 111, 97, 98, 99, 100, 101, 102, 103, 104,
833 105, 106, 107, 108, 109, 110, 111, 98, 99, 100,
834 101, 102, 103, 104, 105, 106, 107, 108, 109, 110,
835 111, 99, 100, 101, 102, 103, 104, 105, 106, 107,
836 108, 109, 110, 111, 101, 102, 103, 104, 105, 106,
837 107, 108, 109, 110, 111
Carl Worth667173e2010-07-28 12:33:56 -0700838};
839
840static const yytype_int16 yycheck[] =
841{
Eric Anholtd4a04f32010-07-28 16:58:39 -0700842 7, 1, 147, 10, 4, 16, 21, 17, 17, 154,
843 20, 21, 22, 17, 24, 25, 26, 27, 28, 29,
Carl Worth667173e2010-07-28 12:33:56 -0700844 30, 31, 32, 33, 34, 35, 36, 37, 38, 39,
Eric Anholtd4a04f32010-07-28 16:58:39 -0700845 40, 41, 42, 43, 17, 45, 46, 47, 48, 49,
846 50, 51, 52, 53, 54, 55, 56, 17, 21, 56,
847 61, 62, 63, 64, 65, 37, 38, 39, 40, 41,
848 42, 43, 45, 70, 39, 40, 41, 42, 43, 76,
849 76, 17, 46, 80, 80, 49, 46, 41, 42, 43,
850 17, 81, 82, 94, 95, 96, 97, 98, 99, 100,
851 101, 102, 103, 104, 105, 106, 107, 108, 109, 110,
852 111, 19, 20, 17, 45, 21, 21, 17, 115, 21,
853 21, 0, 21, 46, 21, 122, 5, 6, 7, 8,
854 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
855 17, 20, 21, 22, 14, 24, 25, 26, 27, 28,
856 29, 30, 31, 32, 33, 34, 35, 36, 37, 38,
857 39, 40, 41, 42, 43, 4, 45, 46, 47, 48,
858 49, 50, 51, 52, 53, 54, 55, 56, 17, 21,
859 10, 20, 21, 22, 82, 24, 25, 26, 27, 28,
860 29, 30, 31, 32, 33, 34, 35, 36, 37, 38,
861 39, 40, 41, 42, 43, 4, 45, 46, 47, 48,
862 49, 50, 51, 52, 53, 54, 55, 56, 17, -1,
863 -1, 20, 21, 22, -1, 24, 25, 26, 27, 28,
864 29, 30, 31, 32, 33, 34, 35, 36, 37, 38,
865 39, 40, 41, 42, 43, 4, 45, 46, 47, 48,
866 49, 50, 51, 52, 53, 54, 55, 56, 17, -1,
867 -1, 20, 21, 22, -1, 24, 25, 26, 27, 28,
868 29, 30, 31, 32, 33, 34, 35, 36, 37, 38,
869 39, 40, 41, 42, 43, 4, 45, 46, 47, 48,
870 49, 50, 51, 52, 53, 54, 55, 56, 17, -1,
871 -1, 20, -1, 22, -1, 24, 25, 26, 27, 28,
872 29, 30, 31, 32, 33, 34, 35, 36, 37, 38,
873 39, 40, 41, 42, 43, -1, 45, 46, 47, 48,
874 49, 50, 51, 52, 53, 54, 55, 56, 17, -1,
875 -1, 20, 21, 22, -1, 24, 25, 26, 27, 28,
876 29, 30, 31, 32, 33, 34, 35, 36, 37, 38,
877 39, 40, 41, 42, 43, -1, 45, 46, 47, 48,
878 49, 50, 51, 52, 53, 54, 55, 56, 17, -1,
879 -1, 20, 21, 22, -1, 24, 25, 26, 27, 28,
880 29, 30, 31, 32, 33, 34, 35, 36, 37, 38,
881 39, 40, 41, 42, 43, -1, 45, 46, 47, 48,
882 49, 50, 51, 52, 53, 54, 55, 56, 17, -1,
883 -1, 20, -1, 22, -1, 24, 25, 26, 27, 28,
884 29, 30, 31, 32, 33, 34, 35, 36, 37, 38,
885 39, 40, 41, 42, 43, -1, 45, 46, 47, 48,
886 49, 50, 51, 52, 53, 54, 55, 56, 19, 20,
Carl Worth667173e2010-07-28 12:33:56 -0700887 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
Eric Anholtd4a04f32010-07-28 16:58:39 -0700888 36, 37, 38, 39, 40, 41, 42, 43, 39, 40,
889 46, -1, -1, 21, 45, -1, 47, 48, 26, 27,
Carl Worth667173e2010-07-28 12:33:56 -0700890 28, 29, 30, 31, 32, 33, 34, 35, 36, 37,
Eric Anholtd4a04f32010-07-28 16:58:39 -0700891 38, 39, 40, 41, 42, 43, 21, -1, -1, -1,
892 -1, 26, 27, 28, 29, 30, 31, 32, 33, 34,
893 35, 36, 37, 38, 39, 40, 41, 42, 43, 27,
894 28, 29, 30, 31, 32, 33, 34, 35, 36, 37,
895 38, 39, 40, 41, 42, 43, 28, 29, 30, 31,
Carl Worth667173e2010-07-28 12:33:56 -0700896 32, 33, 34, 35, 36, 37, 38, 39, 40, 41,
Eric Anholtd4a04f32010-07-28 16:58:39 -0700897 42, 43, 29, 30, 31, 32, 33, 34, 35, 36,
898 37, 38, 39, 40, 41, 42, 43, 30, 31, 32,
899 33, 34, 35, 36, 37, 38, 39, 40, 41, 42,
900 43, 31, 32, 33, 34, 35, 36, 37, 38, 39,
901 40, 41, 42, 43, 33, 34, 35, 36, 37, 38,
902 39, 40, 41, 42, 43
Carl Worth667173e2010-07-28 12:33:56 -0700903};
904
905/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
906 symbol of state STATE-NUM. */
907static const yytype_uint8 yystos[] =
908{
Eric Anholtd4a04f32010-07-28 16:58:39 -0700909 0, 58, 0, 5, 6, 7, 8, 9, 10, 11,
910 12, 13, 14, 15, 16, 17, 18, 20, 21, 22,
Carl Worth667173e2010-07-28 12:33:56 -0700911 24, 25, 26, 27, 28, 29, 30, 31, 32, 33,
Eric Anholtd4a04f32010-07-28 16:58:39 -0700912 34, 35, 36, 37, 38, 39, 40, 41, 42, 43,
Carl Worth667173e2010-07-28 12:33:56 -0700913 45, 46, 47, 48, 49, 50, 51, 52, 53, 54,
Eric Anholtd4a04f32010-07-28 16:58:39 -0700914 55, 56, 59, 60, 61, 65, 71, 72, 73, 19,
915 20, 39, 40, 45, 47, 48, 62, 63, 21, 66,
916 71, 17, 17, 4, 21, 69, 70, 72, 21, 21,
917 70, 17, 17, 17, 62, 63, 21, 72, 63, 63,
918 63, 63, 63, 21, 26, 27, 28, 29, 30, 31,
919 32, 33, 34, 35, 36, 37, 38, 39, 40, 41,
920 42, 43, 21, 45, 67, 71, 17, 45, 21, 69,
921 21, 68, 71, 68, 21, 21, 21, 46, 63, 63,
922 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
923 63, 63, 63, 63, 63, 63, 17, 46, 64, 21,
924 17, 21, 21, 67, 46, 49, 46, 21, 67, 17,
925 21
Carl Worth667173e2010-07-28 12:33:56 -0700926};
927
928#define yyerrok (yyerrstatus = 0)
929#define yyclearin (yychar = YYEMPTY)
930#define YYEMPTY (-2)
931#define YYEOF 0
932
933#define YYACCEPT goto yyacceptlab
934#define YYABORT goto yyabortlab
935#define YYERROR goto yyerrorlab
936
937
938/* Like YYERROR except do call yyerror. This remains here temporarily
939 to ease the transition to the new meaning of YYERROR, for GCC.
Carl Worthe29cd392010-08-10 16:59:20 -0700940 Once GCC version 2 has supplanted version 1, this can go. */
Carl Worth667173e2010-07-28 12:33:56 -0700941
942#define YYFAIL goto yyerrlab
943
944#define YYRECOVERING() (!!yyerrstatus)
945
946#define YYBACKUP(Token, Value) \
947do \
948 if (yychar == YYEMPTY && yylen == 1) \
949 { \
950 yychar = (Token); \
951 yylval = (Value); \
952 yytoken = YYTRANSLATE (yychar); \
953 YYPOPSTACK (1); \
954 goto yybackup; \
955 } \
956 else \
957 { \
958 yyerror (&yylloc, parser, YY_("syntax error: cannot back up")); \
959 YYERROR; \
960 } \
961while (YYID (0))
962
963
964#define YYTERROR 1
965#define YYERRCODE 256
966
967
968/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
969 If N is 0, then set CURRENT to the empty location which ends
970 the previous symbol: RHS[0] (always defined). */
971
972#define YYRHSLOC(Rhs, K) ((Rhs)[K])
973#ifndef YYLLOC_DEFAULT
974# define YYLLOC_DEFAULT(Current, Rhs, N) \
975 do \
976 if (YYID (N)) \
977 { \
978 (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
979 (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
980 (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
981 (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
982 } \
983 else \
984 { \
985 (Current).first_line = (Current).last_line = \
986 YYRHSLOC (Rhs, 0).last_line; \
987 (Current).first_column = (Current).last_column = \
988 YYRHSLOC (Rhs, 0).last_column; \
989 } \
990 while (YYID (0))
991#endif
992
993
994/* YY_LOCATION_PRINT -- Print the location on the stream.
995 This macro was not mandated originally: define only if we know
996 we won't break user code: when these are the locations we know. */
997
998#ifndef YY_LOCATION_PRINT
Carl Worthe29cd392010-08-10 16:59:20 -0700999# if YYLTYPE_IS_TRIVIAL
Carl Worth667173e2010-07-28 12:33:56 -07001000# define YY_LOCATION_PRINT(File, Loc) \
1001 fprintf (File, "%d.%d-%d.%d", \
1002 (Loc).first_line, (Loc).first_column, \
1003 (Loc).last_line, (Loc).last_column)
1004# else
1005# define YY_LOCATION_PRINT(File, Loc) ((void) 0)
1006# endif
1007#endif
1008
1009
1010/* YYLEX -- calling `yylex' with the right arguments. */
1011
1012#ifdef YYLEX_PARAM
1013# define YYLEX yylex (&yylval, &yylloc, YYLEX_PARAM)
1014#else
1015# define YYLEX yylex (&yylval, &yylloc, parser)
1016#endif
1017
1018/* Enable debugging if requested. */
1019#if YYDEBUG
1020
1021# ifndef YYFPRINTF
1022# include <stdio.h> /* INFRINGES ON USER NAME SPACE */
1023# define YYFPRINTF fprintf
1024# endif
1025
1026# define YYDPRINTF(Args) \
1027do { \
1028 if (yydebug) \
1029 YYFPRINTF Args; \
1030} while (YYID (0))
1031
1032# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
1033do { \
1034 if (yydebug) \
1035 { \
1036 YYFPRINTF (stderr, "%s ", Title); \
1037 yy_symbol_print (stderr, \
1038 Type, Value, Location, parser); \
1039 YYFPRINTF (stderr, "\n"); \
1040 } \
1041} while (YYID (0))
1042
1043
1044/*--------------------------------.
1045| Print this symbol on YYOUTPUT. |
1046`--------------------------------*/
1047
1048/*ARGSUSED*/
1049#if (defined __STDC__ || defined __C99__FUNC__ \
1050 || defined __cplusplus || defined _MSC_VER)
1051static void
1052yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, YYLTYPE const * const yylocationp, glcpp_parser_t *parser)
1053#else
1054static void
1055yy_symbol_value_print (yyoutput, yytype, yyvaluep, yylocationp, parser)
1056 FILE *yyoutput;
1057 int yytype;
1058 YYSTYPE const * const yyvaluep;
1059 YYLTYPE const * const yylocationp;
1060 glcpp_parser_t *parser;
1061#endif
1062{
1063 if (!yyvaluep)
1064 return;
1065 YYUSE (yylocationp);
1066 YYUSE (parser);
1067# ifdef YYPRINT
1068 if (yytype < YYNTOKENS)
1069 YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
1070# else
1071 YYUSE (yyoutput);
1072# endif
1073 switch (yytype)
1074 {
1075 default:
1076 break;
1077 }
1078}
1079
1080
1081/*--------------------------------.
1082| Print this symbol on YYOUTPUT. |
1083`--------------------------------*/
1084
1085#if (defined __STDC__ || defined __C99__FUNC__ \
1086 || defined __cplusplus || defined _MSC_VER)
1087static void
1088yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, YYLTYPE const * const yylocationp, glcpp_parser_t *parser)
1089#else
1090static void
1091yy_symbol_print (yyoutput, yytype, yyvaluep, yylocationp, parser)
1092 FILE *yyoutput;
1093 int yytype;
1094 YYSTYPE const * const yyvaluep;
1095 YYLTYPE const * const yylocationp;
1096 glcpp_parser_t *parser;
1097#endif
1098{
1099 if (yytype < YYNTOKENS)
1100 YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
1101 else
1102 YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
1103
1104 YY_LOCATION_PRINT (yyoutput, *yylocationp);
1105 YYFPRINTF (yyoutput, ": ");
1106 yy_symbol_value_print (yyoutput, yytype, yyvaluep, yylocationp, parser);
1107 YYFPRINTF (yyoutput, ")");
1108}
1109
1110/*------------------------------------------------------------------.
1111| yy_stack_print -- Print the state stack from its BOTTOM up to its |
1112| TOP (included). |
1113`------------------------------------------------------------------*/
1114
1115#if (defined __STDC__ || defined __C99__FUNC__ \
1116 || defined __cplusplus || defined _MSC_VER)
1117static void
1118yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop)
1119#else
1120static void
1121yy_stack_print (yybottom, yytop)
1122 yytype_int16 *yybottom;
1123 yytype_int16 *yytop;
1124#endif
1125{
1126 YYFPRINTF (stderr, "Stack now");
1127 for (; yybottom <= yytop; yybottom++)
1128 {
1129 int yybot = *yybottom;
1130 YYFPRINTF (stderr, " %d", yybot);
1131 }
1132 YYFPRINTF (stderr, "\n");
1133}
1134
1135# define YY_STACK_PRINT(Bottom, Top) \
1136do { \
1137 if (yydebug) \
1138 yy_stack_print ((Bottom), (Top)); \
1139} while (YYID (0))
1140
1141
1142/*------------------------------------------------.
1143| Report that the YYRULE is going to be reduced. |
1144`------------------------------------------------*/
1145
1146#if (defined __STDC__ || defined __C99__FUNC__ \
1147 || defined __cplusplus || defined _MSC_VER)
1148static void
1149yy_reduce_print (YYSTYPE *yyvsp, YYLTYPE *yylsp, int yyrule, glcpp_parser_t *parser)
1150#else
1151static void
1152yy_reduce_print (yyvsp, yylsp, yyrule, parser)
1153 YYSTYPE *yyvsp;
1154 YYLTYPE *yylsp;
1155 int yyrule;
1156 glcpp_parser_t *parser;
1157#endif
1158{
1159 int yynrhs = yyr2[yyrule];
1160 int yyi;
1161 unsigned long int yylno = yyrline[yyrule];
1162 YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
1163 yyrule - 1, yylno);
1164 /* The symbols being reduced. */
1165 for (yyi = 0; yyi < yynrhs; yyi++)
1166 {
1167 YYFPRINTF (stderr, " $%d = ", yyi + 1);
1168 yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
1169 &(yyvsp[(yyi + 1) - (yynrhs)])
1170 , &(yylsp[(yyi + 1) - (yynrhs)]) , parser);
1171 YYFPRINTF (stderr, "\n");
1172 }
1173}
1174
1175# define YY_REDUCE_PRINT(Rule) \
1176do { \
1177 if (yydebug) \
1178 yy_reduce_print (yyvsp, yylsp, Rule, parser); \
1179} while (YYID (0))
1180
1181/* Nonzero means print parse trace. It is left uninitialized so that
1182 multiple parsers can coexist. */
1183int yydebug;
1184#else /* !YYDEBUG */
1185# define YYDPRINTF(Args)
1186# define YY_SYMBOL_PRINT(Title, Type, Value, Location)
1187# define YY_STACK_PRINT(Bottom, Top)
1188# define YY_REDUCE_PRINT(Rule)
1189#endif /* !YYDEBUG */
1190
1191
1192/* YYINITDEPTH -- initial size of the parser's stacks. */
1193#ifndef YYINITDEPTH
1194# define YYINITDEPTH 200
1195#endif
1196
1197/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
1198 if the built-in stack extension method is used).
1199
1200 Do not make this value too large; the results are undefined if
1201 YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
1202 evaluated with infinite-precision integer arithmetic. */
1203
1204#ifndef YYMAXDEPTH
1205# define YYMAXDEPTH 10000
1206#endif
1207
1208
1209
1210#if YYERROR_VERBOSE
1211
1212# ifndef yystrlen
1213# if defined __GLIBC__ && defined _STRING_H
1214# define yystrlen strlen
1215# else
1216/* Return the length of YYSTR. */
1217#if (defined __STDC__ || defined __C99__FUNC__ \
1218 || defined __cplusplus || defined _MSC_VER)
1219static YYSIZE_T
1220yystrlen (const char *yystr)
1221#else
1222static YYSIZE_T
1223yystrlen (yystr)
1224 const char *yystr;
1225#endif
1226{
1227 YYSIZE_T yylen;
1228 for (yylen = 0; yystr[yylen]; yylen++)
1229 continue;
1230 return yylen;
1231}
1232# endif
1233# endif
1234
1235# ifndef yystpcpy
1236# if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
1237# define yystpcpy stpcpy
1238# else
1239/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
1240 YYDEST. */
1241#if (defined __STDC__ || defined __C99__FUNC__ \
1242 || defined __cplusplus || defined _MSC_VER)
1243static char *
1244yystpcpy (char *yydest, const char *yysrc)
1245#else
1246static char *
1247yystpcpy (yydest, yysrc)
1248 char *yydest;
1249 const char *yysrc;
1250#endif
1251{
1252 char *yyd = yydest;
1253 const char *yys = yysrc;
1254
1255 while ((*yyd++ = *yys++) != '\0')
1256 continue;
1257
1258 return yyd - 1;
1259}
1260# endif
1261# endif
1262
1263# ifndef yytnamerr
1264/* Copy to YYRES the contents of YYSTR after stripping away unnecessary
1265 quotes and backslashes, so that it's suitable for yyerror. The
1266 heuristic is that double-quoting is unnecessary unless the string
1267 contains an apostrophe, a comma, or backslash (other than
1268 backslash-backslash). YYSTR is taken from yytname. If YYRES is
1269 null, do not copy; instead, return the length of what the result
1270 would have been. */
1271static YYSIZE_T
1272yytnamerr (char *yyres, const char *yystr)
1273{
1274 if (*yystr == '"')
1275 {
1276 YYSIZE_T yyn = 0;
1277 char const *yyp = yystr;
1278
1279 for (;;)
1280 switch (*++yyp)
1281 {
1282 case '\'':
1283 case ',':
1284 goto do_not_strip_quotes;
1285
1286 case '\\':
1287 if (*++yyp != '\\')
1288 goto do_not_strip_quotes;
1289 /* Fall through. */
1290 default:
1291 if (yyres)
1292 yyres[yyn] = *yyp;
1293 yyn++;
1294 break;
1295
1296 case '"':
1297 if (yyres)
1298 yyres[yyn] = '\0';
1299 return yyn;
1300 }
1301 do_not_strip_quotes: ;
1302 }
1303
1304 if (! yyres)
1305 return yystrlen (yystr);
1306
1307 return yystpcpy (yyres, yystr) - yyres;
1308}
1309# endif
1310
1311/* Copy into YYRESULT an error message about the unexpected token
1312 YYCHAR while in state YYSTATE. Return the number of bytes copied,
1313 including the terminating null byte. If YYRESULT is null, do not
1314 copy anything; just return the number of bytes that would be
1315 copied. As a special case, return 0 if an ordinary "syntax error"
1316 message will do. Return YYSIZE_MAXIMUM if overflow occurs during
1317 size calculation. */
1318static YYSIZE_T
1319yysyntax_error (char *yyresult, int yystate, int yychar)
1320{
1321 int yyn = yypact[yystate];
1322
1323 if (! (YYPACT_NINF < yyn && yyn <= YYLAST))
1324 return 0;
1325 else
1326 {
1327 int yytype = YYTRANSLATE (yychar);
1328 YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]);
1329 YYSIZE_T yysize = yysize0;
1330 YYSIZE_T yysize1;
1331 int yysize_overflow = 0;
1332 enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
1333 char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
1334 int yyx;
1335
1336# if 0
1337 /* This is so xgettext sees the translatable formats that are
1338 constructed on the fly. */
1339 YY_("syntax error, unexpected %s");
1340 YY_("syntax error, unexpected %s, expecting %s");
1341 YY_("syntax error, unexpected %s, expecting %s or %s");
1342 YY_("syntax error, unexpected %s, expecting %s or %s or %s");
1343 YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s");
1344# endif
1345 char *yyfmt;
1346 char const *yyf;
1347 static char const yyunexpected[] = "syntax error, unexpected %s";
1348 static char const yyexpecting[] = ", expecting %s";
1349 static char const yyor[] = " or %s";
1350 char yyformat[sizeof yyunexpected
1351 + sizeof yyexpecting - 1
1352 + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2)
1353 * (sizeof yyor - 1))];
1354 char const *yyprefix = yyexpecting;
1355
1356 /* Start YYX at -YYN if negative to avoid negative indexes in
1357 YYCHECK. */
1358 int yyxbegin = yyn < 0 ? -yyn : 0;
1359
1360 /* Stay within bounds of both yycheck and yytname. */
1361 int yychecklim = YYLAST - yyn + 1;
1362 int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
1363 int yycount = 1;
1364
1365 yyarg[0] = yytname[yytype];
1366 yyfmt = yystpcpy (yyformat, yyunexpected);
1367
1368 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
1369 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
1370 {
1371 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
1372 {
1373 yycount = 1;
1374 yysize = yysize0;
1375 yyformat[sizeof yyunexpected - 1] = '\0';
1376 break;
1377 }
1378 yyarg[yycount++] = yytname[yyx];
1379 yysize1 = yysize + yytnamerr (0, yytname[yyx]);
1380 yysize_overflow |= (yysize1 < yysize);
1381 yysize = yysize1;
1382 yyfmt = yystpcpy (yyfmt, yyprefix);
1383 yyprefix = yyor;
1384 }
1385
1386 yyf = YY_(yyformat);
1387 yysize1 = yysize + yystrlen (yyf);
1388 yysize_overflow |= (yysize1 < yysize);
1389 yysize = yysize1;
1390
1391 if (yysize_overflow)
1392 return YYSIZE_MAXIMUM;
1393
1394 if (yyresult)
1395 {
1396 /* Avoid sprintf, as that infringes on the user's name space.
1397 Don't have undefined behavior even if the translation
1398 produced a string with the wrong number of "%s"s. */
1399 char *yyp = yyresult;
1400 int yyi = 0;
1401 while ((*yyp = *yyf) != '\0')
1402 {
1403 if (*yyp == '%' && yyf[1] == 's' && yyi < yycount)
1404 {
1405 yyp += yytnamerr (yyp, yyarg[yyi++]);
1406 yyf += 2;
1407 }
1408 else
1409 {
1410 yyp++;
1411 yyf++;
1412 }
1413 }
1414 }
1415 return yysize;
1416 }
1417}
1418#endif /* YYERROR_VERBOSE */
1419
1420
1421/*-----------------------------------------------.
1422| Release the memory associated to this symbol. |
1423`-----------------------------------------------*/
1424
1425/*ARGSUSED*/
1426#if (defined __STDC__ || defined __C99__FUNC__ \
1427 || defined __cplusplus || defined _MSC_VER)
1428static void
1429yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, YYLTYPE *yylocationp, glcpp_parser_t *parser)
1430#else
1431static void
1432yydestruct (yymsg, yytype, yyvaluep, yylocationp, parser)
1433 const char *yymsg;
1434 int yytype;
1435 YYSTYPE *yyvaluep;
1436 YYLTYPE *yylocationp;
1437 glcpp_parser_t *parser;
1438#endif
1439{
1440 YYUSE (yyvaluep);
1441 YYUSE (yylocationp);
1442 YYUSE (parser);
1443
1444 if (!yymsg)
1445 yymsg = "Deleting";
1446 YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
1447
1448 switch (yytype)
1449 {
1450
1451 default:
1452 break;
1453 }
1454}
1455
1456/* Prevent warnings from -Wmissing-prototypes. */
1457#ifdef YYPARSE_PARAM
1458#if defined __STDC__ || defined __cplusplus
1459int yyparse (void *YYPARSE_PARAM);
1460#else
1461int yyparse ();
1462#endif
1463#else /* ! YYPARSE_PARAM */
1464#if defined __STDC__ || defined __cplusplus
1465int yyparse (glcpp_parser_t *parser);
1466#else
1467int yyparse ();
1468#endif
1469#endif /* ! YYPARSE_PARAM */
1470
1471
1472
1473
1474
1475/*-------------------------.
1476| yyparse or yypush_parse. |
1477`-------------------------*/
1478
1479#ifdef YYPARSE_PARAM
1480#if (defined __STDC__ || defined __C99__FUNC__ \
1481 || defined __cplusplus || defined _MSC_VER)
1482int
1483yyparse (void *YYPARSE_PARAM)
1484#else
1485int
1486yyparse (YYPARSE_PARAM)
1487 void *YYPARSE_PARAM;
1488#endif
1489#else /* ! YYPARSE_PARAM */
1490#if (defined __STDC__ || defined __C99__FUNC__ \
1491 || defined __cplusplus || defined _MSC_VER)
1492int
1493yyparse (glcpp_parser_t *parser)
1494#else
1495int
1496yyparse (parser)
1497 glcpp_parser_t *parser;
1498#endif
1499#endif
1500{
1501/* The lookahead symbol. */
1502int yychar;
1503
1504/* The semantic value of the lookahead symbol. */
1505YYSTYPE yylval;
1506
1507/* Location data for the lookahead symbol. */
1508YYLTYPE yylloc;
1509
1510 /* Number of syntax errors so far. */
1511 int yynerrs;
1512
1513 int yystate;
1514 /* Number of tokens to shift before error messages enabled. */
1515 int yyerrstatus;
1516
1517 /* The stacks and their tools:
1518 `yyss': related to states.
1519 `yyvs': related to semantic values.
1520 `yyls': related to locations.
1521
1522 Refer to the stacks thru separate pointers, to allow yyoverflow
1523 to reallocate them elsewhere. */
1524
1525 /* The state stack. */
1526 yytype_int16 yyssa[YYINITDEPTH];
1527 yytype_int16 *yyss;
1528 yytype_int16 *yyssp;
1529
1530 /* The semantic value stack. */
1531 YYSTYPE yyvsa[YYINITDEPTH];
1532 YYSTYPE *yyvs;
1533 YYSTYPE *yyvsp;
1534
1535 /* The location stack. */
1536 YYLTYPE yylsa[YYINITDEPTH];
1537 YYLTYPE *yyls;
1538 YYLTYPE *yylsp;
1539
1540 /* The locations where the error started and ended. */
1541 YYLTYPE yyerror_range[2];
1542
1543 YYSIZE_T yystacksize;
1544
1545 int yyn;
1546 int yyresult;
1547 /* Lookahead token as an internal (translated) token number. */
1548 int yytoken;
1549 /* The variables used to return semantic value and location from the
1550 action routines. */
1551 YYSTYPE yyval;
1552 YYLTYPE yyloc;
1553
1554#if YYERROR_VERBOSE
1555 /* Buffer for error messages, and its allocated size. */
1556 char yymsgbuf[128];
1557 char *yymsg = yymsgbuf;
1558 YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
1559#endif
1560
1561#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N), yylsp -= (N))
1562
1563 /* The number of symbols on the RHS of the reduced rule.
1564 Keep to zero when no symbol should be popped. */
1565 int yylen = 0;
1566
1567 yytoken = 0;
1568 yyss = yyssa;
1569 yyvs = yyvsa;
1570 yyls = yylsa;
1571 yystacksize = YYINITDEPTH;
1572
1573 YYDPRINTF ((stderr, "Starting parse\n"));
1574
1575 yystate = 0;
1576 yyerrstatus = 0;
1577 yynerrs = 0;
1578 yychar = YYEMPTY; /* Cause a token to be read. */
1579
1580 /* Initialize stack pointers.
1581 Waste one element of value and location stack
1582 so that they stay on the same level as the state stack.
1583 The wasted elements are never initialized. */
1584 yyssp = yyss;
1585 yyvsp = yyvs;
1586 yylsp = yyls;
1587
Carl Worthe29cd392010-08-10 16:59:20 -07001588#if YYLTYPE_IS_TRIVIAL
Carl Worth667173e2010-07-28 12:33:56 -07001589 /* Initialize the default location before parsing starts. */
1590 yylloc.first_line = yylloc.last_line = 1;
1591 yylloc.first_column = yylloc.last_column = 1;
1592#endif
1593
Carl Worthe29cd392010-08-10 16:59:20 -07001594/* User initialization code. */
1595
1596/* Line 1242 of yacc.c */
1597#line 147 "glcpp/glcpp-parse.y"
1598{
1599 yylloc.first_line = 1;
1600 yylloc.first_column = 1;
1601 yylloc.last_line = 1;
1602 yylloc.last_column = 1;
1603 yylloc.source = 0;
1604}
1605
1606/* Line 1242 of yacc.c */
1607#line 1608 "glcpp/glcpp-parse.c"
1608 yylsp[0] = yylloc;
1609
Carl Worth667173e2010-07-28 12:33:56 -07001610 goto yysetstate;
1611
1612/*------------------------------------------------------------.
1613| yynewstate -- Push a new state, which is found in yystate. |
1614`------------------------------------------------------------*/
1615 yynewstate:
1616 /* In all cases, when you get here, the value and location stacks
1617 have just been pushed. So pushing a state here evens the stacks. */
1618 yyssp++;
1619
1620 yysetstate:
1621 *yyssp = yystate;
1622
1623 if (yyss + yystacksize - 1 <= yyssp)
1624 {
1625 /* Get the current used size of the three stacks, in elements. */
1626 YYSIZE_T yysize = yyssp - yyss + 1;
1627
1628#ifdef yyoverflow
1629 {
1630 /* Give user a chance to reallocate the stack. Use copies of
1631 these so that the &'s don't force the real ones into
1632 memory. */
1633 YYSTYPE *yyvs1 = yyvs;
1634 yytype_int16 *yyss1 = yyss;
1635 YYLTYPE *yyls1 = yyls;
1636
1637 /* Each stack pointer address is followed by the size of the
1638 data in use in that stack, in bytes. This used to be a
1639 conditional around just the two extra args, but that might
1640 be undefined if yyoverflow is a macro. */
1641 yyoverflow (YY_("memory exhausted"),
1642 &yyss1, yysize * sizeof (*yyssp),
1643 &yyvs1, yysize * sizeof (*yyvsp),
1644 &yyls1, yysize * sizeof (*yylsp),
1645 &yystacksize);
1646
1647 yyls = yyls1;
1648 yyss = yyss1;
1649 yyvs = yyvs1;
1650 }
1651#else /* no yyoverflow */
1652# ifndef YYSTACK_RELOCATE
1653 goto yyexhaustedlab;
1654# else
1655 /* Extend the stack our own way. */
1656 if (YYMAXDEPTH <= yystacksize)
1657 goto yyexhaustedlab;
1658 yystacksize *= 2;
1659 if (YYMAXDEPTH < yystacksize)
1660 yystacksize = YYMAXDEPTH;
1661
1662 {
1663 yytype_int16 *yyss1 = yyss;
1664 union yyalloc *yyptr =
1665 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
1666 if (! yyptr)
1667 goto yyexhaustedlab;
1668 YYSTACK_RELOCATE (yyss_alloc, yyss);
1669 YYSTACK_RELOCATE (yyvs_alloc, yyvs);
1670 YYSTACK_RELOCATE (yyls_alloc, yyls);
1671# undef YYSTACK_RELOCATE
1672 if (yyss1 != yyssa)
1673 YYSTACK_FREE (yyss1);
1674 }
1675# endif
1676#endif /* no yyoverflow */
1677
1678 yyssp = yyss + yysize - 1;
1679 yyvsp = yyvs + yysize - 1;
1680 yylsp = yyls + yysize - 1;
1681
1682 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
1683 (unsigned long int) yystacksize));
1684
1685 if (yyss + yystacksize - 1 <= yyssp)
1686 YYABORT;
1687 }
1688
1689 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
1690
1691 if (yystate == YYFINAL)
1692 YYACCEPT;
1693
1694 goto yybackup;
1695
1696/*-----------.
1697| yybackup. |
1698`-----------*/
1699yybackup:
1700
1701 /* Do appropriate processing given the current state. Read a
1702 lookahead token if we need one and don't already have one. */
1703
1704 /* First try to decide what to do without reference to lookahead token. */
1705 yyn = yypact[yystate];
1706 if (yyn == YYPACT_NINF)
1707 goto yydefault;
1708
1709 /* Not known => get a lookahead token if don't already have one. */
1710
1711 /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */
1712 if (yychar == YYEMPTY)
1713 {
1714 YYDPRINTF ((stderr, "Reading a token: "));
1715 yychar = YYLEX;
1716 }
1717
1718 if (yychar <= YYEOF)
1719 {
1720 yychar = yytoken = YYEOF;
1721 YYDPRINTF ((stderr, "Now at end of input.\n"));
1722 }
1723 else
1724 {
1725 yytoken = YYTRANSLATE (yychar);
1726 YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
1727 }
1728
1729 /* If the proper action on seeing token YYTOKEN is to reduce or to
1730 detect an error, take that action. */
1731 yyn += yytoken;
1732 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
1733 goto yydefault;
1734 yyn = yytable[yyn];
1735 if (yyn <= 0)
1736 {
1737 if (yyn == 0 || yyn == YYTABLE_NINF)
1738 goto yyerrlab;
1739 yyn = -yyn;
1740 goto yyreduce;
1741 }
1742
1743 /* Count tokens shifted since error; after three, turn off error
1744 status. */
1745 if (yyerrstatus)
1746 yyerrstatus--;
1747
1748 /* Shift the lookahead token. */
1749 YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
1750
1751 /* Discard the shifted token. */
1752 yychar = YYEMPTY;
1753
1754 yystate = yyn;
1755 *++yyvsp = yylval;
1756 *++yylsp = yylloc;
1757 goto yynewstate;
1758
1759
1760/*-----------------------------------------------------------.
1761| yydefault -- do the default action for the current state. |
1762`-----------------------------------------------------------*/
1763yydefault:
1764 yyn = yydefact[yystate];
1765 if (yyn == 0)
1766 goto yyerrlab;
1767 goto yyreduce;
1768
1769
1770/*-----------------------------.
1771| yyreduce -- Do a reduction. |
1772`-----------------------------*/
1773yyreduce:
1774 /* yyn is the number of a rule to reduce with. */
1775 yylen = yyr2[yyn];
1776
1777 /* If YYLEN is nonzero, implement the default value of the action:
1778 `$$ = $1'.
1779
1780 Otherwise, the following line sets YYVAL to garbage.
1781 This behavior is undocumented and Bison
1782 users should not rely upon it. Assigning to YYVAL
1783 unconditionally makes the parser a bit smaller, and it avoids a
1784 GCC warning that YYVAL may be used uninitialized. */
1785 yyval = yyvsp[1-yylen];
1786
1787 /* Default location. */
1788 YYLLOC_DEFAULT (yyloc, (yylsp - yylen), yylen);
1789 YY_REDUCE_PRINT (yyn);
1790 switch (yyn)
1791 {
1792 case 4:
1793
Carl Worthe29cd392010-08-10 16:59:20 -07001794/* Line 1455 of yacc.c */
1795#line 186 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07001796 {
1797 glcpp_print(parser->output, "\n");
1798 ;}
1799 break;
1800
1801 case 5:
1802
Carl Worthe29cd392010-08-10 16:59:20 -07001803/* Line 1455 of yacc.c */
1804#line 189 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07001805 {
1806 _glcpp_parser_print_expanded_token_list (parser, (yyvsp[(1) - (1)].token_list));
1807 glcpp_print(parser->output, "\n");
1808 talloc_free ((yyvsp[(1) - (1)].token_list));
1809 ;}
1810 break;
1811
1812 case 8:
1813
Carl Worthe29cd392010-08-10 16:59:20 -07001814/* Line 1455 of yacc.c */
1815#line 199 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07001816 {
1817 _glcpp_parser_skip_stack_push_if (parser, & (yylsp[(1) - (3)]), (yyvsp[(2) - (3)].ival));
1818 ;}
1819 break;
1820
1821 case 9:
1822
Carl Worthe29cd392010-08-10 16:59:20 -07001823/* Line 1455 of yacc.c */
1824#line 202 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07001825 {
1826 _glcpp_parser_skip_stack_change_if (parser, & (yylsp[(1) - (3)]), "elif", (yyvsp[(2) - (3)].ival));
1827 ;}
1828 break;
1829
1830 case 10:
1831
Carl Worthe29cd392010-08-10 16:59:20 -07001832/* Line 1455 of yacc.c */
1833#line 208 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07001834 {
1835 _define_object_macro (parser, & (yylsp[(2) - (4)]), (yyvsp[(2) - (4)].str), (yyvsp[(3) - (4)].token_list));
1836 ;}
1837 break;
1838
1839 case 11:
1840
Carl Worthe29cd392010-08-10 16:59:20 -07001841/* Line 1455 of yacc.c */
1842#line 211 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07001843 {
1844 _define_function_macro (parser, & (yylsp[(2) - (6)]), (yyvsp[(2) - (6)].str), NULL, (yyvsp[(5) - (6)].token_list));
1845 ;}
1846 break;
1847
1848 case 12:
1849
Carl Worthe29cd392010-08-10 16:59:20 -07001850/* Line 1455 of yacc.c */
1851#line 214 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07001852 {
1853 _define_function_macro (parser, & (yylsp[(2) - (7)]), (yyvsp[(2) - (7)].str), (yyvsp[(4) - (7)].string_list), (yyvsp[(6) - (7)].token_list));
1854 ;}
1855 break;
1856
1857 case 13:
1858
Carl Worthe29cd392010-08-10 16:59:20 -07001859/* Line 1455 of yacc.c */
1860#line 217 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07001861 {
1862 macro_t *macro = hash_table_find (parser->defines, (yyvsp[(2) - (3)].str));
1863 if (macro) {
1864 hash_table_remove (parser->defines, (yyvsp[(2) - (3)].str));
1865 talloc_free (macro);
1866 }
1867 talloc_free ((yyvsp[(2) - (3)].str));
1868 ;}
1869 break;
1870
1871 case 14:
1872
Carl Worthe29cd392010-08-10 16:59:20 -07001873/* Line 1455 of yacc.c */
1874#line 225 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07001875 {
Kenneth Graunkef4239872010-08-04 16:24:39 -07001876 /* If we're skipping to the next #elif/#else case or to #endif,
1877 * don't bother expanding or parsing the expression.
1878 */
1879 if (parser->skip_stack != NULL && parser->skip_stack->type != SKIP_NO_SKIP) {
1880 _glcpp_parser_skip_stack_push_if (parser, & (yylsp[(1) - (3)]), 0);
1881 parser->skip_stack->type = SKIP_TO_ENDIF;
1882 } else {
1883 _glcpp_parser_expand_if (parser, IF_EXPANDED, (yyvsp[(2) - (3)].token_list));
1884 }
Carl Worth667173e2010-07-28 12:33:56 -07001885 ;}
1886 break;
1887
1888 case 15:
1889
Carl Worthe29cd392010-08-10 16:59:20 -07001890/* Line 1455 of yacc.c */
1891#line 236 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07001892 {
1893 macro_t *macro = hash_table_find (parser->defines, (yyvsp[(2) - (4)].str));
1894 talloc_free ((yyvsp[(2) - (4)].str));
1895 _glcpp_parser_skip_stack_push_if (parser, & (yylsp[(1) - (4)]), macro != NULL);
1896 ;}
1897 break;
1898
1899 case 16:
1900
Carl Worthe29cd392010-08-10 16:59:20 -07001901/* Line 1455 of yacc.c */
1902#line 241 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07001903 {
1904 macro_t *macro = hash_table_find (parser->defines, (yyvsp[(2) - (4)].str));
1905 talloc_free ((yyvsp[(2) - (4)].str));
1906 _glcpp_parser_skip_stack_push_if (parser, & (yylsp[(1) - (4)]), macro == NULL);
1907 ;}
1908 break;
1909
1910 case 17:
1911
Carl Worthe29cd392010-08-10 16:59:20 -07001912/* Line 1455 of yacc.c */
1913#line 246 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07001914 {
Kenneth Graunkef4239872010-08-04 16:24:39 -07001915 /* If we just finished a non-skipped #if/#ifdef/#ifndef block,
1916 * don't bother expanding or parsing the expression.
1917 */
1918 if (parser->skip_stack != NULL && parser->skip_stack->type == SKIP_NO_SKIP)
1919 parser->skip_stack->type = SKIP_TO_ENDIF;
1920 else
1921 _glcpp_parser_expand_if (parser, ELIF_EXPANDED, (yyvsp[(2) - (3)].token_list));
Carl Worth667173e2010-07-28 12:33:56 -07001922 ;}
1923 break;
1924
1925 case 18:
1926
Carl Worthe29cd392010-08-10 16:59:20 -07001927/* Line 1455 of yacc.c */
1928#line 255 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07001929 {
1930 /* #elif without an expression results in a warning if the
1931 * condition doesn't matter (we just handled #if 1 or such)
1932 * but an error otherwise. */
1933 if (parser->skip_stack != NULL && parser->skip_stack->type == SKIP_NO_SKIP) {
1934 parser->skip_stack->type = SKIP_TO_ENDIF;
1935 glcpp_warning(& (yylsp[(1) - (2)]), parser, "ignoring illegal #elif without expression");
1936 } else {
1937 glcpp_error(& (yylsp[(1) - (2)]), parser, "#elif needs an expression");
1938 }
1939 ;}
1940 break;
1941
1942 case 19:
1943
Carl Worthe29cd392010-08-10 16:59:20 -07001944/* Line 1455 of yacc.c */
1945#line 266 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07001946 {
1947 _glcpp_parser_skip_stack_change_if (parser, & (yylsp[(1) - (2)]), "else", 1);
1948 ;}
1949 break;
1950
1951 case 20:
1952
Carl Worthe29cd392010-08-10 16:59:20 -07001953/* Line 1455 of yacc.c */
1954#line 269 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07001955 {
1956 _glcpp_parser_skip_stack_pop (parser, & (yylsp[(1) - (2)]));
1957 ;}
1958 break;
1959
Eric Anholtd4a04f32010-07-28 16:58:39 -07001960 case 21:
Carl Worth667173e2010-07-28 12:33:56 -07001961
Carl Worthe29cd392010-08-10 16:59:20 -07001962/* Line 1455 of yacc.c */
1963#line 272 "glcpp/glcpp-parse.y"
Eric Anholtd4a04f32010-07-28 16:58:39 -07001964 {
1965 macro_t *macro = hash_table_find (parser->defines, "__VERSION__");
1966 if (macro) {
1967 hash_table_remove (parser->defines, "__VERSION__");
1968 talloc_free (macro);
1969 }
1970 add_builtin_define (parser, "__VERSION__", (yyvsp[(2) - (3)].ival));
1971 glcpp_printf(parser->output, "#version %" PRIiMAX "\n", (yyvsp[(2) - (3)].ival));
1972 ;}
1973 break;
1974
1975 case 23:
1976
Carl Worthe29cd392010-08-10 16:59:20 -07001977/* Line 1455 of yacc.c */
1978#line 285 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07001979 {
1980 if (strlen ((yyvsp[(1) - (1)].str)) >= 3 && strncmp ((yyvsp[(1) - (1)].str), "0x", 2) == 0) {
1981 (yyval.ival) = strtoll ((yyvsp[(1) - (1)].str) + 2, NULL, 16);
1982 } else if ((yyvsp[(1) - (1)].str)[0] == '0') {
1983 (yyval.ival) = strtoll ((yyvsp[(1) - (1)].str), NULL, 8);
1984 } else {
1985 (yyval.ival) = strtoll ((yyvsp[(1) - (1)].str), NULL, 10);
1986 }
1987 ;}
1988 break;
1989
Carl Worth667173e2010-07-28 12:33:56 -07001990 case 24:
1991
Carl Worthe29cd392010-08-10 16:59:20 -07001992/* Line 1455 of yacc.c */
1993#line 294 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07001994 {
Eric Anholtd4a04f32010-07-28 16:58:39 -07001995 (yyval.ival) = (yyvsp[(1) - (1)].ival);
Carl Worth667173e2010-07-28 12:33:56 -07001996 ;}
1997 break;
1998
1999 case 26:
2000
Carl Worthe29cd392010-08-10 16:59:20 -07002001/* Line 1455 of yacc.c */
2002#line 300 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07002003 {
Eric Anholtd4a04f32010-07-28 16:58:39 -07002004 (yyval.ival) = (yyvsp[(1) - (3)].ival) || (yyvsp[(3) - (3)].ival);
Carl Worth667173e2010-07-28 12:33:56 -07002005 ;}
2006 break;
2007
2008 case 27:
2009
Carl Worthe29cd392010-08-10 16:59:20 -07002010/* Line 1455 of yacc.c */
2011#line 303 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07002012 {
Eric Anholtd4a04f32010-07-28 16:58:39 -07002013 (yyval.ival) = (yyvsp[(1) - (3)].ival) && (yyvsp[(3) - (3)].ival);
Carl Worth667173e2010-07-28 12:33:56 -07002014 ;}
2015 break;
2016
2017 case 28:
2018
Carl Worthe29cd392010-08-10 16:59:20 -07002019/* Line 1455 of yacc.c */
2020#line 306 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07002021 {
Eric Anholtd4a04f32010-07-28 16:58:39 -07002022 (yyval.ival) = (yyvsp[(1) - (3)].ival) | (yyvsp[(3) - (3)].ival);
Carl Worth667173e2010-07-28 12:33:56 -07002023 ;}
2024 break;
2025
2026 case 29:
2027
Carl Worthe29cd392010-08-10 16:59:20 -07002028/* Line 1455 of yacc.c */
2029#line 309 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07002030 {
Eric Anholtd4a04f32010-07-28 16:58:39 -07002031 (yyval.ival) = (yyvsp[(1) - (3)].ival) ^ (yyvsp[(3) - (3)].ival);
Carl Worth667173e2010-07-28 12:33:56 -07002032 ;}
2033 break;
2034
2035 case 30:
2036
Carl Worthe29cd392010-08-10 16:59:20 -07002037/* Line 1455 of yacc.c */
2038#line 312 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07002039 {
Eric Anholtd4a04f32010-07-28 16:58:39 -07002040 (yyval.ival) = (yyvsp[(1) - (3)].ival) & (yyvsp[(3) - (3)].ival);
Carl Worth667173e2010-07-28 12:33:56 -07002041 ;}
2042 break;
2043
2044 case 31:
2045
Carl Worthe29cd392010-08-10 16:59:20 -07002046/* Line 1455 of yacc.c */
2047#line 315 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07002048 {
Eric Anholtd4a04f32010-07-28 16:58:39 -07002049 (yyval.ival) = (yyvsp[(1) - (3)].ival) != (yyvsp[(3) - (3)].ival);
Carl Worth667173e2010-07-28 12:33:56 -07002050 ;}
2051 break;
2052
2053 case 32:
2054
Carl Worthe29cd392010-08-10 16:59:20 -07002055/* Line 1455 of yacc.c */
2056#line 318 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07002057 {
Eric Anholtd4a04f32010-07-28 16:58:39 -07002058 (yyval.ival) = (yyvsp[(1) - (3)].ival) == (yyvsp[(3) - (3)].ival);
Carl Worth667173e2010-07-28 12:33:56 -07002059 ;}
2060 break;
2061
2062 case 33:
2063
Carl Worthe29cd392010-08-10 16:59:20 -07002064/* Line 1455 of yacc.c */
2065#line 321 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07002066 {
Eric Anholtd4a04f32010-07-28 16:58:39 -07002067 (yyval.ival) = (yyvsp[(1) - (3)].ival) >= (yyvsp[(3) - (3)].ival);
Carl Worth667173e2010-07-28 12:33:56 -07002068 ;}
2069 break;
2070
2071 case 34:
2072
Carl Worthe29cd392010-08-10 16:59:20 -07002073/* Line 1455 of yacc.c */
2074#line 324 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07002075 {
Eric Anholtd4a04f32010-07-28 16:58:39 -07002076 (yyval.ival) = (yyvsp[(1) - (3)].ival) <= (yyvsp[(3) - (3)].ival);
Carl Worth667173e2010-07-28 12:33:56 -07002077 ;}
2078 break;
2079
2080 case 35:
2081
Carl Worthe29cd392010-08-10 16:59:20 -07002082/* Line 1455 of yacc.c */
2083#line 327 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07002084 {
Eric Anholtd4a04f32010-07-28 16:58:39 -07002085 (yyval.ival) = (yyvsp[(1) - (3)].ival) > (yyvsp[(3) - (3)].ival);
Carl Worth667173e2010-07-28 12:33:56 -07002086 ;}
2087 break;
2088
2089 case 36:
2090
Carl Worthe29cd392010-08-10 16:59:20 -07002091/* Line 1455 of yacc.c */
2092#line 330 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07002093 {
Eric Anholtd4a04f32010-07-28 16:58:39 -07002094 (yyval.ival) = (yyvsp[(1) - (3)].ival) < (yyvsp[(3) - (3)].ival);
Carl Worth667173e2010-07-28 12:33:56 -07002095 ;}
2096 break;
2097
2098 case 37:
2099
Carl Worthe29cd392010-08-10 16:59:20 -07002100/* Line 1455 of yacc.c */
2101#line 333 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07002102 {
Eric Anholtd4a04f32010-07-28 16:58:39 -07002103 (yyval.ival) = (yyvsp[(1) - (3)].ival) >> (yyvsp[(3) - (3)].ival);
Carl Worth667173e2010-07-28 12:33:56 -07002104 ;}
2105 break;
2106
2107 case 38:
2108
Carl Worthe29cd392010-08-10 16:59:20 -07002109/* Line 1455 of yacc.c */
2110#line 336 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07002111 {
Eric Anholtd4a04f32010-07-28 16:58:39 -07002112 (yyval.ival) = (yyvsp[(1) - (3)].ival) << (yyvsp[(3) - (3)].ival);
Carl Worth667173e2010-07-28 12:33:56 -07002113 ;}
2114 break;
2115
2116 case 39:
2117
Carl Worthe29cd392010-08-10 16:59:20 -07002118/* Line 1455 of yacc.c */
2119#line 339 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07002120 {
Eric Anholtd4a04f32010-07-28 16:58:39 -07002121 (yyval.ival) = (yyvsp[(1) - (3)].ival) - (yyvsp[(3) - (3)].ival);
Carl Worth667173e2010-07-28 12:33:56 -07002122 ;}
2123 break;
2124
2125 case 40:
2126
Carl Worthe29cd392010-08-10 16:59:20 -07002127/* Line 1455 of yacc.c */
2128#line 342 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07002129 {
Eric Anholtd4a04f32010-07-28 16:58:39 -07002130 (yyval.ival) = (yyvsp[(1) - (3)].ival) + (yyvsp[(3) - (3)].ival);
Carl Worth667173e2010-07-28 12:33:56 -07002131 ;}
2132 break;
2133
2134 case 41:
2135
Carl Worthe29cd392010-08-10 16:59:20 -07002136/* Line 1455 of yacc.c */
2137#line 345 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07002138 {
Eric Anholtd4a04f32010-07-28 16:58:39 -07002139 (yyval.ival) = (yyvsp[(1) - (3)].ival) % (yyvsp[(3) - (3)].ival);
Carl Worth667173e2010-07-28 12:33:56 -07002140 ;}
2141 break;
2142
2143 case 42:
2144
Carl Worthe29cd392010-08-10 16:59:20 -07002145/* Line 1455 of yacc.c */
2146#line 348 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07002147 {
Eric Anholtd4a04f32010-07-28 16:58:39 -07002148 (yyval.ival) = (yyvsp[(1) - (3)].ival) / (yyvsp[(3) - (3)].ival);
Carl Worth667173e2010-07-28 12:33:56 -07002149 ;}
2150 break;
2151
2152 case 43:
2153
Carl Worthe29cd392010-08-10 16:59:20 -07002154/* Line 1455 of yacc.c */
2155#line 351 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07002156 {
Eric Anholtd4a04f32010-07-28 16:58:39 -07002157 (yyval.ival) = (yyvsp[(1) - (3)].ival) * (yyvsp[(3) - (3)].ival);
Carl Worth667173e2010-07-28 12:33:56 -07002158 ;}
2159 break;
2160
2161 case 44:
2162
Carl Worthe29cd392010-08-10 16:59:20 -07002163/* Line 1455 of yacc.c */
2164#line 354 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07002165 {
Eric Anholtd4a04f32010-07-28 16:58:39 -07002166 (yyval.ival) = ! (yyvsp[(2) - (2)].ival);
Carl Worth667173e2010-07-28 12:33:56 -07002167 ;}
2168 break;
2169
2170 case 45:
2171
Carl Worthe29cd392010-08-10 16:59:20 -07002172/* Line 1455 of yacc.c */
2173#line 357 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07002174 {
Eric Anholtd4a04f32010-07-28 16:58:39 -07002175 (yyval.ival) = ~ (yyvsp[(2) - (2)].ival);
Carl Worth667173e2010-07-28 12:33:56 -07002176 ;}
2177 break;
2178
2179 case 46:
2180
Carl Worthe29cd392010-08-10 16:59:20 -07002181/* Line 1455 of yacc.c */
2182#line 360 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07002183 {
Eric Anholtd4a04f32010-07-28 16:58:39 -07002184 (yyval.ival) = - (yyvsp[(2) - (2)].ival);
Carl Worth667173e2010-07-28 12:33:56 -07002185 ;}
2186 break;
2187
2188 case 47:
2189
Carl Worthe29cd392010-08-10 16:59:20 -07002190/* Line 1455 of yacc.c */
2191#line 363 "glcpp/glcpp-parse.y"
Eric Anholtd4a04f32010-07-28 16:58:39 -07002192 {
2193 (yyval.ival) = + (yyvsp[(2) - (2)].ival);
2194 ;}
2195 break;
2196
2197 case 48:
2198
Carl Worthe29cd392010-08-10 16:59:20 -07002199/* Line 1455 of yacc.c */
2200#line 366 "glcpp/glcpp-parse.y"
Eric Anholtd4a04f32010-07-28 16:58:39 -07002201 {
2202 (yyval.ival) = (yyvsp[(2) - (3)].ival);
2203 ;}
2204 break;
2205
2206 case 49:
2207
Carl Worthe29cd392010-08-10 16:59:20 -07002208/* Line 1455 of yacc.c */
2209#line 372 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07002210 {
2211 (yyval.string_list) = _string_list_create (parser);
2212 _string_list_append_item ((yyval.string_list), (yyvsp[(1) - (1)].str));
2213 talloc_steal ((yyval.string_list), (yyvsp[(1) - (1)].str));
2214 ;}
2215 break;
2216
Eric Anholtd4a04f32010-07-28 16:58:39 -07002217 case 50:
Carl Worth667173e2010-07-28 12:33:56 -07002218
Carl Worthe29cd392010-08-10 16:59:20 -07002219/* Line 1455 of yacc.c */
2220#line 377 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07002221 {
2222 (yyval.string_list) = (yyvsp[(1) - (3)].string_list);
2223 _string_list_append_item ((yyval.string_list), (yyvsp[(3) - (3)].str));
2224 talloc_steal ((yyval.string_list), (yyvsp[(3) - (3)].str));
2225 ;}
2226 break;
2227
Carl Worth667173e2010-07-28 12:33:56 -07002228 case 51:
2229
Carl Worthe29cd392010-08-10 16:59:20 -07002230/* Line 1455 of yacc.c */
2231#line 385 "glcpp/glcpp-parse.y"
Eric Anholtd4a04f32010-07-28 16:58:39 -07002232 { (yyval.token_list) = NULL; ;}
2233 break;
2234
2235 case 53:
2236
Carl Worthe29cd392010-08-10 16:59:20 -07002237/* Line 1455 of yacc.c */
2238#line 390 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07002239 {
2240 yyerror (& (yylsp[(1) - (2)]), parser, "Invalid tokens after #");
2241 ;}
2242 break;
2243
Eric Anholtd4a04f32010-07-28 16:58:39 -07002244 case 54:
Carl Worth667173e2010-07-28 12:33:56 -07002245
Carl Worthe29cd392010-08-10 16:59:20 -07002246/* Line 1455 of yacc.c */
2247#line 396 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07002248 { (yyval.token_list) = NULL; ;}
2249 break;
2250
Carl Worth667173e2010-07-28 12:33:56 -07002251 case 57:
2252
Carl Worthe29cd392010-08-10 16:59:20 -07002253/* Line 1455 of yacc.c */
2254#line 402 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07002255 {
Eric Anholtd4a04f32010-07-28 16:58:39 -07002256 glcpp_warning(&(yylsp[(1) - (1)]), parser, "extra tokens at end of directive");
2257 ;}
2258 break;
2259
2260 case 58:
2261
Carl Worthe29cd392010-08-10 16:59:20 -07002262/* Line 1455 of yacc.c */
2263#line 409 "glcpp/glcpp-parse.y"
Eric Anholtd4a04f32010-07-28 16:58:39 -07002264 {
2265 int v = hash_table_find (parser->defines, (yyvsp[(2) - (2)].str)) ? 1 : 0;
Carl Worth667173e2010-07-28 12:33:56 -07002266 (yyval.token) = _token_create_ival (parser, INTEGER, v);
2267 ;}
2268 break;
2269
2270 case 59:
2271
Carl Worthe29cd392010-08-10 16:59:20 -07002272/* Line 1455 of yacc.c */
2273#line 413 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07002274 {
Eric Anholtd4a04f32010-07-28 16:58:39 -07002275 int v = hash_table_find (parser->defines, (yyvsp[(3) - (4)].str)) ? 1 : 0;
2276 (yyval.token) = _token_create_ival (parser, INTEGER, v);
Carl Worth667173e2010-07-28 12:33:56 -07002277 ;}
2278 break;
2279
2280 case 61:
2281
Carl Worthe29cd392010-08-10 16:59:20 -07002282/* Line 1455 of yacc.c */
2283#line 422 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07002284 {
Eric Anholtd4a04f32010-07-28 16:58:39 -07002285 parser->space_tokens = 1;
2286 (yyval.token_list) = _token_list_create (parser);
2287 _token_list_append ((yyval.token_list), (yyvsp[(1) - (1)].token));
2288 talloc_unlink (parser, (yyvsp[(1) - (1)].token));
Carl Worth667173e2010-07-28 12:33:56 -07002289 ;}
2290 break;
2291
Kenneth Graunkef4239872010-08-04 16:24:39 -07002292 case 62:
Carl Worth667173e2010-07-28 12:33:56 -07002293
Carl Worthe29cd392010-08-10 16:59:20 -07002294/* Line 1455 of yacc.c */
2295#line 428 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07002296 {
Eric Anholtd4a04f32010-07-28 16:58:39 -07002297 (yyval.token_list) = (yyvsp[(1) - (2)].token_list);
2298 _token_list_append ((yyval.token_list), (yyvsp[(2) - (2)].token));
2299 talloc_unlink (parser, (yyvsp[(2) - (2)].token));
Carl Worth667173e2010-07-28 12:33:56 -07002300 ;}
2301 break;
2302
Kenneth Graunkef4239872010-08-04 16:24:39 -07002303 case 63:
Carl Worth667173e2010-07-28 12:33:56 -07002304
Carl Worthe29cd392010-08-10 16:59:20 -07002305/* Line 1455 of yacc.c */
2306#line 436 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07002307 {
Kenneth Graunkef4239872010-08-04 16:24:39 -07002308 parser->space_tokens = 1;
2309 (yyval.token_list) = _token_list_create (parser);
2310 _token_list_append ((yyval.token_list), (yyvsp[(1) - (1)].token));
2311 talloc_unlink (parser, (yyvsp[(1) - (1)].token));
2312 ;}
2313 break;
2314
2315 case 64:
2316
Carl Worthe29cd392010-08-10 16:59:20 -07002317/* Line 1455 of yacc.c */
2318#line 442 "glcpp/glcpp-parse.y"
Kenneth Graunkef4239872010-08-04 16:24:39 -07002319 {
2320 (yyval.token_list) = (yyvsp[(1) - (2)].token_list);
2321 _token_list_append ((yyval.token_list), (yyvsp[(2) - (2)].token));
2322 talloc_unlink (parser, (yyvsp[(2) - (2)].token));
2323 ;}
2324 break;
2325
2326 case 65:
2327
Carl Worthe29cd392010-08-10 16:59:20 -07002328/* Line 1455 of yacc.c */
2329#line 450 "glcpp/glcpp-parse.y"
Kenneth Graunkef4239872010-08-04 16:24:39 -07002330 {
Eric Anholtd4a04f32010-07-28 16:58:39 -07002331 (yyval.token) = _token_create_str (parser, IDENTIFIER, (yyvsp[(1) - (1)].str));
Carl Worth667173e2010-07-28 12:33:56 -07002332 (yyval.token)->location = yylloc;
2333 ;}
2334 break;
2335
2336 case 66:
2337
Carl Worthe29cd392010-08-10 16:59:20 -07002338/* Line 1455 of yacc.c */
2339#line 454 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07002340 {
Eric Anholtd4a04f32010-07-28 16:58:39 -07002341 (yyval.token) = _token_create_str (parser, INTEGER_STRING, (yyvsp[(1) - (1)].str));
Carl Worth667173e2010-07-28 12:33:56 -07002342 (yyval.token)->location = yylloc;
2343 ;}
2344 break;
2345
2346 case 67:
2347
Carl Worthe29cd392010-08-10 16:59:20 -07002348/* Line 1455 of yacc.c */
2349#line 458 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07002350 {
Eric Anholtd4a04f32010-07-28 16:58:39 -07002351 (yyval.token) = _token_create_ival (parser, (yyvsp[(1) - (1)].ival), (yyvsp[(1) - (1)].ival));
Carl Worth667173e2010-07-28 12:33:56 -07002352 (yyval.token)->location = yylloc;
2353 ;}
2354 break;
2355
2356 case 68:
2357
Carl Worthe29cd392010-08-10 16:59:20 -07002358/* Line 1455 of yacc.c */
2359#line 462 "glcpp/glcpp-parse.y"
Eric Anholtd4a04f32010-07-28 16:58:39 -07002360 {
2361 (yyval.token) = _token_create_str (parser, OTHER, (yyvsp[(1) - (1)].str));
2362 (yyval.token)->location = yylloc;
2363 ;}
Carl Worth667173e2010-07-28 12:33:56 -07002364 break;
2365
2366 case 69:
2367
Carl Worthe29cd392010-08-10 16:59:20 -07002368/* Line 1455 of yacc.c */
2369#line 466 "glcpp/glcpp-parse.y"
Eric Anholtd4a04f32010-07-28 16:58:39 -07002370 {
2371 (yyval.token) = _token_create_ival (parser, SPACE, SPACE);
2372 (yyval.token)->location = yylloc;
2373 ;}
Carl Worth667173e2010-07-28 12:33:56 -07002374 break;
2375
2376 case 70:
2377
Carl Worthe29cd392010-08-10 16:59:20 -07002378/* Line 1455 of yacc.c */
2379#line 473 "glcpp/glcpp-parse.y"
Eric Anholtd4a04f32010-07-28 16:58:39 -07002380 { (yyval.ival) = '['; ;}
Carl Worth667173e2010-07-28 12:33:56 -07002381 break;
2382
2383 case 71:
2384
Carl Worthe29cd392010-08-10 16:59:20 -07002385/* Line 1455 of yacc.c */
2386#line 474 "glcpp/glcpp-parse.y"
Eric Anholtd4a04f32010-07-28 16:58:39 -07002387 { (yyval.ival) = ']'; ;}
Carl Worth667173e2010-07-28 12:33:56 -07002388 break;
2389
2390 case 72:
2391
Carl Worthe29cd392010-08-10 16:59:20 -07002392/* Line 1455 of yacc.c */
2393#line 475 "glcpp/glcpp-parse.y"
Eric Anholtd4a04f32010-07-28 16:58:39 -07002394 { (yyval.ival) = '('; ;}
Carl Worth667173e2010-07-28 12:33:56 -07002395 break;
2396
2397 case 73:
2398
Carl Worthe29cd392010-08-10 16:59:20 -07002399/* Line 1455 of yacc.c */
2400#line 476 "glcpp/glcpp-parse.y"
Eric Anholtd4a04f32010-07-28 16:58:39 -07002401 { (yyval.ival) = ')'; ;}
Carl Worth667173e2010-07-28 12:33:56 -07002402 break;
2403
2404 case 74:
2405
Carl Worthe29cd392010-08-10 16:59:20 -07002406/* Line 1455 of yacc.c */
2407#line 477 "glcpp/glcpp-parse.y"
Eric Anholtd4a04f32010-07-28 16:58:39 -07002408 { (yyval.ival) = '{'; ;}
Carl Worth667173e2010-07-28 12:33:56 -07002409 break;
2410
2411 case 75:
2412
Carl Worthe29cd392010-08-10 16:59:20 -07002413/* Line 1455 of yacc.c */
2414#line 478 "glcpp/glcpp-parse.y"
Eric Anholtd4a04f32010-07-28 16:58:39 -07002415 { (yyval.ival) = '}'; ;}
Carl Worth667173e2010-07-28 12:33:56 -07002416 break;
2417
2418 case 76:
2419
Carl Worthe29cd392010-08-10 16:59:20 -07002420/* Line 1455 of yacc.c */
2421#line 479 "glcpp/glcpp-parse.y"
Eric Anholtd4a04f32010-07-28 16:58:39 -07002422 { (yyval.ival) = '.'; ;}
Carl Worth667173e2010-07-28 12:33:56 -07002423 break;
2424
2425 case 77:
2426
Carl Worthe29cd392010-08-10 16:59:20 -07002427/* Line 1455 of yacc.c */
2428#line 480 "glcpp/glcpp-parse.y"
Eric Anholtd4a04f32010-07-28 16:58:39 -07002429 { (yyval.ival) = '&'; ;}
Carl Worth667173e2010-07-28 12:33:56 -07002430 break;
2431
2432 case 78:
2433
Carl Worthe29cd392010-08-10 16:59:20 -07002434/* Line 1455 of yacc.c */
2435#line 481 "glcpp/glcpp-parse.y"
Eric Anholtd4a04f32010-07-28 16:58:39 -07002436 { (yyval.ival) = '*'; ;}
Carl Worth667173e2010-07-28 12:33:56 -07002437 break;
2438
2439 case 79:
2440
Carl Worthe29cd392010-08-10 16:59:20 -07002441/* Line 1455 of yacc.c */
2442#line 482 "glcpp/glcpp-parse.y"
Eric Anholtd4a04f32010-07-28 16:58:39 -07002443 { (yyval.ival) = '+'; ;}
Carl Worth667173e2010-07-28 12:33:56 -07002444 break;
2445
2446 case 80:
2447
Carl Worthe29cd392010-08-10 16:59:20 -07002448/* Line 1455 of yacc.c */
2449#line 483 "glcpp/glcpp-parse.y"
Eric Anholtd4a04f32010-07-28 16:58:39 -07002450 { (yyval.ival) = '-'; ;}
Carl Worth667173e2010-07-28 12:33:56 -07002451 break;
2452
2453 case 81:
2454
Carl Worthe29cd392010-08-10 16:59:20 -07002455/* Line 1455 of yacc.c */
2456#line 484 "glcpp/glcpp-parse.y"
Eric Anholtd4a04f32010-07-28 16:58:39 -07002457 { (yyval.ival) = '~'; ;}
Carl Worth667173e2010-07-28 12:33:56 -07002458 break;
2459
2460 case 82:
2461
Carl Worthe29cd392010-08-10 16:59:20 -07002462/* Line 1455 of yacc.c */
2463#line 485 "glcpp/glcpp-parse.y"
Eric Anholtd4a04f32010-07-28 16:58:39 -07002464 { (yyval.ival) = '!'; ;}
Carl Worth667173e2010-07-28 12:33:56 -07002465 break;
2466
2467 case 83:
2468
Carl Worthe29cd392010-08-10 16:59:20 -07002469/* Line 1455 of yacc.c */
2470#line 486 "glcpp/glcpp-parse.y"
Eric Anholtd4a04f32010-07-28 16:58:39 -07002471 { (yyval.ival) = '/'; ;}
Carl Worth667173e2010-07-28 12:33:56 -07002472 break;
2473
2474 case 84:
2475
Carl Worthe29cd392010-08-10 16:59:20 -07002476/* Line 1455 of yacc.c */
2477#line 487 "glcpp/glcpp-parse.y"
Eric Anholtd4a04f32010-07-28 16:58:39 -07002478 { (yyval.ival) = '%'; ;}
Carl Worth667173e2010-07-28 12:33:56 -07002479 break;
2480
2481 case 85:
2482
Carl Worthe29cd392010-08-10 16:59:20 -07002483/* Line 1455 of yacc.c */
2484#line 488 "glcpp/glcpp-parse.y"
Eric Anholtd4a04f32010-07-28 16:58:39 -07002485 { (yyval.ival) = LEFT_SHIFT; ;}
Carl Worth667173e2010-07-28 12:33:56 -07002486 break;
2487
2488 case 86:
2489
Carl Worthe29cd392010-08-10 16:59:20 -07002490/* Line 1455 of yacc.c */
2491#line 489 "glcpp/glcpp-parse.y"
Eric Anholtd4a04f32010-07-28 16:58:39 -07002492 { (yyval.ival) = RIGHT_SHIFT; ;}
Carl Worth667173e2010-07-28 12:33:56 -07002493 break;
2494
2495 case 87:
2496
Carl Worthe29cd392010-08-10 16:59:20 -07002497/* Line 1455 of yacc.c */
2498#line 490 "glcpp/glcpp-parse.y"
Eric Anholtd4a04f32010-07-28 16:58:39 -07002499 { (yyval.ival) = '<'; ;}
Carl Worth667173e2010-07-28 12:33:56 -07002500 break;
2501
2502 case 88:
2503
Carl Worthe29cd392010-08-10 16:59:20 -07002504/* Line 1455 of yacc.c */
2505#line 491 "glcpp/glcpp-parse.y"
Eric Anholtd4a04f32010-07-28 16:58:39 -07002506 { (yyval.ival) = '>'; ;}
Carl Worth667173e2010-07-28 12:33:56 -07002507 break;
2508
2509 case 89:
2510
Carl Worthe29cd392010-08-10 16:59:20 -07002511/* Line 1455 of yacc.c */
2512#line 492 "glcpp/glcpp-parse.y"
Eric Anholtd4a04f32010-07-28 16:58:39 -07002513 { (yyval.ival) = LESS_OR_EQUAL; ;}
Carl Worth667173e2010-07-28 12:33:56 -07002514 break;
2515
2516 case 90:
2517
Carl Worthe29cd392010-08-10 16:59:20 -07002518/* Line 1455 of yacc.c */
2519#line 493 "glcpp/glcpp-parse.y"
Eric Anholtd4a04f32010-07-28 16:58:39 -07002520 { (yyval.ival) = GREATER_OR_EQUAL; ;}
Carl Worth667173e2010-07-28 12:33:56 -07002521 break;
2522
2523 case 91:
2524
Carl Worthe29cd392010-08-10 16:59:20 -07002525/* Line 1455 of yacc.c */
2526#line 494 "glcpp/glcpp-parse.y"
Eric Anholtd4a04f32010-07-28 16:58:39 -07002527 { (yyval.ival) = EQUAL; ;}
Carl Worth667173e2010-07-28 12:33:56 -07002528 break;
2529
2530 case 92:
2531
Carl Worthe29cd392010-08-10 16:59:20 -07002532/* Line 1455 of yacc.c */
2533#line 495 "glcpp/glcpp-parse.y"
Eric Anholtd4a04f32010-07-28 16:58:39 -07002534 { (yyval.ival) = NOT_EQUAL; ;}
Carl Worth667173e2010-07-28 12:33:56 -07002535 break;
2536
2537 case 93:
2538
Carl Worthe29cd392010-08-10 16:59:20 -07002539/* Line 1455 of yacc.c */
2540#line 496 "glcpp/glcpp-parse.y"
Eric Anholtd4a04f32010-07-28 16:58:39 -07002541 { (yyval.ival) = '^'; ;}
Carl Worth667173e2010-07-28 12:33:56 -07002542 break;
2543
2544 case 94:
2545
Carl Worthe29cd392010-08-10 16:59:20 -07002546/* Line 1455 of yacc.c */
2547#line 497 "glcpp/glcpp-parse.y"
Eric Anholtd4a04f32010-07-28 16:58:39 -07002548 { (yyval.ival) = '|'; ;}
Carl Worth667173e2010-07-28 12:33:56 -07002549 break;
2550
2551 case 95:
2552
Carl Worthe29cd392010-08-10 16:59:20 -07002553/* Line 1455 of yacc.c */
2554#line 498 "glcpp/glcpp-parse.y"
Eric Anholtd4a04f32010-07-28 16:58:39 -07002555 { (yyval.ival) = AND; ;}
Carl Worth667173e2010-07-28 12:33:56 -07002556 break;
2557
2558 case 96:
2559
Carl Worthe29cd392010-08-10 16:59:20 -07002560/* Line 1455 of yacc.c */
2561#line 499 "glcpp/glcpp-parse.y"
Eric Anholtd4a04f32010-07-28 16:58:39 -07002562 { (yyval.ival) = OR; ;}
Carl Worth667173e2010-07-28 12:33:56 -07002563 break;
2564
2565 case 97:
2566
Carl Worthe29cd392010-08-10 16:59:20 -07002567/* Line 1455 of yacc.c */
2568#line 500 "glcpp/glcpp-parse.y"
Eric Anholtd4a04f32010-07-28 16:58:39 -07002569 { (yyval.ival) = ';'; ;}
Carl Worth667173e2010-07-28 12:33:56 -07002570 break;
2571
2572 case 98:
2573
Carl Worthe29cd392010-08-10 16:59:20 -07002574/* Line 1455 of yacc.c */
2575#line 501 "glcpp/glcpp-parse.y"
Eric Anholtd4a04f32010-07-28 16:58:39 -07002576 { (yyval.ival) = ','; ;}
2577 break;
2578
2579 case 99:
2580
Carl Worthe29cd392010-08-10 16:59:20 -07002581/* Line 1455 of yacc.c */
2582#line 502 "glcpp/glcpp-parse.y"
Eric Anholtd4a04f32010-07-28 16:58:39 -07002583 { (yyval.ival) = '='; ;}
2584 break;
2585
2586 case 100:
2587
Carl Worthe29cd392010-08-10 16:59:20 -07002588/* Line 1455 of yacc.c */
2589#line 503 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07002590 { (yyval.ival) = PASTE; ;}
2591 break;
2592
2593
2594
Carl Worthe29cd392010-08-10 16:59:20 -07002595/* Line 1455 of yacc.c */
2596#line 2597 "glcpp/glcpp-parse.c"
Carl Worth667173e2010-07-28 12:33:56 -07002597 default: break;
2598 }
2599 YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
2600
2601 YYPOPSTACK (yylen);
2602 yylen = 0;
2603 YY_STACK_PRINT (yyss, yyssp);
2604
2605 *++yyvsp = yyval;
2606 *++yylsp = yyloc;
2607
2608 /* Now `shift' the result of the reduction. Determine what state
2609 that goes to, based on the state we popped back to and the rule
2610 number reduced by. */
2611
2612 yyn = yyr1[yyn];
2613
2614 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
2615 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
2616 yystate = yytable[yystate];
2617 else
2618 yystate = yydefgoto[yyn - YYNTOKENS];
2619
2620 goto yynewstate;
2621
2622
2623/*------------------------------------.
2624| yyerrlab -- here on detecting error |
2625`------------------------------------*/
2626yyerrlab:
2627 /* If not already recovering from an error, report this error. */
2628 if (!yyerrstatus)
2629 {
2630 ++yynerrs;
2631#if ! YYERROR_VERBOSE
2632 yyerror (&yylloc, parser, YY_("syntax error"));
2633#else
2634 {
2635 YYSIZE_T yysize = yysyntax_error (0, yystate, yychar);
2636 if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM)
2637 {
2638 YYSIZE_T yyalloc = 2 * yysize;
2639 if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM))
2640 yyalloc = YYSTACK_ALLOC_MAXIMUM;
2641 if (yymsg != yymsgbuf)
2642 YYSTACK_FREE (yymsg);
2643 yymsg = (char *) YYSTACK_ALLOC (yyalloc);
2644 if (yymsg)
2645 yymsg_alloc = yyalloc;
2646 else
2647 {
2648 yymsg = yymsgbuf;
2649 yymsg_alloc = sizeof yymsgbuf;
2650 }
2651 }
2652
2653 if (0 < yysize && yysize <= yymsg_alloc)
2654 {
2655 (void) yysyntax_error (yymsg, yystate, yychar);
2656 yyerror (&yylloc, parser, yymsg);
2657 }
2658 else
2659 {
2660 yyerror (&yylloc, parser, YY_("syntax error"));
2661 if (yysize != 0)
2662 goto yyexhaustedlab;
2663 }
2664 }
2665#endif
2666 }
2667
2668 yyerror_range[0] = yylloc;
2669
2670 if (yyerrstatus == 3)
2671 {
2672 /* If just tried and failed to reuse lookahead token after an
2673 error, discard it. */
2674
2675 if (yychar <= YYEOF)
2676 {
2677 /* Return failure if at end of input. */
2678 if (yychar == YYEOF)
2679 YYABORT;
2680 }
2681 else
2682 {
2683 yydestruct ("Error: discarding",
2684 yytoken, &yylval, &yylloc, parser);
2685 yychar = YYEMPTY;
2686 }
2687 }
2688
2689 /* Else will try to reuse lookahead token after shifting the error
2690 token. */
2691 goto yyerrlab1;
2692
2693
2694/*---------------------------------------------------.
2695| yyerrorlab -- error raised explicitly by YYERROR. |
2696`---------------------------------------------------*/
2697yyerrorlab:
2698
2699 /* Pacify compilers like GCC when the user code never invokes
2700 YYERROR and the label yyerrorlab therefore never appears in user
2701 code. */
2702 if (/*CONSTCOND*/ 0)
2703 goto yyerrorlab;
2704
2705 yyerror_range[0] = yylsp[1-yylen];
2706 /* Do not reclaim the symbols of the rule which action triggered
2707 this YYERROR. */
2708 YYPOPSTACK (yylen);
2709 yylen = 0;
2710 YY_STACK_PRINT (yyss, yyssp);
2711 yystate = *yyssp;
2712 goto yyerrlab1;
2713
2714
2715/*-------------------------------------------------------------.
2716| yyerrlab1 -- common code for both syntax error and YYERROR. |
2717`-------------------------------------------------------------*/
2718yyerrlab1:
2719 yyerrstatus = 3; /* Each real token shifted decrements this. */
2720
2721 for (;;)
2722 {
2723 yyn = yypact[yystate];
2724 if (yyn != YYPACT_NINF)
2725 {
2726 yyn += YYTERROR;
2727 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
2728 {
2729 yyn = yytable[yyn];
2730 if (0 < yyn)
2731 break;
2732 }
2733 }
2734
2735 /* Pop the current state because it cannot handle the error token. */
2736 if (yyssp == yyss)
2737 YYABORT;
2738
2739 yyerror_range[0] = *yylsp;
2740 yydestruct ("Error: popping",
2741 yystos[yystate], yyvsp, yylsp, parser);
2742 YYPOPSTACK (1);
2743 yystate = *yyssp;
2744 YY_STACK_PRINT (yyss, yyssp);
2745 }
2746
2747 *++yyvsp = yylval;
2748
2749 yyerror_range[1] = yylloc;
2750 /* Using YYLLOC is tempting, but would change the location of
2751 the lookahead. YYLOC is available though. */
2752 YYLLOC_DEFAULT (yyloc, (yyerror_range - 1), 2);
2753 *++yylsp = yyloc;
2754
2755 /* Shift the error token. */
2756 YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
2757
2758 yystate = yyn;
2759 goto yynewstate;
2760
2761
2762/*-------------------------------------.
2763| yyacceptlab -- YYACCEPT comes here. |
2764`-------------------------------------*/
2765yyacceptlab:
2766 yyresult = 0;
2767 goto yyreturn;
2768
2769/*-----------------------------------.
2770| yyabortlab -- YYABORT comes here. |
2771`-----------------------------------*/
2772yyabortlab:
2773 yyresult = 1;
2774 goto yyreturn;
2775
2776#if !defined(yyoverflow) || YYERROR_VERBOSE
2777/*-------------------------------------------------.
2778| yyexhaustedlab -- memory exhaustion comes here. |
2779`-------------------------------------------------*/
2780yyexhaustedlab:
2781 yyerror (&yylloc, parser, YY_("memory exhausted"));
2782 yyresult = 2;
2783 /* Fall through. */
2784#endif
2785
2786yyreturn:
2787 if (yychar != YYEMPTY)
2788 yydestruct ("Cleanup: discarding lookahead",
2789 yytoken, &yylval, &yylloc, parser);
2790 /* Do not reclaim the symbols of the rule which action triggered
2791 this YYABORT or YYACCEPT. */
2792 YYPOPSTACK (yylen);
2793 YY_STACK_PRINT (yyss, yyssp);
2794 while (yyssp != yyss)
2795 {
2796 yydestruct ("Cleanup: popping",
2797 yystos[*yyssp], yyvsp, yylsp, parser);
2798 YYPOPSTACK (1);
2799 }
2800#ifndef yyoverflow
2801 if (yyss != yyssa)
2802 YYSTACK_FREE (yyss);
2803#endif
2804#if YYERROR_VERBOSE
2805 if (yymsg != yymsgbuf)
2806 YYSTACK_FREE (yymsg);
2807#endif
2808 /* Make sure YYID is used. */
2809 return YYID (yyresult);
2810}
2811
2812
2813
Carl Worthe29cd392010-08-10 16:59:20 -07002814/* Line 1675 of yacc.c */
2815#line 506 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07002816
2817
2818string_list_t *
2819_string_list_create (void *ctx)
2820{
2821 string_list_t *list;
2822
Kenneth Graunke0ef79a52010-08-03 20:25:13 -07002823 list = talloc (ctx, string_list_t);
Carl Worth667173e2010-07-28 12:33:56 -07002824 list->head = NULL;
2825 list->tail = NULL;
2826
2827 return list;
2828}
2829
2830void
2831_string_list_append_item (string_list_t *list, const char *str)
2832{
2833 string_node_t *node;
2834
Kenneth Graunke0ef79a52010-08-03 20:25:13 -07002835 node = talloc (list, string_node_t);
2836 node->str = talloc_strdup (node, str);
Carl Worth667173e2010-07-28 12:33:56 -07002837
2838 node->next = NULL;
2839
2840 if (list->head == NULL) {
2841 list->head = node;
2842 } else {
2843 list->tail->next = node;
2844 }
2845
2846 list->tail = node;
2847}
2848
2849int
2850_string_list_contains (string_list_t *list, const char *member, int *index)
2851{
2852 string_node_t *node;
2853 int i;
2854
2855 if (list == NULL)
2856 return 0;
2857
2858 for (i = 0, node = list->head; node; i++, node = node->next) {
2859 if (strcmp (node->str, member) == 0) {
2860 if (index)
2861 *index = i;
2862 return 1;
2863 }
2864 }
2865
2866 return 0;
2867}
2868
2869int
2870_string_list_length (string_list_t *list)
2871{
2872 int length = 0;
2873 string_node_t *node;
2874
2875 if (list == NULL)
2876 return 0;
2877
2878 for (node = list->head; node; node = node->next)
2879 length++;
2880
2881 return length;
2882}
2883
2884argument_list_t *
2885_argument_list_create (void *ctx)
2886{
2887 argument_list_t *list;
2888
Kenneth Graunke0ef79a52010-08-03 20:25:13 -07002889 list = talloc (ctx, argument_list_t);
Carl Worth667173e2010-07-28 12:33:56 -07002890 list->head = NULL;
2891 list->tail = NULL;
2892
2893 return list;
2894}
2895
2896void
2897_argument_list_append (argument_list_t *list, token_list_t *argument)
2898{
2899 argument_node_t *node;
2900
Kenneth Graunke0ef79a52010-08-03 20:25:13 -07002901 node = talloc (list, argument_node_t);
Carl Worth667173e2010-07-28 12:33:56 -07002902 node->argument = argument;
2903
2904 node->next = NULL;
2905
2906 if (list->head == NULL) {
2907 list->head = node;
2908 } else {
2909 list->tail->next = node;
2910 }
2911
2912 list->tail = node;
2913}
2914
2915int
2916_argument_list_length (argument_list_t *list)
2917{
2918 int length = 0;
2919 argument_node_t *node;
2920
2921 if (list == NULL)
2922 return 0;
2923
2924 for (node = list->head; node; node = node->next)
2925 length++;
2926
2927 return length;
2928}
2929
2930token_list_t *
2931_argument_list_member_at (argument_list_t *list, int index)
2932{
2933 argument_node_t *node;
2934 int i;
2935
2936 if (list == NULL)
2937 return NULL;
2938
2939 node = list->head;
2940 for (i = 0; i < index; i++) {
2941 node = node->next;
2942 if (node == NULL)
2943 break;
2944 }
2945
2946 if (node)
2947 return node->argument;
2948
2949 return NULL;
2950}
2951
2952/* Note: This function talloc_steal()s the str pointer. */
2953token_t *
2954_token_create_str (void *ctx, int type, char *str)
2955{
2956 token_t *token;
2957
Kenneth Graunke0ef79a52010-08-03 20:25:13 -07002958 token = talloc (ctx, token_t);
Carl Worth667173e2010-07-28 12:33:56 -07002959 token->type = type;
2960 token->value.str = talloc_steal (token, str);
2961
2962 return token;
2963}
2964
2965token_t *
2966_token_create_ival (void *ctx, int type, int ival)
2967{
2968 token_t *token;
2969
Kenneth Graunke0ef79a52010-08-03 20:25:13 -07002970 token = talloc (ctx, token_t);
Carl Worth667173e2010-07-28 12:33:56 -07002971 token->type = type;
2972 token->value.ival = ival;
2973
2974 return token;
2975}
2976
2977token_list_t *
2978_token_list_create (void *ctx)
2979{
2980 token_list_t *list;
2981
Kenneth Graunke0ef79a52010-08-03 20:25:13 -07002982 list = talloc (ctx, token_list_t);
Carl Worth667173e2010-07-28 12:33:56 -07002983 list->head = NULL;
2984 list->tail = NULL;
2985 list->non_space_tail = NULL;
2986
2987 return list;
2988}
2989
2990void
2991_token_list_append (token_list_t *list, token_t *token)
2992{
2993 token_node_t *node;
2994
Kenneth Graunke0ef79a52010-08-03 20:25:13 -07002995 node = talloc (list, token_node_t);
2996 node->token = talloc_reference (list, token);
Carl Worth667173e2010-07-28 12:33:56 -07002997
2998 node->next = NULL;
2999
3000 if (list->head == NULL) {
3001 list->head = node;
3002 } else {
3003 list->tail->next = node;
3004 }
3005
3006 list->tail = node;
3007 if (token->type != SPACE)
3008 list->non_space_tail = node;
3009}
3010
3011void
3012_token_list_append_list (token_list_t *list, token_list_t *tail)
3013{
3014 if (tail == NULL || tail->head == NULL)
3015 return;
3016
3017 if (list->head == NULL) {
3018 list->head = tail->head;
3019 } else {
3020 list->tail->next = tail->head;
3021 }
3022
3023 list->tail = tail->tail;
3024 list->non_space_tail = tail->non_space_tail;
3025}
3026
3027static token_list_t *
3028_token_list_copy (void *ctx, token_list_t *other)
3029{
3030 token_list_t *copy;
3031 token_node_t *node;
3032
3033 if (other == NULL)
3034 return NULL;
3035
3036 copy = _token_list_create (ctx);
3037 for (node = other->head; node; node = node->next)
3038 _token_list_append (copy, node->token);
3039
3040 return copy;
3041}
3042
3043static void
3044_token_list_trim_trailing_space (token_list_t *list)
3045{
3046 token_node_t *tail, *next;
3047
3048 if (list->non_space_tail) {
3049 tail = list->non_space_tail->next;
3050 list->non_space_tail->next = NULL;
3051 list->tail = list->non_space_tail;
3052
3053 while (tail) {
3054 next = tail->next;
3055 talloc_free (tail);
3056 tail = next;
3057 }
3058 }
3059}
3060
3061static void
3062_token_print (char **out, token_t *token)
3063{
3064 if (token->type < 256) {
3065 glcpp_printf (*out, "%c", token->type);
3066 return;
3067 }
3068
3069 switch (token->type) {
3070 case INTEGER:
Eric Anholt8605c292010-07-28 16:53:51 -07003071 glcpp_printf (*out, "%" PRIiMAX, token->value.ival);
Carl Worth667173e2010-07-28 12:33:56 -07003072 break;
3073 case IDENTIFIER:
3074 case INTEGER_STRING:
3075 case OTHER:
3076 glcpp_print (*out, token->value.str);
3077 break;
3078 case SPACE:
3079 glcpp_print (*out, " ");
3080 break;
3081 case LEFT_SHIFT:
3082 glcpp_print (*out, "<<");
3083 break;
3084 case RIGHT_SHIFT:
3085 glcpp_print (*out, ">>");
3086 break;
3087 case LESS_OR_EQUAL:
3088 glcpp_print (*out, "<=");
3089 break;
3090 case GREATER_OR_EQUAL:
3091 glcpp_print (*out, ">=");
3092 break;
3093 case EQUAL:
3094 glcpp_print (*out, "==");
3095 break;
3096 case NOT_EQUAL:
3097 glcpp_print (*out, "!=");
3098 break;
3099 case AND:
3100 glcpp_print (*out, "&&");
3101 break;
3102 case OR:
3103 glcpp_print (*out, "||");
3104 break;
3105 case PASTE:
3106 glcpp_print (*out, "##");
3107 break;
3108 case COMMA_FINAL:
3109 glcpp_print (*out, ",");
3110 break;
3111 case PLACEHOLDER:
3112 /* Nothing to print. */
3113 break;
3114 default:
3115 assert(!"Error: Don't know how to print token.");
3116 break;
3117 }
3118}
3119
3120/* Return a new token (talloc()ed off of 'token') formed by pasting
3121 * 'token' and 'other'. Note that this function may return 'token' or
3122 * 'other' directly rather than allocating anything new.
3123 *
3124 * Caution: Only very cursory error-checking is performed to see if
3125 * the final result is a valid single token. */
3126static token_t *
3127_token_paste (glcpp_parser_t *parser, token_t *token, token_t *other)
3128{
3129 token_t *combined = NULL;
3130
3131 /* Pasting a placeholder onto anything makes no change. */
3132 if (other->type == PLACEHOLDER)
3133 return token;
3134
3135 /* When 'token' is a placeholder, just return 'other'. */
3136 if (token->type == PLACEHOLDER)
3137 return other;
3138
3139 /* A very few single-character punctuators can be combined
3140 * with another to form a multi-character punctuator. */
3141 switch (token->type) {
3142 case '<':
3143 if (other->type == '<')
3144 combined = _token_create_ival (token, LEFT_SHIFT, LEFT_SHIFT);
3145 else if (other->type == '=')
3146 combined = _token_create_ival (token, LESS_OR_EQUAL, LESS_OR_EQUAL);
3147 break;
3148 case '>':
3149 if (other->type == '>')
3150 combined = _token_create_ival (token, RIGHT_SHIFT, RIGHT_SHIFT);
3151 else if (other->type == '=')
3152 combined = _token_create_ival (token, GREATER_OR_EQUAL, GREATER_OR_EQUAL);
3153 break;
3154 case '=':
3155 if (other->type == '=')
3156 combined = _token_create_ival (token, EQUAL, EQUAL);
3157 break;
3158 case '!':
3159 if (other->type == '=')
3160 combined = _token_create_ival (token, NOT_EQUAL, NOT_EQUAL);
3161 break;
3162 case '&':
3163 if (other->type == '&')
3164 combined = _token_create_ival (token, AND, AND);
3165 break;
3166 case '|':
3167 if (other->type == '|')
3168 combined = _token_create_ival (token, OR, OR);
3169 break;
3170 }
3171
3172 if (combined != NULL) {
3173 /* Inherit the location from the first token */
3174 combined->location = token->location;
3175 return combined;
3176 }
3177
3178 /* Two string-valued tokens can usually just be mashed
3179 * together.
3180 *
3181 * XXX: This isn't actually legitimate. Several things here
3182 * should result in a diagnostic since the result cannot be a
3183 * valid, single pre-processing token. For example, pasting
3184 * "123" and "abc" is not legal, but we don't catch that
3185 * here. */
3186 if ((token->type == IDENTIFIER || token->type == OTHER || token->type == INTEGER_STRING) &&
3187 (other->type == IDENTIFIER || other->type == OTHER || other->type == INTEGER_STRING))
3188 {
3189 char *str;
3190
Kenneth Graunke0ef79a52010-08-03 20:25:13 -07003191 str = talloc_asprintf (token, "%s%s", token->value.str,
3192 other->value.str);
Carl Worth667173e2010-07-28 12:33:56 -07003193 combined = _token_create_str (token, token->type, str);
3194 combined->location = token->location;
3195 return combined;
3196 }
3197
3198 glcpp_error (&token->location, parser, "");
3199 glcpp_print (parser->info_log, "Pasting \"");
3200 _token_print (&parser->info_log, token);
3201 glcpp_print (parser->info_log, "\" and \"");
3202 _token_print (&parser->info_log, other);
3203 glcpp_print (parser->info_log, "\" does not give a valid preprocessing token.\n");
3204
3205 return token;
3206}
3207
3208static void
3209_token_list_print (glcpp_parser_t *parser, token_list_t *list)
3210{
3211 token_node_t *node;
3212
3213 if (list == NULL)
3214 return;
3215
3216 for (node = list->head; node; node = node->next)
3217 _token_print (&parser->output, node->token);
3218}
3219
3220void
3221yyerror (YYLTYPE *locp, glcpp_parser_t *parser, const char *error)
3222{
3223 glcpp_error(locp, parser, "%s", error);
3224}
3225
Eric Anholtd4a04f32010-07-28 16:58:39 -07003226static void add_builtin_define(glcpp_parser_t *parser,
3227 const char *name, int value)
3228{
3229 token_t *tok;
3230 token_list_t *list;
3231
3232 tok = _token_create_ival (parser, INTEGER, value);
3233
3234 list = _token_list_create(parser);
3235 _token_list_append(list, tok);
3236 _define_object_macro(parser, NULL, name, list);
3237
3238 talloc_unlink(parser, tok);
3239}
3240
Carl Worth667173e2010-07-28 12:33:56 -07003241glcpp_parser_t *
3242glcpp_parser_create (const struct gl_extensions *extensions)
3243{
3244 glcpp_parser_t *parser;
Eric Anholtd4a04f32010-07-28 16:58:39 -07003245 int language_version;
Carl Worth667173e2010-07-28 12:33:56 -07003246
Kenneth Graunke0ef79a52010-08-03 20:25:13 -07003247 parser = talloc (NULL, glcpp_parser_t);
Carl Worth667173e2010-07-28 12:33:56 -07003248
3249 glcpp_lex_init_extra (parser, &parser->scanner);
3250 parser->defines = hash_table_ctor (32, hash_table_string_hash,
3251 hash_table_string_compare);
3252 parser->active = NULL;
3253 parser->lexing_if = 0;
3254 parser->space_tokens = 1;
3255 parser->newline_as_space = 0;
3256 parser->in_control_line = 0;
3257 parser->paren_count = 0;
3258
3259 parser->skip_stack = NULL;
3260
3261 parser->lex_from_list = NULL;
3262 parser->lex_from_node = NULL;
3263
3264 parser->output = talloc_strdup(parser, "");
3265 parser->info_log = talloc_strdup(parser, "");
3266 parser->error = 0;
3267
3268 /* Add pre-defined macros. */
Eric Anholtd4a04f32010-07-28 16:58:39 -07003269 add_builtin_define(parser, "GL_ARB_draw_buffers", 1);
3270 add_builtin_define(parser, "GL_ARB_texture_rectangle", 1);
Carl Worth667173e2010-07-28 12:33:56 -07003271
Eric Anholtd4a04f32010-07-28 16:58:39 -07003272 if (extensions != NULL) {
3273 if (extensions->EXT_texture_array) {
3274 add_builtin_define(parser, "GL_EXT_texture_array", 1);
3275 }
Carl Worth667173e2010-07-28 12:33:56 -07003276
Eric Anholtd4a04f32010-07-28 16:58:39 -07003277 if (extensions->ARB_fragment_coord_conventions)
3278 add_builtin_define(parser, "GL_ARB_fragment_coord_conventions",
3279 1);
Carl Worth667173e2010-07-28 12:33:56 -07003280 }
3281
Eric Anholtd4a04f32010-07-28 16:58:39 -07003282 language_version = 110;
Eric Anholtd4a04f32010-07-28 16:58:39 -07003283 add_builtin_define(parser, "__VERSION__", language_version);
Carl Worth667173e2010-07-28 12:33:56 -07003284
3285 return parser;
3286}
3287
3288int
3289glcpp_parser_parse (glcpp_parser_t *parser)
3290{
3291 return yyparse (parser);
3292}
3293
3294void
3295glcpp_parser_destroy (glcpp_parser_t *parser)
3296{
3297 if (parser->skip_stack)
3298 glcpp_error (&parser->skip_stack->loc, parser, "Unterminated #if\n");
3299 glcpp_lex_destroy (parser->scanner);
3300 hash_table_dtor (parser->defines);
3301 talloc_free (parser);
3302}
3303
3304typedef enum function_status
3305{
3306 FUNCTION_STATUS_SUCCESS,
3307 FUNCTION_NOT_A_FUNCTION,
3308 FUNCTION_UNBALANCED_PARENTHESES
3309} function_status_t;
3310
3311/* Find a set of function-like macro arguments by looking for a
3312 * balanced set of parentheses.
3313 *
3314 * When called, 'node' should be the opening-parenthesis token, (or
3315 * perhaps preceeding SPACE tokens). Upon successful return *last will
3316 * be the last consumed node, (corresponding to the closing right
3317 * parenthesis).
3318 *
3319 * Return values:
3320 *
3321 * FUNCTION_STATUS_SUCCESS:
3322 *
3323 * Successfully parsed a set of function arguments.
3324 *
3325 * FUNCTION_NOT_A_FUNCTION:
3326 *
3327 * Macro name not followed by a '('. This is not an error, but
3328 * simply that the macro name should be treated as a non-macro.
3329 *
3330 * FUNCTION_UNBALANCED_PARENTHESES
3331 *
3332 * Macro name is not followed by a balanced set of parentheses.
3333 */
3334static function_status_t
3335_arguments_parse (argument_list_t *arguments,
3336 token_node_t *node,
3337 token_node_t **last)
3338{
3339 token_list_t *argument;
3340 int paren_count;
3341
3342 node = node->next;
3343
3344 /* Ignore whitespace before first parenthesis. */
3345 while (node && node->token->type == SPACE)
3346 node = node->next;
3347
3348 if (node == NULL || node->token->type != '(')
3349 return FUNCTION_NOT_A_FUNCTION;
3350
3351 node = node->next;
3352
3353 argument = _token_list_create (arguments);
3354 _argument_list_append (arguments, argument);
3355
3356 for (paren_count = 1; node; node = node->next) {
3357 if (node->token->type == '(')
3358 {
3359 paren_count++;
3360 }
3361 else if (node->token->type == ')')
3362 {
3363 paren_count--;
3364 if (paren_count == 0)
3365 break;
3366 }
3367
3368 if (node->token->type == ',' &&
3369 paren_count == 1)
3370 {
3371 _token_list_trim_trailing_space (argument);
3372 argument = _token_list_create (arguments);
3373 _argument_list_append (arguments, argument);
3374 }
3375 else {
3376 if (argument->head == NULL) {
3377 /* Don't treat initial whitespace as
3378 * part of the arguement. */
3379 if (node->token->type == SPACE)
3380 continue;
3381 }
3382 _token_list_append (argument, node->token);
3383 }
3384 }
3385
3386 if (paren_count)
3387 return FUNCTION_UNBALANCED_PARENTHESES;
3388
3389 *last = node;
3390
3391 return FUNCTION_STATUS_SUCCESS;
3392}
3393
3394static token_list_t *
3395_token_list_create_with_one_space (void *ctx)
3396{
3397 token_list_t *list;
3398 token_t *space;
3399
3400 list = _token_list_create (ctx);
3401 space = _token_create_ival (list, SPACE, SPACE);
3402 _token_list_append (list, space);
3403
3404 return list;
3405}
3406
Kenneth Graunke16b4eed2010-08-04 16:10:03 -07003407static void
3408_glcpp_parser_expand_if (glcpp_parser_t *parser, int type, token_list_t *list)
3409{
3410 token_list_t *expanded;
3411 token_t *token;
3412
3413 expanded = _token_list_create (parser);
3414 token = _token_create_ival (parser, type, type);
3415 _token_list_append (expanded, token);
3416 _glcpp_parser_expand_token_list (parser, list);
3417 _token_list_append_list (expanded, list);
3418 glcpp_parser_lex_from (parser, expanded);
3419}
3420
Carl Worth667173e2010-07-28 12:33:56 -07003421/* This is a helper function that's essentially part of the
3422 * implementation of _glcpp_parser_expand_node. It shouldn't be called
3423 * except for by that function.
3424 *
3425 * Returns NULL if node is a simple token with no expansion, (that is,
3426 * although 'node' corresponds to an identifier defined as a
3427 * function-like macro, it is not followed with a parenthesized
3428 * argument list).
3429 *
3430 * Compute the complete expansion of node (which is a function-like
3431 * macro) and subsequent nodes which are arguments.
3432 *
3433 * Returns the token list that results from the expansion and sets
3434 * *last to the last node in the list that was consumed by the
3435 * expansion. Specifically, *last will be set as follows: as the
3436 * token of the closing right parenthesis.
3437 */
3438static token_list_t *
3439_glcpp_parser_expand_function (glcpp_parser_t *parser,
3440 token_node_t *node,
3441 token_node_t **last)
3442
3443{
3444 macro_t *macro;
3445 const char *identifier;
3446 argument_list_t *arguments;
3447 function_status_t status;
3448 token_list_t *substituted;
3449 int parameter_index;
3450
3451 identifier = node->token->value.str;
3452
3453 macro = hash_table_find (parser->defines, identifier);
3454
3455 assert (macro->is_function);
3456
3457 arguments = _argument_list_create (parser);
3458 status = _arguments_parse (arguments, node, last);
3459
3460 switch (status) {
3461 case FUNCTION_STATUS_SUCCESS:
3462 break;
3463 case FUNCTION_NOT_A_FUNCTION:
3464 return NULL;
3465 case FUNCTION_UNBALANCED_PARENTHESES:
3466 glcpp_error (&node->token->location, parser, "Macro %s call has unbalanced parentheses\n", identifier);
3467 return NULL;
3468 }
3469
3470 /* Replace a macro defined as empty with a SPACE token. */
3471 if (macro->replacements == NULL) {
3472 talloc_free (arguments);
3473 return _token_list_create_with_one_space (parser);
3474 }
3475
3476 if (! ((_argument_list_length (arguments) ==
3477 _string_list_length (macro->parameters)) ||
3478 (_string_list_length (macro->parameters) == 0 &&
3479 _argument_list_length (arguments) == 1 &&
3480 arguments->head->argument->head == NULL)))
3481 {
3482 glcpp_error (&node->token->location, parser,
3483 "Error: macro %s invoked with %d arguments (expected %d)\n",
3484 identifier,
3485 _argument_list_length (arguments),
3486 _string_list_length (macro->parameters));
3487 return NULL;
3488 }
3489
3490 /* Perform argument substitution on the replacement list. */
3491 substituted = _token_list_create (arguments);
3492
3493 for (node = macro->replacements->head; node; node = node->next)
3494 {
3495 if (node->token->type == IDENTIFIER &&
3496 _string_list_contains (macro->parameters,
3497 node->token->value.str,
3498 &parameter_index))
3499 {
3500 token_list_t *argument;
3501 argument = _argument_list_member_at (arguments,
3502 parameter_index);
3503 /* Before substituting, we expand the argument
3504 * tokens, or append a placeholder token for
3505 * an empty argument. */
3506 if (argument->head) {
3507 token_list_t *expanded_argument;
3508 expanded_argument = _token_list_copy (parser,
3509 argument);
3510 _glcpp_parser_expand_token_list (parser,
3511 expanded_argument);
3512 _token_list_append_list (substituted,
3513 expanded_argument);
3514 } else {
3515 token_t *new_token;
3516
3517 new_token = _token_create_ival (substituted,
3518 PLACEHOLDER,
3519 PLACEHOLDER);
3520 _token_list_append (substituted, new_token);
3521 }
3522 } else {
3523 _token_list_append (substituted, node->token);
3524 }
3525 }
3526
3527 /* After argument substitution, and before further expansion
3528 * below, implement token pasting. */
3529
3530 _token_list_trim_trailing_space (substituted);
3531
3532 node = substituted->head;
3533 while (node)
3534 {
3535 token_node_t *next_non_space;
3536
3537 /* Look ahead for a PASTE token, skipping space. */
3538 next_non_space = node->next;
3539 while (next_non_space && next_non_space->token->type == SPACE)
3540 next_non_space = next_non_space->next;
3541
3542 if (next_non_space == NULL)
3543 break;
3544
3545 if (next_non_space->token->type != PASTE) {
3546 node = next_non_space;
3547 continue;
3548 }
3549
3550 /* Now find the next non-space token after the PASTE. */
3551 next_non_space = next_non_space->next;
3552 while (next_non_space && next_non_space->token->type == SPACE)
3553 next_non_space = next_non_space->next;
3554
3555 if (next_non_space == NULL) {
3556 yyerror (&node->token->location, parser, "'##' cannot appear at either end of a macro expansion\n");
3557 return NULL;
3558 }
3559
3560 node->token = _token_paste (parser, node->token, next_non_space->token);
3561 node->next = next_non_space->next;
3562 if (next_non_space == substituted->tail)
3563 substituted->tail = node;
3564
3565 node = node->next;
3566 }
3567
3568 substituted->non_space_tail = substituted->tail;
3569
3570 return substituted;
3571}
3572
3573/* Compute the complete expansion of node, (and subsequent nodes after
3574 * 'node' in the case that 'node' is a function-like macro and
3575 * subsequent nodes are arguments).
3576 *
3577 * Returns NULL if node is a simple token with no expansion.
3578 *
3579 * Otherwise, returns the token list that results from the expansion
3580 * and sets *last to the last node in the list that was consumed by
3581 * the expansion. Specifically, *last will be set as follows:
3582 *
3583 * As 'node' in the case of object-like macro expansion.
3584 *
3585 * As the token of the closing right parenthesis in the case of
3586 * function-like macro expansion.
3587 */
3588static token_list_t *
3589_glcpp_parser_expand_node (glcpp_parser_t *parser,
3590 token_node_t *node,
3591 token_node_t **last)
3592{
3593 token_t *token = node->token;
3594 const char *identifier;
3595 macro_t *macro;
3596
3597 /* We only expand identifiers */
3598 if (token->type != IDENTIFIER) {
3599 /* We change any COMMA into a COMMA_FINAL to prevent
3600 * it being mistaken for an argument separator
3601 * later. */
3602 if (token->type == ',') {
3603 token->type = COMMA_FINAL;
3604 token->value.ival = COMMA_FINAL;
3605 }
3606
3607 return NULL;
3608 }
3609
3610 /* Look up this identifier in the hash table. */
3611 identifier = token->value.str;
3612 macro = hash_table_find (parser->defines, identifier);
3613
3614 /* Not a macro, so no expansion needed. */
3615 if (macro == NULL)
3616 return NULL;
3617
3618 /* Finally, don't expand this macro if we're already actively
3619 * expanding it, (to avoid infinite recursion). */
3620 if (_active_list_contains (parser->active, identifier)) {
3621 /* We change the token type here from IDENTIFIER to
3622 * OTHER to prevent any future expansion of this
3623 * unexpanded token. */
3624 char *str;
3625 token_list_t *expansion;
3626 token_t *final;
3627
Kenneth Graunke0ef79a52010-08-03 20:25:13 -07003628 str = talloc_strdup (parser, token->value.str);
Carl Worth667173e2010-07-28 12:33:56 -07003629 final = _token_create_str (parser, OTHER, str);
3630 expansion = _token_list_create (parser);
3631 _token_list_append (expansion, final);
3632 *last = node;
3633 return expansion;
3634 }
3635
3636 if (! macro->is_function)
3637 {
3638 *last = node;
3639
3640 /* Replace a macro defined as empty with a SPACE token. */
3641 if (macro->replacements == NULL)
3642 return _token_list_create_with_one_space (parser);
3643
3644 return _token_list_copy (parser, macro->replacements);
3645 }
3646
3647 return _glcpp_parser_expand_function (parser, node, last);
3648}
3649
3650/* Push a new identifier onto the active list, returning the new list.
3651 *
3652 * Here, 'marker' is the token node that appears in the list after the
3653 * expansion of 'identifier'. That is, when the list iterator begins
3654 * examinging 'marker', then it is time to pop this node from the
3655 * active stack.
3656 */
3657active_list_t *
3658_active_list_push (active_list_t *list,
3659 const char *identifier,
3660 token_node_t *marker)
3661{
3662 active_list_t *node;
3663
Kenneth Graunke0ef79a52010-08-03 20:25:13 -07003664 node = talloc (list, active_list_t);
3665 node->identifier = talloc_strdup (node, identifier);
Carl Worth667173e2010-07-28 12:33:56 -07003666 node->marker = marker;
3667 node->next = list;
3668
3669 return node;
3670}
3671
3672active_list_t *
3673_active_list_pop (active_list_t *list)
3674{
3675 active_list_t *node = list;
3676
3677 if (node == NULL)
3678 return NULL;
3679
3680 node = list->next;
3681 talloc_free (list);
3682
3683 return node;
3684}
3685
3686int
3687_active_list_contains (active_list_t *list, const char *identifier)
3688{
3689 active_list_t *node;
3690
3691 if (list == NULL)
3692 return 0;
3693
3694 for (node = list; node; node = node->next)
3695 if (strcmp (node->identifier, identifier) == 0)
3696 return 1;
3697
3698 return 0;
3699}
3700
3701/* Walk over the token list replacing nodes with their expansion.
3702 * Whenever nodes are expanded the walking will walk over the new
3703 * nodes, continuing to expand as necessary. The results are placed in
3704 * 'list' itself;
3705 */
3706static void
3707_glcpp_parser_expand_token_list (glcpp_parser_t *parser,
3708 token_list_t *list)
3709{
3710 token_node_t *node_prev;
3711 token_node_t *node, *last = NULL;
3712 token_list_t *expansion;
3713
3714 if (list == NULL)
3715 return;
3716
3717 _token_list_trim_trailing_space (list);
3718
3719 node_prev = NULL;
3720 node = list->head;
3721
3722 while (node) {
3723
3724 while (parser->active && parser->active->marker == node)
3725 parser->active = _active_list_pop (parser->active);
3726
3727 /* Find the expansion for node, which will replace all
3728 * nodes from node to last, inclusive. */
3729 expansion = _glcpp_parser_expand_node (parser, node, &last);
3730 if (expansion) {
3731 token_node_t *n;
3732
3733 for (n = node; n != last->next; n = n->next)
3734 while (parser->active &&
3735 parser->active->marker == n)
3736 {
3737 parser->active = _active_list_pop (parser->active);
3738 }
3739
3740 parser->active = _active_list_push (parser->active,
3741 node->token->value.str,
3742 last->next);
3743
3744 /* Splice expansion into list, supporting a
3745 * simple deletion if the expansion is
3746 * empty. */
3747 if (expansion->head) {
3748 if (node_prev)
3749 node_prev->next = expansion->head;
3750 else
3751 list->head = expansion->head;
3752 expansion->tail->next = last->next;
3753 if (last == list->tail)
3754 list->tail = expansion->tail;
3755 } else {
3756 if (node_prev)
3757 node_prev->next = last->next;
3758 else
3759 list->head = last->next;
3760 if (last == list->tail)
3761 list->tail = NULL;
3762 }
3763 } else {
3764 node_prev = node;
3765 }
3766 node = node_prev ? node_prev->next : list->head;
3767 }
3768
3769 while (parser->active)
3770 parser->active = _active_list_pop (parser->active);
3771
3772 list->non_space_tail = list->tail;
3773}
3774
3775void
3776_glcpp_parser_print_expanded_token_list (glcpp_parser_t *parser,
3777 token_list_t *list)
3778{
3779 if (list == NULL)
3780 return;
3781
3782 _glcpp_parser_expand_token_list (parser, list);
3783
3784 _token_list_trim_trailing_space (list);
3785
3786 _token_list_print (parser, list);
3787}
3788
3789static void
3790_check_for_reserved_macro_name (glcpp_parser_t *parser, YYLTYPE *loc,
3791 const char *identifier)
3792{
3793 /* According to the GLSL specification, macro names starting with "__"
3794 * or "GL_" are reserved for future use. So, don't allow them.
3795 */
3796 if (strncmp(identifier, "__", 2) == 0) {
3797 glcpp_error (loc, parser, "Macro names starting with \"__\" are reserved.\n");
3798 }
3799 if (strncmp(identifier, "GL_", 3) == 0) {
3800 glcpp_error (loc, parser, "Macro names starting with \"GL_\" are reserved.\n");
3801 }
3802}
3803
3804void
3805_define_object_macro (glcpp_parser_t *parser,
3806 YYLTYPE *loc,
3807 const char *identifier,
3808 token_list_t *replacements)
3809{
3810 macro_t *macro;
3811
3812 if (loc != NULL)
3813 _check_for_reserved_macro_name(parser, loc, identifier);
3814
Kenneth Graunke0ef79a52010-08-03 20:25:13 -07003815 macro = talloc (parser, macro_t);
Carl Worth667173e2010-07-28 12:33:56 -07003816
3817 macro->is_function = 0;
3818 macro->parameters = NULL;
3819 macro->identifier = talloc_strdup (macro, identifier);
3820 macro->replacements = talloc_steal (macro, replacements);
3821
3822 hash_table_insert (parser->defines, macro, identifier);
3823}
3824
3825void
3826_define_function_macro (glcpp_parser_t *parser,
3827 YYLTYPE *loc,
3828 const char *identifier,
3829 string_list_t *parameters,
3830 token_list_t *replacements)
3831{
3832 macro_t *macro;
3833
3834 _check_for_reserved_macro_name(parser, loc, identifier);
3835
Kenneth Graunke0ef79a52010-08-03 20:25:13 -07003836 macro = talloc (parser, macro_t);
Carl Worth667173e2010-07-28 12:33:56 -07003837
3838 macro->is_function = 1;
3839 macro->parameters = talloc_steal (macro, parameters);
3840 macro->identifier = talloc_strdup (macro, identifier);
3841 macro->replacements = talloc_steal (macro, replacements);
3842
3843 hash_table_insert (parser->defines, macro, identifier);
3844}
3845
3846static int
3847glcpp_parser_lex (YYSTYPE *yylval, YYLTYPE *yylloc, glcpp_parser_t *parser)
3848{
3849 token_node_t *node;
3850 int ret;
3851
3852 if (parser->lex_from_list == NULL) {
3853 ret = glcpp_lex (yylval, yylloc, parser->scanner);
3854
3855 /* XXX: This ugly block of code exists for the sole
3856 * purpose of converting a NEWLINE token into a SPACE
3857 * token, but only in the case where we have seen a
3858 * function-like macro name, but have not yet seen its
3859 * closing parenthesis.
3860 *
3861 * There's perhaps a more compact way to do this with
3862 * mid-rule actions in the grammar.
3863 *
3864 * I'm definitely not pleased with the complexity of
3865 * this code here.
3866 */
3867 if (parser->newline_as_space)
3868 {
3869 if (ret == '(') {
3870 parser->paren_count++;
3871 } else if (ret == ')') {
3872 parser->paren_count--;
3873 if (parser->paren_count == 0)
3874 parser->newline_as_space = 0;
3875 } else if (ret == NEWLINE) {
3876 ret = SPACE;
3877 } else if (ret != SPACE) {
3878 if (parser->paren_count == 0)
3879 parser->newline_as_space = 0;
3880 }
3881 }
3882 else if (parser->in_control_line)
3883 {
3884 if (ret == NEWLINE)
3885 parser->in_control_line = 0;
3886 }
3887 else if (ret == HASH_DEFINE_OBJ || ret == HASH_DEFINE_FUNC ||
3888 ret == HASH_UNDEF || ret == HASH_IF ||
3889 ret == HASH_IFDEF || ret == HASH_IFNDEF ||
3890 ret == HASH_ELIF || ret == HASH_ELSE ||
3891 ret == HASH_ENDIF || ret == HASH)
3892 {
3893 parser->in_control_line = 1;
3894 }
3895 else if (ret == IDENTIFIER)
3896 {
3897 macro_t *macro;
3898 macro = hash_table_find (parser->defines,
3899 yylval->str);
3900 if (macro && macro->is_function) {
3901 parser->newline_as_space = 1;
3902 parser->paren_count = 0;
3903 }
3904 }
3905
3906 return ret;
3907 }
3908
3909 node = parser->lex_from_node;
3910
3911 if (node == NULL) {
3912 talloc_free (parser->lex_from_list);
3913 parser->lex_from_list = NULL;
3914 return NEWLINE;
3915 }
3916
3917 *yylval = node->token->value;
3918 ret = node->token->type;
3919
3920 parser->lex_from_node = node->next;
3921
3922 return ret;
3923}
3924
3925static void
3926glcpp_parser_lex_from (glcpp_parser_t *parser, token_list_t *list)
3927{
3928 token_node_t *node;
3929
3930 assert (parser->lex_from_list == NULL);
3931
3932 /* Copy list, eliminating any space tokens. */
3933 parser->lex_from_list = _token_list_create (parser);
3934
3935 for (node = list->head; node; node = node->next) {
3936 if (node->token->type == SPACE)
3937 continue;
3938 _token_list_append (parser->lex_from_list, node->token);
3939 }
3940
3941 talloc_free (list);
3942
3943 parser->lex_from_node = parser->lex_from_list->head;
3944
3945 /* It's possible the list consisted of nothing but whitespace. */
3946 if (parser->lex_from_node == NULL) {
3947 talloc_free (parser->lex_from_list);
3948 parser->lex_from_list = NULL;
3949 }
3950}
3951
3952static void
3953_glcpp_parser_skip_stack_push_if (glcpp_parser_t *parser, YYLTYPE *loc,
3954 int condition)
3955{
3956 skip_type_t current = SKIP_NO_SKIP;
3957 skip_node_t *node;
3958
3959 if (parser->skip_stack)
3960 current = parser->skip_stack->type;
3961
Kenneth Graunke0ef79a52010-08-03 20:25:13 -07003962 node = talloc (parser, skip_node_t);
Carl Worth667173e2010-07-28 12:33:56 -07003963 node->loc = *loc;
3964
3965 if (current == SKIP_NO_SKIP) {
3966 if (condition)
3967 node->type = SKIP_NO_SKIP;
3968 else
3969 node->type = SKIP_TO_ELSE;
3970 } else {
3971 node->type = SKIP_TO_ENDIF;
3972 }
3973
3974 node->next = parser->skip_stack;
3975 parser->skip_stack = node;
3976}
3977
3978static void
3979_glcpp_parser_skip_stack_change_if (glcpp_parser_t *parser, YYLTYPE *loc,
3980 const char *type, int condition)
3981{
3982 if (parser->skip_stack == NULL) {
3983 glcpp_error (loc, parser, "%s without #if\n", type);
3984 return;
3985 }
3986
3987 if (parser->skip_stack->type == SKIP_TO_ELSE) {
3988 if (condition)
3989 parser->skip_stack->type = SKIP_NO_SKIP;
3990 } else {
3991 parser->skip_stack->type = SKIP_TO_ENDIF;
3992 }
3993}
3994
3995static void
3996_glcpp_parser_skip_stack_pop (glcpp_parser_t *parser, YYLTYPE *loc)
3997{
3998 skip_node_t *node;
3999
4000 if (parser->skip_stack == NULL) {
4001 glcpp_error (loc, parser, "#endif without #if\n");
4002 return;
4003 }
4004
4005 node = parser->skip_stack;
4006 parser->skip_stack = node->next;
4007 talloc_free (node);
4008}
4009