blob: b081d22e752e382e5a13c5e582a9d634acef282f [file] [log] [blame]
Carl Worthe29cd392010-08-10 16:59:20 -07001
2/* A Bison parser, made by GNU Bison 2.4.1. */
Carl Worth667173e2010-07-28 12:33:56 -07003
4/* Skeleton implementation for Bison's Yacc-like parsers in C
5
Carl Worthe29cd392010-08-10 16:59:20 -07006 Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
7 Free Software Foundation, Inc.
Carl Worth667173e2010-07-28 12:33:56 -07008
9 This program is free software: you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation, either version 3 of the License, or
12 (at your option) any later version.
13
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with this program. If not, see <http://www.gnu.org/licenses/>. */
21
22/* As a special exception, you may create a larger work that contains
23 part or all of the Bison parser skeleton and distribute that work
24 under terms of your choice, so long as that work isn't itself a
25 parser generator using the skeleton or a modified version thereof
26 as a parser skeleton. Alternatively, if you modify or redistribute
27 the parser skeleton itself, you may (at your option) remove this
28 special exception, which will cause the skeleton and the resulting
29 Bison output files to be licensed under the GNU General Public
30 License without this special exception.
31
32 This special exception was added by the Free Software Foundation in
33 version 2.2 of Bison. */
34
35/* C LALR(1) parser skeleton written by Richard Stallman, by
36 simplifying the original so-called "semantic" parser. */
37
38/* All symbols defined below should begin with yy or YY, to avoid
39 infringing on user name space. This should be done even for local
40 variables, as they might otherwise be expanded by user macros.
41 There are some unavoidable exceptions within include files to
42 define necessary library symbols; they are noted "INFRINGES ON
43 USER NAME SPACE" below. */
44
45/* Identify Bison output. */
46#define YYBISON 1
47
48/* Bison version. */
Carl Worthe29cd392010-08-10 16:59:20 -070049#define YYBISON_VERSION "2.4.1"
Carl Worth667173e2010-07-28 12:33:56 -070050
51/* Skeleton name. */
52#define YYSKELETON_NAME "yacc.c"
53
54/* Pure parsers. */
55#define YYPURE 1
56
57/* Push parsers. */
58#define YYPUSH 0
59
60/* Pull parsers. */
61#define YYPULL 1
62
63/* Using locations. */
64#define YYLSP_NEEDED 1
65
66
67
68/* Copy the first part of user declarations. */
69
70/* Line 189 of yacc.c */
71#line 1 "glcpp/glcpp-parse.y"
72
73/*
74 * Copyright © 2010 Intel Corporation
75 *
76 * Permission is hereby granted, free of charge, to any person obtaining a
77 * copy of this software and associated documentation files (the "Software"),
78 * to deal in the Software without restriction, including without limitation
79 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
80 * and/or sell copies of the Software, and to permit persons to whom the
81 * Software is furnished to do so, subject to the following conditions:
82 *
83 * The above copyright notice and this permission notice (including the next
84 * paragraph) shall be included in all copies or substantial portions of the
85 * Software.
86 *
87 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
88 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
89 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
90 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
91 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
92 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
93 * DEALINGS IN THE SOFTWARE.
94 */
95
96#include <stdio.h>
97#include <stdlib.h>
Ian Romanick188f60f2010-08-12 10:07:05 -070098#include <string.h>
Carl Worth667173e2010-07-28 12:33:56 -070099#include <assert.h>
Ian Romanicka77a6bc2010-08-13 16:22:21 -0700100#include <stdint.h>
Carl Worth667173e2010-07-28 12:33:56 -0700101
102#include "glcpp.h"
103#include "main/mtypes.h"
104
105#define glcpp_print(stream, str) stream = talloc_strdup_append(stream, str)
106#define glcpp_printf(stream, fmt, args...) \
107 stream = talloc_asprintf_append(stream, fmt, args)
108
109static void
110yyerror (YYLTYPE *locp, glcpp_parser_t *parser, const char *error);
111
112static void
113_define_object_macro (glcpp_parser_t *parser,
114 YYLTYPE *loc,
115 const char *macro,
116 token_list_t *replacements);
117
118static void
119_define_function_macro (glcpp_parser_t *parser,
120 YYLTYPE *loc,
121 const char *macro,
122 string_list_t *parameters,
123 token_list_t *replacements);
124
125static string_list_t *
126_string_list_create (void *ctx);
127
128static void
129_string_list_append_item (string_list_t *list, const char *str);
130
131static int
132_string_list_contains (string_list_t *list, const char *member, int *index);
133
134static int
135_string_list_length (string_list_t *list);
136
137static argument_list_t *
138_argument_list_create (void *ctx);
139
140static void
141_argument_list_append (argument_list_t *list, token_list_t *argument);
142
143static int
144_argument_list_length (argument_list_t *list);
145
146static token_list_t *
147_argument_list_member_at (argument_list_t *list, int index);
148
149/* Note: This function talloc_steal()s the str pointer. */
150static token_t *
151_token_create_str (void *ctx, int type, char *str);
152
153static token_t *
154_token_create_ival (void *ctx, int type, int ival);
155
156static token_list_t *
157_token_list_create (void *ctx);
158
159/* Note: This function adds a talloc_reference() to token.
160 *
161 * You may want to talloc_unlink any current reference if you no
162 * longer need it. */
163static void
164_token_list_append (token_list_t *list, token_t *token);
165
166static void
167_token_list_append_list (token_list_t *list, token_list_t *tail);
168
169static active_list_t *
170_active_list_push (active_list_t *list,
171 const char *identifier,
172 token_node_t *marker);
173
174static active_list_t *
175_active_list_pop (active_list_t *list);
176
177int
178_active_list_contains (active_list_t *list, const char *identifier);
179
180static void
Kenneth Graunke16b4eed2010-08-04 16:10:03 -0700181_glcpp_parser_expand_if (glcpp_parser_t *parser, int type, token_list_t *list);
182
183static void
Carl Worth667173e2010-07-28 12:33:56 -0700184_glcpp_parser_expand_token_list (glcpp_parser_t *parser,
185 token_list_t *list);
186
187static void
188_glcpp_parser_print_expanded_token_list (glcpp_parser_t *parser,
189 token_list_t *list);
190
191static void
192_glcpp_parser_skip_stack_push_if (glcpp_parser_t *parser, YYLTYPE *loc,
193 int condition);
194
195static void
196_glcpp_parser_skip_stack_change_if (glcpp_parser_t *parser, YYLTYPE *loc,
197 const char *type, int condition);
198
199static void
200_glcpp_parser_skip_stack_pop (glcpp_parser_t *parser, YYLTYPE *loc);
201
202#define yylex glcpp_parser_lex
203
204static int
205glcpp_parser_lex (YYSTYPE *yylval, YYLTYPE *yylloc, glcpp_parser_t *parser);
206
207static void
208glcpp_parser_lex_from (glcpp_parser_t *parser, token_list_t *list);
209
Eric Anholtd4a04f32010-07-28 16:58:39 -0700210static void
211add_builtin_define(glcpp_parser_t *parser, const char *name, int value);
212
Carl Worth667173e2010-07-28 12:33:56 -0700213
214
215/* Line 189 of yacc.c */
Ian Romanick188f60f2010-08-12 10:07:05 -0700216#line 217 "glcpp/glcpp-parse.c"
Carl Worth667173e2010-07-28 12:33:56 -0700217
218/* Enabling traces. */
219#ifndef YYDEBUG
220# define YYDEBUG 0
221#endif
222
223/* Enabling verbose error messages. */
224#ifdef YYERROR_VERBOSE
225# undef YYERROR_VERBOSE
226# define YYERROR_VERBOSE 1
227#else
228# define YYERROR_VERBOSE 1
229#endif
230
231/* Enabling the token table. */
232#ifndef YYTOKEN_TABLE
233# define YYTOKEN_TABLE 0
234#endif
235
236
237/* Tokens. */
238#ifndef YYTOKENTYPE
239# define YYTOKENTYPE
240 /* Put the tokens into the symbol table, so that GDB and other debuggers
241 know about them. */
242 enum yytokentype {
243 COMMA_FINAL = 258,
244 DEFINED = 259,
245 ELIF_EXPANDED = 260,
246 HASH = 261,
247 HASH_DEFINE_FUNC = 262,
248 HASH_DEFINE_OBJ = 263,
249 HASH_ELIF = 264,
250 HASH_ELSE = 265,
251 HASH_ENDIF = 266,
252 HASH_IF = 267,
253 HASH_IFDEF = 268,
254 HASH_IFNDEF = 269,
255 HASH_UNDEF = 270,
Eric Anholtd4a04f32010-07-28 16:58:39 -0700256 HASH_VERSION = 271,
257 IDENTIFIER = 272,
258 IF_EXPANDED = 273,
259 INTEGER = 274,
260 INTEGER_STRING = 275,
261 NEWLINE = 276,
262 OTHER = 277,
263 PLACEHOLDER = 278,
264 SPACE = 279,
265 PASTE = 280,
266 OR = 281,
267 AND = 282,
268 NOT_EQUAL = 283,
269 EQUAL = 284,
270 GREATER_OR_EQUAL = 285,
271 LESS_OR_EQUAL = 286,
272 RIGHT_SHIFT = 287,
273 LEFT_SHIFT = 288,
274 UNARY = 289
Carl Worth667173e2010-07-28 12:33:56 -0700275 };
276#endif
277
278
279
280#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
281
282# define yystype YYSTYPE /* obsolescent; will be withdrawn */
283# define YYSTYPE_IS_DECLARED 1
284#endif
285
286#if ! defined YYLTYPE && ! defined YYLTYPE_IS_DECLARED
287typedef struct YYLTYPE
288{
289 int first_line;
290 int first_column;
291 int last_line;
292 int last_column;
293} YYLTYPE;
294# define yyltype YYLTYPE /* obsolescent; will be withdrawn */
295# define YYLTYPE_IS_DECLARED 1
296# define YYLTYPE_IS_TRIVIAL 1
297#endif
298
299
300/* Copy the second part of user declarations. */
301
302
303/* Line 264 of yacc.c */
Ian Romanick188f60f2010-08-12 10:07:05 -0700304#line 305 "glcpp/glcpp-parse.c"
Carl Worth667173e2010-07-28 12:33:56 -0700305
306#ifdef short
307# undef short
308#endif
309
310#ifdef YYTYPE_UINT8
311typedef YYTYPE_UINT8 yytype_uint8;
312#else
313typedef unsigned char yytype_uint8;
314#endif
315
316#ifdef YYTYPE_INT8
317typedef YYTYPE_INT8 yytype_int8;
318#elif (defined __STDC__ || defined __C99__FUNC__ \
319 || defined __cplusplus || defined _MSC_VER)
320typedef signed char yytype_int8;
321#else
322typedef short int yytype_int8;
323#endif
324
325#ifdef YYTYPE_UINT16
326typedef YYTYPE_UINT16 yytype_uint16;
327#else
328typedef unsigned short int yytype_uint16;
329#endif
330
331#ifdef YYTYPE_INT16
332typedef YYTYPE_INT16 yytype_int16;
333#else
334typedef short int yytype_int16;
335#endif
336
337#ifndef YYSIZE_T
338# ifdef __SIZE_TYPE__
339# define YYSIZE_T __SIZE_TYPE__
340# elif defined size_t
341# define YYSIZE_T size_t
342# elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \
343 || defined __cplusplus || defined _MSC_VER)
344# include <stddef.h> /* INFRINGES ON USER NAME SPACE */
345# define YYSIZE_T size_t
346# else
347# define YYSIZE_T unsigned int
348# endif
349#endif
350
351#define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
352
353#ifndef YY_
Carl Worthe29cd392010-08-10 16:59:20 -0700354# if YYENABLE_NLS
Carl Worth667173e2010-07-28 12:33:56 -0700355# if ENABLE_NLS
356# include <libintl.h> /* INFRINGES ON USER NAME SPACE */
357# define YY_(msgid) dgettext ("bison-runtime", msgid)
358# endif
359# endif
360# ifndef YY_
361# define YY_(msgid) msgid
362# endif
363#endif
364
365/* Suppress unused-variable warnings by "using" E. */
366#if ! defined lint || defined __GNUC__
367# define YYUSE(e) ((void) (e))
368#else
369# define YYUSE(e) /* empty */
370#endif
371
372/* Identity function, used to suppress warnings about constant conditions. */
373#ifndef lint
374# define YYID(n) (n)
375#else
376#if (defined __STDC__ || defined __C99__FUNC__ \
377 || defined __cplusplus || defined _MSC_VER)
378static int
379YYID (int yyi)
380#else
381static int
382YYID (yyi)
383 int yyi;
384#endif
385{
386 return yyi;
387}
388#endif
389
390#if ! defined yyoverflow || YYERROR_VERBOSE
391
392/* The parser invokes alloca or malloc; define the necessary symbols. */
393
394# ifdef YYSTACK_USE_ALLOCA
395# if YYSTACK_USE_ALLOCA
396# ifdef __GNUC__
397# define YYSTACK_ALLOC __builtin_alloca
398# elif defined __BUILTIN_VA_ARG_INCR
399# include <alloca.h> /* INFRINGES ON USER NAME SPACE */
400# elif defined _AIX
401# define YYSTACK_ALLOC __alloca
402# elif defined _MSC_VER
403# include <malloc.h> /* INFRINGES ON USER NAME SPACE */
404# define alloca _alloca
405# else
406# define YYSTACK_ALLOC alloca
407# if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
408 || defined __cplusplus || defined _MSC_VER)
409# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
410# ifndef _STDLIB_H
411# define _STDLIB_H 1
412# endif
413# endif
414# endif
415# endif
416# endif
417
418# ifdef YYSTACK_ALLOC
419 /* Pacify GCC's `empty if-body' warning. */
420# define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0))
421# ifndef YYSTACK_ALLOC_MAXIMUM
422 /* The OS might guarantee only one guard page at the bottom of the stack,
423 and a page size can be as small as 4096 bytes. So we cannot safely
424 invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
425 to allow for a few compiler-allocated temporary stack slots. */
426# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
427# endif
428# else
429# define YYSTACK_ALLOC YYMALLOC
430# define YYSTACK_FREE YYFREE
431# ifndef YYSTACK_ALLOC_MAXIMUM
432# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
433# endif
434# if (defined __cplusplus && ! defined _STDLIB_H \
435 && ! ((defined YYMALLOC || defined malloc) \
436 && (defined YYFREE || defined free)))
437# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
438# ifndef _STDLIB_H
439# define _STDLIB_H 1
440# endif
441# endif
442# ifndef YYMALLOC
443# define YYMALLOC malloc
444# if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
445 || defined __cplusplus || defined _MSC_VER)
446void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
447# endif
448# endif
449# ifndef YYFREE
450# define YYFREE free
451# if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
452 || defined __cplusplus || defined _MSC_VER)
453void free (void *); /* INFRINGES ON USER NAME SPACE */
454# endif
455# endif
456# endif
457#endif /* ! defined yyoverflow || YYERROR_VERBOSE */
458
459
460#if (! defined yyoverflow \
461 && (! defined __cplusplus \
462 || (defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL \
463 && defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
464
465/* A type that is properly aligned for any stack member. */
466union yyalloc
467{
468 yytype_int16 yyss_alloc;
469 YYSTYPE yyvs_alloc;
470 YYLTYPE yyls_alloc;
471};
472
473/* The size of the maximum gap between one aligned stack and the next. */
474# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
475
476/* The size of an array large to enough to hold all stacks, each with
477 N elements. */
478# define YYSTACK_BYTES(N) \
479 ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE) + sizeof (YYLTYPE)) \
480 + 2 * YYSTACK_GAP_MAXIMUM)
481
482/* Copy COUNT objects from FROM to TO. The source and destination do
483 not overlap. */
484# ifndef YYCOPY
485# if defined __GNUC__ && 1 < __GNUC__
486# define YYCOPY(To, From, Count) \
487 __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
488# else
489# define YYCOPY(To, From, Count) \
490 do \
491 { \
492 YYSIZE_T yyi; \
493 for (yyi = 0; yyi < (Count); yyi++) \
494 (To)[yyi] = (From)[yyi]; \
495 } \
496 while (YYID (0))
497# endif
498# endif
499
500/* Relocate STACK from its old location to the new one. The
501 local variables YYSIZE and YYSTACKSIZE give the old and new number of
502 elements in the stack, and YYPTR gives the new location of the
503 stack. Advance YYPTR to a properly aligned location for the next
504 stack. */
505# define YYSTACK_RELOCATE(Stack_alloc, Stack) \
506 do \
507 { \
508 YYSIZE_T yynewbytes; \
509 YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \
510 Stack = &yyptr->Stack_alloc; \
511 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
512 yyptr += yynewbytes / sizeof (*yyptr); \
513 } \
514 while (YYID (0))
515
516#endif
517
518/* YYFINAL -- State number of the termination state. */
519#define YYFINAL 2
520/* YYLAST -- Last index in YYTABLE. */
Carl Worth6b9e7b02010-08-11 14:00:21 -0700521#define YYLAST 606
Carl Worth667173e2010-07-28 12:33:56 -0700522
523/* YYNTOKENS -- Number of terminals. */
Eric Anholtd4a04f32010-07-28 16:58:39 -0700524#define YYNTOKENS 57
Carl Worth667173e2010-07-28 12:33:56 -0700525/* YYNNTS -- Number of nonterminals. */
Eric Anholtd4a04f32010-07-28 16:58:39 -0700526#define YYNNTS 17
Carl Worth667173e2010-07-28 12:33:56 -0700527/* YYNRULES -- Number of rules. */
Carl Worth6b9e7b02010-08-11 14:00:21 -0700528#define YYNRULES 101
Carl Worth667173e2010-07-28 12:33:56 -0700529/* YYNRULES -- Number of states. */
Carl Worth6b9e7b02010-08-11 14:00:21 -0700530#define YYNSTATES 162
Carl Worth667173e2010-07-28 12:33:56 -0700531
532/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
533#define YYUNDEFTOK 2
Eric Anholtd4a04f32010-07-28 16:58:39 -0700534#define YYMAXUTOK 289
Carl Worth667173e2010-07-28 12:33:56 -0700535
536#define YYTRANSLATE(YYX) \
537 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
538
539/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
540static const yytype_uint8 yytranslate[] =
541{
542 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
543 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
544 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
Eric Anholtd4a04f32010-07-28 16:58:39 -0700545 2, 2, 2, 47, 2, 2, 2, 43, 30, 2,
546 45, 46, 41, 39, 49, 40, 54, 42, 2, 2,
547 2, 2, 2, 2, 2, 2, 2, 2, 2, 55,
548 33, 56, 34, 2, 2, 2, 2, 2, 2, 2,
Carl Worth667173e2010-07-28 12:33:56 -0700549 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
550 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
Eric Anholtd4a04f32010-07-28 16:58:39 -0700551 2, 50, 2, 51, 29, 2, 2, 2, 2, 2,
Carl Worth667173e2010-07-28 12:33:56 -0700552 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
553 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
Eric Anholtd4a04f32010-07-28 16:58:39 -0700554 2, 2, 2, 52, 28, 53, 48, 2, 2, 2,
Carl Worth667173e2010-07-28 12:33:56 -0700555 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
556 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
557 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
558 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
559 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
560 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
561 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
562 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
563 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
564 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
565 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
566 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
567 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
568 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
569 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
Eric Anholtd4a04f32010-07-28 16:58:39 -0700570 25, 26, 27, 31, 32, 35, 36, 37, 38, 44
Carl Worth667173e2010-07-28 12:33:56 -0700571};
572
573#if YYDEBUG
574/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
575 YYRHS. */
576static const yytype_uint16 yyprhs[] =
577{
578 0, 0, 3, 4, 7, 9, 11, 13, 16, 20,
Carl Worth6b9e7b02010-08-11 14:00:21 -0700579 24, 29, 36, 44, 48, 52, 55, 60, 65, 69,
580 72, 75, 78, 82, 85, 87, 89, 91, 95, 99,
581 103, 107, 111, 115, 119, 123, 127, 131, 135, 139,
582 143, 147, 151, 155, 159, 163, 166, 169, 172, 175,
583 179, 181, 185, 187, 190, 193, 194, 196, 197, 199,
584 202, 207, 209, 211, 214, 216, 219, 221, 223, 225,
585 227, 229, 231, 233, 235, 237, 239, 241, 243, 245,
586 247, 249, 251, 253, 255, 257, 259, 261, 263, 265,
587 267, 269, 271, 273, 275, 277, 279, 281, 283, 285,
588 287, 289
Carl Worth667173e2010-07-28 12:33:56 -0700589};
590
591/* YYRHS -- A `-1'-separated list of the rules' RHS. */
592static const yytype_int8 yyrhs[] =
593{
Eric Anholtd4a04f32010-07-28 16:58:39 -0700594 58, 0, -1, -1, 58, 59, -1, 61, -1, 65,
595 -1, 60, -1, 6, 66, -1, 18, 63, 21, -1,
596 5, 63, 21, -1, 8, 17, 67, 21, -1, 7,
597 17, 45, 46, 67, 21, -1, 7, 17, 45, 64,
598 46, 67, 21, -1, 15, 17, 21, -1, 12, 70,
Carl Worth6b9e7b02010-08-11 14:00:21 -0700599 21, -1, 12, 21, -1, 13, 17, 68, 21, -1,
600 14, 17, 68, 21, -1, 9, 70, 21, -1, 9,
601 21, -1, 10, 21, -1, 11, 21, -1, 16, 62,
602 21, -1, 6, 21, -1, 20, -1, 19, -1, 62,
603 -1, 63, 26, 63, -1, 63, 27, 63, -1, 63,
604 28, 63, -1, 63, 29, 63, -1, 63, 30, 63,
605 -1, 63, 31, 63, -1, 63, 32, 63, -1, 63,
606 35, 63, -1, 63, 36, 63, -1, 63, 34, 63,
607 -1, 63, 33, 63, -1, 63, 37, 63, -1, 63,
608 38, 63, -1, 63, 40, 63, -1, 63, 39, 63,
609 -1, 63, 43, 63, -1, 63, 42, 63, -1, 63,
610 41, 63, -1, 47, 63, -1, 48, 63, -1, 40,
611 63, -1, 39, 63, -1, 45, 63, 46, -1, 17,
612 -1, 64, 49, 17, -1, 21, -1, 71, 21, -1,
613 71, 21, -1, -1, 71, -1, -1, 71, -1, 4,
614 17, -1, 4, 45, 17, 46, -1, 72, -1, 69,
615 -1, 70, 69, -1, 72, -1, 71, 72, -1, 17,
616 -1, 20, -1, 73, -1, 22, -1, 24, -1, 50,
617 -1, 51, -1, 45, -1, 46, -1, 52, -1, 53,
618 -1, 54, -1, 30, -1, 41, -1, 39, -1, 40,
619 -1, 48, -1, 47, -1, 42, -1, 43, -1, 38,
620 -1, 37, -1, 33, -1, 34, -1, 36, -1, 35,
621 -1, 32, -1, 31, -1, 29, -1, 28, -1, 27,
622 -1, 26, -1, 55, -1, 49, -1, 56, -1, 25,
623 -1
Carl Worth667173e2010-07-28 12:33:56 -0700624};
625
626/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
627static const yytype_uint16 yyrline[] =
628{
Ian Romanick188f60f2010-08-12 10:07:05 -0700629 0, 181, 181, 183, 187, 190, 195, 196, 200, 203,
630 209, 212, 215, 218, 226, 245, 255, 260, 265, 284,
631 299, 302, 305, 314, 318, 327, 332, 333, 336, 339,
632 342, 345, 348, 351, 354, 357, 360, 363, 366, 369,
633 372, 375, 378, 381, 384, 387, 390, 393, 396, 399,
634 405, 410, 418, 419, 423, 429, 430, 433, 435, 442,
635 446, 450, 455, 461, 469, 475, 483, 487, 491, 495,
636 499, 506, 507, 508, 509, 510, 511, 512, 513, 514,
637 515, 516, 517, 518, 519, 520, 521, 522, 523, 524,
638 525, 526, 527, 528, 529, 530, 531, 532, 533, 534,
639 535, 536
Carl Worth667173e2010-07-28 12:33:56 -0700640};
641#endif
642
643#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
644/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
645 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
646static const char *const yytname[] =
647{
648 "$end", "error", "$undefined", "COMMA_FINAL", "DEFINED",
649 "ELIF_EXPANDED", "HASH", "HASH_DEFINE_FUNC", "HASH_DEFINE_OBJ",
650 "HASH_ELIF", "HASH_ELSE", "HASH_ENDIF", "HASH_IF", "HASH_IFDEF",
Eric Anholtd4a04f32010-07-28 16:58:39 -0700651 "HASH_IFNDEF", "HASH_UNDEF", "HASH_VERSION", "IDENTIFIER", "IF_EXPANDED",
652 "INTEGER", "INTEGER_STRING", "NEWLINE", "OTHER", "PLACEHOLDER", "SPACE",
653 "PASTE", "OR", "AND", "'|'", "'^'", "'&'", "NOT_EQUAL", "EQUAL", "'<'",
654 "'>'", "GREATER_OR_EQUAL", "LESS_OR_EQUAL", "RIGHT_SHIFT", "LEFT_SHIFT",
655 "'+'", "'-'", "'*'", "'/'", "'%'", "UNARY", "'('", "')'", "'!'", "'~'",
656 "','", "'['", "']'", "'{'", "'}'", "'.'", "';'", "'='", "$accept",
657 "input", "line", "expanded_line", "control_line", "integer_constant",
658 "expression", "identifier_list", "text_line", "non_directive",
659 "replacement_list", "junk", "conditional_token", "conditional_tokens",
660 "pp_tokens", "preprocessing_token", "operator", 0
Carl Worth667173e2010-07-28 12:33:56 -0700661};
662#endif
663
664# ifdef YYPRINT
665/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
666 token YYLEX-NUM. */
667static const yytype_uint16 yytoknum[] =
668{
669 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
670 265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
Eric Anholtd4a04f32010-07-28 16:58:39 -0700671 275, 276, 277, 278, 279, 280, 281, 282, 124, 94,
672 38, 283, 284, 60, 62, 285, 286, 287, 288, 43,
673 45, 42, 47, 37, 289, 40, 41, 33, 126, 44,
674 91, 93, 123, 125, 46, 59, 61
Carl Worth667173e2010-07-28 12:33:56 -0700675};
676# endif
677
678/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
679static const yytype_uint8 yyr1[] =
680{
Eric Anholtd4a04f32010-07-28 16:58:39 -0700681 0, 57, 58, 58, 59, 59, 59, 59, 60, 60,
Carl Worth667173e2010-07-28 12:33:56 -0700682 61, 61, 61, 61, 61, 61, 61, 61, 61, 61,
Carl Worth6b9e7b02010-08-11 14:00:21 -0700683 61, 61, 61, 61, 62, 62, 63, 63, 63, 63,
Eric Anholtd4a04f32010-07-28 16:58:39 -0700684 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
Carl Worth6b9e7b02010-08-11 14:00:21 -0700685 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
686 64, 64, 65, 65, 66, 67, 67, 68, 68, 69,
687 69, 69, 70, 70, 71, 71, 72, 72, 72, 72,
688 72, 73, 73, 73, 73, 73, 73, 73, 73, 73,
Eric Anholtd4a04f32010-07-28 16:58:39 -0700689 73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
690 73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
Carl Worth6b9e7b02010-08-11 14:00:21 -0700691 73, 73
Carl Worth667173e2010-07-28 12:33:56 -0700692};
693
694/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
695static const yytype_uint8 yyr2[] =
696{
697 0, 2, 0, 2, 1, 1, 1, 2, 3, 3,
Carl Worth6b9e7b02010-08-11 14:00:21 -0700698 4, 6, 7, 3, 3, 2, 4, 4, 3, 2,
699 2, 2, 3, 2, 1, 1, 1, 3, 3, 3,
Carl Worth667173e2010-07-28 12:33:56 -0700700 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
Carl Worth6b9e7b02010-08-11 14:00:21 -0700701 3, 3, 3, 3, 3, 2, 2, 2, 2, 3,
702 1, 3, 1, 2, 2, 0, 1, 0, 1, 2,
703 4, 1, 1, 2, 1, 2, 1, 1, 1, 1,
Carl Worth667173e2010-07-28 12:33:56 -0700704 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
705 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
Eric Anholtd4a04f32010-07-28 16:58:39 -0700706 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
Carl Worth6b9e7b02010-08-11 14:00:21 -0700707 1, 1
Carl Worth667173e2010-07-28 12:33:56 -0700708};
709
710/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
711 STATE-NUM when YYTABLE doesn't specify something else to do. Zero
712 means the default is an error. */
713static const yytype_uint8 yydefact[] =
714{
715 2, 0, 1, 0, 0, 0, 0, 0, 0, 0,
Carl Worth6b9e7b02010-08-11 14:00:21 -0700716 0, 0, 0, 0, 0, 66, 0, 67, 52, 69,
717 70, 101, 97, 96, 95, 94, 78, 93, 92, 88,
718 89, 91, 90, 87, 86, 80, 81, 79, 84, 85,
719 73, 74, 83, 82, 99, 71, 72, 75, 76, 77,
720 98, 100, 3, 6, 4, 5, 0, 64, 68, 25,
721 24, 0, 0, 0, 0, 0, 26, 0, 23, 7,
722 0, 0, 55, 0, 19, 62, 0, 61, 20, 21,
723 15, 0, 57, 57, 0, 0, 0, 53, 65, 48,
724 47, 0, 45, 46, 9, 0, 0, 0, 0, 0,
Eric Anholtd4a04f32010-07-28 16:58:39 -0700725 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Carl Worth6b9e7b02010-08-11 14:00:21 -0700726 0, 0, 0, 54, 0, 0, 56, 59, 0, 18,
727 63, 14, 0, 58, 0, 13, 22, 8, 49, 27,
728 28, 29, 30, 31, 32, 33, 37, 36, 34, 35,
729 38, 39, 41, 40, 44, 43, 42, 50, 55, 0,
730 10, 0, 16, 17, 0, 55, 0, 60, 11, 0,
731 51, 12
Carl Worth667173e2010-07-28 12:33:56 -0700732};
733
734/* YYDEFGOTO[NTERM-NUM]. */
735static const yytype_int16 yydefgoto[] =
736{
Carl Worth6b9e7b02010-08-11 14:00:21 -0700737 -1, 1, 52, 53, 54, 66, 67, 149, 55, 69,
738 115, 122, 75, 76, 116, 57, 58
Carl Worth667173e2010-07-28 12:33:56 -0700739};
740
741/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
742 STATE-NUM. */
Carl Worth6b9e7b02010-08-11 14:00:21 -0700743#define YYPACT_NINF -147
Carl Worth667173e2010-07-28 12:33:56 -0700744static const yytype_int16 yypact[] =
745{
Carl Worth6b9e7b02010-08-11 14:00:21 -0700746 -147, 112, -147, 28, -10, 55, 62, 152, -15, 59,
747 192, 85, 86, 87, 51, -147, 28, -147, -147, -147,
748 -147, -147, -147, -147, -147, -147, -147, -147, -147, -147,
749 -147, -147, -147, -147, -147, -147, -147, -147, -147, -147,
750 -147, -147, -147, -147, -147, -147, -147, -147, -147, -147,
751 -147, -147, -147, -147, -147, -147, 312, -147, -147, -147,
752 -147, 28, 28, 28, 28, 28, -147, 428, -147, -147,
753 352, 63, 392, 17, -147, -147, 232, -147, -147, -147,
754 -147, 272, 392, 392, 84, 89, 451, -147, -147, -147,
755 -147, 469, -147, -147, -147, 28, 28, 28, 28, 28,
756 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
757 28, 28, 28, -147, 60, 90, 392, -147, 96, -147,
758 -147, -147, 93, 392, 94, -147, -147, -147, -147, 489,
759 505, 520, 534, 547, 558, 558, 18, 18, 18, 18,
760 563, 563, 23, 23, -147, -147, -147, -147, 392, 32,
761 -147, 61, -147, -147, 110, 392, 118, -147, -147, 149,
762 -147, -147
Carl Worth667173e2010-07-28 12:33:56 -0700763};
764
765/* YYPGOTO[NTERM-NUM]. */
Eric Anholtd4a04f32010-07-28 16:58:39 -0700766static const yytype_int16 yypgoto[] =
Carl Worth667173e2010-07-28 12:33:56 -0700767{
Carl Worth6b9e7b02010-08-11 14:00:21 -0700768 -147, -147, -147, -147, -147, 157, -11, -147, -147, -147,
769 -146, 92, -68, 200, 0, -7, -147
Carl Worth667173e2010-07-28 12:33:56 -0700770};
771
772/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
773 positive, shift that token. If negative, reduce the rule which
774 number is the opposite. If zero, do what YYDEFACT says.
775 If YYTABLE_NINF, syntax error. */
776#define YYTABLE_NINF -1
777static const yytype_uint8 yytable[] =
778{
Carl Worth6b9e7b02010-08-11 14:00:21 -0700779 77, 56, 154, 77, 70, 86, 78, 15, 120, 159,
780 17, 68, 19, 120, 20, 21, 22, 23, 24, 25,
Carl Worth667173e2010-07-28 12:33:56 -0700781 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
Carl Worth6b9e7b02010-08-11 14:00:21 -0700782 36, 37, 38, 39, 117, 40, 41, 42, 43, 44,
783 45, 46, 47, 48, 49, 50, 51, 59, 60, 88,
784 89, 90, 91, 92, 93, 106, 107, 108, 109, 110,
785 111, 112, 118, 88, 110, 111, 112, 61, 62, 77,
786 59, 60, 71, 63, 77, 64, 65, 147, 155, 72,
787 79, 156, 123, 123, 129, 130, 131, 132, 133, 134,
Eric Anholtd4a04f32010-07-28 16:58:39 -0700788 135, 136, 137, 138, 139, 140, 141, 142, 143, 144,
Carl Worth6b9e7b02010-08-11 14:00:21 -0700789 145, 146, 82, 83, 84, 125, 148, 157, 114, 88,
790 126, 150, 2, 151, 152, 153, 88, 3, 4, 5,
791 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
792 16, 158, 17, 18, 19, 160, 20, 21, 22, 23,
793 24, 25, 26, 27, 28, 29, 30, 31, 32, 33,
794 34, 35, 36, 37, 38, 39, 73, 40, 41, 42,
795 43, 44, 45, 46, 47, 48, 49, 50, 51, 15,
796 161, 85, 17, 74, 19, 124, 20, 21, 22, 23,
797 24, 25, 26, 27, 28, 29, 30, 31, 32, 33,
798 34, 35, 36, 37, 38, 39, 73, 40, 41, 42,
799 43, 44, 45, 46, 47, 48, 49, 50, 51, 15,
800 81, 0, 17, 80, 19, 0, 20, 21, 22, 23,
801 24, 25, 26, 27, 28, 29, 30, 31, 32, 33,
802 34, 35, 36, 37, 38, 39, 73, 40, 41, 42,
803 43, 44, 45, 46, 47, 48, 49, 50, 51, 15,
804 0, 0, 17, 119, 19, 0, 20, 21, 22, 23,
805 24, 25, 26, 27, 28, 29, 30, 31, 32, 33,
806 34, 35, 36, 37, 38, 39, 73, 40, 41, 42,
807 43, 44, 45, 46, 47, 48, 49, 50, 51, 15,
808 0, 0, 17, 121, 19, 0, 20, 21, 22, 23,
809 24, 25, 26, 27, 28, 29, 30, 31, 32, 33,
810 34, 35, 36, 37, 38, 39, 0, 40, 41, 42,
811 43, 44, 45, 46, 47, 48, 49, 50, 51, 15,
812 0, 0, 17, 87, 19, 0, 20, 21, 22, 23,
813 24, 25, 26, 27, 28, 29, 30, 31, 32, 33,
814 34, 35, 36, 37, 38, 39, 0, 40, 41, 42,
815 43, 44, 45, 46, 47, 48, 49, 50, 51, 15,
816 0, 0, 17, 113, 19, 0, 20, 21, 22, 23,
817 24, 25, 26, 27, 28, 29, 30, 31, 32, 33,
818 34, 35, 36, 37, 38, 39, 0, 40, 41, 42,
819 43, 44, 45, 46, 47, 48, 49, 50, 51, 15,
820 0, 0, 17, 0, 19, 0, 20, 21, 22, 23,
821 24, 25, 26, 27, 28, 29, 30, 31, 32, 33,
822 34, 35, 36, 37, 38, 39, 0, 40, 41, 42,
823 43, 44, 45, 46, 47, 48, 49, 50, 51, 94,
824 0, 0, 0, 0, 95, 96, 97, 98, 99, 100,
Eric Anholtd4a04f32010-07-28 16:58:39 -0700825 101, 102, 103, 104, 105, 106, 107, 108, 109, 110,
Carl Worth6b9e7b02010-08-11 14:00:21 -0700826 111, 112, 127, 0, 0, 0, 0, 95, 96, 97,
827 98, 99, 100, 101, 102, 103, 104, 105, 106, 107,
828 108, 109, 110, 111, 112, 95, 96, 97, 98, 99,
829 100, 101, 102, 103, 104, 105, 106, 107, 108, 109,
830 110, 111, 112, 0, 0, 128, 96, 97, 98, 99,
831 100, 101, 102, 103, 104, 105, 106, 107, 108, 109,
832 110, 111, 112, 97, 98, 99, 100, 101, 102, 103,
833 104, 105, 106, 107, 108, 109, 110, 111, 112, 98,
834 99, 100, 101, 102, 103, 104, 105, 106, 107, 108,
835 109, 110, 111, 112, 99, 100, 101, 102, 103, 104,
836 105, 106, 107, 108, 109, 110, 111, 112, 100, 101,
837 102, 103, 104, 105, 106, 107, 108, 109, 110, 111,
838 112, 102, 103, 104, 105, 106, 107, 108, 109, 110,
839 111, 112, 108, 109, 110, 111, 112
Carl Worth667173e2010-07-28 12:33:56 -0700840};
841
842static const yytype_int16 yycheck[] =
843{
Carl Worth6b9e7b02010-08-11 14:00:21 -0700844 7, 1, 148, 10, 4, 16, 21, 17, 76, 155,
845 20, 21, 22, 81, 24, 25, 26, 27, 28, 29,
Carl Worth667173e2010-07-28 12:33:56 -0700846 30, 31, 32, 33, 34, 35, 36, 37, 38, 39,
Eric Anholtd4a04f32010-07-28 16:58:39 -0700847 40, 41, 42, 43, 17, 45, 46, 47, 48, 49,
Carl Worth6b9e7b02010-08-11 14:00:21 -0700848 50, 51, 52, 53, 54, 55, 56, 19, 20, 56,
Eric Anholtd4a04f32010-07-28 16:58:39 -0700849 61, 62, 63, 64, 65, 37, 38, 39, 40, 41,
Carl Worth6b9e7b02010-08-11 14:00:21 -0700850 42, 43, 45, 70, 41, 42, 43, 39, 40, 76,
851 19, 20, 17, 45, 81, 47, 48, 17, 46, 17,
852 21, 49, 82, 83, 95, 96, 97, 98, 99, 100,
Eric Anholtd4a04f32010-07-28 16:58:39 -0700853 101, 102, 103, 104, 105, 106, 107, 108, 109, 110,
Carl Worth6b9e7b02010-08-11 14:00:21 -0700854 111, 112, 17, 17, 17, 21, 46, 46, 45, 116,
855 21, 21, 0, 17, 21, 21, 123, 5, 6, 7,
856 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
857 18, 21, 20, 21, 22, 17, 24, 25, 26, 27,
Carl Worth667173e2010-07-28 12:33:56 -0700858 28, 29, 30, 31, 32, 33, 34, 35, 36, 37,
Carl Worth6b9e7b02010-08-11 14:00:21 -0700859 38, 39, 40, 41, 42, 43, 4, 45, 46, 47,
860 48, 49, 50, 51, 52, 53, 54, 55, 56, 17,
861 21, 14, 20, 21, 22, 83, 24, 25, 26, 27,
Eric Anholtd4a04f32010-07-28 16:58:39 -0700862 28, 29, 30, 31, 32, 33, 34, 35, 36, 37,
Carl Worth6b9e7b02010-08-11 14:00:21 -0700863 38, 39, 40, 41, 42, 43, 4, 45, 46, 47,
864 48, 49, 50, 51, 52, 53, 54, 55, 56, 17,
865 10, -1, 20, 21, 22, -1, 24, 25, 26, 27,
866 28, 29, 30, 31, 32, 33, 34, 35, 36, 37,
867 38, 39, 40, 41, 42, 43, 4, 45, 46, 47,
868 48, 49, 50, 51, 52, 53, 54, 55, 56, 17,
869 -1, -1, 20, 21, 22, -1, 24, 25, 26, 27,
870 28, 29, 30, 31, 32, 33, 34, 35, 36, 37,
871 38, 39, 40, 41, 42, 43, 4, 45, 46, 47,
872 48, 49, 50, 51, 52, 53, 54, 55, 56, 17,
873 -1, -1, 20, 21, 22, -1, 24, 25, 26, 27,
874 28, 29, 30, 31, 32, 33, 34, 35, 36, 37,
875 38, 39, 40, 41, 42, 43, -1, 45, 46, 47,
876 48, 49, 50, 51, 52, 53, 54, 55, 56, 17,
877 -1, -1, 20, 21, 22, -1, 24, 25, 26, 27,
878 28, 29, 30, 31, 32, 33, 34, 35, 36, 37,
879 38, 39, 40, 41, 42, 43, -1, 45, 46, 47,
880 48, 49, 50, 51, 52, 53, 54, 55, 56, 17,
881 -1, -1, 20, 21, 22, -1, 24, 25, 26, 27,
882 28, 29, 30, 31, 32, 33, 34, 35, 36, 37,
883 38, 39, 40, 41, 42, 43, -1, 45, 46, 47,
884 48, 49, 50, 51, 52, 53, 54, 55, 56, 17,
885 -1, -1, 20, -1, 22, -1, 24, 25, 26, 27,
886 28, 29, 30, 31, 32, 33, 34, 35, 36, 37,
887 38, 39, 40, 41, 42, 43, -1, 45, 46, 47,
888 48, 49, 50, 51, 52, 53, 54, 55, 56, 21,
889 -1, -1, -1, -1, 26, 27, 28, 29, 30, 31,
Carl Worth667173e2010-07-28 12:33:56 -0700890 32, 33, 34, 35, 36, 37, 38, 39, 40, 41,
Carl Worth6b9e7b02010-08-11 14:00:21 -0700891 42, 43, 21, -1, -1, -1, -1, 26, 27, 28,
892 29, 30, 31, 32, 33, 34, 35, 36, 37, 38,
893 39, 40, 41, 42, 43, 26, 27, 28, 29, 30,
894 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
895 41, 42, 43, -1, -1, 46, 27, 28, 29, 30,
896 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
897 41, 42, 43, 28, 29, 30, 31, 32, 33, 34,
898 35, 36, 37, 38, 39, 40, 41, 42, 43, 29,
899 30, 31, 32, 33, 34, 35, 36, 37, 38, 39,
900 40, 41, 42, 43, 30, 31, 32, 33, 34, 35,
901 36, 37, 38, 39, 40, 41, 42, 43, 31, 32,
Eric Anholtd4a04f32010-07-28 16:58:39 -0700902 33, 34, 35, 36, 37, 38, 39, 40, 41, 42,
Carl Worth6b9e7b02010-08-11 14:00:21 -0700903 43, 33, 34, 35, 36, 37, 38, 39, 40, 41,
904 42, 43, 39, 40, 41, 42, 43
Carl Worth667173e2010-07-28 12:33:56 -0700905};
906
907/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
908 symbol of state STATE-NUM. */
909static const yytype_uint8 yystos[] =
910{
Eric Anholtd4a04f32010-07-28 16:58:39 -0700911 0, 58, 0, 5, 6, 7, 8, 9, 10, 11,
912 12, 13, 14, 15, 16, 17, 18, 20, 21, 22,
Carl Worth667173e2010-07-28 12:33:56 -0700913 24, 25, 26, 27, 28, 29, 30, 31, 32, 33,
Eric Anholtd4a04f32010-07-28 16:58:39 -0700914 34, 35, 36, 37, 38, 39, 40, 41, 42, 43,
Carl Worth667173e2010-07-28 12:33:56 -0700915 45, 46, 47, 48, 49, 50, 51, 52, 53, 54,
Eric Anholtd4a04f32010-07-28 16:58:39 -0700916 55, 56, 59, 60, 61, 65, 71, 72, 73, 19,
917 20, 39, 40, 45, 47, 48, 62, 63, 21, 66,
918 71, 17, 17, 4, 21, 69, 70, 72, 21, 21,
Carl Worth6b9e7b02010-08-11 14:00:21 -0700919 21, 70, 17, 17, 17, 62, 63, 21, 72, 63,
920 63, 63, 63, 63, 21, 26, 27, 28, 29, 30,
921 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
922 41, 42, 43, 21, 45, 67, 71, 17, 45, 21,
923 69, 21, 68, 71, 68, 21, 21, 21, 46, 63,
Eric Anholtd4a04f32010-07-28 16:58:39 -0700924 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
Carl Worth6b9e7b02010-08-11 14:00:21 -0700925 63, 63, 63, 63, 63, 63, 63, 17, 46, 64,
926 21, 17, 21, 21, 67, 46, 49, 46, 21, 67,
927 17, 21
Carl Worth667173e2010-07-28 12:33:56 -0700928};
929
930#define yyerrok (yyerrstatus = 0)
931#define yyclearin (yychar = YYEMPTY)
932#define YYEMPTY (-2)
933#define YYEOF 0
934
935#define YYACCEPT goto yyacceptlab
936#define YYABORT goto yyabortlab
937#define YYERROR goto yyerrorlab
938
939
940/* Like YYERROR except do call yyerror. This remains here temporarily
941 to ease the transition to the new meaning of YYERROR, for GCC.
Carl Worthe29cd392010-08-10 16:59:20 -0700942 Once GCC version 2 has supplanted version 1, this can go. */
Carl Worth667173e2010-07-28 12:33:56 -0700943
944#define YYFAIL goto yyerrlab
945
946#define YYRECOVERING() (!!yyerrstatus)
947
948#define YYBACKUP(Token, Value) \
949do \
950 if (yychar == YYEMPTY && yylen == 1) \
951 { \
952 yychar = (Token); \
953 yylval = (Value); \
954 yytoken = YYTRANSLATE (yychar); \
955 YYPOPSTACK (1); \
956 goto yybackup; \
957 } \
958 else \
959 { \
960 yyerror (&yylloc, parser, YY_("syntax error: cannot back up")); \
961 YYERROR; \
962 } \
963while (YYID (0))
964
965
966#define YYTERROR 1
967#define YYERRCODE 256
968
969
970/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
971 If N is 0, then set CURRENT to the empty location which ends
972 the previous symbol: RHS[0] (always defined). */
973
974#define YYRHSLOC(Rhs, K) ((Rhs)[K])
975#ifndef YYLLOC_DEFAULT
976# define YYLLOC_DEFAULT(Current, Rhs, N) \
977 do \
978 if (YYID (N)) \
979 { \
980 (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
981 (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
982 (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
983 (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
984 } \
985 else \
986 { \
987 (Current).first_line = (Current).last_line = \
988 YYRHSLOC (Rhs, 0).last_line; \
989 (Current).first_column = (Current).last_column = \
990 YYRHSLOC (Rhs, 0).last_column; \
991 } \
992 while (YYID (0))
993#endif
994
995
996/* YY_LOCATION_PRINT -- Print the location on the stream.
997 This macro was not mandated originally: define only if we know
998 we won't break user code: when these are the locations we know. */
999
1000#ifndef YY_LOCATION_PRINT
Carl Worthe29cd392010-08-10 16:59:20 -07001001# if YYLTYPE_IS_TRIVIAL
Carl Worth667173e2010-07-28 12:33:56 -07001002# define YY_LOCATION_PRINT(File, Loc) \
1003 fprintf (File, "%d.%d-%d.%d", \
1004 (Loc).first_line, (Loc).first_column, \
1005 (Loc).last_line, (Loc).last_column)
1006# else
1007# define YY_LOCATION_PRINT(File, Loc) ((void) 0)
1008# endif
1009#endif
1010
1011
1012/* YYLEX -- calling `yylex' with the right arguments. */
1013
1014#ifdef YYLEX_PARAM
1015# define YYLEX yylex (&yylval, &yylloc, YYLEX_PARAM)
1016#else
1017# define YYLEX yylex (&yylval, &yylloc, parser)
1018#endif
1019
1020/* Enable debugging if requested. */
1021#if YYDEBUG
1022
1023# ifndef YYFPRINTF
1024# include <stdio.h> /* INFRINGES ON USER NAME SPACE */
1025# define YYFPRINTF fprintf
1026# endif
1027
1028# define YYDPRINTF(Args) \
1029do { \
1030 if (yydebug) \
1031 YYFPRINTF Args; \
1032} while (YYID (0))
1033
1034# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
1035do { \
1036 if (yydebug) \
1037 { \
1038 YYFPRINTF (stderr, "%s ", Title); \
1039 yy_symbol_print (stderr, \
1040 Type, Value, Location, parser); \
1041 YYFPRINTF (stderr, "\n"); \
1042 } \
1043} while (YYID (0))
1044
1045
1046/*--------------------------------.
1047| Print this symbol on YYOUTPUT. |
1048`--------------------------------*/
1049
1050/*ARGSUSED*/
1051#if (defined __STDC__ || defined __C99__FUNC__ \
1052 || defined __cplusplus || defined _MSC_VER)
1053static void
1054yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, YYLTYPE const * const yylocationp, glcpp_parser_t *parser)
1055#else
1056static void
1057yy_symbol_value_print (yyoutput, yytype, yyvaluep, yylocationp, parser)
1058 FILE *yyoutput;
1059 int yytype;
1060 YYSTYPE const * const yyvaluep;
1061 YYLTYPE const * const yylocationp;
1062 glcpp_parser_t *parser;
1063#endif
1064{
1065 if (!yyvaluep)
1066 return;
1067 YYUSE (yylocationp);
1068 YYUSE (parser);
1069# ifdef YYPRINT
1070 if (yytype < YYNTOKENS)
1071 YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
1072# else
1073 YYUSE (yyoutput);
1074# endif
1075 switch (yytype)
1076 {
1077 default:
1078 break;
1079 }
1080}
1081
1082
1083/*--------------------------------.
1084| Print this symbol on YYOUTPUT. |
1085`--------------------------------*/
1086
1087#if (defined __STDC__ || defined __C99__FUNC__ \
1088 || defined __cplusplus || defined _MSC_VER)
1089static void
1090yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, YYLTYPE const * const yylocationp, glcpp_parser_t *parser)
1091#else
1092static void
1093yy_symbol_print (yyoutput, yytype, yyvaluep, yylocationp, parser)
1094 FILE *yyoutput;
1095 int yytype;
1096 YYSTYPE const * const yyvaluep;
1097 YYLTYPE const * const yylocationp;
1098 glcpp_parser_t *parser;
1099#endif
1100{
1101 if (yytype < YYNTOKENS)
1102 YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
1103 else
1104 YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
1105
1106 YY_LOCATION_PRINT (yyoutput, *yylocationp);
1107 YYFPRINTF (yyoutput, ": ");
1108 yy_symbol_value_print (yyoutput, yytype, yyvaluep, yylocationp, parser);
1109 YYFPRINTF (yyoutput, ")");
1110}
1111
1112/*------------------------------------------------------------------.
1113| yy_stack_print -- Print the state stack from its BOTTOM up to its |
1114| TOP (included). |
1115`------------------------------------------------------------------*/
1116
1117#if (defined __STDC__ || defined __C99__FUNC__ \
1118 || defined __cplusplus || defined _MSC_VER)
1119static void
1120yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop)
1121#else
1122static void
1123yy_stack_print (yybottom, yytop)
1124 yytype_int16 *yybottom;
1125 yytype_int16 *yytop;
1126#endif
1127{
1128 YYFPRINTF (stderr, "Stack now");
1129 for (; yybottom <= yytop; yybottom++)
1130 {
1131 int yybot = *yybottom;
1132 YYFPRINTF (stderr, " %d", yybot);
1133 }
1134 YYFPRINTF (stderr, "\n");
1135}
1136
1137# define YY_STACK_PRINT(Bottom, Top) \
1138do { \
1139 if (yydebug) \
1140 yy_stack_print ((Bottom), (Top)); \
1141} while (YYID (0))
1142
1143
1144/*------------------------------------------------.
1145| Report that the YYRULE is going to be reduced. |
1146`------------------------------------------------*/
1147
1148#if (defined __STDC__ || defined __C99__FUNC__ \
1149 || defined __cplusplus || defined _MSC_VER)
1150static void
1151yy_reduce_print (YYSTYPE *yyvsp, YYLTYPE *yylsp, int yyrule, glcpp_parser_t *parser)
1152#else
1153static void
1154yy_reduce_print (yyvsp, yylsp, yyrule, parser)
1155 YYSTYPE *yyvsp;
1156 YYLTYPE *yylsp;
1157 int yyrule;
1158 glcpp_parser_t *parser;
1159#endif
1160{
1161 int yynrhs = yyr2[yyrule];
1162 int yyi;
1163 unsigned long int yylno = yyrline[yyrule];
1164 YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
1165 yyrule - 1, yylno);
1166 /* The symbols being reduced. */
1167 for (yyi = 0; yyi < yynrhs; yyi++)
1168 {
1169 YYFPRINTF (stderr, " $%d = ", yyi + 1);
1170 yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
1171 &(yyvsp[(yyi + 1) - (yynrhs)])
1172 , &(yylsp[(yyi + 1) - (yynrhs)]) , parser);
1173 YYFPRINTF (stderr, "\n");
1174 }
1175}
1176
1177# define YY_REDUCE_PRINT(Rule) \
1178do { \
1179 if (yydebug) \
1180 yy_reduce_print (yyvsp, yylsp, Rule, parser); \
1181} while (YYID (0))
1182
1183/* Nonzero means print parse trace. It is left uninitialized so that
1184 multiple parsers can coexist. */
1185int yydebug;
1186#else /* !YYDEBUG */
1187# define YYDPRINTF(Args)
1188# define YY_SYMBOL_PRINT(Title, Type, Value, Location)
1189# define YY_STACK_PRINT(Bottom, Top)
1190# define YY_REDUCE_PRINT(Rule)
1191#endif /* !YYDEBUG */
1192
1193
1194/* YYINITDEPTH -- initial size of the parser's stacks. */
1195#ifndef YYINITDEPTH
1196# define YYINITDEPTH 200
1197#endif
1198
1199/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
1200 if the built-in stack extension method is used).
1201
1202 Do not make this value too large; the results are undefined if
1203 YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
1204 evaluated with infinite-precision integer arithmetic. */
1205
1206#ifndef YYMAXDEPTH
1207# define YYMAXDEPTH 10000
1208#endif
1209
1210
1211
1212#if YYERROR_VERBOSE
1213
1214# ifndef yystrlen
1215# if defined __GLIBC__ && defined _STRING_H
1216# define yystrlen strlen
1217# else
1218/* Return the length of YYSTR. */
1219#if (defined __STDC__ || defined __C99__FUNC__ \
1220 || defined __cplusplus || defined _MSC_VER)
1221static YYSIZE_T
1222yystrlen (const char *yystr)
1223#else
1224static YYSIZE_T
1225yystrlen (yystr)
1226 const char *yystr;
1227#endif
1228{
1229 YYSIZE_T yylen;
1230 for (yylen = 0; yystr[yylen]; yylen++)
1231 continue;
1232 return yylen;
1233}
1234# endif
1235# endif
1236
1237# ifndef yystpcpy
1238# if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
1239# define yystpcpy stpcpy
1240# else
1241/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
1242 YYDEST. */
1243#if (defined __STDC__ || defined __C99__FUNC__ \
1244 || defined __cplusplus || defined _MSC_VER)
1245static char *
1246yystpcpy (char *yydest, const char *yysrc)
1247#else
1248static char *
1249yystpcpy (yydest, yysrc)
1250 char *yydest;
1251 const char *yysrc;
1252#endif
1253{
1254 char *yyd = yydest;
1255 const char *yys = yysrc;
1256
1257 while ((*yyd++ = *yys++) != '\0')
1258 continue;
1259
1260 return yyd - 1;
1261}
1262# endif
1263# endif
1264
1265# ifndef yytnamerr
1266/* Copy to YYRES the contents of YYSTR after stripping away unnecessary
1267 quotes and backslashes, so that it's suitable for yyerror. The
1268 heuristic is that double-quoting is unnecessary unless the string
1269 contains an apostrophe, a comma, or backslash (other than
1270 backslash-backslash). YYSTR is taken from yytname. If YYRES is
1271 null, do not copy; instead, return the length of what the result
1272 would have been. */
1273static YYSIZE_T
1274yytnamerr (char *yyres, const char *yystr)
1275{
1276 if (*yystr == '"')
1277 {
1278 YYSIZE_T yyn = 0;
1279 char const *yyp = yystr;
1280
1281 for (;;)
1282 switch (*++yyp)
1283 {
1284 case '\'':
1285 case ',':
1286 goto do_not_strip_quotes;
1287
1288 case '\\':
1289 if (*++yyp != '\\')
1290 goto do_not_strip_quotes;
1291 /* Fall through. */
1292 default:
1293 if (yyres)
1294 yyres[yyn] = *yyp;
1295 yyn++;
1296 break;
1297
1298 case '"':
1299 if (yyres)
1300 yyres[yyn] = '\0';
1301 return yyn;
1302 }
1303 do_not_strip_quotes: ;
1304 }
1305
1306 if (! yyres)
1307 return yystrlen (yystr);
1308
1309 return yystpcpy (yyres, yystr) - yyres;
1310}
1311# endif
1312
1313/* Copy into YYRESULT an error message about the unexpected token
1314 YYCHAR while in state YYSTATE. Return the number of bytes copied,
1315 including the terminating null byte. If YYRESULT is null, do not
1316 copy anything; just return the number of bytes that would be
1317 copied. As a special case, return 0 if an ordinary "syntax error"
1318 message will do. Return YYSIZE_MAXIMUM if overflow occurs during
1319 size calculation. */
1320static YYSIZE_T
1321yysyntax_error (char *yyresult, int yystate, int yychar)
1322{
1323 int yyn = yypact[yystate];
1324
1325 if (! (YYPACT_NINF < yyn && yyn <= YYLAST))
1326 return 0;
1327 else
1328 {
1329 int yytype = YYTRANSLATE (yychar);
1330 YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]);
1331 YYSIZE_T yysize = yysize0;
1332 YYSIZE_T yysize1;
1333 int yysize_overflow = 0;
1334 enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
1335 char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
1336 int yyx;
1337
1338# if 0
1339 /* This is so xgettext sees the translatable formats that are
1340 constructed on the fly. */
1341 YY_("syntax error, unexpected %s");
1342 YY_("syntax error, unexpected %s, expecting %s");
1343 YY_("syntax error, unexpected %s, expecting %s or %s");
1344 YY_("syntax error, unexpected %s, expecting %s or %s or %s");
1345 YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s");
1346# endif
1347 char *yyfmt;
1348 char const *yyf;
1349 static char const yyunexpected[] = "syntax error, unexpected %s";
1350 static char const yyexpecting[] = ", expecting %s";
1351 static char const yyor[] = " or %s";
1352 char yyformat[sizeof yyunexpected
1353 + sizeof yyexpecting - 1
1354 + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2)
1355 * (sizeof yyor - 1))];
1356 char const *yyprefix = yyexpecting;
1357
1358 /* Start YYX at -YYN if negative to avoid negative indexes in
1359 YYCHECK. */
1360 int yyxbegin = yyn < 0 ? -yyn : 0;
1361
1362 /* Stay within bounds of both yycheck and yytname. */
1363 int yychecklim = YYLAST - yyn + 1;
1364 int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
1365 int yycount = 1;
1366
1367 yyarg[0] = yytname[yytype];
1368 yyfmt = yystpcpy (yyformat, yyunexpected);
1369
1370 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
1371 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
1372 {
1373 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
1374 {
1375 yycount = 1;
1376 yysize = yysize0;
1377 yyformat[sizeof yyunexpected - 1] = '\0';
1378 break;
1379 }
1380 yyarg[yycount++] = yytname[yyx];
1381 yysize1 = yysize + yytnamerr (0, yytname[yyx]);
1382 yysize_overflow |= (yysize1 < yysize);
1383 yysize = yysize1;
1384 yyfmt = yystpcpy (yyfmt, yyprefix);
1385 yyprefix = yyor;
1386 }
1387
1388 yyf = YY_(yyformat);
1389 yysize1 = yysize + yystrlen (yyf);
1390 yysize_overflow |= (yysize1 < yysize);
1391 yysize = yysize1;
1392
1393 if (yysize_overflow)
1394 return YYSIZE_MAXIMUM;
1395
1396 if (yyresult)
1397 {
1398 /* Avoid sprintf, as that infringes on the user's name space.
1399 Don't have undefined behavior even if the translation
1400 produced a string with the wrong number of "%s"s. */
1401 char *yyp = yyresult;
1402 int yyi = 0;
1403 while ((*yyp = *yyf) != '\0')
1404 {
1405 if (*yyp == '%' && yyf[1] == 's' && yyi < yycount)
1406 {
1407 yyp += yytnamerr (yyp, yyarg[yyi++]);
1408 yyf += 2;
1409 }
1410 else
1411 {
1412 yyp++;
1413 yyf++;
1414 }
1415 }
1416 }
1417 return yysize;
1418 }
1419}
1420#endif /* YYERROR_VERBOSE */
1421
1422
1423/*-----------------------------------------------.
1424| Release the memory associated to this symbol. |
1425`-----------------------------------------------*/
1426
1427/*ARGSUSED*/
1428#if (defined __STDC__ || defined __C99__FUNC__ \
1429 || defined __cplusplus || defined _MSC_VER)
1430static void
1431yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, YYLTYPE *yylocationp, glcpp_parser_t *parser)
1432#else
1433static void
1434yydestruct (yymsg, yytype, yyvaluep, yylocationp, parser)
1435 const char *yymsg;
1436 int yytype;
1437 YYSTYPE *yyvaluep;
1438 YYLTYPE *yylocationp;
1439 glcpp_parser_t *parser;
1440#endif
1441{
1442 YYUSE (yyvaluep);
1443 YYUSE (yylocationp);
1444 YYUSE (parser);
1445
1446 if (!yymsg)
1447 yymsg = "Deleting";
1448 YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
1449
1450 switch (yytype)
1451 {
1452
1453 default:
1454 break;
1455 }
1456}
1457
1458/* Prevent warnings from -Wmissing-prototypes. */
1459#ifdef YYPARSE_PARAM
1460#if defined __STDC__ || defined __cplusplus
1461int yyparse (void *YYPARSE_PARAM);
1462#else
1463int yyparse ();
1464#endif
1465#else /* ! YYPARSE_PARAM */
1466#if defined __STDC__ || defined __cplusplus
1467int yyparse (glcpp_parser_t *parser);
1468#else
1469int yyparse ();
1470#endif
1471#endif /* ! YYPARSE_PARAM */
1472
1473
1474
1475
1476
1477/*-------------------------.
1478| yyparse or yypush_parse. |
1479`-------------------------*/
1480
1481#ifdef YYPARSE_PARAM
1482#if (defined __STDC__ || defined __C99__FUNC__ \
1483 || defined __cplusplus || defined _MSC_VER)
1484int
1485yyparse (void *YYPARSE_PARAM)
1486#else
1487int
1488yyparse (YYPARSE_PARAM)
1489 void *YYPARSE_PARAM;
1490#endif
1491#else /* ! YYPARSE_PARAM */
1492#if (defined __STDC__ || defined __C99__FUNC__ \
1493 || defined __cplusplus || defined _MSC_VER)
1494int
1495yyparse (glcpp_parser_t *parser)
1496#else
1497int
1498yyparse (parser)
1499 glcpp_parser_t *parser;
1500#endif
1501#endif
1502{
1503/* The lookahead symbol. */
1504int yychar;
1505
1506/* The semantic value of the lookahead symbol. */
1507YYSTYPE yylval;
1508
1509/* Location data for the lookahead symbol. */
1510YYLTYPE yylloc;
1511
1512 /* Number of syntax errors so far. */
1513 int yynerrs;
1514
1515 int yystate;
1516 /* Number of tokens to shift before error messages enabled. */
1517 int yyerrstatus;
1518
1519 /* The stacks and their tools:
1520 `yyss': related to states.
1521 `yyvs': related to semantic values.
1522 `yyls': related to locations.
1523
1524 Refer to the stacks thru separate pointers, to allow yyoverflow
1525 to reallocate them elsewhere. */
1526
1527 /* The state stack. */
1528 yytype_int16 yyssa[YYINITDEPTH];
1529 yytype_int16 *yyss;
1530 yytype_int16 *yyssp;
1531
1532 /* The semantic value stack. */
1533 YYSTYPE yyvsa[YYINITDEPTH];
1534 YYSTYPE *yyvs;
1535 YYSTYPE *yyvsp;
1536
1537 /* The location stack. */
1538 YYLTYPE yylsa[YYINITDEPTH];
1539 YYLTYPE *yyls;
1540 YYLTYPE *yylsp;
1541
1542 /* The locations where the error started and ended. */
1543 YYLTYPE yyerror_range[2];
1544
1545 YYSIZE_T yystacksize;
1546
1547 int yyn;
1548 int yyresult;
1549 /* Lookahead token as an internal (translated) token number. */
1550 int yytoken;
1551 /* The variables used to return semantic value and location from the
1552 action routines. */
1553 YYSTYPE yyval;
1554 YYLTYPE yyloc;
1555
1556#if YYERROR_VERBOSE
1557 /* Buffer for error messages, and its allocated size. */
1558 char yymsgbuf[128];
1559 char *yymsg = yymsgbuf;
1560 YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
1561#endif
1562
1563#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N), yylsp -= (N))
1564
1565 /* The number of symbols on the RHS of the reduced rule.
1566 Keep to zero when no symbol should be popped. */
1567 int yylen = 0;
1568
1569 yytoken = 0;
1570 yyss = yyssa;
1571 yyvs = yyvsa;
1572 yyls = yylsa;
1573 yystacksize = YYINITDEPTH;
1574
1575 YYDPRINTF ((stderr, "Starting parse\n"));
1576
1577 yystate = 0;
1578 yyerrstatus = 0;
1579 yynerrs = 0;
1580 yychar = YYEMPTY; /* Cause a token to be read. */
1581
1582 /* Initialize stack pointers.
1583 Waste one element of value and location stack
1584 so that they stay on the same level as the state stack.
1585 The wasted elements are never initialized. */
1586 yyssp = yyss;
1587 yyvsp = yyvs;
1588 yylsp = yyls;
1589
Carl Worthe29cd392010-08-10 16:59:20 -07001590#if YYLTYPE_IS_TRIVIAL
Carl Worth667173e2010-07-28 12:33:56 -07001591 /* Initialize the default location before parsing starts. */
1592 yylloc.first_line = yylloc.last_line = 1;
1593 yylloc.first_column = yylloc.last_column = 1;
1594#endif
1595
Carl Worthe29cd392010-08-10 16:59:20 -07001596/* User initialization code. */
1597
1598/* Line 1242 of yacc.c */
Ian Romanick188f60f2010-08-12 10:07:05 -07001599#line 148 "glcpp/glcpp-parse.y"
Carl Worthe29cd392010-08-10 16:59:20 -07001600{
1601 yylloc.first_line = 1;
1602 yylloc.first_column = 1;
1603 yylloc.last_line = 1;
1604 yylloc.last_column = 1;
1605 yylloc.source = 0;
1606}
1607
1608/* Line 1242 of yacc.c */
Ian Romanick188f60f2010-08-12 10:07:05 -07001609#line 1610 "glcpp/glcpp-parse.c"
Carl Worthe29cd392010-08-10 16:59:20 -07001610 yylsp[0] = yylloc;
1611
Carl Worth667173e2010-07-28 12:33:56 -07001612 goto yysetstate;
1613
1614/*------------------------------------------------------------.
1615| yynewstate -- Push a new state, which is found in yystate. |
1616`------------------------------------------------------------*/
1617 yynewstate:
1618 /* In all cases, when you get here, the value and location stacks
1619 have just been pushed. So pushing a state here evens the stacks. */
1620 yyssp++;
1621
1622 yysetstate:
1623 *yyssp = yystate;
1624
1625 if (yyss + yystacksize - 1 <= yyssp)
1626 {
1627 /* Get the current used size of the three stacks, in elements. */
1628 YYSIZE_T yysize = yyssp - yyss + 1;
1629
1630#ifdef yyoverflow
1631 {
1632 /* Give user a chance to reallocate the stack. Use copies of
1633 these so that the &'s don't force the real ones into
1634 memory. */
1635 YYSTYPE *yyvs1 = yyvs;
1636 yytype_int16 *yyss1 = yyss;
1637 YYLTYPE *yyls1 = yyls;
1638
1639 /* Each stack pointer address is followed by the size of the
1640 data in use in that stack, in bytes. This used to be a
1641 conditional around just the two extra args, but that might
1642 be undefined if yyoverflow is a macro. */
1643 yyoverflow (YY_("memory exhausted"),
1644 &yyss1, yysize * sizeof (*yyssp),
1645 &yyvs1, yysize * sizeof (*yyvsp),
1646 &yyls1, yysize * sizeof (*yylsp),
1647 &yystacksize);
1648
1649 yyls = yyls1;
1650 yyss = yyss1;
1651 yyvs = yyvs1;
1652 }
1653#else /* no yyoverflow */
1654# ifndef YYSTACK_RELOCATE
1655 goto yyexhaustedlab;
1656# else
1657 /* Extend the stack our own way. */
1658 if (YYMAXDEPTH <= yystacksize)
1659 goto yyexhaustedlab;
1660 yystacksize *= 2;
1661 if (YYMAXDEPTH < yystacksize)
1662 yystacksize = YYMAXDEPTH;
1663
1664 {
1665 yytype_int16 *yyss1 = yyss;
1666 union yyalloc *yyptr =
1667 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
1668 if (! yyptr)
1669 goto yyexhaustedlab;
1670 YYSTACK_RELOCATE (yyss_alloc, yyss);
1671 YYSTACK_RELOCATE (yyvs_alloc, yyvs);
1672 YYSTACK_RELOCATE (yyls_alloc, yyls);
1673# undef YYSTACK_RELOCATE
1674 if (yyss1 != yyssa)
1675 YYSTACK_FREE (yyss1);
1676 }
1677# endif
1678#endif /* no yyoverflow */
1679
1680 yyssp = yyss + yysize - 1;
1681 yyvsp = yyvs + yysize - 1;
1682 yylsp = yyls + yysize - 1;
1683
1684 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
1685 (unsigned long int) yystacksize));
1686
1687 if (yyss + yystacksize - 1 <= yyssp)
1688 YYABORT;
1689 }
1690
1691 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
1692
1693 if (yystate == YYFINAL)
1694 YYACCEPT;
1695
1696 goto yybackup;
1697
1698/*-----------.
1699| yybackup. |
1700`-----------*/
1701yybackup:
1702
1703 /* Do appropriate processing given the current state. Read a
1704 lookahead token if we need one and don't already have one. */
1705
1706 /* First try to decide what to do without reference to lookahead token. */
1707 yyn = yypact[yystate];
1708 if (yyn == YYPACT_NINF)
1709 goto yydefault;
1710
1711 /* Not known => get a lookahead token if don't already have one. */
1712
1713 /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */
1714 if (yychar == YYEMPTY)
1715 {
1716 YYDPRINTF ((stderr, "Reading a token: "));
1717 yychar = YYLEX;
1718 }
1719
1720 if (yychar <= YYEOF)
1721 {
1722 yychar = yytoken = YYEOF;
1723 YYDPRINTF ((stderr, "Now at end of input.\n"));
1724 }
1725 else
1726 {
1727 yytoken = YYTRANSLATE (yychar);
1728 YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
1729 }
1730
1731 /* If the proper action on seeing token YYTOKEN is to reduce or to
1732 detect an error, take that action. */
1733 yyn += yytoken;
1734 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
1735 goto yydefault;
1736 yyn = yytable[yyn];
1737 if (yyn <= 0)
1738 {
1739 if (yyn == 0 || yyn == YYTABLE_NINF)
1740 goto yyerrlab;
1741 yyn = -yyn;
1742 goto yyreduce;
1743 }
1744
1745 /* Count tokens shifted since error; after three, turn off error
1746 status. */
1747 if (yyerrstatus)
1748 yyerrstatus--;
1749
1750 /* Shift the lookahead token. */
1751 YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
1752
1753 /* Discard the shifted token. */
1754 yychar = YYEMPTY;
1755
1756 yystate = yyn;
1757 *++yyvsp = yylval;
1758 *++yylsp = yylloc;
1759 goto yynewstate;
1760
1761
1762/*-----------------------------------------------------------.
1763| yydefault -- do the default action for the current state. |
1764`-----------------------------------------------------------*/
1765yydefault:
1766 yyn = yydefact[yystate];
1767 if (yyn == 0)
1768 goto yyerrlab;
1769 goto yyreduce;
1770
1771
1772/*-----------------------------.
1773| yyreduce -- Do a reduction. |
1774`-----------------------------*/
1775yyreduce:
1776 /* yyn is the number of a rule to reduce with. */
1777 yylen = yyr2[yyn];
1778
1779 /* If YYLEN is nonzero, implement the default value of the action:
1780 `$$ = $1'.
1781
1782 Otherwise, the following line sets YYVAL to garbage.
1783 This behavior is undocumented and Bison
1784 users should not rely upon it. Assigning to YYVAL
1785 unconditionally makes the parser a bit smaller, and it avoids a
1786 GCC warning that YYVAL may be used uninitialized. */
1787 yyval = yyvsp[1-yylen];
1788
1789 /* Default location. */
1790 YYLLOC_DEFAULT (yyloc, (yylsp - yylen), yylen);
1791 YY_REDUCE_PRINT (yyn);
1792 switch (yyn)
1793 {
1794 case 4:
1795
Carl Worthe29cd392010-08-10 16:59:20 -07001796/* Line 1455 of yacc.c */
Ian Romanick188f60f2010-08-12 10:07:05 -07001797#line 187 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07001798 {
1799 glcpp_print(parser->output, "\n");
1800 ;}
1801 break;
1802
1803 case 5:
1804
Carl Worthe29cd392010-08-10 16:59:20 -07001805/* Line 1455 of yacc.c */
Ian Romanick188f60f2010-08-12 10:07:05 -07001806#line 190 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07001807 {
1808 _glcpp_parser_print_expanded_token_list (parser, (yyvsp[(1) - (1)].token_list));
1809 glcpp_print(parser->output, "\n");
1810 talloc_free ((yyvsp[(1) - (1)].token_list));
1811 ;}
1812 break;
1813
1814 case 8:
1815
Carl Worthe29cd392010-08-10 16:59:20 -07001816/* Line 1455 of yacc.c */
Ian Romanick188f60f2010-08-12 10:07:05 -07001817#line 200 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07001818 {
1819 _glcpp_parser_skip_stack_push_if (parser, & (yylsp[(1) - (3)]), (yyvsp[(2) - (3)].ival));
1820 ;}
1821 break;
1822
1823 case 9:
1824
Carl Worthe29cd392010-08-10 16:59:20 -07001825/* Line 1455 of yacc.c */
Ian Romanick188f60f2010-08-12 10:07:05 -07001826#line 203 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07001827 {
1828 _glcpp_parser_skip_stack_change_if (parser, & (yylsp[(1) - (3)]), "elif", (yyvsp[(2) - (3)].ival));
1829 ;}
1830 break;
1831
1832 case 10:
1833
Carl Worthe29cd392010-08-10 16:59:20 -07001834/* Line 1455 of yacc.c */
Ian Romanick188f60f2010-08-12 10:07:05 -07001835#line 209 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07001836 {
1837 _define_object_macro (parser, & (yylsp[(2) - (4)]), (yyvsp[(2) - (4)].str), (yyvsp[(3) - (4)].token_list));
1838 ;}
1839 break;
1840
1841 case 11:
1842
Carl Worthe29cd392010-08-10 16:59:20 -07001843/* Line 1455 of yacc.c */
Ian Romanick188f60f2010-08-12 10:07:05 -07001844#line 212 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07001845 {
1846 _define_function_macro (parser, & (yylsp[(2) - (6)]), (yyvsp[(2) - (6)].str), NULL, (yyvsp[(5) - (6)].token_list));
1847 ;}
1848 break;
1849
1850 case 12:
1851
Carl Worthe29cd392010-08-10 16:59:20 -07001852/* Line 1455 of yacc.c */
Ian Romanick188f60f2010-08-12 10:07:05 -07001853#line 215 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07001854 {
1855 _define_function_macro (parser, & (yylsp[(2) - (7)]), (yyvsp[(2) - (7)].str), (yyvsp[(4) - (7)].string_list), (yyvsp[(6) - (7)].token_list));
1856 ;}
1857 break;
1858
1859 case 13:
1860
Carl Worthe29cd392010-08-10 16:59:20 -07001861/* Line 1455 of yacc.c */
Ian Romanick188f60f2010-08-12 10:07:05 -07001862#line 218 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07001863 {
1864 macro_t *macro = hash_table_find (parser->defines, (yyvsp[(2) - (3)].str));
1865 if (macro) {
1866 hash_table_remove (parser->defines, (yyvsp[(2) - (3)].str));
1867 talloc_free (macro);
1868 }
1869 talloc_free ((yyvsp[(2) - (3)].str));
1870 ;}
1871 break;
1872
1873 case 14:
1874
Carl Worthe29cd392010-08-10 16:59:20 -07001875/* Line 1455 of yacc.c */
Ian Romanick188f60f2010-08-12 10:07:05 -07001876#line 226 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07001877 {
Carl Worth764e0962010-08-11 12:45:55 -07001878 /* Be careful to only evaluate the 'if' expression if
1879 * we are not skipping. When we are skipping, we
1880 * simply push a new 0-valued 'if' onto the skip
1881 * stack.
1882 *
1883 * This avoids generating diagnostics for invalid
1884 * expressions that are being skipped. */
1885 if (parser->skip_stack == NULL ||
1886 parser->skip_stack->type == SKIP_NO_SKIP)
1887 {
1888 _glcpp_parser_expand_if (parser, IF_EXPANDED, (yyvsp[(2) - (3)].token_list));
1889 }
1890 else
1891 {
Kenneth Graunkef4239872010-08-04 16:24:39 -07001892 _glcpp_parser_skip_stack_push_if (parser, & (yylsp[(1) - (3)]), 0);
1893 parser->skip_stack->type = SKIP_TO_ENDIF;
Kenneth Graunkef4239872010-08-04 16:24:39 -07001894 }
Carl Worth667173e2010-07-28 12:33:56 -07001895 ;}
1896 break;
1897
1898 case 15:
1899
Carl Worthe29cd392010-08-10 16:59:20 -07001900/* Line 1455 of yacc.c */
Ian Romanick188f60f2010-08-12 10:07:05 -07001901#line 245 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07001902 {
Carl Worth6b9e7b02010-08-11 14:00:21 -07001903 /* #if without an expression is only an error if we
1904 * are not skipping */
1905 if (parser->skip_stack == NULL ||
1906 parser->skip_stack->type == SKIP_NO_SKIP)
1907 {
1908 glcpp_error(& (yylsp[(1) - (2)]), parser, "#if with no expression");
1909 }
1910 _glcpp_parser_skip_stack_push_if (parser, & (yylsp[(1) - (2)]), 0);
Carl Worth667173e2010-07-28 12:33:56 -07001911 ;}
1912 break;
1913
1914 case 16:
1915
Carl Worthe29cd392010-08-10 16:59:20 -07001916/* Line 1455 of yacc.c */
Ian Romanick188f60f2010-08-12 10:07:05 -07001917#line 255 "glcpp/glcpp-parse.y"
Carl Worth6b9e7b02010-08-11 14:00:21 -07001918 {
1919 macro_t *macro = hash_table_find (parser->defines, (yyvsp[(2) - (4)].str));
1920 talloc_free ((yyvsp[(2) - (4)].str));
1921 _glcpp_parser_skip_stack_push_if (parser, & (yylsp[(1) - (4)]), macro != NULL);
1922 ;}
1923 break;
1924
1925 case 17:
1926
1927/* Line 1455 of yacc.c */
Ian Romanick188f60f2010-08-12 10:07:05 -07001928#line 260 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07001929 {
1930 macro_t *macro = hash_table_find (parser->defines, (yyvsp[(2) - (4)].str));
1931 talloc_free ((yyvsp[(2) - (4)].str));
1932 _glcpp_parser_skip_stack_push_if (parser, & (yylsp[(1) - (4)]), macro == NULL);
1933 ;}
1934 break;
1935
Carl Worth6b9e7b02010-08-11 14:00:21 -07001936 case 18:
Carl Worth667173e2010-07-28 12:33:56 -07001937
Carl Worthe29cd392010-08-10 16:59:20 -07001938/* Line 1455 of yacc.c */
Ian Romanick188f60f2010-08-12 10:07:05 -07001939#line 265 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07001940 {
Carl Worth764e0962010-08-11 12:45:55 -07001941 /* Be careful to only evaluate the 'elif' expression
1942 * if we are not skipping. When we are skipping, we
1943 * simply change to a 0-valued 'elif' on the skip
1944 * stack.
1945 *
1946 * This avoids generating diagnostics for invalid
1947 * expressions that are being skipped. */
1948 if (parser->skip_stack &&
1949 parser->skip_stack->type == SKIP_TO_ELSE)
1950 {
Kenneth Graunkef4239872010-08-04 16:24:39 -07001951 _glcpp_parser_expand_if (parser, ELIF_EXPANDED, (yyvsp[(2) - (3)].token_list));
Carl Worth764e0962010-08-11 12:45:55 -07001952 }
1953 else
1954 {
1955 _glcpp_parser_skip_stack_change_if (parser, & (yylsp[(1) - (3)]),
1956 "elif", 0);
1957 }
Carl Worth667173e2010-07-28 12:33:56 -07001958 ;}
1959 break;
1960
Carl Worth6b9e7b02010-08-11 14:00:21 -07001961 case 19:
Carl Worth667173e2010-07-28 12:33:56 -07001962
Carl Worthe29cd392010-08-10 16:59:20 -07001963/* Line 1455 of yacc.c */
Ian Romanick188f60f2010-08-12 10:07:05 -07001964#line 284 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07001965 {
Carl Worth764e0962010-08-11 12:45:55 -07001966 /* #elif without an expression is an error unless we
1967 * are skipping. */
1968 if (parser->skip_stack &&
1969 parser->skip_stack->type == SKIP_TO_ELSE)
1970 {
Carl Worth624dd582010-08-11 13:50:51 -07001971 glcpp_error(& (yylsp[(1) - (2)]), parser, "#elif with no expression");
Carl Worth667173e2010-07-28 12:33:56 -07001972 }
Carl Worth764e0962010-08-11 12:45:55 -07001973 else
1974 {
1975 _glcpp_parser_skip_stack_change_if (parser, & (yylsp[(1) - (2)]),
1976 "elif", 0);
1977 glcpp_warning(& (yylsp[(1) - (2)]), parser, "ignoring illegal #elif without expression");
1978 }
Carl Worth667173e2010-07-28 12:33:56 -07001979 ;}
1980 break;
1981
Carl Worth667173e2010-07-28 12:33:56 -07001982 case 20:
1983
Carl Worthe29cd392010-08-10 16:59:20 -07001984/* Line 1455 of yacc.c */
Ian Romanick188f60f2010-08-12 10:07:05 -07001985#line 299 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07001986 {
Carl Worth6b9e7b02010-08-11 14:00:21 -07001987 _glcpp_parser_skip_stack_change_if (parser, & (yylsp[(1) - (2)]), "else", 1);
Carl Worth667173e2010-07-28 12:33:56 -07001988 ;}
1989 break;
1990
Eric Anholtd4a04f32010-07-28 16:58:39 -07001991 case 21:
Carl Worth667173e2010-07-28 12:33:56 -07001992
Carl Worthe29cd392010-08-10 16:59:20 -07001993/* Line 1455 of yacc.c */
Ian Romanick188f60f2010-08-12 10:07:05 -07001994#line 302 "glcpp/glcpp-parse.y"
Carl Worth6b9e7b02010-08-11 14:00:21 -07001995 {
1996 _glcpp_parser_skip_stack_pop (parser, & (yylsp[(1) - (2)]));
1997 ;}
1998 break;
1999
2000 case 22:
2001
2002/* Line 1455 of yacc.c */
Ian Romanick188f60f2010-08-12 10:07:05 -07002003#line 305 "glcpp/glcpp-parse.y"
Eric Anholtd4a04f32010-07-28 16:58:39 -07002004 {
2005 macro_t *macro = hash_table_find (parser->defines, "__VERSION__");
2006 if (macro) {
2007 hash_table_remove (parser->defines, "__VERSION__");
2008 talloc_free (macro);
2009 }
2010 add_builtin_define (parser, "__VERSION__", (yyvsp[(2) - (3)].ival));
2011 glcpp_printf(parser->output, "#version %" PRIiMAX "\n", (yyvsp[(2) - (3)].ival));
2012 ;}
2013 break;
2014
Carl Worth6b9e7b02010-08-11 14:00:21 -07002015 case 24:
Eric Anholtd4a04f32010-07-28 16:58:39 -07002016
Carl Worthe29cd392010-08-10 16:59:20 -07002017/* Line 1455 of yacc.c */
Ian Romanick188f60f2010-08-12 10:07:05 -07002018#line 318 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07002019 {
2020 if (strlen ((yyvsp[(1) - (1)].str)) >= 3 && strncmp ((yyvsp[(1) - (1)].str), "0x", 2) == 0) {
2021 (yyval.ival) = strtoll ((yyvsp[(1) - (1)].str) + 2, NULL, 16);
2022 } else if ((yyvsp[(1) - (1)].str)[0] == '0') {
2023 (yyval.ival) = strtoll ((yyvsp[(1) - (1)].str), NULL, 8);
2024 } else {
2025 (yyval.ival) = strtoll ((yyvsp[(1) - (1)].str), NULL, 10);
2026 }
2027 ;}
2028 break;
2029
Carl Worth6b9e7b02010-08-11 14:00:21 -07002030 case 25:
Carl Worth667173e2010-07-28 12:33:56 -07002031
Carl Worthe29cd392010-08-10 16:59:20 -07002032/* Line 1455 of yacc.c */
Ian Romanick188f60f2010-08-12 10:07:05 -07002033#line 327 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07002034 {
Eric Anholtd4a04f32010-07-28 16:58:39 -07002035 (yyval.ival) = (yyvsp[(1) - (1)].ival);
Carl Worth667173e2010-07-28 12:33:56 -07002036 ;}
2037 break;
2038
Carl Worth667173e2010-07-28 12:33:56 -07002039 case 27:
2040
Carl Worthe29cd392010-08-10 16:59:20 -07002041/* Line 1455 of yacc.c */
Ian Romanick188f60f2010-08-12 10:07:05 -07002042#line 333 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07002043 {
Carl Worth6b9e7b02010-08-11 14:00:21 -07002044 (yyval.ival) = (yyvsp[(1) - (3)].ival) || (yyvsp[(3) - (3)].ival);
Carl Worth667173e2010-07-28 12:33:56 -07002045 ;}
2046 break;
2047
2048 case 28:
2049
Carl Worthe29cd392010-08-10 16:59:20 -07002050/* Line 1455 of yacc.c */
Ian Romanick188f60f2010-08-12 10:07:05 -07002051#line 336 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07002052 {
Carl Worth6b9e7b02010-08-11 14:00:21 -07002053 (yyval.ival) = (yyvsp[(1) - (3)].ival) && (yyvsp[(3) - (3)].ival);
Carl Worth667173e2010-07-28 12:33:56 -07002054 ;}
2055 break;
2056
2057 case 29:
2058
Carl Worthe29cd392010-08-10 16:59:20 -07002059/* Line 1455 of yacc.c */
Ian Romanick188f60f2010-08-12 10:07:05 -07002060#line 339 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07002061 {
Carl Worth6b9e7b02010-08-11 14:00:21 -07002062 (yyval.ival) = (yyvsp[(1) - (3)].ival) | (yyvsp[(3) - (3)].ival);
Carl Worth667173e2010-07-28 12:33:56 -07002063 ;}
2064 break;
2065
2066 case 30:
2067
Carl Worthe29cd392010-08-10 16:59:20 -07002068/* Line 1455 of yacc.c */
Ian Romanick188f60f2010-08-12 10:07:05 -07002069#line 342 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07002070 {
Carl Worth6b9e7b02010-08-11 14:00:21 -07002071 (yyval.ival) = (yyvsp[(1) - (3)].ival) ^ (yyvsp[(3) - (3)].ival);
Carl Worth667173e2010-07-28 12:33:56 -07002072 ;}
2073 break;
2074
2075 case 31:
2076
Carl Worthe29cd392010-08-10 16:59:20 -07002077/* Line 1455 of yacc.c */
Ian Romanick188f60f2010-08-12 10:07:05 -07002078#line 345 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07002079 {
Carl Worth6b9e7b02010-08-11 14:00:21 -07002080 (yyval.ival) = (yyvsp[(1) - (3)].ival) & (yyvsp[(3) - (3)].ival);
Carl Worth667173e2010-07-28 12:33:56 -07002081 ;}
2082 break;
2083
2084 case 32:
2085
Carl Worthe29cd392010-08-10 16:59:20 -07002086/* Line 1455 of yacc.c */
Ian Romanick188f60f2010-08-12 10:07:05 -07002087#line 348 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07002088 {
Carl Worth6b9e7b02010-08-11 14:00:21 -07002089 (yyval.ival) = (yyvsp[(1) - (3)].ival) != (yyvsp[(3) - (3)].ival);
Carl Worth667173e2010-07-28 12:33:56 -07002090 ;}
2091 break;
2092
2093 case 33:
2094
Carl Worthe29cd392010-08-10 16:59:20 -07002095/* Line 1455 of yacc.c */
Ian Romanick188f60f2010-08-12 10:07:05 -07002096#line 351 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07002097 {
Carl Worth6b9e7b02010-08-11 14:00:21 -07002098 (yyval.ival) = (yyvsp[(1) - (3)].ival) == (yyvsp[(3) - (3)].ival);
Carl Worth667173e2010-07-28 12:33:56 -07002099 ;}
2100 break;
2101
2102 case 34:
2103
Carl Worthe29cd392010-08-10 16:59:20 -07002104/* Line 1455 of yacc.c */
Ian Romanick188f60f2010-08-12 10:07:05 -07002105#line 354 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07002106 {
Carl Worth6b9e7b02010-08-11 14:00:21 -07002107 (yyval.ival) = (yyvsp[(1) - (3)].ival) >= (yyvsp[(3) - (3)].ival);
Carl Worth667173e2010-07-28 12:33:56 -07002108 ;}
2109 break;
2110
2111 case 35:
2112
Carl Worthe29cd392010-08-10 16:59:20 -07002113/* Line 1455 of yacc.c */
Ian Romanick188f60f2010-08-12 10:07:05 -07002114#line 357 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07002115 {
Carl Worth6b9e7b02010-08-11 14:00:21 -07002116 (yyval.ival) = (yyvsp[(1) - (3)].ival) <= (yyvsp[(3) - (3)].ival);
Carl Worth667173e2010-07-28 12:33:56 -07002117 ;}
2118 break;
2119
2120 case 36:
2121
Carl Worthe29cd392010-08-10 16:59:20 -07002122/* Line 1455 of yacc.c */
Ian Romanick188f60f2010-08-12 10:07:05 -07002123#line 360 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07002124 {
Carl Worth6b9e7b02010-08-11 14:00:21 -07002125 (yyval.ival) = (yyvsp[(1) - (3)].ival) > (yyvsp[(3) - (3)].ival);
Carl Worth667173e2010-07-28 12:33:56 -07002126 ;}
2127 break;
2128
2129 case 37:
2130
Carl Worthe29cd392010-08-10 16:59:20 -07002131/* Line 1455 of yacc.c */
Ian Romanick188f60f2010-08-12 10:07:05 -07002132#line 363 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07002133 {
Carl Worth6b9e7b02010-08-11 14:00:21 -07002134 (yyval.ival) = (yyvsp[(1) - (3)].ival) < (yyvsp[(3) - (3)].ival);
Carl Worth667173e2010-07-28 12:33:56 -07002135 ;}
2136 break;
2137
2138 case 38:
2139
Carl Worthe29cd392010-08-10 16:59:20 -07002140/* Line 1455 of yacc.c */
Ian Romanick188f60f2010-08-12 10:07:05 -07002141#line 366 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07002142 {
Carl Worth6b9e7b02010-08-11 14:00:21 -07002143 (yyval.ival) = (yyvsp[(1) - (3)].ival) >> (yyvsp[(3) - (3)].ival);
Carl Worth667173e2010-07-28 12:33:56 -07002144 ;}
2145 break;
2146
2147 case 39:
2148
Carl Worthe29cd392010-08-10 16:59:20 -07002149/* Line 1455 of yacc.c */
Ian Romanick188f60f2010-08-12 10:07:05 -07002150#line 369 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07002151 {
Carl Worth6b9e7b02010-08-11 14:00:21 -07002152 (yyval.ival) = (yyvsp[(1) - (3)].ival) << (yyvsp[(3) - (3)].ival);
Carl Worth667173e2010-07-28 12:33:56 -07002153 ;}
2154 break;
2155
2156 case 40:
2157
Carl Worthe29cd392010-08-10 16:59:20 -07002158/* Line 1455 of yacc.c */
Ian Romanick188f60f2010-08-12 10:07:05 -07002159#line 372 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07002160 {
Carl Worth6b9e7b02010-08-11 14:00:21 -07002161 (yyval.ival) = (yyvsp[(1) - (3)].ival) - (yyvsp[(3) - (3)].ival);
Carl Worth667173e2010-07-28 12:33:56 -07002162 ;}
2163 break;
2164
2165 case 41:
2166
Carl Worthe29cd392010-08-10 16:59:20 -07002167/* Line 1455 of yacc.c */
Ian Romanick188f60f2010-08-12 10:07:05 -07002168#line 375 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07002169 {
Carl Worth6b9e7b02010-08-11 14:00:21 -07002170 (yyval.ival) = (yyvsp[(1) - (3)].ival) + (yyvsp[(3) - (3)].ival);
Carl Worth667173e2010-07-28 12:33:56 -07002171 ;}
2172 break;
2173
2174 case 42:
2175
Carl Worthe29cd392010-08-10 16:59:20 -07002176/* Line 1455 of yacc.c */
Ian Romanick188f60f2010-08-12 10:07:05 -07002177#line 378 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07002178 {
Carl Worth6b9e7b02010-08-11 14:00:21 -07002179 (yyval.ival) = (yyvsp[(1) - (3)].ival) % (yyvsp[(3) - (3)].ival);
Carl Worth667173e2010-07-28 12:33:56 -07002180 ;}
2181 break;
2182
2183 case 43:
2184
Carl Worthe29cd392010-08-10 16:59:20 -07002185/* Line 1455 of yacc.c */
Ian Romanick188f60f2010-08-12 10:07:05 -07002186#line 381 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07002187 {
Carl Worth6b9e7b02010-08-11 14:00:21 -07002188 (yyval.ival) = (yyvsp[(1) - (3)].ival) / (yyvsp[(3) - (3)].ival);
Carl Worth667173e2010-07-28 12:33:56 -07002189 ;}
2190 break;
2191
2192 case 44:
2193
Carl Worthe29cd392010-08-10 16:59:20 -07002194/* Line 1455 of yacc.c */
Ian Romanick188f60f2010-08-12 10:07:05 -07002195#line 384 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07002196 {
Carl Worth6b9e7b02010-08-11 14:00:21 -07002197 (yyval.ival) = (yyvsp[(1) - (3)].ival) * (yyvsp[(3) - (3)].ival);
Carl Worth667173e2010-07-28 12:33:56 -07002198 ;}
2199 break;
2200
2201 case 45:
2202
Carl Worthe29cd392010-08-10 16:59:20 -07002203/* Line 1455 of yacc.c */
Ian Romanick188f60f2010-08-12 10:07:05 -07002204#line 387 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07002205 {
Carl Worth6b9e7b02010-08-11 14:00:21 -07002206 (yyval.ival) = ! (yyvsp[(2) - (2)].ival);
Carl Worth667173e2010-07-28 12:33:56 -07002207 ;}
2208 break;
2209
2210 case 46:
2211
Carl Worthe29cd392010-08-10 16:59:20 -07002212/* Line 1455 of yacc.c */
Ian Romanick188f60f2010-08-12 10:07:05 -07002213#line 390 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07002214 {
Carl Worth6b9e7b02010-08-11 14:00:21 -07002215 (yyval.ival) = ~ (yyvsp[(2) - (2)].ival);
Carl Worth667173e2010-07-28 12:33:56 -07002216 ;}
2217 break;
2218
2219 case 47:
2220
Carl Worthe29cd392010-08-10 16:59:20 -07002221/* Line 1455 of yacc.c */
Ian Romanick188f60f2010-08-12 10:07:05 -07002222#line 393 "glcpp/glcpp-parse.y"
Eric Anholtd4a04f32010-07-28 16:58:39 -07002223 {
Carl Worth6b9e7b02010-08-11 14:00:21 -07002224 (yyval.ival) = - (yyvsp[(2) - (2)].ival);
Eric Anholtd4a04f32010-07-28 16:58:39 -07002225 ;}
2226 break;
2227
2228 case 48:
2229
Carl Worthe29cd392010-08-10 16:59:20 -07002230/* Line 1455 of yacc.c */
Ian Romanick188f60f2010-08-12 10:07:05 -07002231#line 396 "glcpp/glcpp-parse.y"
Eric Anholtd4a04f32010-07-28 16:58:39 -07002232 {
Carl Worth6b9e7b02010-08-11 14:00:21 -07002233 (yyval.ival) = + (yyvsp[(2) - (2)].ival);
Eric Anholtd4a04f32010-07-28 16:58:39 -07002234 ;}
2235 break;
2236
2237 case 49:
2238
Carl Worthe29cd392010-08-10 16:59:20 -07002239/* Line 1455 of yacc.c */
Ian Romanick188f60f2010-08-12 10:07:05 -07002240#line 399 "glcpp/glcpp-parse.y"
Carl Worth6b9e7b02010-08-11 14:00:21 -07002241 {
2242 (yyval.ival) = (yyvsp[(2) - (3)].ival);
2243 ;}
2244 break;
2245
2246 case 50:
2247
2248/* Line 1455 of yacc.c */
Ian Romanick188f60f2010-08-12 10:07:05 -07002249#line 405 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07002250 {
2251 (yyval.string_list) = _string_list_create (parser);
2252 _string_list_append_item ((yyval.string_list), (yyvsp[(1) - (1)].str));
2253 talloc_steal ((yyval.string_list), (yyvsp[(1) - (1)].str));
2254 ;}
2255 break;
2256
Carl Worth6b9e7b02010-08-11 14:00:21 -07002257 case 51:
Carl Worth667173e2010-07-28 12:33:56 -07002258
Carl Worthe29cd392010-08-10 16:59:20 -07002259/* Line 1455 of yacc.c */
Ian Romanick188f60f2010-08-12 10:07:05 -07002260#line 410 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07002261 {
2262 (yyval.string_list) = (yyvsp[(1) - (3)].string_list);
2263 _string_list_append_item ((yyval.string_list), (yyvsp[(3) - (3)].str));
2264 talloc_steal ((yyval.string_list), (yyvsp[(3) - (3)].str));
2265 ;}
2266 break;
2267
Carl Worth6b9e7b02010-08-11 14:00:21 -07002268 case 52:
Carl Worth667173e2010-07-28 12:33:56 -07002269
Carl Worthe29cd392010-08-10 16:59:20 -07002270/* Line 1455 of yacc.c */
Ian Romanick188f60f2010-08-12 10:07:05 -07002271#line 418 "glcpp/glcpp-parse.y"
Eric Anholtd4a04f32010-07-28 16:58:39 -07002272 { (yyval.token_list) = NULL; ;}
2273 break;
2274
Eric Anholtd4a04f32010-07-28 16:58:39 -07002275 case 54:
Carl Worth667173e2010-07-28 12:33:56 -07002276
Carl Worthe29cd392010-08-10 16:59:20 -07002277/* Line 1455 of yacc.c */
Ian Romanick188f60f2010-08-12 10:07:05 -07002278#line 423 "glcpp/glcpp-parse.y"
Carl Worth6b9e7b02010-08-11 14:00:21 -07002279 {
2280 yyerror (& (yylsp[(1) - (2)]), parser, "Invalid tokens after #");
2281 ;}
Carl Worth667173e2010-07-28 12:33:56 -07002282 break;
2283
Carl Worth6b9e7b02010-08-11 14:00:21 -07002284 case 55:
Carl Worth667173e2010-07-28 12:33:56 -07002285
Carl Worthe29cd392010-08-10 16:59:20 -07002286/* Line 1455 of yacc.c */
Ian Romanick188f60f2010-08-12 10:07:05 -07002287#line 429 "glcpp/glcpp-parse.y"
Carl Worth6b9e7b02010-08-11 14:00:21 -07002288 { (yyval.token_list) = NULL; ;}
Eric Anholtd4a04f32010-07-28 16:58:39 -07002289 break;
2290
2291 case 58:
2292
Carl Worthe29cd392010-08-10 16:59:20 -07002293/* Line 1455 of yacc.c */
Ian Romanick188f60f2010-08-12 10:07:05 -07002294#line 435 "glcpp/glcpp-parse.y"
Eric Anholtd4a04f32010-07-28 16:58:39 -07002295 {
Carl Worth6b9e7b02010-08-11 14:00:21 -07002296 glcpp_warning(&(yylsp[(1) - (1)]), parser, "extra tokens at end of directive");
Carl Worth667173e2010-07-28 12:33:56 -07002297 ;}
2298 break;
2299
2300 case 59:
2301
Carl Worthe29cd392010-08-10 16:59:20 -07002302/* Line 1455 of yacc.c */
Ian Romanick188f60f2010-08-12 10:07:05 -07002303#line 442 "glcpp/glcpp-parse.y"
Carl Worth6b9e7b02010-08-11 14:00:21 -07002304 {
2305 int v = hash_table_find (parser->defines, (yyvsp[(2) - (2)].str)) ? 1 : 0;
2306 (yyval.token) = _token_create_ival (parser, INTEGER, v);
2307 ;}
2308 break;
2309
2310 case 60:
2311
2312/* Line 1455 of yacc.c */
Ian Romanick188f60f2010-08-12 10:07:05 -07002313#line 446 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07002314 {
Eric Anholtd4a04f32010-07-28 16:58:39 -07002315 int v = hash_table_find (parser->defines, (yyvsp[(3) - (4)].str)) ? 1 : 0;
2316 (yyval.token) = _token_create_ival (parser, INTEGER, v);
Carl Worth667173e2010-07-28 12:33:56 -07002317 ;}
2318 break;
2319
Carl Worth6b9e7b02010-08-11 14:00:21 -07002320 case 62:
Carl Worth667173e2010-07-28 12:33:56 -07002321
Carl Worthe29cd392010-08-10 16:59:20 -07002322/* Line 1455 of yacc.c */
Ian Romanick188f60f2010-08-12 10:07:05 -07002323#line 455 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07002324 {
Eric Anholtd4a04f32010-07-28 16:58:39 -07002325 parser->space_tokens = 1;
2326 (yyval.token_list) = _token_list_create (parser);
2327 _token_list_append ((yyval.token_list), (yyvsp[(1) - (1)].token));
2328 talloc_unlink (parser, (yyvsp[(1) - (1)].token));
Carl Worth667173e2010-07-28 12:33:56 -07002329 ;}
2330 break;
2331
Kenneth Graunkef4239872010-08-04 16:24:39 -07002332 case 63:
Carl Worth667173e2010-07-28 12:33:56 -07002333
Carl Worthe29cd392010-08-10 16:59:20 -07002334/* Line 1455 of yacc.c */
Ian Romanick188f60f2010-08-12 10:07:05 -07002335#line 461 "glcpp/glcpp-parse.y"
Carl Worth6b9e7b02010-08-11 14:00:21 -07002336 {
2337 (yyval.token_list) = (yyvsp[(1) - (2)].token_list);
2338 _token_list_append ((yyval.token_list), (yyvsp[(2) - (2)].token));
2339 talloc_unlink (parser, (yyvsp[(2) - (2)].token));
2340 ;}
2341 break;
2342
2343 case 64:
2344
2345/* Line 1455 of yacc.c */
Ian Romanick188f60f2010-08-12 10:07:05 -07002346#line 469 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07002347 {
Kenneth Graunkef4239872010-08-04 16:24:39 -07002348 parser->space_tokens = 1;
2349 (yyval.token_list) = _token_list_create (parser);
2350 _token_list_append ((yyval.token_list), (yyvsp[(1) - (1)].token));
2351 talloc_unlink (parser, (yyvsp[(1) - (1)].token));
2352 ;}
2353 break;
2354
Carl Worth6b9e7b02010-08-11 14:00:21 -07002355 case 65:
Kenneth Graunkef4239872010-08-04 16:24:39 -07002356
Carl Worthe29cd392010-08-10 16:59:20 -07002357/* Line 1455 of yacc.c */
Ian Romanick188f60f2010-08-12 10:07:05 -07002358#line 475 "glcpp/glcpp-parse.y"
Kenneth Graunkef4239872010-08-04 16:24:39 -07002359 {
2360 (yyval.token_list) = (yyvsp[(1) - (2)].token_list);
2361 _token_list_append ((yyval.token_list), (yyvsp[(2) - (2)].token));
2362 talloc_unlink (parser, (yyvsp[(2) - (2)].token));
2363 ;}
2364 break;
2365
Carl Worth667173e2010-07-28 12:33:56 -07002366 case 66:
2367
Carl Worthe29cd392010-08-10 16:59:20 -07002368/* Line 1455 of yacc.c */
Ian Romanick188f60f2010-08-12 10:07:05 -07002369#line 483 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07002370 {
Carl Worth6b9e7b02010-08-11 14:00:21 -07002371 (yyval.token) = _token_create_str (parser, IDENTIFIER, (yyvsp[(1) - (1)].str));
Carl Worth667173e2010-07-28 12:33:56 -07002372 (yyval.token)->location = yylloc;
2373 ;}
2374 break;
2375
2376 case 67:
2377
Carl Worthe29cd392010-08-10 16:59:20 -07002378/* Line 1455 of yacc.c */
Ian Romanick188f60f2010-08-12 10:07:05 -07002379#line 487 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07002380 {
Carl Worth6b9e7b02010-08-11 14:00:21 -07002381 (yyval.token) = _token_create_str (parser, INTEGER_STRING, (yyvsp[(1) - (1)].str));
Carl Worth667173e2010-07-28 12:33:56 -07002382 (yyval.token)->location = yylloc;
2383 ;}
2384 break;
2385
2386 case 68:
2387
Carl Worthe29cd392010-08-10 16:59:20 -07002388/* Line 1455 of yacc.c */
Ian Romanick188f60f2010-08-12 10:07:05 -07002389#line 491 "glcpp/glcpp-parse.y"
Eric Anholtd4a04f32010-07-28 16:58:39 -07002390 {
Carl Worth6b9e7b02010-08-11 14:00:21 -07002391 (yyval.token) = _token_create_ival (parser, (yyvsp[(1) - (1)].ival), (yyvsp[(1) - (1)].ival));
Eric Anholtd4a04f32010-07-28 16:58:39 -07002392 (yyval.token)->location = yylloc;
2393 ;}
Carl Worth667173e2010-07-28 12:33:56 -07002394 break;
2395
2396 case 69:
2397
Carl Worthe29cd392010-08-10 16:59:20 -07002398/* Line 1455 of yacc.c */
Ian Romanick188f60f2010-08-12 10:07:05 -07002399#line 495 "glcpp/glcpp-parse.y"
Eric Anholtd4a04f32010-07-28 16:58:39 -07002400 {
Carl Worth6b9e7b02010-08-11 14:00:21 -07002401 (yyval.token) = _token_create_str (parser, OTHER, (yyvsp[(1) - (1)].str));
Eric Anholtd4a04f32010-07-28 16:58:39 -07002402 (yyval.token)->location = yylloc;
2403 ;}
Carl Worth667173e2010-07-28 12:33:56 -07002404 break;
2405
2406 case 70:
2407
Carl Worthe29cd392010-08-10 16:59:20 -07002408/* Line 1455 of yacc.c */
Ian Romanick188f60f2010-08-12 10:07:05 -07002409#line 499 "glcpp/glcpp-parse.y"
Carl Worth6b9e7b02010-08-11 14:00:21 -07002410 {
2411 (yyval.token) = _token_create_ival (parser, SPACE, SPACE);
2412 (yyval.token)->location = yylloc;
2413 ;}
Carl Worth667173e2010-07-28 12:33:56 -07002414 break;
2415
2416 case 71:
2417
Carl Worthe29cd392010-08-10 16:59:20 -07002418/* Line 1455 of yacc.c */
Ian Romanick188f60f2010-08-12 10:07:05 -07002419#line 506 "glcpp/glcpp-parse.y"
Carl Worth6b9e7b02010-08-11 14:00:21 -07002420 { (yyval.ival) = '['; ;}
Carl Worth667173e2010-07-28 12:33:56 -07002421 break;
2422
2423 case 72:
2424
Carl Worthe29cd392010-08-10 16:59:20 -07002425/* Line 1455 of yacc.c */
Ian Romanick188f60f2010-08-12 10:07:05 -07002426#line 507 "glcpp/glcpp-parse.y"
Carl Worth6b9e7b02010-08-11 14:00:21 -07002427 { (yyval.ival) = ']'; ;}
Carl Worth667173e2010-07-28 12:33:56 -07002428 break;
2429
2430 case 73:
2431
Carl Worthe29cd392010-08-10 16:59:20 -07002432/* Line 1455 of yacc.c */
Ian Romanick188f60f2010-08-12 10:07:05 -07002433#line 508 "glcpp/glcpp-parse.y"
Carl Worth6b9e7b02010-08-11 14:00:21 -07002434 { (yyval.ival) = '('; ;}
Carl Worth667173e2010-07-28 12:33:56 -07002435 break;
2436
2437 case 74:
2438
Carl Worthe29cd392010-08-10 16:59:20 -07002439/* Line 1455 of yacc.c */
Ian Romanick188f60f2010-08-12 10:07:05 -07002440#line 509 "glcpp/glcpp-parse.y"
Carl Worth6b9e7b02010-08-11 14:00:21 -07002441 { (yyval.ival) = ')'; ;}
Carl Worth667173e2010-07-28 12:33:56 -07002442 break;
2443
2444 case 75:
2445
Carl Worthe29cd392010-08-10 16:59:20 -07002446/* Line 1455 of yacc.c */
Ian Romanick188f60f2010-08-12 10:07:05 -07002447#line 510 "glcpp/glcpp-parse.y"
Carl Worth6b9e7b02010-08-11 14:00:21 -07002448 { (yyval.ival) = '{'; ;}
Carl Worth667173e2010-07-28 12:33:56 -07002449 break;
2450
2451 case 76:
2452
Carl Worthe29cd392010-08-10 16:59:20 -07002453/* Line 1455 of yacc.c */
Ian Romanick188f60f2010-08-12 10:07:05 -07002454#line 511 "glcpp/glcpp-parse.y"
Carl Worth6b9e7b02010-08-11 14:00:21 -07002455 { (yyval.ival) = '}'; ;}
Carl Worth667173e2010-07-28 12:33:56 -07002456 break;
2457
2458 case 77:
2459
Carl Worthe29cd392010-08-10 16:59:20 -07002460/* Line 1455 of yacc.c */
Ian Romanick188f60f2010-08-12 10:07:05 -07002461#line 512 "glcpp/glcpp-parse.y"
Carl Worth6b9e7b02010-08-11 14:00:21 -07002462 { (yyval.ival) = '.'; ;}
Carl Worth667173e2010-07-28 12:33:56 -07002463 break;
2464
2465 case 78:
2466
Carl Worthe29cd392010-08-10 16:59:20 -07002467/* Line 1455 of yacc.c */
Ian Romanick188f60f2010-08-12 10:07:05 -07002468#line 513 "glcpp/glcpp-parse.y"
Carl Worth6b9e7b02010-08-11 14:00:21 -07002469 { (yyval.ival) = '&'; ;}
Carl Worth667173e2010-07-28 12:33:56 -07002470 break;
2471
2472 case 79:
2473
Carl Worthe29cd392010-08-10 16:59:20 -07002474/* Line 1455 of yacc.c */
Ian Romanick188f60f2010-08-12 10:07:05 -07002475#line 514 "glcpp/glcpp-parse.y"
Carl Worth6b9e7b02010-08-11 14:00:21 -07002476 { (yyval.ival) = '*'; ;}
Carl Worth667173e2010-07-28 12:33:56 -07002477 break;
2478
2479 case 80:
2480
Carl Worthe29cd392010-08-10 16:59:20 -07002481/* Line 1455 of yacc.c */
Ian Romanick188f60f2010-08-12 10:07:05 -07002482#line 515 "glcpp/glcpp-parse.y"
Carl Worth6b9e7b02010-08-11 14:00:21 -07002483 { (yyval.ival) = '+'; ;}
Carl Worth667173e2010-07-28 12:33:56 -07002484 break;
2485
2486 case 81:
2487
Carl Worthe29cd392010-08-10 16:59:20 -07002488/* Line 1455 of yacc.c */
Ian Romanick188f60f2010-08-12 10:07:05 -07002489#line 516 "glcpp/glcpp-parse.y"
Carl Worth6b9e7b02010-08-11 14:00:21 -07002490 { (yyval.ival) = '-'; ;}
Carl Worth667173e2010-07-28 12:33:56 -07002491 break;
2492
2493 case 82:
2494
Carl Worthe29cd392010-08-10 16:59:20 -07002495/* Line 1455 of yacc.c */
Ian Romanick188f60f2010-08-12 10:07:05 -07002496#line 517 "glcpp/glcpp-parse.y"
Carl Worth6b9e7b02010-08-11 14:00:21 -07002497 { (yyval.ival) = '~'; ;}
Carl Worth667173e2010-07-28 12:33:56 -07002498 break;
2499
2500 case 83:
2501
Carl Worthe29cd392010-08-10 16:59:20 -07002502/* Line 1455 of yacc.c */
Ian Romanick188f60f2010-08-12 10:07:05 -07002503#line 518 "glcpp/glcpp-parse.y"
Carl Worth6b9e7b02010-08-11 14:00:21 -07002504 { (yyval.ival) = '!'; ;}
Carl Worth667173e2010-07-28 12:33:56 -07002505 break;
2506
2507 case 84:
2508
Carl Worthe29cd392010-08-10 16:59:20 -07002509/* Line 1455 of yacc.c */
Ian Romanick188f60f2010-08-12 10:07:05 -07002510#line 519 "glcpp/glcpp-parse.y"
Carl Worth6b9e7b02010-08-11 14:00:21 -07002511 { (yyval.ival) = '/'; ;}
Carl Worth667173e2010-07-28 12:33:56 -07002512 break;
2513
2514 case 85:
2515
Carl Worthe29cd392010-08-10 16:59:20 -07002516/* Line 1455 of yacc.c */
Ian Romanick188f60f2010-08-12 10:07:05 -07002517#line 520 "glcpp/glcpp-parse.y"
Carl Worth6b9e7b02010-08-11 14:00:21 -07002518 { (yyval.ival) = '%'; ;}
Carl Worth667173e2010-07-28 12:33:56 -07002519 break;
2520
2521 case 86:
2522
Carl Worthe29cd392010-08-10 16:59:20 -07002523/* Line 1455 of yacc.c */
Ian Romanick188f60f2010-08-12 10:07:05 -07002524#line 521 "glcpp/glcpp-parse.y"
Carl Worth6b9e7b02010-08-11 14:00:21 -07002525 { (yyval.ival) = LEFT_SHIFT; ;}
Carl Worth667173e2010-07-28 12:33:56 -07002526 break;
2527
2528 case 87:
2529
Carl Worthe29cd392010-08-10 16:59:20 -07002530/* Line 1455 of yacc.c */
Ian Romanick188f60f2010-08-12 10:07:05 -07002531#line 522 "glcpp/glcpp-parse.y"
Carl Worth6b9e7b02010-08-11 14:00:21 -07002532 { (yyval.ival) = RIGHT_SHIFT; ;}
Carl Worth667173e2010-07-28 12:33:56 -07002533 break;
2534
2535 case 88:
2536
Carl Worthe29cd392010-08-10 16:59:20 -07002537/* Line 1455 of yacc.c */
Ian Romanick188f60f2010-08-12 10:07:05 -07002538#line 523 "glcpp/glcpp-parse.y"
Carl Worth6b9e7b02010-08-11 14:00:21 -07002539 { (yyval.ival) = '<'; ;}
Carl Worth667173e2010-07-28 12:33:56 -07002540 break;
2541
2542 case 89:
2543
Carl Worthe29cd392010-08-10 16:59:20 -07002544/* Line 1455 of yacc.c */
Ian Romanick188f60f2010-08-12 10:07:05 -07002545#line 524 "glcpp/glcpp-parse.y"
Carl Worth6b9e7b02010-08-11 14:00:21 -07002546 { (yyval.ival) = '>'; ;}
Carl Worth667173e2010-07-28 12:33:56 -07002547 break;
2548
2549 case 90:
2550
Carl Worthe29cd392010-08-10 16:59:20 -07002551/* Line 1455 of yacc.c */
Ian Romanick188f60f2010-08-12 10:07:05 -07002552#line 525 "glcpp/glcpp-parse.y"
Carl Worth6b9e7b02010-08-11 14:00:21 -07002553 { (yyval.ival) = LESS_OR_EQUAL; ;}
Carl Worth667173e2010-07-28 12:33:56 -07002554 break;
2555
2556 case 91:
2557
Carl Worthe29cd392010-08-10 16:59:20 -07002558/* Line 1455 of yacc.c */
Ian Romanick188f60f2010-08-12 10:07:05 -07002559#line 526 "glcpp/glcpp-parse.y"
Carl Worth6b9e7b02010-08-11 14:00:21 -07002560 { (yyval.ival) = GREATER_OR_EQUAL; ;}
Carl Worth667173e2010-07-28 12:33:56 -07002561 break;
2562
2563 case 92:
2564
Carl Worthe29cd392010-08-10 16:59:20 -07002565/* Line 1455 of yacc.c */
Ian Romanick188f60f2010-08-12 10:07:05 -07002566#line 527 "glcpp/glcpp-parse.y"
Carl Worth6b9e7b02010-08-11 14:00:21 -07002567 { (yyval.ival) = EQUAL; ;}
Carl Worth667173e2010-07-28 12:33:56 -07002568 break;
2569
2570 case 93:
2571
Carl Worthe29cd392010-08-10 16:59:20 -07002572/* Line 1455 of yacc.c */
Ian Romanick188f60f2010-08-12 10:07:05 -07002573#line 528 "glcpp/glcpp-parse.y"
Carl Worth6b9e7b02010-08-11 14:00:21 -07002574 { (yyval.ival) = NOT_EQUAL; ;}
Carl Worth667173e2010-07-28 12:33:56 -07002575 break;
2576
2577 case 94:
2578
Carl Worthe29cd392010-08-10 16:59:20 -07002579/* Line 1455 of yacc.c */
Ian Romanick188f60f2010-08-12 10:07:05 -07002580#line 529 "glcpp/glcpp-parse.y"
Carl Worth6b9e7b02010-08-11 14:00:21 -07002581 { (yyval.ival) = '^'; ;}
Carl Worth667173e2010-07-28 12:33:56 -07002582 break;
2583
2584 case 95:
2585
Carl Worthe29cd392010-08-10 16:59:20 -07002586/* Line 1455 of yacc.c */
Ian Romanick188f60f2010-08-12 10:07:05 -07002587#line 530 "glcpp/glcpp-parse.y"
Carl Worth6b9e7b02010-08-11 14:00:21 -07002588 { (yyval.ival) = '|'; ;}
Carl Worth667173e2010-07-28 12:33:56 -07002589 break;
2590
2591 case 96:
2592
Carl Worthe29cd392010-08-10 16:59:20 -07002593/* Line 1455 of yacc.c */
Ian Romanick188f60f2010-08-12 10:07:05 -07002594#line 531 "glcpp/glcpp-parse.y"
Carl Worth6b9e7b02010-08-11 14:00:21 -07002595 { (yyval.ival) = AND; ;}
Carl Worth667173e2010-07-28 12:33:56 -07002596 break;
2597
2598 case 97:
2599
Carl Worthe29cd392010-08-10 16:59:20 -07002600/* Line 1455 of yacc.c */
Ian Romanick188f60f2010-08-12 10:07:05 -07002601#line 532 "glcpp/glcpp-parse.y"
Carl Worth6b9e7b02010-08-11 14:00:21 -07002602 { (yyval.ival) = OR; ;}
Carl Worth667173e2010-07-28 12:33:56 -07002603 break;
2604
2605 case 98:
2606
Carl Worthe29cd392010-08-10 16:59:20 -07002607/* Line 1455 of yacc.c */
Ian Romanick188f60f2010-08-12 10:07:05 -07002608#line 533 "glcpp/glcpp-parse.y"
Carl Worth6b9e7b02010-08-11 14:00:21 -07002609 { (yyval.ival) = ';'; ;}
Eric Anholtd4a04f32010-07-28 16:58:39 -07002610 break;
2611
2612 case 99:
2613
Carl Worthe29cd392010-08-10 16:59:20 -07002614/* Line 1455 of yacc.c */
Ian Romanick188f60f2010-08-12 10:07:05 -07002615#line 534 "glcpp/glcpp-parse.y"
Carl Worth6b9e7b02010-08-11 14:00:21 -07002616 { (yyval.ival) = ','; ;}
Eric Anholtd4a04f32010-07-28 16:58:39 -07002617 break;
2618
2619 case 100:
2620
Carl Worthe29cd392010-08-10 16:59:20 -07002621/* Line 1455 of yacc.c */
Ian Romanick188f60f2010-08-12 10:07:05 -07002622#line 535 "glcpp/glcpp-parse.y"
Carl Worth6b9e7b02010-08-11 14:00:21 -07002623 { (yyval.ival) = '='; ;}
2624 break;
2625
2626 case 101:
2627
2628/* Line 1455 of yacc.c */
Ian Romanick188f60f2010-08-12 10:07:05 -07002629#line 536 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07002630 { (yyval.ival) = PASTE; ;}
2631 break;
2632
2633
2634
Carl Worthe29cd392010-08-10 16:59:20 -07002635/* Line 1455 of yacc.c */
Ian Romanick188f60f2010-08-12 10:07:05 -07002636#line 2637 "glcpp/glcpp-parse.c"
Carl Worth667173e2010-07-28 12:33:56 -07002637 default: break;
2638 }
2639 YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
2640
2641 YYPOPSTACK (yylen);
2642 yylen = 0;
2643 YY_STACK_PRINT (yyss, yyssp);
2644
2645 *++yyvsp = yyval;
2646 *++yylsp = yyloc;
2647
2648 /* Now `shift' the result of the reduction. Determine what state
2649 that goes to, based on the state we popped back to and the rule
2650 number reduced by. */
2651
2652 yyn = yyr1[yyn];
2653
2654 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
2655 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
2656 yystate = yytable[yystate];
2657 else
2658 yystate = yydefgoto[yyn - YYNTOKENS];
2659
2660 goto yynewstate;
2661
2662
2663/*------------------------------------.
2664| yyerrlab -- here on detecting error |
2665`------------------------------------*/
2666yyerrlab:
2667 /* If not already recovering from an error, report this error. */
2668 if (!yyerrstatus)
2669 {
2670 ++yynerrs;
2671#if ! YYERROR_VERBOSE
2672 yyerror (&yylloc, parser, YY_("syntax error"));
2673#else
2674 {
2675 YYSIZE_T yysize = yysyntax_error (0, yystate, yychar);
2676 if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM)
2677 {
2678 YYSIZE_T yyalloc = 2 * yysize;
2679 if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM))
2680 yyalloc = YYSTACK_ALLOC_MAXIMUM;
2681 if (yymsg != yymsgbuf)
2682 YYSTACK_FREE (yymsg);
2683 yymsg = (char *) YYSTACK_ALLOC (yyalloc);
2684 if (yymsg)
2685 yymsg_alloc = yyalloc;
2686 else
2687 {
2688 yymsg = yymsgbuf;
2689 yymsg_alloc = sizeof yymsgbuf;
2690 }
2691 }
2692
2693 if (0 < yysize && yysize <= yymsg_alloc)
2694 {
2695 (void) yysyntax_error (yymsg, yystate, yychar);
2696 yyerror (&yylloc, parser, yymsg);
2697 }
2698 else
2699 {
2700 yyerror (&yylloc, parser, YY_("syntax error"));
2701 if (yysize != 0)
2702 goto yyexhaustedlab;
2703 }
2704 }
2705#endif
2706 }
2707
2708 yyerror_range[0] = yylloc;
2709
2710 if (yyerrstatus == 3)
2711 {
2712 /* If just tried and failed to reuse lookahead token after an
2713 error, discard it. */
2714
2715 if (yychar <= YYEOF)
2716 {
2717 /* Return failure if at end of input. */
2718 if (yychar == YYEOF)
2719 YYABORT;
2720 }
2721 else
2722 {
2723 yydestruct ("Error: discarding",
2724 yytoken, &yylval, &yylloc, parser);
2725 yychar = YYEMPTY;
2726 }
2727 }
2728
2729 /* Else will try to reuse lookahead token after shifting the error
2730 token. */
2731 goto yyerrlab1;
2732
2733
2734/*---------------------------------------------------.
2735| yyerrorlab -- error raised explicitly by YYERROR. |
2736`---------------------------------------------------*/
2737yyerrorlab:
2738
2739 /* Pacify compilers like GCC when the user code never invokes
2740 YYERROR and the label yyerrorlab therefore never appears in user
2741 code. */
2742 if (/*CONSTCOND*/ 0)
2743 goto yyerrorlab;
2744
2745 yyerror_range[0] = yylsp[1-yylen];
2746 /* Do not reclaim the symbols of the rule which action triggered
2747 this YYERROR. */
2748 YYPOPSTACK (yylen);
2749 yylen = 0;
2750 YY_STACK_PRINT (yyss, yyssp);
2751 yystate = *yyssp;
2752 goto yyerrlab1;
2753
2754
2755/*-------------------------------------------------------------.
2756| yyerrlab1 -- common code for both syntax error and YYERROR. |
2757`-------------------------------------------------------------*/
2758yyerrlab1:
2759 yyerrstatus = 3; /* Each real token shifted decrements this. */
2760
2761 for (;;)
2762 {
2763 yyn = yypact[yystate];
2764 if (yyn != YYPACT_NINF)
2765 {
2766 yyn += YYTERROR;
2767 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
2768 {
2769 yyn = yytable[yyn];
2770 if (0 < yyn)
2771 break;
2772 }
2773 }
2774
2775 /* Pop the current state because it cannot handle the error token. */
2776 if (yyssp == yyss)
2777 YYABORT;
2778
2779 yyerror_range[0] = *yylsp;
2780 yydestruct ("Error: popping",
2781 yystos[yystate], yyvsp, yylsp, parser);
2782 YYPOPSTACK (1);
2783 yystate = *yyssp;
2784 YY_STACK_PRINT (yyss, yyssp);
2785 }
2786
2787 *++yyvsp = yylval;
2788
2789 yyerror_range[1] = yylloc;
2790 /* Using YYLLOC is tempting, but would change the location of
2791 the lookahead. YYLOC is available though. */
2792 YYLLOC_DEFAULT (yyloc, (yyerror_range - 1), 2);
2793 *++yylsp = yyloc;
2794
2795 /* Shift the error token. */
2796 YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
2797
2798 yystate = yyn;
2799 goto yynewstate;
2800
2801
2802/*-------------------------------------.
2803| yyacceptlab -- YYACCEPT comes here. |
2804`-------------------------------------*/
2805yyacceptlab:
2806 yyresult = 0;
2807 goto yyreturn;
2808
2809/*-----------------------------------.
2810| yyabortlab -- YYABORT comes here. |
2811`-----------------------------------*/
2812yyabortlab:
2813 yyresult = 1;
2814 goto yyreturn;
2815
2816#if !defined(yyoverflow) || YYERROR_VERBOSE
2817/*-------------------------------------------------.
2818| yyexhaustedlab -- memory exhaustion comes here. |
2819`-------------------------------------------------*/
2820yyexhaustedlab:
2821 yyerror (&yylloc, parser, YY_("memory exhausted"));
2822 yyresult = 2;
2823 /* Fall through. */
2824#endif
2825
2826yyreturn:
2827 if (yychar != YYEMPTY)
2828 yydestruct ("Cleanup: discarding lookahead",
2829 yytoken, &yylval, &yylloc, parser);
2830 /* Do not reclaim the symbols of the rule which action triggered
2831 this YYABORT or YYACCEPT. */
2832 YYPOPSTACK (yylen);
2833 YY_STACK_PRINT (yyss, yyssp);
2834 while (yyssp != yyss)
2835 {
2836 yydestruct ("Cleanup: popping",
2837 yystos[*yyssp], yyvsp, yylsp, parser);
2838 YYPOPSTACK (1);
2839 }
2840#ifndef yyoverflow
2841 if (yyss != yyssa)
2842 YYSTACK_FREE (yyss);
2843#endif
2844#if YYERROR_VERBOSE
2845 if (yymsg != yymsgbuf)
2846 YYSTACK_FREE (yymsg);
2847#endif
2848 /* Make sure YYID is used. */
2849 return YYID (yyresult);
2850}
2851
2852
2853
Carl Worthe29cd392010-08-10 16:59:20 -07002854/* Line 1675 of yacc.c */
Ian Romanick188f60f2010-08-12 10:07:05 -07002855#line 539 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07002856
2857
2858string_list_t *
2859_string_list_create (void *ctx)
2860{
2861 string_list_t *list;
2862
Kenneth Graunke0ef79a52010-08-03 20:25:13 -07002863 list = talloc (ctx, string_list_t);
Carl Worth667173e2010-07-28 12:33:56 -07002864 list->head = NULL;
2865 list->tail = NULL;
2866
2867 return list;
2868}
2869
2870void
2871_string_list_append_item (string_list_t *list, const char *str)
2872{
2873 string_node_t *node;
2874
Kenneth Graunke0ef79a52010-08-03 20:25:13 -07002875 node = talloc (list, string_node_t);
2876 node->str = talloc_strdup (node, str);
Carl Worth667173e2010-07-28 12:33:56 -07002877
2878 node->next = NULL;
2879
2880 if (list->head == NULL) {
2881 list->head = node;
2882 } else {
2883 list->tail->next = node;
2884 }
2885
2886 list->tail = node;
2887}
2888
2889int
2890_string_list_contains (string_list_t *list, const char *member, int *index)
2891{
2892 string_node_t *node;
2893 int i;
2894
2895 if (list == NULL)
2896 return 0;
2897
2898 for (i = 0, node = list->head; node; i++, node = node->next) {
2899 if (strcmp (node->str, member) == 0) {
2900 if (index)
2901 *index = i;
2902 return 1;
2903 }
2904 }
2905
2906 return 0;
2907}
2908
2909int
2910_string_list_length (string_list_t *list)
2911{
2912 int length = 0;
2913 string_node_t *node;
2914
2915 if (list == NULL)
2916 return 0;
2917
2918 for (node = list->head; node; node = node->next)
2919 length++;
2920
2921 return length;
2922}
2923
2924argument_list_t *
2925_argument_list_create (void *ctx)
2926{
2927 argument_list_t *list;
2928
Kenneth Graunke0ef79a52010-08-03 20:25:13 -07002929 list = talloc (ctx, argument_list_t);
Carl Worth667173e2010-07-28 12:33:56 -07002930 list->head = NULL;
2931 list->tail = NULL;
2932
2933 return list;
2934}
2935
2936void
2937_argument_list_append (argument_list_t *list, token_list_t *argument)
2938{
2939 argument_node_t *node;
2940
Kenneth Graunke0ef79a52010-08-03 20:25:13 -07002941 node = talloc (list, argument_node_t);
Carl Worth667173e2010-07-28 12:33:56 -07002942 node->argument = argument;
2943
2944 node->next = NULL;
2945
2946 if (list->head == NULL) {
2947 list->head = node;
2948 } else {
2949 list->tail->next = node;
2950 }
2951
2952 list->tail = node;
2953}
2954
2955int
2956_argument_list_length (argument_list_t *list)
2957{
2958 int length = 0;
2959 argument_node_t *node;
2960
2961 if (list == NULL)
2962 return 0;
2963
2964 for (node = list->head; node; node = node->next)
2965 length++;
2966
2967 return length;
2968}
2969
2970token_list_t *
2971_argument_list_member_at (argument_list_t *list, int index)
2972{
2973 argument_node_t *node;
2974 int i;
2975
2976 if (list == NULL)
2977 return NULL;
2978
2979 node = list->head;
2980 for (i = 0; i < index; i++) {
2981 node = node->next;
2982 if (node == NULL)
2983 break;
2984 }
2985
2986 if (node)
2987 return node->argument;
2988
2989 return NULL;
2990}
2991
2992/* Note: This function talloc_steal()s the str pointer. */
2993token_t *
2994_token_create_str (void *ctx, int type, char *str)
2995{
2996 token_t *token;
2997
Kenneth Graunke0ef79a52010-08-03 20:25:13 -07002998 token = talloc (ctx, token_t);
Carl Worth667173e2010-07-28 12:33:56 -07002999 token->type = type;
3000 token->value.str = talloc_steal (token, str);
3001
3002 return token;
3003}
3004
3005token_t *
3006_token_create_ival (void *ctx, int type, int ival)
3007{
3008 token_t *token;
3009
Kenneth Graunke0ef79a52010-08-03 20:25:13 -07003010 token = talloc (ctx, token_t);
Carl Worth667173e2010-07-28 12:33:56 -07003011 token->type = type;
3012 token->value.ival = ival;
3013
3014 return token;
3015}
3016
3017token_list_t *
3018_token_list_create (void *ctx)
3019{
3020 token_list_t *list;
3021
Kenneth Graunke0ef79a52010-08-03 20:25:13 -07003022 list = talloc (ctx, token_list_t);
Carl Worth667173e2010-07-28 12:33:56 -07003023 list->head = NULL;
3024 list->tail = NULL;
3025 list->non_space_tail = NULL;
3026
3027 return list;
3028}
3029
3030void
3031_token_list_append (token_list_t *list, token_t *token)
3032{
3033 token_node_t *node;
3034
Kenneth Graunke0ef79a52010-08-03 20:25:13 -07003035 node = talloc (list, token_node_t);
3036 node->token = talloc_reference (list, token);
Carl Worth667173e2010-07-28 12:33:56 -07003037
3038 node->next = NULL;
3039
3040 if (list->head == NULL) {
3041 list->head = node;
3042 } else {
3043 list->tail->next = node;
3044 }
3045
3046 list->tail = node;
3047 if (token->type != SPACE)
3048 list->non_space_tail = node;
3049}
3050
3051void
3052_token_list_append_list (token_list_t *list, token_list_t *tail)
3053{
3054 if (tail == NULL || tail->head == NULL)
3055 return;
3056
3057 if (list->head == NULL) {
3058 list->head = tail->head;
3059 } else {
3060 list->tail->next = tail->head;
3061 }
3062
3063 list->tail = tail->tail;
3064 list->non_space_tail = tail->non_space_tail;
3065}
3066
3067static token_list_t *
3068_token_list_copy (void *ctx, token_list_t *other)
3069{
3070 token_list_t *copy;
3071 token_node_t *node;
3072
3073 if (other == NULL)
3074 return NULL;
3075
3076 copy = _token_list_create (ctx);
3077 for (node = other->head; node; node = node->next)
3078 _token_list_append (copy, node->token);
3079
3080 return copy;
3081}
3082
3083static void
3084_token_list_trim_trailing_space (token_list_t *list)
3085{
3086 token_node_t *tail, *next;
3087
3088 if (list->non_space_tail) {
3089 tail = list->non_space_tail->next;
3090 list->non_space_tail->next = NULL;
3091 list->tail = list->non_space_tail;
3092
3093 while (tail) {
3094 next = tail->next;
3095 talloc_free (tail);
3096 tail = next;
3097 }
3098 }
3099}
3100
3101static void
3102_token_print (char **out, token_t *token)
3103{
3104 if (token->type < 256) {
3105 glcpp_printf (*out, "%c", token->type);
3106 return;
3107 }
3108
3109 switch (token->type) {
3110 case INTEGER:
Eric Anholt8605c292010-07-28 16:53:51 -07003111 glcpp_printf (*out, "%" PRIiMAX, token->value.ival);
Carl Worth667173e2010-07-28 12:33:56 -07003112 break;
3113 case IDENTIFIER:
3114 case INTEGER_STRING:
3115 case OTHER:
3116 glcpp_print (*out, token->value.str);
3117 break;
3118 case SPACE:
3119 glcpp_print (*out, " ");
3120 break;
3121 case LEFT_SHIFT:
3122 glcpp_print (*out, "<<");
3123 break;
3124 case RIGHT_SHIFT:
3125 glcpp_print (*out, ">>");
3126 break;
3127 case LESS_OR_EQUAL:
3128 glcpp_print (*out, "<=");
3129 break;
3130 case GREATER_OR_EQUAL:
3131 glcpp_print (*out, ">=");
3132 break;
3133 case EQUAL:
3134 glcpp_print (*out, "==");
3135 break;
3136 case NOT_EQUAL:
3137 glcpp_print (*out, "!=");
3138 break;
3139 case AND:
3140 glcpp_print (*out, "&&");
3141 break;
3142 case OR:
3143 glcpp_print (*out, "||");
3144 break;
3145 case PASTE:
3146 glcpp_print (*out, "##");
3147 break;
3148 case COMMA_FINAL:
3149 glcpp_print (*out, ",");
3150 break;
3151 case PLACEHOLDER:
3152 /* Nothing to print. */
3153 break;
3154 default:
3155 assert(!"Error: Don't know how to print token.");
3156 break;
3157 }
3158}
3159
3160/* Return a new token (talloc()ed off of 'token') formed by pasting
3161 * 'token' and 'other'. Note that this function may return 'token' or
3162 * 'other' directly rather than allocating anything new.
3163 *
3164 * Caution: Only very cursory error-checking is performed to see if
3165 * the final result is a valid single token. */
3166static token_t *
3167_token_paste (glcpp_parser_t *parser, token_t *token, token_t *other)
3168{
3169 token_t *combined = NULL;
3170
3171 /* Pasting a placeholder onto anything makes no change. */
3172 if (other->type == PLACEHOLDER)
3173 return token;
3174
3175 /* When 'token' is a placeholder, just return 'other'. */
3176 if (token->type == PLACEHOLDER)
3177 return other;
3178
3179 /* A very few single-character punctuators can be combined
3180 * with another to form a multi-character punctuator. */
3181 switch (token->type) {
3182 case '<':
3183 if (other->type == '<')
3184 combined = _token_create_ival (token, LEFT_SHIFT, LEFT_SHIFT);
3185 else if (other->type == '=')
3186 combined = _token_create_ival (token, LESS_OR_EQUAL, LESS_OR_EQUAL);
3187 break;
3188 case '>':
3189 if (other->type == '>')
3190 combined = _token_create_ival (token, RIGHT_SHIFT, RIGHT_SHIFT);
3191 else if (other->type == '=')
3192 combined = _token_create_ival (token, GREATER_OR_EQUAL, GREATER_OR_EQUAL);
3193 break;
3194 case '=':
3195 if (other->type == '=')
3196 combined = _token_create_ival (token, EQUAL, EQUAL);
3197 break;
3198 case '!':
3199 if (other->type == '=')
3200 combined = _token_create_ival (token, NOT_EQUAL, NOT_EQUAL);
3201 break;
3202 case '&':
3203 if (other->type == '&')
3204 combined = _token_create_ival (token, AND, AND);
3205 break;
3206 case '|':
3207 if (other->type == '|')
3208 combined = _token_create_ival (token, OR, OR);
3209 break;
3210 }
3211
3212 if (combined != NULL) {
3213 /* Inherit the location from the first token */
3214 combined->location = token->location;
3215 return combined;
3216 }
3217
3218 /* Two string-valued tokens can usually just be mashed
3219 * together.
3220 *
3221 * XXX: This isn't actually legitimate. Several things here
3222 * should result in a diagnostic since the result cannot be a
3223 * valid, single pre-processing token. For example, pasting
3224 * "123" and "abc" is not legal, but we don't catch that
3225 * here. */
3226 if ((token->type == IDENTIFIER || token->type == OTHER || token->type == INTEGER_STRING) &&
3227 (other->type == IDENTIFIER || other->type == OTHER || other->type == INTEGER_STRING))
3228 {
3229 char *str;
3230
Kenneth Graunke0ef79a52010-08-03 20:25:13 -07003231 str = talloc_asprintf (token, "%s%s", token->value.str,
3232 other->value.str);
Carl Worth667173e2010-07-28 12:33:56 -07003233 combined = _token_create_str (token, token->type, str);
3234 combined->location = token->location;
3235 return combined;
3236 }
3237
3238 glcpp_error (&token->location, parser, "");
3239 glcpp_print (parser->info_log, "Pasting \"");
3240 _token_print (&parser->info_log, token);
3241 glcpp_print (parser->info_log, "\" and \"");
3242 _token_print (&parser->info_log, other);
3243 glcpp_print (parser->info_log, "\" does not give a valid preprocessing token.\n");
3244
3245 return token;
3246}
3247
3248static void
3249_token_list_print (glcpp_parser_t *parser, token_list_t *list)
3250{
3251 token_node_t *node;
3252
3253 if (list == NULL)
3254 return;
3255
3256 for (node = list->head; node; node = node->next)
3257 _token_print (&parser->output, node->token);
3258}
3259
3260void
3261yyerror (YYLTYPE *locp, glcpp_parser_t *parser, const char *error)
3262{
3263 glcpp_error(locp, parser, "%s", error);
3264}
3265
Eric Anholtd4a04f32010-07-28 16:58:39 -07003266static void add_builtin_define(glcpp_parser_t *parser,
3267 const char *name, int value)
3268{
3269 token_t *tok;
3270 token_list_t *list;
3271
3272 tok = _token_create_ival (parser, INTEGER, value);
3273
3274 list = _token_list_create(parser);
3275 _token_list_append(list, tok);
3276 _define_object_macro(parser, NULL, name, list);
3277
3278 talloc_unlink(parser, tok);
3279}
3280
Carl Worth667173e2010-07-28 12:33:56 -07003281glcpp_parser_t *
3282glcpp_parser_create (const struct gl_extensions *extensions)
3283{
3284 glcpp_parser_t *parser;
Eric Anholtd4a04f32010-07-28 16:58:39 -07003285 int language_version;
Carl Worth667173e2010-07-28 12:33:56 -07003286
Kenneth Graunke0ef79a52010-08-03 20:25:13 -07003287 parser = talloc (NULL, glcpp_parser_t);
Carl Worth667173e2010-07-28 12:33:56 -07003288
3289 glcpp_lex_init_extra (parser, &parser->scanner);
3290 parser->defines = hash_table_ctor (32, hash_table_string_hash,
3291 hash_table_string_compare);
3292 parser->active = NULL;
3293 parser->lexing_if = 0;
3294 parser->space_tokens = 1;
3295 parser->newline_as_space = 0;
3296 parser->in_control_line = 0;
3297 parser->paren_count = 0;
3298
3299 parser->skip_stack = NULL;
3300
3301 parser->lex_from_list = NULL;
3302 parser->lex_from_node = NULL;
3303
3304 parser->output = talloc_strdup(parser, "");
3305 parser->info_log = talloc_strdup(parser, "");
3306 parser->error = 0;
3307
3308 /* Add pre-defined macros. */
Eric Anholtd4a04f32010-07-28 16:58:39 -07003309 add_builtin_define(parser, "GL_ARB_draw_buffers", 1);
3310 add_builtin_define(parser, "GL_ARB_texture_rectangle", 1);
Carl Worth667173e2010-07-28 12:33:56 -07003311
Eric Anholtd4a04f32010-07-28 16:58:39 -07003312 if (extensions != NULL) {
3313 if (extensions->EXT_texture_array) {
3314 add_builtin_define(parser, "GL_EXT_texture_array", 1);
3315 }
Carl Worth667173e2010-07-28 12:33:56 -07003316
Eric Anholtd4a04f32010-07-28 16:58:39 -07003317 if (extensions->ARB_fragment_coord_conventions)
3318 add_builtin_define(parser, "GL_ARB_fragment_coord_conventions",
3319 1);
Carl Worth667173e2010-07-28 12:33:56 -07003320 }
3321
Eric Anholtd4a04f32010-07-28 16:58:39 -07003322 language_version = 110;
Eric Anholtd4a04f32010-07-28 16:58:39 -07003323 add_builtin_define(parser, "__VERSION__", language_version);
Carl Worth667173e2010-07-28 12:33:56 -07003324
3325 return parser;
3326}
3327
3328int
3329glcpp_parser_parse (glcpp_parser_t *parser)
3330{
3331 return yyparse (parser);
3332}
3333
3334void
3335glcpp_parser_destroy (glcpp_parser_t *parser)
3336{
Carl Worth667173e2010-07-28 12:33:56 -07003337 glcpp_lex_destroy (parser->scanner);
3338 hash_table_dtor (parser->defines);
3339 talloc_free (parser);
3340}
3341
3342typedef enum function_status
3343{
3344 FUNCTION_STATUS_SUCCESS,
3345 FUNCTION_NOT_A_FUNCTION,
3346 FUNCTION_UNBALANCED_PARENTHESES
3347} function_status_t;
3348
3349/* Find a set of function-like macro arguments by looking for a
3350 * balanced set of parentheses.
3351 *
3352 * When called, 'node' should be the opening-parenthesis token, (or
3353 * perhaps preceeding SPACE tokens). Upon successful return *last will
3354 * be the last consumed node, (corresponding to the closing right
3355 * parenthesis).
3356 *
3357 * Return values:
3358 *
3359 * FUNCTION_STATUS_SUCCESS:
3360 *
3361 * Successfully parsed a set of function arguments.
3362 *
3363 * FUNCTION_NOT_A_FUNCTION:
3364 *
3365 * Macro name not followed by a '('. This is not an error, but
3366 * simply that the macro name should be treated as a non-macro.
3367 *
3368 * FUNCTION_UNBALANCED_PARENTHESES
3369 *
3370 * Macro name is not followed by a balanced set of parentheses.
3371 */
3372static function_status_t
3373_arguments_parse (argument_list_t *arguments,
3374 token_node_t *node,
3375 token_node_t **last)
3376{
3377 token_list_t *argument;
3378 int paren_count;
3379
3380 node = node->next;
3381
3382 /* Ignore whitespace before first parenthesis. */
3383 while (node && node->token->type == SPACE)
3384 node = node->next;
3385
3386 if (node == NULL || node->token->type != '(')
3387 return FUNCTION_NOT_A_FUNCTION;
3388
3389 node = node->next;
3390
3391 argument = _token_list_create (arguments);
3392 _argument_list_append (arguments, argument);
3393
3394 for (paren_count = 1; node; node = node->next) {
3395 if (node->token->type == '(')
3396 {
3397 paren_count++;
3398 }
3399 else if (node->token->type == ')')
3400 {
3401 paren_count--;
3402 if (paren_count == 0)
3403 break;
3404 }
3405
3406 if (node->token->type == ',' &&
3407 paren_count == 1)
3408 {
3409 _token_list_trim_trailing_space (argument);
3410 argument = _token_list_create (arguments);
3411 _argument_list_append (arguments, argument);
3412 }
3413 else {
3414 if (argument->head == NULL) {
3415 /* Don't treat initial whitespace as
3416 * part of the arguement. */
3417 if (node->token->type == SPACE)
3418 continue;
3419 }
3420 _token_list_append (argument, node->token);
3421 }
3422 }
3423
3424 if (paren_count)
3425 return FUNCTION_UNBALANCED_PARENTHESES;
3426
3427 *last = node;
3428
3429 return FUNCTION_STATUS_SUCCESS;
3430}
3431
3432static token_list_t *
3433_token_list_create_with_one_space (void *ctx)
3434{
3435 token_list_t *list;
3436 token_t *space;
3437
3438 list = _token_list_create (ctx);
3439 space = _token_create_ival (list, SPACE, SPACE);
3440 _token_list_append (list, space);
3441
3442 return list;
3443}
3444
Kenneth Graunke16b4eed2010-08-04 16:10:03 -07003445static void
3446_glcpp_parser_expand_if (glcpp_parser_t *parser, int type, token_list_t *list)
3447{
3448 token_list_t *expanded;
3449 token_t *token;
3450
3451 expanded = _token_list_create (parser);
3452 token = _token_create_ival (parser, type, type);
3453 _token_list_append (expanded, token);
3454 _glcpp_parser_expand_token_list (parser, list);
3455 _token_list_append_list (expanded, list);
3456 glcpp_parser_lex_from (parser, expanded);
3457}
3458
Carl Worth667173e2010-07-28 12:33:56 -07003459/* This is a helper function that's essentially part of the
3460 * implementation of _glcpp_parser_expand_node. It shouldn't be called
3461 * except for by that function.
3462 *
3463 * Returns NULL if node is a simple token with no expansion, (that is,
3464 * although 'node' corresponds to an identifier defined as a
3465 * function-like macro, it is not followed with a parenthesized
3466 * argument list).
3467 *
3468 * Compute the complete expansion of node (which is a function-like
3469 * macro) and subsequent nodes which are arguments.
3470 *
3471 * Returns the token list that results from the expansion and sets
3472 * *last to the last node in the list that was consumed by the
3473 * expansion. Specifically, *last will be set as follows: as the
3474 * token of the closing right parenthesis.
3475 */
3476static token_list_t *
3477_glcpp_parser_expand_function (glcpp_parser_t *parser,
3478 token_node_t *node,
3479 token_node_t **last)
3480
3481{
3482 macro_t *macro;
3483 const char *identifier;
3484 argument_list_t *arguments;
3485 function_status_t status;
3486 token_list_t *substituted;
3487 int parameter_index;
3488
3489 identifier = node->token->value.str;
3490
3491 macro = hash_table_find (parser->defines, identifier);
3492
3493 assert (macro->is_function);
3494
3495 arguments = _argument_list_create (parser);
3496 status = _arguments_parse (arguments, node, last);
3497
3498 switch (status) {
3499 case FUNCTION_STATUS_SUCCESS:
3500 break;
3501 case FUNCTION_NOT_A_FUNCTION:
3502 return NULL;
3503 case FUNCTION_UNBALANCED_PARENTHESES:
3504 glcpp_error (&node->token->location, parser, "Macro %s call has unbalanced parentheses\n", identifier);
3505 return NULL;
3506 }
3507
3508 /* Replace a macro defined as empty with a SPACE token. */
3509 if (macro->replacements == NULL) {
3510 talloc_free (arguments);
3511 return _token_list_create_with_one_space (parser);
3512 }
3513
3514 if (! ((_argument_list_length (arguments) ==
3515 _string_list_length (macro->parameters)) ||
3516 (_string_list_length (macro->parameters) == 0 &&
3517 _argument_list_length (arguments) == 1 &&
3518 arguments->head->argument->head == NULL)))
3519 {
3520 glcpp_error (&node->token->location, parser,
3521 "Error: macro %s invoked with %d arguments (expected %d)\n",
3522 identifier,
3523 _argument_list_length (arguments),
3524 _string_list_length (macro->parameters));
3525 return NULL;
3526 }
3527
3528 /* Perform argument substitution on the replacement list. */
3529 substituted = _token_list_create (arguments);
3530
3531 for (node = macro->replacements->head; node; node = node->next)
3532 {
3533 if (node->token->type == IDENTIFIER &&
3534 _string_list_contains (macro->parameters,
3535 node->token->value.str,
3536 &parameter_index))
3537 {
3538 token_list_t *argument;
3539 argument = _argument_list_member_at (arguments,
3540 parameter_index);
3541 /* Before substituting, we expand the argument
3542 * tokens, or append a placeholder token for
3543 * an empty argument. */
3544 if (argument->head) {
3545 token_list_t *expanded_argument;
3546 expanded_argument = _token_list_copy (parser,
3547 argument);
3548 _glcpp_parser_expand_token_list (parser,
3549 expanded_argument);
3550 _token_list_append_list (substituted,
3551 expanded_argument);
3552 } else {
3553 token_t *new_token;
3554
3555 new_token = _token_create_ival (substituted,
3556 PLACEHOLDER,
3557 PLACEHOLDER);
3558 _token_list_append (substituted, new_token);
3559 }
3560 } else {
3561 _token_list_append (substituted, node->token);
3562 }
3563 }
3564
3565 /* After argument substitution, and before further expansion
3566 * below, implement token pasting. */
3567
3568 _token_list_trim_trailing_space (substituted);
3569
3570 node = substituted->head;
3571 while (node)
3572 {
3573 token_node_t *next_non_space;
3574
3575 /* Look ahead for a PASTE token, skipping space. */
3576 next_non_space = node->next;
3577 while (next_non_space && next_non_space->token->type == SPACE)
3578 next_non_space = next_non_space->next;
3579
3580 if (next_non_space == NULL)
3581 break;
3582
3583 if (next_non_space->token->type != PASTE) {
3584 node = next_non_space;
3585 continue;
3586 }
3587
3588 /* Now find the next non-space token after the PASTE. */
3589 next_non_space = next_non_space->next;
3590 while (next_non_space && next_non_space->token->type == SPACE)
3591 next_non_space = next_non_space->next;
3592
3593 if (next_non_space == NULL) {
3594 yyerror (&node->token->location, parser, "'##' cannot appear at either end of a macro expansion\n");
3595 return NULL;
3596 }
3597
3598 node->token = _token_paste (parser, node->token, next_non_space->token);
3599 node->next = next_non_space->next;
3600 if (next_non_space == substituted->tail)
3601 substituted->tail = node;
3602
3603 node = node->next;
3604 }
3605
3606 substituted->non_space_tail = substituted->tail;
3607
3608 return substituted;
3609}
3610
3611/* Compute the complete expansion of node, (and subsequent nodes after
3612 * 'node' in the case that 'node' is a function-like macro and
3613 * subsequent nodes are arguments).
3614 *
3615 * Returns NULL if node is a simple token with no expansion.
3616 *
3617 * Otherwise, returns the token list that results from the expansion
3618 * and sets *last to the last node in the list that was consumed by
3619 * the expansion. Specifically, *last will be set as follows:
3620 *
3621 * As 'node' in the case of object-like macro expansion.
3622 *
3623 * As the token of the closing right parenthesis in the case of
3624 * function-like macro expansion.
3625 */
3626static token_list_t *
3627_glcpp_parser_expand_node (glcpp_parser_t *parser,
3628 token_node_t *node,
3629 token_node_t **last)
3630{
3631 token_t *token = node->token;
3632 const char *identifier;
3633 macro_t *macro;
3634
3635 /* We only expand identifiers */
3636 if (token->type != IDENTIFIER) {
3637 /* We change any COMMA into a COMMA_FINAL to prevent
3638 * it being mistaken for an argument separator
3639 * later. */
3640 if (token->type == ',') {
3641 token->type = COMMA_FINAL;
3642 token->value.ival = COMMA_FINAL;
3643 }
3644
3645 return NULL;
3646 }
3647
3648 /* Look up this identifier in the hash table. */
3649 identifier = token->value.str;
3650 macro = hash_table_find (parser->defines, identifier);
3651
3652 /* Not a macro, so no expansion needed. */
3653 if (macro == NULL)
3654 return NULL;
3655
3656 /* Finally, don't expand this macro if we're already actively
3657 * expanding it, (to avoid infinite recursion). */
3658 if (_active_list_contains (parser->active, identifier)) {
3659 /* We change the token type here from IDENTIFIER to
3660 * OTHER to prevent any future expansion of this
3661 * unexpanded token. */
3662 char *str;
3663 token_list_t *expansion;
3664 token_t *final;
3665
Kenneth Graunke0ef79a52010-08-03 20:25:13 -07003666 str = talloc_strdup (parser, token->value.str);
Carl Worth667173e2010-07-28 12:33:56 -07003667 final = _token_create_str (parser, OTHER, str);
3668 expansion = _token_list_create (parser);
3669 _token_list_append (expansion, final);
3670 *last = node;
3671 return expansion;
3672 }
3673
3674 if (! macro->is_function)
3675 {
3676 *last = node;
3677
3678 /* Replace a macro defined as empty with a SPACE token. */
3679 if (macro->replacements == NULL)
3680 return _token_list_create_with_one_space (parser);
3681
3682 return _token_list_copy (parser, macro->replacements);
3683 }
3684
3685 return _glcpp_parser_expand_function (parser, node, last);
3686}
3687
3688/* Push a new identifier onto the active list, returning the new list.
3689 *
3690 * Here, 'marker' is the token node that appears in the list after the
3691 * expansion of 'identifier'. That is, when the list iterator begins
3692 * examinging 'marker', then it is time to pop this node from the
3693 * active stack.
3694 */
3695active_list_t *
3696_active_list_push (active_list_t *list,
3697 const char *identifier,
3698 token_node_t *marker)
3699{
3700 active_list_t *node;
3701
Kenneth Graunke0ef79a52010-08-03 20:25:13 -07003702 node = talloc (list, active_list_t);
3703 node->identifier = talloc_strdup (node, identifier);
Carl Worth667173e2010-07-28 12:33:56 -07003704 node->marker = marker;
3705 node->next = list;
3706
3707 return node;
3708}
3709
3710active_list_t *
3711_active_list_pop (active_list_t *list)
3712{
3713 active_list_t *node = list;
3714
3715 if (node == NULL)
3716 return NULL;
3717
3718 node = list->next;
3719 talloc_free (list);
3720
3721 return node;
3722}
3723
3724int
3725_active_list_contains (active_list_t *list, const char *identifier)
3726{
3727 active_list_t *node;
3728
3729 if (list == NULL)
3730 return 0;
3731
3732 for (node = list; node; node = node->next)
3733 if (strcmp (node->identifier, identifier) == 0)
3734 return 1;
3735
3736 return 0;
3737}
3738
3739/* Walk over the token list replacing nodes with their expansion.
3740 * Whenever nodes are expanded the walking will walk over the new
3741 * nodes, continuing to expand as necessary. The results are placed in
3742 * 'list' itself;
3743 */
3744static void
3745_glcpp_parser_expand_token_list (glcpp_parser_t *parser,
3746 token_list_t *list)
3747{
3748 token_node_t *node_prev;
3749 token_node_t *node, *last = NULL;
3750 token_list_t *expansion;
3751
3752 if (list == NULL)
3753 return;
3754
3755 _token_list_trim_trailing_space (list);
3756
3757 node_prev = NULL;
3758 node = list->head;
3759
3760 while (node) {
3761
3762 while (parser->active && parser->active->marker == node)
3763 parser->active = _active_list_pop (parser->active);
3764
3765 /* Find the expansion for node, which will replace all
3766 * nodes from node to last, inclusive. */
3767 expansion = _glcpp_parser_expand_node (parser, node, &last);
3768 if (expansion) {
3769 token_node_t *n;
3770
3771 for (n = node; n != last->next; n = n->next)
3772 while (parser->active &&
3773 parser->active->marker == n)
3774 {
3775 parser->active = _active_list_pop (parser->active);
3776 }
3777
3778 parser->active = _active_list_push (parser->active,
3779 node->token->value.str,
3780 last->next);
3781
3782 /* Splice expansion into list, supporting a
3783 * simple deletion if the expansion is
3784 * empty. */
3785 if (expansion->head) {
3786 if (node_prev)
3787 node_prev->next = expansion->head;
3788 else
3789 list->head = expansion->head;
3790 expansion->tail->next = last->next;
3791 if (last == list->tail)
3792 list->tail = expansion->tail;
3793 } else {
3794 if (node_prev)
3795 node_prev->next = last->next;
3796 else
3797 list->head = last->next;
3798 if (last == list->tail)
3799 list->tail = NULL;
3800 }
3801 } else {
3802 node_prev = node;
3803 }
3804 node = node_prev ? node_prev->next : list->head;
3805 }
3806
3807 while (parser->active)
3808 parser->active = _active_list_pop (parser->active);
3809
3810 list->non_space_tail = list->tail;
3811}
3812
3813void
3814_glcpp_parser_print_expanded_token_list (glcpp_parser_t *parser,
3815 token_list_t *list)
3816{
3817 if (list == NULL)
3818 return;
3819
3820 _glcpp_parser_expand_token_list (parser, list);
3821
3822 _token_list_trim_trailing_space (list);
3823
3824 _token_list_print (parser, list);
3825}
3826
3827static void
3828_check_for_reserved_macro_name (glcpp_parser_t *parser, YYLTYPE *loc,
3829 const char *identifier)
3830{
3831 /* According to the GLSL specification, macro names starting with "__"
3832 * or "GL_" are reserved for future use. So, don't allow them.
3833 */
3834 if (strncmp(identifier, "__", 2) == 0) {
3835 glcpp_error (loc, parser, "Macro names starting with \"__\" are reserved.\n");
3836 }
3837 if (strncmp(identifier, "GL_", 3) == 0) {
3838 glcpp_error (loc, parser, "Macro names starting with \"GL_\" are reserved.\n");
3839 }
3840}
3841
3842void
3843_define_object_macro (glcpp_parser_t *parser,
3844 YYLTYPE *loc,
3845 const char *identifier,
3846 token_list_t *replacements)
3847{
3848 macro_t *macro;
3849
3850 if (loc != NULL)
3851 _check_for_reserved_macro_name(parser, loc, identifier);
3852
Kenneth Graunke0ef79a52010-08-03 20:25:13 -07003853 macro = talloc (parser, macro_t);
Carl Worth667173e2010-07-28 12:33:56 -07003854
3855 macro->is_function = 0;
3856 macro->parameters = NULL;
3857 macro->identifier = talloc_strdup (macro, identifier);
3858 macro->replacements = talloc_steal (macro, replacements);
3859
3860 hash_table_insert (parser->defines, macro, identifier);
3861}
3862
3863void
3864_define_function_macro (glcpp_parser_t *parser,
3865 YYLTYPE *loc,
3866 const char *identifier,
3867 string_list_t *parameters,
3868 token_list_t *replacements)
3869{
3870 macro_t *macro;
3871
3872 _check_for_reserved_macro_name(parser, loc, identifier);
3873
Kenneth Graunke0ef79a52010-08-03 20:25:13 -07003874 macro = talloc (parser, macro_t);
Carl Worth667173e2010-07-28 12:33:56 -07003875
3876 macro->is_function = 1;
3877 macro->parameters = talloc_steal (macro, parameters);
3878 macro->identifier = talloc_strdup (macro, identifier);
3879 macro->replacements = talloc_steal (macro, replacements);
3880
3881 hash_table_insert (parser->defines, macro, identifier);
3882}
3883
3884static int
3885glcpp_parser_lex (YYSTYPE *yylval, YYLTYPE *yylloc, glcpp_parser_t *parser)
3886{
3887 token_node_t *node;
3888 int ret;
3889
3890 if (parser->lex_from_list == NULL) {
3891 ret = glcpp_lex (yylval, yylloc, parser->scanner);
3892
3893 /* XXX: This ugly block of code exists for the sole
3894 * purpose of converting a NEWLINE token into a SPACE
3895 * token, but only in the case where we have seen a
3896 * function-like macro name, but have not yet seen its
3897 * closing parenthesis.
3898 *
3899 * There's perhaps a more compact way to do this with
3900 * mid-rule actions in the grammar.
3901 *
3902 * I'm definitely not pleased with the complexity of
3903 * this code here.
3904 */
3905 if (parser->newline_as_space)
3906 {
3907 if (ret == '(') {
3908 parser->paren_count++;
3909 } else if (ret == ')') {
3910 parser->paren_count--;
3911 if (parser->paren_count == 0)
3912 parser->newline_as_space = 0;
3913 } else if (ret == NEWLINE) {
3914 ret = SPACE;
3915 } else if (ret != SPACE) {
3916 if (parser->paren_count == 0)
3917 parser->newline_as_space = 0;
3918 }
3919 }
3920 else if (parser->in_control_line)
3921 {
3922 if (ret == NEWLINE)
3923 parser->in_control_line = 0;
3924 }
3925 else if (ret == HASH_DEFINE_OBJ || ret == HASH_DEFINE_FUNC ||
3926 ret == HASH_UNDEF || ret == HASH_IF ||
3927 ret == HASH_IFDEF || ret == HASH_IFNDEF ||
3928 ret == HASH_ELIF || ret == HASH_ELSE ||
3929 ret == HASH_ENDIF || ret == HASH)
3930 {
3931 parser->in_control_line = 1;
3932 }
3933 else if (ret == IDENTIFIER)
3934 {
3935 macro_t *macro;
3936 macro = hash_table_find (parser->defines,
3937 yylval->str);
3938 if (macro && macro->is_function) {
3939 parser->newline_as_space = 1;
3940 parser->paren_count = 0;
3941 }
3942 }
3943
3944 return ret;
3945 }
3946
3947 node = parser->lex_from_node;
3948
3949 if (node == NULL) {
3950 talloc_free (parser->lex_from_list);
3951 parser->lex_from_list = NULL;
3952 return NEWLINE;
3953 }
3954
3955 *yylval = node->token->value;
3956 ret = node->token->type;
3957
3958 parser->lex_from_node = node->next;
3959
3960 return ret;
3961}
3962
3963static void
3964glcpp_parser_lex_from (glcpp_parser_t *parser, token_list_t *list)
3965{
3966 token_node_t *node;
3967
3968 assert (parser->lex_from_list == NULL);
3969
3970 /* Copy list, eliminating any space tokens. */
3971 parser->lex_from_list = _token_list_create (parser);
3972
3973 for (node = list->head; node; node = node->next) {
3974 if (node->token->type == SPACE)
3975 continue;
3976 _token_list_append (parser->lex_from_list, node->token);
3977 }
3978
3979 talloc_free (list);
3980
3981 parser->lex_from_node = parser->lex_from_list->head;
3982
3983 /* It's possible the list consisted of nothing but whitespace. */
3984 if (parser->lex_from_node == NULL) {
3985 talloc_free (parser->lex_from_list);
3986 parser->lex_from_list = NULL;
3987 }
3988}
3989
3990static void
3991_glcpp_parser_skip_stack_push_if (glcpp_parser_t *parser, YYLTYPE *loc,
3992 int condition)
3993{
3994 skip_type_t current = SKIP_NO_SKIP;
3995 skip_node_t *node;
3996
3997 if (parser->skip_stack)
3998 current = parser->skip_stack->type;
3999
Kenneth Graunke0ef79a52010-08-03 20:25:13 -07004000 node = talloc (parser, skip_node_t);
Carl Worth667173e2010-07-28 12:33:56 -07004001 node->loc = *loc;
4002
4003 if (current == SKIP_NO_SKIP) {
4004 if (condition)
4005 node->type = SKIP_NO_SKIP;
4006 else
4007 node->type = SKIP_TO_ELSE;
4008 } else {
4009 node->type = SKIP_TO_ENDIF;
4010 }
4011
4012 node->next = parser->skip_stack;
4013 parser->skip_stack = node;
4014}
4015
4016static void
4017_glcpp_parser_skip_stack_change_if (glcpp_parser_t *parser, YYLTYPE *loc,
4018 const char *type, int condition)
4019{
4020 if (parser->skip_stack == NULL) {
4021 glcpp_error (loc, parser, "%s without #if\n", type);
4022 return;
4023 }
4024
4025 if (parser->skip_stack->type == SKIP_TO_ELSE) {
4026 if (condition)
4027 parser->skip_stack->type = SKIP_NO_SKIP;
4028 } else {
4029 parser->skip_stack->type = SKIP_TO_ENDIF;
4030 }
4031}
4032
4033static void
4034_glcpp_parser_skip_stack_pop (glcpp_parser_t *parser, YYLTYPE *loc)
4035{
4036 skip_node_t *node;
4037
4038 if (parser->skip_stack == NULL) {
4039 glcpp_error (loc, parser, "#endif without #if\n");
4040 return;
4041 }
4042
4043 node = parser->skip_stack;
4044 parser->skip_stack = node->next;
4045 talloc_free (node);
4046}
4047