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