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