blob: f0ad4a08ec771cf5641b2923304b94be2af6dffc [file] [log] [blame]
Carl Worth667173e2010-07-28 12:33:56 -07001
2/* A Bison parser, made by GNU Bison 2.4.1. */
3
4/* Skeleton implementation for Bison's Yacc-like parsers in C
5
6 Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
7 Free Software Foundation, Inc.
8
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. */
49#define YYBISON_VERSION "2.4.1"
50
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
180_glcpp_parser_expand_token_list (glcpp_parser_t *parser,
181 token_list_t *list);
182
183static void
184_glcpp_parser_print_expanded_token_list (glcpp_parser_t *parser,
185 token_list_t *list);
186
187static void
188_glcpp_parser_skip_stack_push_if (glcpp_parser_t *parser, YYLTYPE *loc,
189 int condition);
190
191static void
192_glcpp_parser_skip_stack_change_if (glcpp_parser_t *parser, YYLTYPE *loc,
193 const char *type, int condition);
194
195static void
196_glcpp_parser_skip_stack_pop (glcpp_parser_t *parser, YYLTYPE *loc);
197
198#define yylex glcpp_parser_lex
199
200static int
201glcpp_parser_lex (YYSTYPE *yylval, YYLTYPE *yylloc, glcpp_parser_t *parser);
202
203static void
204glcpp_parser_lex_from (glcpp_parser_t *parser, token_list_t *list);
205
Eric Anholtd4a04f32010-07-28 16:58:39 -0700206static void
207add_builtin_define(glcpp_parser_t *parser, const char *name, int value);
208
Carl Worth667173e2010-07-28 12:33:56 -0700209
210
211/* Line 189 of yacc.c */
Eric Anholtd4a04f32010-07-28 16:58:39 -0700212#line 213 "glcpp/glcpp-parse.c"
Carl Worth667173e2010-07-28 12:33:56 -0700213
214/* Enabling traces. */
215#ifndef YYDEBUG
216# define YYDEBUG 0
217#endif
218
219/* Enabling verbose error messages. */
220#ifdef YYERROR_VERBOSE
221# undef YYERROR_VERBOSE
222# define YYERROR_VERBOSE 1
223#else
224# define YYERROR_VERBOSE 1
225#endif
226
227/* Enabling the token table. */
228#ifndef YYTOKEN_TABLE
229# define YYTOKEN_TABLE 0
230#endif
231
232
233/* Tokens. */
234#ifndef YYTOKENTYPE
235# define YYTOKENTYPE
236 /* Put the tokens into the symbol table, so that GDB and other debuggers
237 know about them. */
238 enum yytokentype {
239 COMMA_FINAL = 258,
240 DEFINED = 259,
241 ELIF_EXPANDED = 260,
242 HASH = 261,
243 HASH_DEFINE_FUNC = 262,
244 HASH_DEFINE_OBJ = 263,
245 HASH_ELIF = 264,
246 HASH_ELSE = 265,
247 HASH_ENDIF = 266,
248 HASH_IF = 267,
249 HASH_IFDEF = 268,
250 HASH_IFNDEF = 269,
251 HASH_UNDEF = 270,
Eric Anholtd4a04f32010-07-28 16:58:39 -0700252 HASH_VERSION = 271,
253 IDENTIFIER = 272,
254 IF_EXPANDED = 273,
255 INTEGER = 274,
256 INTEGER_STRING = 275,
257 NEWLINE = 276,
258 OTHER = 277,
259 PLACEHOLDER = 278,
260 SPACE = 279,
261 PASTE = 280,
262 OR = 281,
263 AND = 282,
264 NOT_EQUAL = 283,
265 EQUAL = 284,
266 GREATER_OR_EQUAL = 285,
267 LESS_OR_EQUAL = 286,
268 RIGHT_SHIFT = 287,
269 LEFT_SHIFT = 288,
270 UNARY = 289
Carl Worth667173e2010-07-28 12:33:56 -0700271 };
272#endif
273
274
275
276#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
277
278# define yystype YYSTYPE /* obsolescent; will be withdrawn */
279# define YYSTYPE_IS_DECLARED 1
280#endif
281
282#if ! defined YYLTYPE && ! defined YYLTYPE_IS_DECLARED
283typedef struct YYLTYPE
284{
285 int first_line;
286 int first_column;
287 int last_line;
288 int last_column;
289} YYLTYPE;
290# define yyltype YYLTYPE /* obsolescent; will be withdrawn */
291# define YYLTYPE_IS_DECLARED 1
292# define YYLTYPE_IS_TRIVIAL 1
293#endif
294
295
296/* Copy the second part of user declarations. */
297
298
299/* Line 264 of yacc.c */
Eric Anholtd4a04f32010-07-28 16:58:39 -0700300#line 301 "glcpp/glcpp-parse.c"
Carl Worth667173e2010-07-28 12:33:56 -0700301
302#ifdef short
303# undef short
304#endif
305
306#ifdef YYTYPE_UINT8
307typedef YYTYPE_UINT8 yytype_uint8;
308#else
309typedef unsigned char yytype_uint8;
310#endif
311
312#ifdef YYTYPE_INT8
313typedef YYTYPE_INT8 yytype_int8;
314#elif (defined __STDC__ || defined __C99__FUNC__ \
315 || defined __cplusplus || defined _MSC_VER)
316typedef signed char yytype_int8;
317#else
318typedef short int yytype_int8;
319#endif
320
321#ifdef YYTYPE_UINT16
322typedef YYTYPE_UINT16 yytype_uint16;
323#else
324typedef unsigned short int yytype_uint16;
325#endif
326
327#ifdef YYTYPE_INT16
328typedef YYTYPE_INT16 yytype_int16;
329#else
330typedef short int yytype_int16;
331#endif
332
333#ifndef YYSIZE_T
334# ifdef __SIZE_TYPE__
335# define YYSIZE_T __SIZE_TYPE__
336# elif defined size_t
337# define YYSIZE_T size_t
338# elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \
339 || defined __cplusplus || defined _MSC_VER)
340# include <stddef.h> /* INFRINGES ON USER NAME SPACE */
341# define YYSIZE_T size_t
342# else
343# define YYSIZE_T unsigned int
344# endif
345#endif
346
347#define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
348
349#ifndef YY_
350# if YYENABLE_NLS
351# if ENABLE_NLS
352# include <libintl.h> /* INFRINGES ON USER NAME SPACE */
353# define YY_(msgid) dgettext ("bison-runtime", msgid)
354# endif
355# endif
356# ifndef YY_
357# define YY_(msgid) msgid
358# endif
359#endif
360
361/* Suppress unused-variable warnings by "using" E. */
362#if ! defined lint || defined __GNUC__
363# define YYUSE(e) ((void) (e))
364#else
365# define YYUSE(e) /* empty */
366#endif
367
368/* Identity function, used to suppress warnings about constant conditions. */
369#ifndef lint
370# define YYID(n) (n)
371#else
372#if (defined __STDC__ || defined __C99__FUNC__ \
373 || defined __cplusplus || defined _MSC_VER)
374static int
375YYID (int yyi)
376#else
377static int
378YYID (yyi)
379 int yyi;
380#endif
381{
382 return yyi;
383}
384#endif
385
386#if ! defined yyoverflow || YYERROR_VERBOSE
387
388/* The parser invokes alloca or malloc; define the necessary symbols. */
389
390# ifdef YYSTACK_USE_ALLOCA
391# if YYSTACK_USE_ALLOCA
392# ifdef __GNUC__
393# define YYSTACK_ALLOC __builtin_alloca
394# elif defined __BUILTIN_VA_ARG_INCR
395# include <alloca.h> /* INFRINGES ON USER NAME SPACE */
396# elif defined _AIX
397# define YYSTACK_ALLOC __alloca
398# elif defined _MSC_VER
399# include <malloc.h> /* INFRINGES ON USER NAME SPACE */
400# define alloca _alloca
401# else
402# define YYSTACK_ALLOC alloca
403# if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
404 || defined __cplusplus || defined _MSC_VER)
405# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
406# ifndef _STDLIB_H
407# define _STDLIB_H 1
408# endif
409# endif
410# endif
411# endif
412# endif
413
414# ifdef YYSTACK_ALLOC
415 /* Pacify GCC's `empty if-body' warning. */
416# define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0))
417# ifndef YYSTACK_ALLOC_MAXIMUM
418 /* The OS might guarantee only one guard page at the bottom of the stack,
419 and a page size can be as small as 4096 bytes. So we cannot safely
420 invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
421 to allow for a few compiler-allocated temporary stack slots. */
422# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
423# endif
424# else
425# define YYSTACK_ALLOC YYMALLOC
426# define YYSTACK_FREE YYFREE
427# ifndef YYSTACK_ALLOC_MAXIMUM
428# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
429# endif
430# if (defined __cplusplus && ! defined _STDLIB_H \
431 && ! ((defined YYMALLOC || defined malloc) \
432 && (defined YYFREE || defined free)))
433# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
434# ifndef _STDLIB_H
435# define _STDLIB_H 1
436# endif
437# endif
438# ifndef YYMALLOC
439# define YYMALLOC malloc
440# if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
441 || defined __cplusplus || defined _MSC_VER)
442void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
443# endif
444# endif
445# ifndef YYFREE
446# define YYFREE free
447# if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
448 || defined __cplusplus || defined _MSC_VER)
449void free (void *); /* INFRINGES ON USER NAME SPACE */
450# endif
451# endif
452# endif
453#endif /* ! defined yyoverflow || YYERROR_VERBOSE */
454
455
456#if (! defined yyoverflow \
457 && (! defined __cplusplus \
458 || (defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL \
459 && defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
460
461/* A type that is properly aligned for any stack member. */
462union yyalloc
463{
464 yytype_int16 yyss_alloc;
465 YYSTYPE yyvs_alloc;
466 YYLTYPE yyls_alloc;
467};
468
469/* The size of the maximum gap between one aligned stack and the next. */
470# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
471
472/* The size of an array large to enough to hold all stacks, each with
473 N elements. */
474# define YYSTACK_BYTES(N) \
475 ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE) + sizeof (YYLTYPE)) \
476 + 2 * YYSTACK_GAP_MAXIMUM)
477
478/* Copy COUNT objects from FROM to TO. The source and destination do
479 not overlap. */
480# ifndef YYCOPY
481# if defined __GNUC__ && 1 < __GNUC__
482# define YYCOPY(To, From, Count) \
483 __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
484# else
485# define YYCOPY(To, From, Count) \
486 do \
487 { \
488 YYSIZE_T yyi; \
489 for (yyi = 0; yyi < (Count); yyi++) \
490 (To)[yyi] = (From)[yyi]; \
491 } \
492 while (YYID (0))
493# endif
494# endif
495
496/* Relocate STACK from its old location to the new one. The
497 local variables YYSIZE and YYSTACKSIZE give the old and new number of
498 elements in the stack, and YYPTR gives the new location of the
499 stack. Advance YYPTR to a properly aligned location for the next
500 stack. */
501# define YYSTACK_RELOCATE(Stack_alloc, Stack) \
502 do \
503 { \
504 YYSIZE_T yynewbytes; \
505 YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \
506 Stack = &yyptr->Stack_alloc; \
507 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
508 yyptr += yynewbytes / sizeof (*yyptr); \
509 } \
510 while (YYID (0))
511
512#endif
513
514/* YYFINAL -- State number of the termination state. */
515#define YYFINAL 2
516/* YYLAST -- Last index in YYTABLE. */
Eric Anholtd4a04f32010-07-28 16:58:39 -0700517#define YYLAST 604
Carl Worth667173e2010-07-28 12:33:56 -0700518
519/* YYNTOKENS -- Number of terminals. */
Eric Anholtd4a04f32010-07-28 16:58:39 -0700520#define YYNTOKENS 57
Carl Worth667173e2010-07-28 12:33:56 -0700521/* YYNNTS -- Number of nonterminals. */
Eric Anholtd4a04f32010-07-28 16:58:39 -0700522#define YYNNTS 17
Carl Worth667173e2010-07-28 12:33:56 -0700523/* YYNRULES -- Number of rules. */
Eric Anholtd4a04f32010-07-28 16:58:39 -0700524#define YYNRULES 100
Carl Worth667173e2010-07-28 12:33:56 -0700525/* YYNRULES -- Number of states. */
Eric Anholtd4a04f32010-07-28 16:58:39 -0700526#define YYNSTATES 161
Carl Worth667173e2010-07-28 12:33:56 -0700527
528/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
529#define YYUNDEFTOK 2
Eric Anholtd4a04f32010-07-28 16:58:39 -0700530#define YYMAXUTOK 289
Carl Worth667173e2010-07-28 12:33:56 -0700531
532#define YYTRANSLATE(YYX) \
533 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
534
535/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
536static const yytype_uint8 yytranslate[] =
537{
538 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
539 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
540 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
Eric Anholtd4a04f32010-07-28 16:58:39 -0700541 2, 2, 2, 47, 2, 2, 2, 43, 30, 2,
542 45, 46, 41, 39, 49, 40, 54, 42, 2, 2,
543 2, 2, 2, 2, 2, 2, 2, 2, 2, 55,
544 33, 56, 34, 2, 2, 2, 2, 2, 2, 2,
Carl Worth667173e2010-07-28 12:33:56 -0700545 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
546 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
Eric Anholtd4a04f32010-07-28 16:58:39 -0700547 2, 50, 2, 51, 29, 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, 2, 2, 52, 28, 53, 48, 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,
553 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
554 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
555 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
556 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
557 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
558 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
559 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
560 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
561 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
562 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
563 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
564 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
565 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
Eric Anholtd4a04f32010-07-28 16:58:39 -0700566 25, 26, 27, 31, 32, 35, 36, 37, 38, 44
Carl Worth667173e2010-07-28 12:33:56 -0700567};
568
569#if YYDEBUG
570/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
571 YYRHS. */
572static const yytype_uint16 yyprhs[] =
573{
574 0, 0, 3, 4, 7, 9, 11, 13, 16, 20,
575 24, 29, 36, 44, 48, 52, 57, 62, 66, 69,
Eric Anholtd4a04f32010-07-28 16:58:39 -0700576 72, 75, 79, 82, 84, 86, 88, 92, 96, 100,
577 104, 108, 112, 116, 120, 124, 128, 132, 136, 140,
578 144, 148, 152, 156, 160, 163, 166, 169, 172, 176,
579 178, 182, 184, 187, 190, 191, 193, 194, 196, 199,
580 204, 206, 208, 211, 213, 216, 218, 220, 222, 224,
581 226, 228, 230, 232, 234, 236, 238, 240, 242, 244,
582 246, 248, 250, 252, 254, 256, 258, 260, 262, 264,
583 266, 268, 270, 272, 274, 276, 278, 280, 282, 284,
584 286
Carl Worth667173e2010-07-28 12:33:56 -0700585};
586
587/* YYRHS -- A `-1'-separated list of the rules' RHS. */
588static const yytype_int8 yyrhs[] =
589{
Eric Anholtd4a04f32010-07-28 16:58:39 -0700590 58, 0, -1, -1, 58, 59, -1, 61, -1, 65,
591 -1, 60, -1, 6, 66, -1, 18, 63, 21, -1,
592 5, 63, 21, -1, 8, 17, 67, 21, -1, 7,
593 17, 45, 46, 67, 21, -1, 7, 17, 45, 64,
594 46, 67, 21, -1, 15, 17, 21, -1, 12, 70,
595 21, -1, 13, 17, 68, 21, -1, 14, 17, 68,
596 21, -1, 9, 70, 21, -1, 9, 21, -1, 10,
597 21, -1, 11, 21, -1, 16, 62, 21, -1, 6,
598 21, -1, 20, -1, 19, -1, 62, -1, 63, 26,
599 63, -1, 63, 27, 63, -1, 63, 28, 63, -1,
600 63, 29, 63, -1, 63, 30, 63, -1, 63, 31,
601 63, -1, 63, 32, 63, -1, 63, 35, 63, -1,
602 63, 36, 63, -1, 63, 34, 63, -1, 63, 33,
603 63, -1, 63, 37, 63, -1, 63, 38, 63, -1,
604 63, 40, 63, -1, 63, 39, 63, -1, 63, 43,
605 63, -1, 63, 42, 63, -1, 63, 41, 63, -1,
606 47, 63, -1, 48, 63, -1, 40, 63, -1, 39,
607 63, -1, 45, 63, 46, -1, 17, -1, 64, 49,
608 17, -1, 21, -1, 71, 21, -1, 71, 21, -1,
609 -1, 71, -1, -1, 71, -1, 4, 17, -1, 4,
610 45, 17, 46, -1, 72, -1, 69, -1, 70, 69,
611 -1, 72, -1, 71, 72, -1, 17, -1, 20, -1,
612 73, -1, 22, -1, 24, -1, 50, -1, 51, -1,
613 45, -1, 46, -1, 52, -1, 53, -1, 54, -1,
614 30, -1, 41, -1, 39, -1, 40, -1, 48, -1,
615 47, -1, 42, -1, 43, -1, 38, -1, 37, -1,
616 33, -1, 34, -1, 36, -1, 35, -1, 32, -1,
617 31, -1, 29, -1, 28, -1, 27, -1, 26, -1,
618 55, -1, 49, -1, 56, -1, 25, -1
Carl Worth667173e2010-07-28 12:33:56 -0700619};
620
621/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
622static const yytype_uint16 yyrline[] =
623{
Eric Anholtd4a04f32010-07-28 16:58:39 -0700624 0, 169, 169, 171, 175, 178, 183, 184, 188, 191,
625 197, 200, 203, 206, 214, 226, 231, 236, 248, 259,
626 262, 265, 274, 278, 287, 292, 293, 296, 299, 302,
627 305, 308, 311, 314, 317, 320, 323, 326, 329, 332,
628 335, 338, 341, 344, 347, 350, 353, 356, 359, 365,
629 370, 378, 379, 383, 389, 390, 393, 395, 402, 406,
630 410, 415, 421, 429, 435, 443, 447, 451, 455, 459,
631 466, 467, 468, 469, 470, 471, 472, 473, 474, 475,
632 476, 477, 478, 479, 480, 481, 482, 483, 484, 485,
633 486, 487, 488, 489, 490, 491, 492, 493, 494, 495,
634 496
Carl Worth667173e2010-07-28 12:33:56 -0700635};
636#endif
637
638#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
639/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
640 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
641static const char *const yytname[] =
642{
643 "$end", "error", "$undefined", "COMMA_FINAL", "DEFINED",
644 "ELIF_EXPANDED", "HASH", "HASH_DEFINE_FUNC", "HASH_DEFINE_OBJ",
645 "HASH_ELIF", "HASH_ELSE", "HASH_ENDIF", "HASH_IF", "HASH_IFDEF",
Eric Anholtd4a04f32010-07-28 16:58:39 -0700646 "HASH_IFNDEF", "HASH_UNDEF", "HASH_VERSION", "IDENTIFIER", "IF_EXPANDED",
647 "INTEGER", "INTEGER_STRING", "NEWLINE", "OTHER", "PLACEHOLDER", "SPACE",
648 "PASTE", "OR", "AND", "'|'", "'^'", "'&'", "NOT_EQUAL", "EQUAL", "'<'",
649 "'>'", "GREATER_OR_EQUAL", "LESS_OR_EQUAL", "RIGHT_SHIFT", "LEFT_SHIFT",
650 "'+'", "'-'", "'*'", "'/'", "'%'", "UNARY", "'('", "')'", "'!'", "'~'",
651 "','", "'['", "']'", "'{'", "'}'", "'.'", "';'", "'='", "$accept",
652 "input", "line", "expanded_line", "control_line", "integer_constant",
653 "expression", "identifier_list", "text_line", "non_directive",
654 "replacement_list", "junk", "conditional_token", "conditional_tokens",
655 "pp_tokens", "preprocessing_token", "operator", 0
Carl Worth667173e2010-07-28 12:33:56 -0700656};
657#endif
658
659# ifdef YYPRINT
660/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
661 token YYLEX-NUM. */
662static const yytype_uint16 yytoknum[] =
663{
664 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
665 265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
Eric Anholtd4a04f32010-07-28 16:58:39 -0700666 275, 276, 277, 278, 279, 280, 281, 282, 124, 94,
667 38, 283, 284, 60, 62, 285, 286, 287, 288, 43,
668 45, 42, 47, 37, 289, 40, 41, 33, 126, 44,
669 91, 93, 123, 125, 46, 59, 61
Carl Worth667173e2010-07-28 12:33:56 -0700670};
671# endif
672
673/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
674static const yytype_uint8 yyr1[] =
675{
Eric Anholtd4a04f32010-07-28 16:58:39 -0700676 0, 57, 58, 58, 59, 59, 59, 59, 60, 60,
Carl Worth667173e2010-07-28 12:33:56 -0700677 61, 61, 61, 61, 61, 61, 61, 61, 61, 61,
Eric Anholtd4a04f32010-07-28 16:58:39 -0700678 61, 61, 61, 62, 62, 63, 63, 63, 63, 63,
679 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
680 63, 63, 63, 63, 63, 63, 63, 63, 63, 64,
681 64, 65, 65, 66, 67, 67, 68, 68, 69, 69,
682 69, 70, 70, 71, 71, 72, 72, 72, 72, 72,
683 73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
684 73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
685 73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
686 73
Carl Worth667173e2010-07-28 12:33:56 -0700687};
688
689/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
690static const yytype_uint8 yyr2[] =
691{
692 0, 2, 0, 2, 1, 1, 1, 2, 3, 3,
693 4, 6, 7, 3, 3, 4, 4, 3, 2, 2,
Eric Anholtd4a04f32010-07-28 16:58:39 -0700694 2, 3, 2, 1, 1, 1, 3, 3, 3, 3,
Carl Worth667173e2010-07-28 12:33:56 -0700695 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
Eric Anholtd4a04f32010-07-28 16:58:39 -0700696 3, 3, 3, 3, 2, 2, 2, 2, 3, 1,
697 3, 1, 2, 2, 0, 1, 0, 1, 2, 4,
698 1, 1, 2, 1, 2, 1, 1, 1, 1, 1,
Carl Worth667173e2010-07-28 12:33:56 -0700699 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
700 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
Eric Anholtd4a04f32010-07-28 16:58:39 -0700701 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
702 1
Carl Worth667173e2010-07-28 12:33:56 -0700703};
704
705/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
706 STATE-NUM when YYTABLE doesn't specify something else to do. Zero
707 means the default is an error. */
708static const yytype_uint8 yydefact[] =
709{
710 2, 0, 1, 0, 0, 0, 0, 0, 0, 0,
Eric Anholtd4a04f32010-07-28 16:58:39 -0700711 0, 0, 0, 0, 0, 65, 0, 66, 51, 68,
712 69, 100, 96, 95, 94, 93, 77, 92, 91, 87,
713 88, 90, 89, 86, 85, 79, 80, 78, 83, 84,
714 72, 73, 82, 81, 98, 70, 71, 74, 75, 76,
715 97, 99, 3, 6, 4, 5, 0, 63, 67, 24,
716 23, 0, 0, 0, 0, 0, 25, 0, 22, 7,
717 0, 0, 54, 0, 18, 61, 0, 60, 19, 20,
718 0, 56, 56, 0, 0, 0, 52, 64, 47, 46,
719 0, 44, 45, 9, 0, 0, 0, 0, 0, 0,
720 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
721 0, 0, 53, 0, 0, 55, 58, 0, 17, 62,
722 14, 0, 57, 0, 13, 21, 8, 48, 26, 27,
723 28, 29, 30, 31, 32, 36, 35, 33, 34, 37,
724 38, 40, 39, 43, 42, 41, 49, 54, 0, 10,
725 0, 15, 16, 0, 54, 0, 59, 11, 0, 50,
726 12
Carl Worth667173e2010-07-28 12:33:56 -0700727};
728
729/* YYDEFGOTO[NTERM-NUM]. */
730static const yytype_int16 yydefgoto[] =
731{
Eric Anholtd4a04f32010-07-28 16:58:39 -0700732 -1, 1, 52, 53, 54, 66, 67, 148, 55, 69,
733 114, 121, 75, 76, 115, 57, 58
Carl Worth667173e2010-07-28 12:33:56 -0700734};
735
736/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
737 STATE-NUM. */
Eric Anholtd4a04f32010-07-28 16:58:39 -0700738#define YYPACT_NINF -146
Carl Worth667173e2010-07-28 12:33:56 -0700739static const yytype_int16 yypact[] =
740{
Eric Anholtd4a04f32010-07-28 16:58:39 -0700741 -146, 111, -146, 429, -10, -9, -4, 151, -15, 27,
742 271, 54, 63, 86, 82, -146, 429, -146, -146, -146,
743 -146, -146, -146, -146, -146, -146, -146, -146, -146, -146,
744 -146, -146, -146, -146, -146, -146, -146, -146, -146, -146,
745 -146, -146, -146, -146, -146, -146, -146, -146, -146, -146,
746 -146, -146, -146, -146, -146, -146, 311, -146, -146, -146,
747 -146, 429, 429, 429, 429, 429, -146, 452, -146, -146,
748 351, 59, 391, 17, -146, -146, 191, -146, -146, -146,
749 231, 391, 391, 84, 85, 475, -146, -146, -146, -146,
750 424, -146, -146, -146, 429, 429, 429, 429, 429, 429,
751 429, 429, 429, 429, 429, 429, 429, 429, 429, 429,
752 429, 429, -146, 30, 88, 391, -146, 90, -146, -146,
753 -146, 89, 391, 91, -146, -146, -146, -146, 492, 508,
754 523, 537, 550, 561, 561, 18, 18, 18, 18, 25,
755 25, 36, 36, -146, -146, -146, -146, 391, 26, -146,
756 67, -146, -146, 93, 391, 113, -146, -146, 148, -146,
757 -146
Carl Worth667173e2010-07-28 12:33:56 -0700758};
759
760/* YYPGOTO[NTERM-NUM]. */
Eric Anholtd4a04f32010-07-28 16:58:39 -0700761static const yytype_int16 yypgoto[] =
Carl Worth667173e2010-07-28 12:33:56 -0700762{
Eric Anholtd4a04f32010-07-28 16:58:39 -0700763 -146, -146, -146, -146, -146, 120, -11, -146, -146, -146,
764 -145, 92, -6, 160, 0, -7, -146
Carl Worth667173e2010-07-28 12:33:56 -0700765};
766
767/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
768 positive, shift that token. If negative, reduce the rule which
769 number is the opposite. If zero, do what YYDEFACT says.
770 If YYTABLE_NINF, syntax error. */
771#define YYTABLE_NINF -1
772static const yytype_uint8 yytable[] =
773{
Eric Anholtd4a04f32010-07-28 16:58:39 -0700774 77, 56, 153, 77, 70, 85, 78, 15, 71, 158,
775 17, 68, 19, 72, 20, 21, 22, 23, 24, 25,
Carl Worth667173e2010-07-28 12:33:56 -0700776 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
Eric Anholtd4a04f32010-07-28 16:58:39 -0700777 36, 37, 38, 39, 116, 40, 41, 42, 43, 44,
778 45, 46, 47, 48, 49, 50, 51, 146, 79, 87,
779 88, 89, 90, 91, 92, 105, 106, 107, 108, 109,
780 110, 111, 117, 87, 107, 108, 109, 110, 111, 77,
781 119, 81, 154, 77, 119, 155, 147, 109, 110, 111,
782 82, 122, 122, 128, 129, 130, 131, 132, 133, 134,
783 135, 136, 137, 138, 139, 140, 141, 142, 143, 144,
784 145, 59, 60, 83, 113, 124, 125, 150, 87, 149,
785 151, 2, 152, 156, 157, 87, 3, 4, 5, 6,
786 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
787 159, 17, 18, 19, 84, 20, 21, 22, 23, 24,
788 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
789 35, 36, 37, 38, 39, 73, 40, 41, 42, 43,
790 44, 45, 46, 47, 48, 49, 50, 51, 15, 160,
791 80, 17, 74, 19, 123, 20, 21, 22, 23, 24,
792 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
793 35, 36, 37, 38, 39, 73, 40, 41, 42, 43,
794 44, 45, 46, 47, 48, 49, 50, 51, 15, 0,
795 0, 17, 118, 19, 0, 20, 21, 22, 23, 24,
796 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
797 35, 36, 37, 38, 39, 73, 40, 41, 42, 43,
798 44, 45, 46, 47, 48, 49, 50, 51, 15, 0,
799 0, 17, 120, 19, 0, 20, 21, 22, 23, 24,
800 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
801 35, 36, 37, 38, 39, 73, 40, 41, 42, 43,
802 44, 45, 46, 47, 48, 49, 50, 51, 15, 0,
803 0, 17, 0, 19, 0, 20, 21, 22, 23, 24,
804 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
805 35, 36, 37, 38, 39, 0, 40, 41, 42, 43,
806 44, 45, 46, 47, 48, 49, 50, 51, 15, 0,
807 0, 17, 86, 19, 0, 20, 21, 22, 23, 24,
808 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
809 35, 36, 37, 38, 39, 0, 40, 41, 42, 43,
810 44, 45, 46, 47, 48, 49, 50, 51, 15, 0,
811 0, 17, 112, 19, 0, 20, 21, 22, 23, 24,
812 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
813 35, 36, 37, 38, 39, 0, 40, 41, 42, 43,
814 44, 45, 46, 47, 48, 49, 50, 51, 15, 0,
815 0, 17, 0, 19, 0, 20, 21, 22, 23, 24,
816 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
817 35, 36, 37, 38, 39, 0, 40, 41, 42, 43,
818 44, 45, 46, 47, 48, 49, 50, 51, 59, 60,
Carl Worth667173e2010-07-28 12:33:56 -0700819 94, 95, 96, 97, 98, 99, 100, 101, 102, 103,
Eric Anholtd4a04f32010-07-28 16:58:39 -0700820 104, 105, 106, 107, 108, 109, 110, 111, 61, 62,
821 127, 0, 0, 93, 63, 0, 64, 65, 94, 95,
822 96, 97, 98, 99, 100, 101, 102, 103, 104, 105,
823 106, 107, 108, 109, 110, 111, 126, 0, 0, 0,
824 0, 94, 95, 96, 97, 98, 99, 100, 101, 102,
825 103, 104, 105, 106, 107, 108, 109, 110, 111, 95,
826 96, 97, 98, 99, 100, 101, 102, 103, 104, 105,
827 106, 107, 108, 109, 110, 111, 96, 97, 98, 99,
828 100, 101, 102, 103, 104, 105, 106, 107, 108, 109,
829 110, 111, 97, 98, 99, 100, 101, 102, 103, 104,
830 105, 106, 107, 108, 109, 110, 111, 98, 99, 100,
831 101, 102, 103, 104, 105, 106, 107, 108, 109, 110,
832 111, 99, 100, 101, 102, 103, 104, 105, 106, 107,
833 108, 109, 110, 111, 101, 102, 103, 104, 105, 106,
834 107, 108, 109, 110, 111
Carl Worth667173e2010-07-28 12:33:56 -0700835};
836
837static const yytype_int16 yycheck[] =
838{
Eric Anholtd4a04f32010-07-28 16:58:39 -0700839 7, 1, 147, 10, 4, 16, 21, 17, 17, 154,
840 20, 21, 22, 17, 24, 25, 26, 27, 28, 29,
Carl Worth667173e2010-07-28 12:33:56 -0700841 30, 31, 32, 33, 34, 35, 36, 37, 38, 39,
Eric Anholtd4a04f32010-07-28 16:58:39 -0700842 40, 41, 42, 43, 17, 45, 46, 47, 48, 49,
843 50, 51, 52, 53, 54, 55, 56, 17, 21, 56,
844 61, 62, 63, 64, 65, 37, 38, 39, 40, 41,
845 42, 43, 45, 70, 39, 40, 41, 42, 43, 76,
846 76, 17, 46, 80, 80, 49, 46, 41, 42, 43,
847 17, 81, 82, 94, 95, 96, 97, 98, 99, 100,
848 101, 102, 103, 104, 105, 106, 107, 108, 109, 110,
849 111, 19, 20, 17, 45, 21, 21, 17, 115, 21,
850 21, 0, 21, 46, 21, 122, 5, 6, 7, 8,
851 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
852 17, 20, 21, 22, 14, 24, 25, 26, 27, 28,
853 29, 30, 31, 32, 33, 34, 35, 36, 37, 38,
854 39, 40, 41, 42, 43, 4, 45, 46, 47, 48,
855 49, 50, 51, 52, 53, 54, 55, 56, 17, 21,
856 10, 20, 21, 22, 82, 24, 25, 26, 27, 28,
857 29, 30, 31, 32, 33, 34, 35, 36, 37, 38,
858 39, 40, 41, 42, 43, 4, 45, 46, 47, 48,
859 49, 50, 51, 52, 53, 54, 55, 56, 17, -1,
860 -1, 20, 21, 22, -1, 24, 25, 26, 27, 28,
861 29, 30, 31, 32, 33, 34, 35, 36, 37, 38,
862 39, 40, 41, 42, 43, 4, 45, 46, 47, 48,
863 49, 50, 51, 52, 53, 54, 55, 56, 17, -1,
864 -1, 20, 21, 22, -1, 24, 25, 26, 27, 28,
865 29, 30, 31, 32, 33, 34, 35, 36, 37, 38,
866 39, 40, 41, 42, 43, 4, 45, 46, 47, 48,
867 49, 50, 51, 52, 53, 54, 55, 56, 17, -1,
868 -1, 20, -1, 22, -1, 24, 25, 26, 27, 28,
869 29, 30, 31, 32, 33, 34, 35, 36, 37, 38,
870 39, 40, 41, 42, 43, -1, 45, 46, 47, 48,
871 49, 50, 51, 52, 53, 54, 55, 56, 17, -1,
872 -1, 20, 21, 22, -1, 24, 25, 26, 27, 28,
873 29, 30, 31, 32, 33, 34, 35, 36, 37, 38,
874 39, 40, 41, 42, 43, -1, 45, 46, 47, 48,
875 49, 50, 51, 52, 53, 54, 55, 56, 17, -1,
876 -1, 20, 21, 22, -1, 24, 25, 26, 27, 28,
877 29, 30, 31, 32, 33, 34, 35, 36, 37, 38,
878 39, 40, 41, 42, 43, -1, 45, 46, 47, 48,
879 49, 50, 51, 52, 53, 54, 55, 56, 17, -1,
880 -1, 20, -1, 22, -1, 24, 25, 26, 27, 28,
881 29, 30, 31, 32, 33, 34, 35, 36, 37, 38,
882 39, 40, 41, 42, 43, -1, 45, 46, 47, 48,
883 49, 50, 51, 52, 53, 54, 55, 56, 19, 20,
Carl Worth667173e2010-07-28 12:33:56 -0700884 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
Eric Anholtd4a04f32010-07-28 16:58:39 -0700885 36, 37, 38, 39, 40, 41, 42, 43, 39, 40,
886 46, -1, -1, 21, 45, -1, 47, 48, 26, 27,
Carl Worth667173e2010-07-28 12:33:56 -0700887 28, 29, 30, 31, 32, 33, 34, 35, 36, 37,
Eric Anholtd4a04f32010-07-28 16:58:39 -0700888 38, 39, 40, 41, 42, 43, 21, -1, -1, -1,
889 -1, 26, 27, 28, 29, 30, 31, 32, 33, 34,
890 35, 36, 37, 38, 39, 40, 41, 42, 43, 27,
891 28, 29, 30, 31, 32, 33, 34, 35, 36, 37,
892 38, 39, 40, 41, 42, 43, 28, 29, 30, 31,
Carl Worth667173e2010-07-28 12:33:56 -0700893 32, 33, 34, 35, 36, 37, 38, 39, 40, 41,
Eric Anholtd4a04f32010-07-28 16:58:39 -0700894 42, 43, 29, 30, 31, 32, 33, 34, 35, 36,
895 37, 38, 39, 40, 41, 42, 43, 30, 31, 32,
896 33, 34, 35, 36, 37, 38, 39, 40, 41, 42,
897 43, 31, 32, 33, 34, 35, 36, 37, 38, 39,
898 40, 41, 42, 43, 33, 34, 35, 36, 37, 38,
899 39, 40, 41, 42, 43
Carl Worth667173e2010-07-28 12:33:56 -0700900};
901
902/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
903 symbol of state STATE-NUM. */
904static const yytype_uint8 yystos[] =
905{
Eric Anholtd4a04f32010-07-28 16:58:39 -0700906 0, 58, 0, 5, 6, 7, 8, 9, 10, 11,
907 12, 13, 14, 15, 16, 17, 18, 20, 21, 22,
Carl Worth667173e2010-07-28 12:33:56 -0700908 24, 25, 26, 27, 28, 29, 30, 31, 32, 33,
Eric Anholtd4a04f32010-07-28 16:58:39 -0700909 34, 35, 36, 37, 38, 39, 40, 41, 42, 43,
Carl Worth667173e2010-07-28 12:33:56 -0700910 45, 46, 47, 48, 49, 50, 51, 52, 53, 54,
Eric Anholtd4a04f32010-07-28 16:58:39 -0700911 55, 56, 59, 60, 61, 65, 71, 72, 73, 19,
912 20, 39, 40, 45, 47, 48, 62, 63, 21, 66,
913 71, 17, 17, 4, 21, 69, 70, 72, 21, 21,
914 70, 17, 17, 17, 62, 63, 21, 72, 63, 63,
915 63, 63, 63, 21, 26, 27, 28, 29, 30, 31,
916 32, 33, 34, 35, 36, 37, 38, 39, 40, 41,
917 42, 43, 21, 45, 67, 71, 17, 45, 21, 69,
918 21, 68, 71, 68, 21, 21, 21, 46, 63, 63,
919 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
920 63, 63, 63, 63, 63, 63, 17, 46, 64, 21,
921 17, 21, 21, 67, 46, 49, 46, 21, 67, 17,
922 21
Carl Worth667173e2010-07-28 12:33:56 -0700923};
924
925#define yyerrok (yyerrstatus = 0)
926#define yyclearin (yychar = YYEMPTY)
927#define YYEMPTY (-2)
928#define YYEOF 0
929
930#define YYACCEPT goto yyacceptlab
931#define YYABORT goto yyabortlab
932#define YYERROR goto yyerrorlab
933
934
935/* Like YYERROR except do call yyerror. This remains here temporarily
936 to ease the transition to the new meaning of YYERROR, for GCC.
937 Once GCC version 2 has supplanted version 1, this can go. */
938
939#define YYFAIL goto yyerrlab
940
941#define YYRECOVERING() (!!yyerrstatus)
942
943#define YYBACKUP(Token, Value) \
944do \
945 if (yychar == YYEMPTY && yylen == 1) \
946 { \
947 yychar = (Token); \
948 yylval = (Value); \
949 yytoken = YYTRANSLATE (yychar); \
950 YYPOPSTACK (1); \
951 goto yybackup; \
952 } \
953 else \
954 { \
955 yyerror (&yylloc, parser, YY_("syntax error: cannot back up")); \
956 YYERROR; \
957 } \
958while (YYID (0))
959
960
961#define YYTERROR 1
962#define YYERRCODE 256
963
964
965/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
966 If N is 0, then set CURRENT to the empty location which ends
967 the previous symbol: RHS[0] (always defined). */
968
969#define YYRHSLOC(Rhs, K) ((Rhs)[K])
970#ifndef YYLLOC_DEFAULT
971# define YYLLOC_DEFAULT(Current, Rhs, N) \
972 do \
973 if (YYID (N)) \
974 { \
975 (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
976 (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
977 (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
978 (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
979 } \
980 else \
981 { \
982 (Current).first_line = (Current).last_line = \
983 YYRHSLOC (Rhs, 0).last_line; \
984 (Current).first_column = (Current).last_column = \
985 YYRHSLOC (Rhs, 0).last_column; \
986 } \
987 while (YYID (0))
988#endif
989
990
991/* YY_LOCATION_PRINT -- Print the location on the stream.
992 This macro was not mandated originally: define only if we know
993 we won't break user code: when these are the locations we know. */
994
995#ifndef YY_LOCATION_PRINT
996# if YYLTYPE_IS_TRIVIAL
997# define YY_LOCATION_PRINT(File, Loc) \
998 fprintf (File, "%d.%d-%d.%d", \
999 (Loc).first_line, (Loc).first_column, \
1000 (Loc).last_line, (Loc).last_column)
1001# else
1002# define YY_LOCATION_PRINT(File, Loc) ((void) 0)
1003# endif
1004#endif
1005
1006
1007/* YYLEX -- calling `yylex' with the right arguments. */
1008
1009#ifdef YYLEX_PARAM
1010# define YYLEX yylex (&yylval, &yylloc, YYLEX_PARAM)
1011#else
1012# define YYLEX yylex (&yylval, &yylloc, parser)
1013#endif
1014
1015/* Enable debugging if requested. */
1016#if YYDEBUG
1017
1018# ifndef YYFPRINTF
1019# include <stdio.h> /* INFRINGES ON USER NAME SPACE */
1020# define YYFPRINTF fprintf
1021# endif
1022
1023# define YYDPRINTF(Args) \
1024do { \
1025 if (yydebug) \
1026 YYFPRINTF Args; \
1027} while (YYID (0))
1028
1029# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
1030do { \
1031 if (yydebug) \
1032 { \
1033 YYFPRINTF (stderr, "%s ", Title); \
1034 yy_symbol_print (stderr, \
1035 Type, Value, Location, parser); \
1036 YYFPRINTF (stderr, "\n"); \
1037 } \
1038} while (YYID (0))
1039
1040
1041/*--------------------------------.
1042| Print this symbol on YYOUTPUT. |
1043`--------------------------------*/
1044
1045/*ARGSUSED*/
1046#if (defined __STDC__ || defined __C99__FUNC__ \
1047 || defined __cplusplus || defined _MSC_VER)
1048static void
1049yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, YYLTYPE const * const yylocationp, glcpp_parser_t *parser)
1050#else
1051static void
1052yy_symbol_value_print (yyoutput, yytype, yyvaluep, yylocationp, parser)
1053 FILE *yyoutput;
1054 int yytype;
1055 YYSTYPE const * const yyvaluep;
1056 YYLTYPE const * const yylocationp;
1057 glcpp_parser_t *parser;
1058#endif
1059{
1060 if (!yyvaluep)
1061 return;
1062 YYUSE (yylocationp);
1063 YYUSE (parser);
1064# ifdef YYPRINT
1065 if (yytype < YYNTOKENS)
1066 YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
1067# else
1068 YYUSE (yyoutput);
1069# endif
1070 switch (yytype)
1071 {
1072 default:
1073 break;
1074 }
1075}
1076
1077
1078/*--------------------------------.
1079| Print this symbol on YYOUTPUT. |
1080`--------------------------------*/
1081
1082#if (defined __STDC__ || defined __C99__FUNC__ \
1083 || defined __cplusplus || defined _MSC_VER)
1084static void
1085yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, YYLTYPE const * const yylocationp, glcpp_parser_t *parser)
1086#else
1087static void
1088yy_symbol_print (yyoutput, yytype, yyvaluep, yylocationp, parser)
1089 FILE *yyoutput;
1090 int yytype;
1091 YYSTYPE const * const yyvaluep;
1092 YYLTYPE const * const yylocationp;
1093 glcpp_parser_t *parser;
1094#endif
1095{
1096 if (yytype < YYNTOKENS)
1097 YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
1098 else
1099 YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
1100
1101 YY_LOCATION_PRINT (yyoutput, *yylocationp);
1102 YYFPRINTF (yyoutput, ": ");
1103 yy_symbol_value_print (yyoutput, yytype, yyvaluep, yylocationp, parser);
1104 YYFPRINTF (yyoutput, ")");
1105}
1106
1107/*------------------------------------------------------------------.
1108| yy_stack_print -- Print the state stack from its BOTTOM up to its |
1109| TOP (included). |
1110`------------------------------------------------------------------*/
1111
1112#if (defined __STDC__ || defined __C99__FUNC__ \
1113 || defined __cplusplus || defined _MSC_VER)
1114static void
1115yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop)
1116#else
1117static void
1118yy_stack_print (yybottom, yytop)
1119 yytype_int16 *yybottom;
1120 yytype_int16 *yytop;
1121#endif
1122{
1123 YYFPRINTF (stderr, "Stack now");
1124 for (; yybottom <= yytop; yybottom++)
1125 {
1126 int yybot = *yybottom;
1127 YYFPRINTF (stderr, " %d", yybot);
1128 }
1129 YYFPRINTF (stderr, "\n");
1130}
1131
1132# define YY_STACK_PRINT(Bottom, Top) \
1133do { \
1134 if (yydebug) \
1135 yy_stack_print ((Bottom), (Top)); \
1136} while (YYID (0))
1137
1138
1139/*------------------------------------------------.
1140| Report that the YYRULE is going to be reduced. |
1141`------------------------------------------------*/
1142
1143#if (defined __STDC__ || defined __C99__FUNC__ \
1144 || defined __cplusplus || defined _MSC_VER)
1145static void
1146yy_reduce_print (YYSTYPE *yyvsp, YYLTYPE *yylsp, int yyrule, glcpp_parser_t *parser)
1147#else
1148static void
1149yy_reduce_print (yyvsp, yylsp, yyrule, parser)
1150 YYSTYPE *yyvsp;
1151 YYLTYPE *yylsp;
1152 int yyrule;
1153 glcpp_parser_t *parser;
1154#endif
1155{
1156 int yynrhs = yyr2[yyrule];
1157 int yyi;
1158 unsigned long int yylno = yyrline[yyrule];
1159 YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
1160 yyrule - 1, yylno);
1161 /* The symbols being reduced. */
1162 for (yyi = 0; yyi < yynrhs; yyi++)
1163 {
1164 YYFPRINTF (stderr, " $%d = ", yyi + 1);
1165 yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
1166 &(yyvsp[(yyi + 1) - (yynrhs)])
1167 , &(yylsp[(yyi + 1) - (yynrhs)]) , parser);
1168 YYFPRINTF (stderr, "\n");
1169 }
1170}
1171
1172# define YY_REDUCE_PRINT(Rule) \
1173do { \
1174 if (yydebug) \
1175 yy_reduce_print (yyvsp, yylsp, Rule, parser); \
1176} while (YYID (0))
1177
1178/* Nonzero means print parse trace. It is left uninitialized so that
1179 multiple parsers can coexist. */
1180int yydebug;
1181#else /* !YYDEBUG */
1182# define YYDPRINTF(Args)
1183# define YY_SYMBOL_PRINT(Title, Type, Value, Location)
1184# define YY_STACK_PRINT(Bottom, Top)
1185# define YY_REDUCE_PRINT(Rule)
1186#endif /* !YYDEBUG */
1187
1188
1189/* YYINITDEPTH -- initial size of the parser's stacks. */
1190#ifndef YYINITDEPTH
1191# define YYINITDEPTH 200
1192#endif
1193
1194/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
1195 if the built-in stack extension method is used).
1196
1197 Do not make this value too large; the results are undefined if
1198 YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
1199 evaluated with infinite-precision integer arithmetic. */
1200
1201#ifndef YYMAXDEPTH
1202# define YYMAXDEPTH 10000
1203#endif
1204
1205
1206
1207#if YYERROR_VERBOSE
1208
1209# ifndef yystrlen
1210# if defined __GLIBC__ && defined _STRING_H
1211# define yystrlen strlen
1212# else
1213/* Return the length of YYSTR. */
1214#if (defined __STDC__ || defined __C99__FUNC__ \
1215 || defined __cplusplus || defined _MSC_VER)
1216static YYSIZE_T
1217yystrlen (const char *yystr)
1218#else
1219static YYSIZE_T
1220yystrlen (yystr)
1221 const char *yystr;
1222#endif
1223{
1224 YYSIZE_T yylen;
1225 for (yylen = 0; yystr[yylen]; yylen++)
1226 continue;
1227 return yylen;
1228}
1229# endif
1230# endif
1231
1232# ifndef yystpcpy
1233# if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
1234# define yystpcpy stpcpy
1235# else
1236/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
1237 YYDEST. */
1238#if (defined __STDC__ || defined __C99__FUNC__ \
1239 || defined __cplusplus || defined _MSC_VER)
1240static char *
1241yystpcpy (char *yydest, const char *yysrc)
1242#else
1243static char *
1244yystpcpy (yydest, yysrc)
1245 char *yydest;
1246 const char *yysrc;
1247#endif
1248{
1249 char *yyd = yydest;
1250 const char *yys = yysrc;
1251
1252 while ((*yyd++ = *yys++) != '\0')
1253 continue;
1254
1255 return yyd - 1;
1256}
1257# endif
1258# endif
1259
1260# ifndef yytnamerr
1261/* Copy to YYRES the contents of YYSTR after stripping away unnecessary
1262 quotes and backslashes, so that it's suitable for yyerror. The
1263 heuristic is that double-quoting is unnecessary unless the string
1264 contains an apostrophe, a comma, or backslash (other than
1265 backslash-backslash). YYSTR is taken from yytname. If YYRES is
1266 null, do not copy; instead, return the length of what the result
1267 would have been. */
1268static YYSIZE_T
1269yytnamerr (char *yyres, const char *yystr)
1270{
1271 if (*yystr == '"')
1272 {
1273 YYSIZE_T yyn = 0;
1274 char const *yyp = yystr;
1275
1276 for (;;)
1277 switch (*++yyp)
1278 {
1279 case '\'':
1280 case ',':
1281 goto do_not_strip_quotes;
1282
1283 case '\\':
1284 if (*++yyp != '\\')
1285 goto do_not_strip_quotes;
1286 /* Fall through. */
1287 default:
1288 if (yyres)
1289 yyres[yyn] = *yyp;
1290 yyn++;
1291 break;
1292
1293 case '"':
1294 if (yyres)
1295 yyres[yyn] = '\0';
1296 return yyn;
1297 }
1298 do_not_strip_quotes: ;
1299 }
1300
1301 if (! yyres)
1302 return yystrlen (yystr);
1303
1304 return yystpcpy (yyres, yystr) - yyres;
1305}
1306# endif
1307
1308/* Copy into YYRESULT an error message about the unexpected token
1309 YYCHAR while in state YYSTATE. Return the number of bytes copied,
1310 including the terminating null byte. If YYRESULT is null, do not
1311 copy anything; just return the number of bytes that would be
1312 copied. As a special case, return 0 if an ordinary "syntax error"
1313 message will do. Return YYSIZE_MAXIMUM if overflow occurs during
1314 size calculation. */
1315static YYSIZE_T
1316yysyntax_error (char *yyresult, int yystate, int yychar)
1317{
1318 int yyn = yypact[yystate];
1319
1320 if (! (YYPACT_NINF < yyn && yyn <= YYLAST))
1321 return 0;
1322 else
1323 {
1324 int yytype = YYTRANSLATE (yychar);
1325 YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]);
1326 YYSIZE_T yysize = yysize0;
1327 YYSIZE_T yysize1;
1328 int yysize_overflow = 0;
1329 enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
1330 char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
1331 int yyx;
1332
1333# if 0
1334 /* This is so xgettext sees the translatable formats that are
1335 constructed on the fly. */
1336 YY_("syntax error, unexpected %s");
1337 YY_("syntax error, unexpected %s, expecting %s");
1338 YY_("syntax error, unexpected %s, expecting %s or %s");
1339 YY_("syntax error, unexpected %s, expecting %s or %s or %s");
1340 YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s");
1341# endif
1342 char *yyfmt;
1343 char const *yyf;
1344 static char const yyunexpected[] = "syntax error, unexpected %s";
1345 static char const yyexpecting[] = ", expecting %s";
1346 static char const yyor[] = " or %s";
1347 char yyformat[sizeof yyunexpected
1348 + sizeof yyexpecting - 1
1349 + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2)
1350 * (sizeof yyor - 1))];
1351 char const *yyprefix = yyexpecting;
1352
1353 /* Start YYX at -YYN if negative to avoid negative indexes in
1354 YYCHECK. */
1355 int yyxbegin = yyn < 0 ? -yyn : 0;
1356
1357 /* Stay within bounds of both yycheck and yytname. */
1358 int yychecklim = YYLAST - yyn + 1;
1359 int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
1360 int yycount = 1;
1361
1362 yyarg[0] = yytname[yytype];
1363 yyfmt = yystpcpy (yyformat, yyunexpected);
1364
1365 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
1366 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
1367 {
1368 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
1369 {
1370 yycount = 1;
1371 yysize = yysize0;
1372 yyformat[sizeof yyunexpected - 1] = '\0';
1373 break;
1374 }
1375 yyarg[yycount++] = yytname[yyx];
1376 yysize1 = yysize + yytnamerr (0, yytname[yyx]);
1377 yysize_overflow |= (yysize1 < yysize);
1378 yysize = yysize1;
1379 yyfmt = yystpcpy (yyfmt, yyprefix);
1380 yyprefix = yyor;
1381 }
1382
1383 yyf = YY_(yyformat);
1384 yysize1 = yysize + yystrlen (yyf);
1385 yysize_overflow |= (yysize1 < yysize);
1386 yysize = yysize1;
1387
1388 if (yysize_overflow)
1389 return YYSIZE_MAXIMUM;
1390
1391 if (yyresult)
1392 {
1393 /* Avoid sprintf, as that infringes on the user's name space.
1394 Don't have undefined behavior even if the translation
1395 produced a string with the wrong number of "%s"s. */
1396 char *yyp = yyresult;
1397 int yyi = 0;
1398 while ((*yyp = *yyf) != '\0')
1399 {
1400 if (*yyp == '%' && yyf[1] == 's' && yyi < yycount)
1401 {
1402 yyp += yytnamerr (yyp, yyarg[yyi++]);
1403 yyf += 2;
1404 }
1405 else
1406 {
1407 yyp++;
1408 yyf++;
1409 }
1410 }
1411 }
1412 return yysize;
1413 }
1414}
1415#endif /* YYERROR_VERBOSE */
1416
1417
1418/*-----------------------------------------------.
1419| Release the memory associated to this symbol. |
1420`-----------------------------------------------*/
1421
1422/*ARGSUSED*/
1423#if (defined __STDC__ || defined __C99__FUNC__ \
1424 || defined __cplusplus || defined _MSC_VER)
1425static void
1426yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, YYLTYPE *yylocationp, glcpp_parser_t *parser)
1427#else
1428static void
1429yydestruct (yymsg, yytype, yyvaluep, yylocationp, parser)
1430 const char *yymsg;
1431 int yytype;
1432 YYSTYPE *yyvaluep;
1433 YYLTYPE *yylocationp;
1434 glcpp_parser_t *parser;
1435#endif
1436{
1437 YYUSE (yyvaluep);
1438 YYUSE (yylocationp);
1439 YYUSE (parser);
1440
1441 if (!yymsg)
1442 yymsg = "Deleting";
1443 YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
1444
1445 switch (yytype)
1446 {
1447
1448 default:
1449 break;
1450 }
1451}
1452
1453/* Prevent warnings from -Wmissing-prototypes. */
1454#ifdef YYPARSE_PARAM
1455#if defined __STDC__ || defined __cplusplus
1456int yyparse (void *YYPARSE_PARAM);
1457#else
1458int yyparse ();
1459#endif
1460#else /* ! YYPARSE_PARAM */
1461#if defined __STDC__ || defined __cplusplus
1462int yyparse (glcpp_parser_t *parser);
1463#else
1464int yyparse ();
1465#endif
1466#endif /* ! YYPARSE_PARAM */
1467
1468
1469
1470
1471
1472/*-------------------------.
1473| yyparse or yypush_parse. |
1474`-------------------------*/
1475
1476#ifdef YYPARSE_PARAM
1477#if (defined __STDC__ || defined __C99__FUNC__ \
1478 || defined __cplusplus || defined _MSC_VER)
1479int
1480yyparse (void *YYPARSE_PARAM)
1481#else
1482int
1483yyparse (YYPARSE_PARAM)
1484 void *YYPARSE_PARAM;
1485#endif
1486#else /* ! YYPARSE_PARAM */
1487#if (defined __STDC__ || defined __C99__FUNC__ \
1488 || defined __cplusplus || defined _MSC_VER)
1489int
1490yyparse (glcpp_parser_t *parser)
1491#else
1492int
1493yyparse (parser)
1494 glcpp_parser_t *parser;
1495#endif
1496#endif
1497{
1498/* The lookahead symbol. */
1499int yychar;
1500
1501/* The semantic value of the lookahead symbol. */
1502YYSTYPE yylval;
1503
1504/* Location data for the lookahead symbol. */
1505YYLTYPE yylloc;
1506
1507 /* Number of syntax errors so far. */
1508 int yynerrs;
1509
1510 int yystate;
1511 /* Number of tokens to shift before error messages enabled. */
1512 int yyerrstatus;
1513
1514 /* The stacks and their tools:
1515 `yyss': related to states.
1516 `yyvs': related to semantic values.
1517 `yyls': related to locations.
1518
1519 Refer to the stacks thru separate pointers, to allow yyoverflow
1520 to reallocate them elsewhere. */
1521
1522 /* The state stack. */
1523 yytype_int16 yyssa[YYINITDEPTH];
1524 yytype_int16 *yyss;
1525 yytype_int16 *yyssp;
1526
1527 /* The semantic value stack. */
1528 YYSTYPE yyvsa[YYINITDEPTH];
1529 YYSTYPE *yyvs;
1530 YYSTYPE *yyvsp;
1531
1532 /* The location stack. */
1533 YYLTYPE yylsa[YYINITDEPTH];
1534 YYLTYPE *yyls;
1535 YYLTYPE *yylsp;
1536
1537 /* The locations where the error started and ended. */
1538 YYLTYPE yyerror_range[2];
1539
1540 YYSIZE_T yystacksize;
1541
1542 int yyn;
1543 int yyresult;
1544 /* Lookahead token as an internal (translated) token number. */
1545 int yytoken;
1546 /* The variables used to return semantic value and location from the
1547 action routines. */
1548 YYSTYPE yyval;
1549 YYLTYPE yyloc;
1550
1551#if YYERROR_VERBOSE
1552 /* Buffer for error messages, and its allocated size. */
1553 char yymsgbuf[128];
1554 char *yymsg = yymsgbuf;
1555 YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
1556#endif
1557
1558#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N), yylsp -= (N))
1559
1560 /* The number of symbols on the RHS of the reduced rule.
1561 Keep to zero when no symbol should be popped. */
1562 int yylen = 0;
1563
1564 yytoken = 0;
1565 yyss = yyssa;
1566 yyvs = yyvsa;
1567 yyls = yylsa;
1568 yystacksize = YYINITDEPTH;
1569
1570 YYDPRINTF ((stderr, "Starting parse\n"));
1571
1572 yystate = 0;
1573 yyerrstatus = 0;
1574 yynerrs = 0;
1575 yychar = YYEMPTY; /* Cause a token to be read. */
1576
1577 /* Initialize stack pointers.
1578 Waste one element of value and location stack
1579 so that they stay on the same level as the state stack.
1580 The wasted elements are never initialized. */
1581 yyssp = yyss;
1582 yyvsp = yyvs;
1583 yylsp = yyls;
1584
1585#if YYLTYPE_IS_TRIVIAL
1586 /* Initialize the default location before parsing starts. */
1587 yylloc.first_line = yylloc.last_line = 1;
1588 yylloc.first_column = yylloc.last_column = 1;
1589#endif
1590
1591 goto yysetstate;
1592
1593/*------------------------------------------------------------.
1594| yynewstate -- Push a new state, which is found in yystate. |
1595`------------------------------------------------------------*/
1596 yynewstate:
1597 /* In all cases, when you get here, the value and location stacks
1598 have just been pushed. So pushing a state here evens the stacks. */
1599 yyssp++;
1600
1601 yysetstate:
1602 *yyssp = yystate;
1603
1604 if (yyss + yystacksize - 1 <= yyssp)
1605 {
1606 /* Get the current used size of the three stacks, in elements. */
1607 YYSIZE_T yysize = yyssp - yyss + 1;
1608
1609#ifdef yyoverflow
1610 {
1611 /* Give user a chance to reallocate the stack. Use copies of
1612 these so that the &'s don't force the real ones into
1613 memory. */
1614 YYSTYPE *yyvs1 = yyvs;
1615 yytype_int16 *yyss1 = yyss;
1616 YYLTYPE *yyls1 = yyls;
1617
1618 /* Each stack pointer address is followed by the size of the
1619 data in use in that stack, in bytes. This used to be a
1620 conditional around just the two extra args, but that might
1621 be undefined if yyoverflow is a macro. */
1622 yyoverflow (YY_("memory exhausted"),
1623 &yyss1, yysize * sizeof (*yyssp),
1624 &yyvs1, yysize * sizeof (*yyvsp),
1625 &yyls1, yysize * sizeof (*yylsp),
1626 &yystacksize);
1627
1628 yyls = yyls1;
1629 yyss = yyss1;
1630 yyvs = yyvs1;
1631 }
1632#else /* no yyoverflow */
1633# ifndef YYSTACK_RELOCATE
1634 goto yyexhaustedlab;
1635# else
1636 /* Extend the stack our own way. */
1637 if (YYMAXDEPTH <= yystacksize)
1638 goto yyexhaustedlab;
1639 yystacksize *= 2;
1640 if (YYMAXDEPTH < yystacksize)
1641 yystacksize = YYMAXDEPTH;
1642
1643 {
1644 yytype_int16 *yyss1 = yyss;
1645 union yyalloc *yyptr =
1646 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
1647 if (! yyptr)
1648 goto yyexhaustedlab;
1649 YYSTACK_RELOCATE (yyss_alloc, yyss);
1650 YYSTACK_RELOCATE (yyvs_alloc, yyvs);
1651 YYSTACK_RELOCATE (yyls_alloc, yyls);
1652# undef YYSTACK_RELOCATE
1653 if (yyss1 != yyssa)
1654 YYSTACK_FREE (yyss1);
1655 }
1656# endif
1657#endif /* no yyoverflow */
1658
1659 yyssp = yyss + yysize - 1;
1660 yyvsp = yyvs + yysize - 1;
1661 yylsp = yyls + yysize - 1;
1662
1663 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
1664 (unsigned long int) yystacksize));
1665
1666 if (yyss + yystacksize - 1 <= yyssp)
1667 YYABORT;
1668 }
1669
1670 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
1671
1672 if (yystate == YYFINAL)
1673 YYACCEPT;
1674
1675 goto yybackup;
1676
1677/*-----------.
1678| yybackup. |
1679`-----------*/
1680yybackup:
1681
1682 /* Do appropriate processing given the current state. Read a
1683 lookahead token if we need one and don't already have one. */
1684
1685 /* First try to decide what to do without reference to lookahead token. */
1686 yyn = yypact[yystate];
1687 if (yyn == YYPACT_NINF)
1688 goto yydefault;
1689
1690 /* Not known => get a lookahead token if don't already have one. */
1691
1692 /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */
1693 if (yychar == YYEMPTY)
1694 {
1695 YYDPRINTF ((stderr, "Reading a token: "));
1696 yychar = YYLEX;
1697 }
1698
1699 if (yychar <= YYEOF)
1700 {
1701 yychar = yytoken = YYEOF;
1702 YYDPRINTF ((stderr, "Now at end of input.\n"));
1703 }
1704 else
1705 {
1706 yytoken = YYTRANSLATE (yychar);
1707 YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
1708 }
1709
1710 /* If the proper action on seeing token YYTOKEN is to reduce or to
1711 detect an error, take that action. */
1712 yyn += yytoken;
1713 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
1714 goto yydefault;
1715 yyn = yytable[yyn];
1716 if (yyn <= 0)
1717 {
1718 if (yyn == 0 || yyn == YYTABLE_NINF)
1719 goto yyerrlab;
1720 yyn = -yyn;
1721 goto yyreduce;
1722 }
1723
1724 /* Count tokens shifted since error; after three, turn off error
1725 status. */
1726 if (yyerrstatus)
1727 yyerrstatus--;
1728
1729 /* Shift the lookahead token. */
1730 YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
1731
1732 /* Discard the shifted token. */
1733 yychar = YYEMPTY;
1734
1735 yystate = yyn;
1736 *++yyvsp = yylval;
1737 *++yylsp = yylloc;
1738 goto yynewstate;
1739
1740
1741/*-----------------------------------------------------------.
1742| yydefault -- do the default action for the current state. |
1743`-----------------------------------------------------------*/
1744yydefault:
1745 yyn = yydefact[yystate];
1746 if (yyn == 0)
1747 goto yyerrlab;
1748 goto yyreduce;
1749
1750
1751/*-----------------------------.
1752| yyreduce -- Do a reduction. |
1753`-----------------------------*/
1754yyreduce:
1755 /* yyn is the number of a rule to reduce with. */
1756 yylen = yyr2[yyn];
1757
1758 /* If YYLEN is nonzero, implement the default value of the action:
1759 `$$ = $1'.
1760
1761 Otherwise, the following line sets YYVAL to garbage.
1762 This behavior is undocumented and Bison
1763 users should not rely upon it. Assigning to YYVAL
1764 unconditionally makes the parser a bit smaller, and it avoids a
1765 GCC warning that YYVAL may be used uninitialized. */
1766 yyval = yyvsp[1-yylen];
1767
1768 /* Default location. */
1769 YYLLOC_DEFAULT (yyloc, (yylsp - yylen), yylen);
1770 YY_REDUCE_PRINT (yyn);
1771 switch (yyn)
1772 {
1773 case 4:
1774
1775/* Line 1455 of yacc.c */
Eric Anholtd4a04f32010-07-28 16:58:39 -07001776#line 175 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07001777 {
1778 glcpp_print(parser->output, "\n");
1779 ;}
1780 break;
1781
1782 case 5:
1783
1784/* Line 1455 of yacc.c */
Eric Anholtd4a04f32010-07-28 16:58:39 -07001785#line 178 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07001786 {
1787 _glcpp_parser_print_expanded_token_list (parser, (yyvsp[(1) - (1)].token_list));
1788 glcpp_print(parser->output, "\n");
1789 talloc_free ((yyvsp[(1) - (1)].token_list));
1790 ;}
1791 break;
1792
1793 case 8:
1794
1795/* Line 1455 of yacc.c */
Eric Anholtd4a04f32010-07-28 16:58:39 -07001796#line 188 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07001797 {
1798 _glcpp_parser_skip_stack_push_if (parser, & (yylsp[(1) - (3)]), (yyvsp[(2) - (3)].ival));
1799 ;}
1800 break;
1801
1802 case 9:
1803
1804/* Line 1455 of yacc.c */
Eric Anholtd4a04f32010-07-28 16:58:39 -07001805#line 191 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07001806 {
1807 _glcpp_parser_skip_stack_change_if (parser, & (yylsp[(1) - (3)]), "elif", (yyvsp[(2) - (3)].ival));
1808 ;}
1809 break;
1810
1811 case 10:
1812
1813/* Line 1455 of yacc.c */
Eric Anholtd4a04f32010-07-28 16:58:39 -07001814#line 197 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07001815 {
1816 _define_object_macro (parser, & (yylsp[(2) - (4)]), (yyvsp[(2) - (4)].str), (yyvsp[(3) - (4)].token_list));
1817 ;}
1818 break;
1819
1820 case 11:
1821
1822/* Line 1455 of yacc.c */
Eric Anholtd4a04f32010-07-28 16:58:39 -07001823#line 200 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07001824 {
1825 _define_function_macro (parser, & (yylsp[(2) - (6)]), (yyvsp[(2) - (6)].str), NULL, (yyvsp[(5) - (6)].token_list));
1826 ;}
1827 break;
1828
1829 case 12:
1830
1831/* Line 1455 of yacc.c */
Eric Anholtd4a04f32010-07-28 16:58:39 -07001832#line 203 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07001833 {
1834 _define_function_macro (parser, & (yylsp[(2) - (7)]), (yyvsp[(2) - (7)].str), (yyvsp[(4) - (7)].string_list), (yyvsp[(6) - (7)].token_list));
1835 ;}
1836 break;
1837
1838 case 13:
1839
1840/* Line 1455 of yacc.c */
Eric Anholtd4a04f32010-07-28 16:58:39 -07001841#line 206 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07001842 {
1843 macro_t *macro = hash_table_find (parser->defines, (yyvsp[(2) - (3)].str));
1844 if (macro) {
1845 hash_table_remove (parser->defines, (yyvsp[(2) - (3)].str));
1846 talloc_free (macro);
1847 }
1848 talloc_free ((yyvsp[(2) - (3)].str));
1849 ;}
1850 break;
1851
1852 case 14:
1853
1854/* Line 1455 of yacc.c */
Eric Anholtd4a04f32010-07-28 16:58:39 -07001855#line 214 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07001856 {
1857 token_list_t *expanded;
1858 token_t *token;
1859
1860 expanded = _token_list_create (parser);
1861 token = _token_create_ival (parser, IF_EXPANDED, IF_EXPANDED);
1862 _token_list_append (expanded, token);
1863 talloc_unlink (parser, token);
1864 _glcpp_parser_expand_token_list (parser, (yyvsp[(2) - (3)].token_list));
1865 _token_list_append_list (expanded, (yyvsp[(2) - (3)].token_list));
1866 glcpp_parser_lex_from (parser, expanded);
1867 ;}
1868 break;
1869
1870 case 15:
1871
1872/* Line 1455 of yacc.c */
Eric Anholtd4a04f32010-07-28 16:58:39 -07001873#line 226 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07001874 {
1875 macro_t *macro = hash_table_find (parser->defines, (yyvsp[(2) - (4)].str));
1876 talloc_free ((yyvsp[(2) - (4)].str));
1877 _glcpp_parser_skip_stack_push_if (parser, & (yylsp[(1) - (4)]), macro != NULL);
1878 ;}
1879 break;
1880
1881 case 16:
1882
1883/* Line 1455 of yacc.c */
Eric Anholtd4a04f32010-07-28 16:58:39 -07001884#line 231 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07001885 {
1886 macro_t *macro = hash_table_find (parser->defines, (yyvsp[(2) - (4)].str));
1887 talloc_free ((yyvsp[(2) - (4)].str));
1888 _glcpp_parser_skip_stack_push_if (parser, & (yylsp[(1) - (4)]), macro == NULL);
1889 ;}
1890 break;
1891
1892 case 17:
1893
1894/* Line 1455 of yacc.c */
Eric Anholtd4a04f32010-07-28 16:58:39 -07001895#line 236 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07001896 {
1897 token_list_t *expanded;
1898 token_t *token;
1899
1900 expanded = _token_list_create (parser);
1901 token = _token_create_ival (parser, ELIF_EXPANDED, ELIF_EXPANDED);
1902 _token_list_append (expanded, token);
1903 talloc_unlink (parser, token);
1904 _glcpp_parser_expand_token_list (parser, (yyvsp[(2) - (3)].token_list));
1905 _token_list_append_list (expanded, (yyvsp[(2) - (3)].token_list));
1906 glcpp_parser_lex_from (parser, expanded);
1907 ;}
1908 break;
1909
1910 case 18:
1911
1912/* Line 1455 of yacc.c */
Eric Anholtd4a04f32010-07-28 16:58:39 -07001913#line 248 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07001914 {
1915 /* #elif without an expression results in a warning if the
1916 * condition doesn't matter (we just handled #if 1 or such)
1917 * but an error otherwise. */
1918 if (parser->skip_stack != NULL && parser->skip_stack->type == SKIP_NO_SKIP) {
1919 parser->skip_stack->type = SKIP_TO_ENDIF;
1920 glcpp_warning(& (yylsp[(1) - (2)]), parser, "ignoring illegal #elif without expression");
1921 } else {
1922 glcpp_error(& (yylsp[(1) - (2)]), parser, "#elif needs an expression");
1923 }
1924 ;}
1925 break;
1926
1927 case 19:
1928
1929/* Line 1455 of yacc.c */
Eric Anholtd4a04f32010-07-28 16:58:39 -07001930#line 259 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07001931 {
1932 _glcpp_parser_skip_stack_change_if (parser, & (yylsp[(1) - (2)]), "else", 1);
1933 ;}
1934 break;
1935
1936 case 20:
1937
1938/* Line 1455 of yacc.c */
Eric Anholtd4a04f32010-07-28 16:58:39 -07001939#line 262 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07001940 {
1941 _glcpp_parser_skip_stack_pop (parser, & (yylsp[(1) - (2)]));
1942 ;}
1943 break;
1944
Eric Anholtd4a04f32010-07-28 16:58:39 -07001945 case 21:
Carl Worth667173e2010-07-28 12:33:56 -07001946
1947/* Line 1455 of yacc.c */
Eric Anholtd4a04f32010-07-28 16:58:39 -07001948#line 265 "glcpp/glcpp-parse.y"
1949 {
1950 macro_t *macro = hash_table_find (parser->defines, "__VERSION__");
1951 if (macro) {
1952 hash_table_remove (parser->defines, "__VERSION__");
1953 talloc_free (macro);
1954 }
1955 add_builtin_define (parser, "__VERSION__", (yyvsp[(2) - (3)].ival));
1956 glcpp_printf(parser->output, "#version %" PRIiMAX "\n", (yyvsp[(2) - (3)].ival));
1957 ;}
1958 break;
1959
1960 case 23:
1961
1962/* Line 1455 of yacc.c */
1963#line 278 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07001964 {
1965 if (strlen ((yyvsp[(1) - (1)].str)) >= 3 && strncmp ((yyvsp[(1) - (1)].str), "0x", 2) == 0) {
1966 (yyval.ival) = strtoll ((yyvsp[(1) - (1)].str) + 2, NULL, 16);
1967 } else if ((yyvsp[(1) - (1)].str)[0] == '0') {
1968 (yyval.ival) = strtoll ((yyvsp[(1) - (1)].str), NULL, 8);
1969 } else {
1970 (yyval.ival) = strtoll ((yyvsp[(1) - (1)].str), NULL, 10);
1971 }
1972 ;}
1973 break;
1974
Carl Worth667173e2010-07-28 12:33:56 -07001975 case 24:
1976
1977/* Line 1455 of yacc.c */
Eric Anholtd4a04f32010-07-28 16:58:39 -07001978#line 287 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07001979 {
Eric Anholtd4a04f32010-07-28 16:58:39 -07001980 (yyval.ival) = (yyvsp[(1) - (1)].ival);
Carl Worth667173e2010-07-28 12:33:56 -07001981 ;}
1982 break;
1983
1984 case 26:
1985
1986/* Line 1455 of yacc.c */
Eric Anholtd4a04f32010-07-28 16:58:39 -07001987#line 293 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07001988 {
Eric Anholtd4a04f32010-07-28 16:58:39 -07001989 (yyval.ival) = (yyvsp[(1) - (3)].ival) || (yyvsp[(3) - (3)].ival);
Carl Worth667173e2010-07-28 12:33:56 -07001990 ;}
1991 break;
1992
1993 case 27:
1994
1995/* Line 1455 of yacc.c */
Eric Anholtd4a04f32010-07-28 16:58:39 -07001996#line 296 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07001997 {
Eric Anholtd4a04f32010-07-28 16:58:39 -07001998 (yyval.ival) = (yyvsp[(1) - (3)].ival) && (yyvsp[(3) - (3)].ival);
Carl Worth667173e2010-07-28 12:33:56 -07001999 ;}
2000 break;
2001
2002 case 28:
2003
2004/* Line 1455 of yacc.c */
Eric Anholtd4a04f32010-07-28 16:58:39 -07002005#line 299 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07002006 {
Eric Anholtd4a04f32010-07-28 16:58:39 -07002007 (yyval.ival) = (yyvsp[(1) - (3)].ival) | (yyvsp[(3) - (3)].ival);
Carl Worth667173e2010-07-28 12:33:56 -07002008 ;}
2009 break;
2010
2011 case 29:
2012
2013/* Line 1455 of yacc.c */
Eric Anholtd4a04f32010-07-28 16:58:39 -07002014#line 302 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07002015 {
Eric Anholtd4a04f32010-07-28 16:58:39 -07002016 (yyval.ival) = (yyvsp[(1) - (3)].ival) ^ (yyvsp[(3) - (3)].ival);
Carl Worth667173e2010-07-28 12:33:56 -07002017 ;}
2018 break;
2019
2020 case 30:
2021
2022/* Line 1455 of yacc.c */
Eric Anholtd4a04f32010-07-28 16:58:39 -07002023#line 305 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07002024 {
Eric Anholtd4a04f32010-07-28 16:58:39 -07002025 (yyval.ival) = (yyvsp[(1) - (3)].ival) & (yyvsp[(3) - (3)].ival);
Carl Worth667173e2010-07-28 12:33:56 -07002026 ;}
2027 break;
2028
2029 case 31:
2030
2031/* Line 1455 of yacc.c */
Eric Anholtd4a04f32010-07-28 16:58:39 -07002032#line 308 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07002033 {
Eric Anholtd4a04f32010-07-28 16:58:39 -07002034 (yyval.ival) = (yyvsp[(1) - (3)].ival) != (yyvsp[(3) - (3)].ival);
Carl Worth667173e2010-07-28 12:33:56 -07002035 ;}
2036 break;
2037
2038 case 32:
2039
2040/* Line 1455 of yacc.c */
Eric Anholtd4a04f32010-07-28 16:58:39 -07002041#line 311 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07002042 {
Eric Anholtd4a04f32010-07-28 16:58:39 -07002043 (yyval.ival) = (yyvsp[(1) - (3)].ival) == (yyvsp[(3) - (3)].ival);
Carl Worth667173e2010-07-28 12:33:56 -07002044 ;}
2045 break;
2046
2047 case 33:
2048
2049/* Line 1455 of yacc.c */
Eric Anholtd4a04f32010-07-28 16:58:39 -07002050#line 314 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07002051 {
Eric Anholtd4a04f32010-07-28 16:58:39 -07002052 (yyval.ival) = (yyvsp[(1) - (3)].ival) >= (yyvsp[(3) - (3)].ival);
Carl Worth667173e2010-07-28 12:33:56 -07002053 ;}
2054 break;
2055
2056 case 34:
2057
2058/* Line 1455 of yacc.c */
Eric Anholtd4a04f32010-07-28 16:58:39 -07002059#line 317 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07002060 {
Eric Anholtd4a04f32010-07-28 16:58:39 -07002061 (yyval.ival) = (yyvsp[(1) - (3)].ival) <= (yyvsp[(3) - (3)].ival);
Carl Worth667173e2010-07-28 12:33:56 -07002062 ;}
2063 break;
2064
2065 case 35:
2066
2067/* Line 1455 of yacc.c */
Eric Anholtd4a04f32010-07-28 16:58:39 -07002068#line 320 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07002069 {
Eric Anholtd4a04f32010-07-28 16:58:39 -07002070 (yyval.ival) = (yyvsp[(1) - (3)].ival) > (yyvsp[(3) - (3)].ival);
Carl Worth667173e2010-07-28 12:33:56 -07002071 ;}
2072 break;
2073
2074 case 36:
2075
2076/* Line 1455 of yacc.c */
Eric Anholtd4a04f32010-07-28 16:58:39 -07002077#line 323 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07002078 {
Eric Anholtd4a04f32010-07-28 16:58:39 -07002079 (yyval.ival) = (yyvsp[(1) - (3)].ival) < (yyvsp[(3) - (3)].ival);
Carl Worth667173e2010-07-28 12:33:56 -07002080 ;}
2081 break;
2082
2083 case 37:
2084
2085/* Line 1455 of yacc.c */
Eric Anholtd4a04f32010-07-28 16:58:39 -07002086#line 326 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07002087 {
Eric Anholtd4a04f32010-07-28 16:58:39 -07002088 (yyval.ival) = (yyvsp[(1) - (3)].ival) >> (yyvsp[(3) - (3)].ival);
Carl Worth667173e2010-07-28 12:33:56 -07002089 ;}
2090 break;
2091
2092 case 38:
2093
2094/* Line 1455 of yacc.c */
Eric Anholtd4a04f32010-07-28 16:58:39 -07002095#line 329 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07002096 {
Eric Anholtd4a04f32010-07-28 16:58:39 -07002097 (yyval.ival) = (yyvsp[(1) - (3)].ival) << (yyvsp[(3) - (3)].ival);
Carl Worth667173e2010-07-28 12:33:56 -07002098 ;}
2099 break;
2100
2101 case 39:
2102
2103/* Line 1455 of yacc.c */
Eric Anholtd4a04f32010-07-28 16:58:39 -07002104#line 332 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07002105 {
Eric Anholtd4a04f32010-07-28 16:58:39 -07002106 (yyval.ival) = (yyvsp[(1) - (3)].ival) - (yyvsp[(3) - (3)].ival);
Carl Worth667173e2010-07-28 12:33:56 -07002107 ;}
2108 break;
2109
2110 case 40:
2111
2112/* Line 1455 of yacc.c */
Eric Anholtd4a04f32010-07-28 16:58:39 -07002113#line 335 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07002114 {
Eric Anholtd4a04f32010-07-28 16:58:39 -07002115 (yyval.ival) = (yyvsp[(1) - (3)].ival) + (yyvsp[(3) - (3)].ival);
Carl Worth667173e2010-07-28 12:33:56 -07002116 ;}
2117 break;
2118
2119 case 41:
2120
2121/* Line 1455 of yacc.c */
Eric Anholtd4a04f32010-07-28 16:58:39 -07002122#line 338 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07002123 {
Eric Anholtd4a04f32010-07-28 16:58:39 -07002124 (yyval.ival) = (yyvsp[(1) - (3)].ival) % (yyvsp[(3) - (3)].ival);
Carl Worth667173e2010-07-28 12:33:56 -07002125 ;}
2126 break;
2127
2128 case 42:
2129
2130/* Line 1455 of yacc.c */
Eric Anholtd4a04f32010-07-28 16:58:39 -07002131#line 341 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07002132 {
Eric Anholtd4a04f32010-07-28 16:58:39 -07002133 (yyval.ival) = (yyvsp[(1) - (3)].ival) / (yyvsp[(3) - (3)].ival);
Carl Worth667173e2010-07-28 12:33:56 -07002134 ;}
2135 break;
2136
2137 case 43:
2138
2139/* Line 1455 of yacc.c */
Eric Anholtd4a04f32010-07-28 16:58:39 -07002140#line 344 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07002141 {
Eric Anholtd4a04f32010-07-28 16:58:39 -07002142 (yyval.ival) = (yyvsp[(1) - (3)].ival) * (yyvsp[(3) - (3)].ival);
Carl Worth667173e2010-07-28 12:33:56 -07002143 ;}
2144 break;
2145
2146 case 44:
2147
2148/* Line 1455 of yacc.c */
Eric Anholtd4a04f32010-07-28 16:58:39 -07002149#line 347 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07002150 {
Eric Anholtd4a04f32010-07-28 16:58:39 -07002151 (yyval.ival) = ! (yyvsp[(2) - (2)].ival);
Carl Worth667173e2010-07-28 12:33:56 -07002152 ;}
2153 break;
2154
2155 case 45:
2156
2157/* Line 1455 of yacc.c */
Eric Anholtd4a04f32010-07-28 16:58:39 -07002158#line 350 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07002159 {
Eric Anholtd4a04f32010-07-28 16:58:39 -07002160 (yyval.ival) = ~ (yyvsp[(2) - (2)].ival);
Carl Worth667173e2010-07-28 12:33:56 -07002161 ;}
2162 break;
2163
2164 case 46:
2165
2166/* Line 1455 of yacc.c */
Eric Anholtd4a04f32010-07-28 16:58:39 -07002167#line 353 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07002168 {
Eric Anholtd4a04f32010-07-28 16:58:39 -07002169 (yyval.ival) = - (yyvsp[(2) - (2)].ival);
Carl Worth667173e2010-07-28 12:33:56 -07002170 ;}
2171 break;
2172
2173 case 47:
2174
2175/* Line 1455 of yacc.c */
Eric Anholtd4a04f32010-07-28 16:58:39 -07002176#line 356 "glcpp/glcpp-parse.y"
2177 {
2178 (yyval.ival) = + (yyvsp[(2) - (2)].ival);
2179 ;}
2180 break;
2181
2182 case 48:
2183
2184/* Line 1455 of yacc.c */
2185#line 359 "glcpp/glcpp-parse.y"
2186 {
2187 (yyval.ival) = (yyvsp[(2) - (3)].ival);
2188 ;}
2189 break;
2190
2191 case 49:
2192
2193/* Line 1455 of yacc.c */
2194#line 365 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07002195 {
2196 (yyval.string_list) = _string_list_create (parser);
2197 _string_list_append_item ((yyval.string_list), (yyvsp[(1) - (1)].str));
2198 talloc_steal ((yyval.string_list), (yyvsp[(1) - (1)].str));
2199 ;}
2200 break;
2201
Eric Anholtd4a04f32010-07-28 16:58:39 -07002202 case 50:
Carl Worth667173e2010-07-28 12:33:56 -07002203
2204/* Line 1455 of yacc.c */
Eric Anholtd4a04f32010-07-28 16:58:39 -07002205#line 370 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07002206 {
2207 (yyval.string_list) = (yyvsp[(1) - (3)].string_list);
2208 _string_list_append_item ((yyval.string_list), (yyvsp[(3) - (3)].str));
2209 talloc_steal ((yyval.string_list), (yyvsp[(3) - (3)].str));
2210 ;}
2211 break;
2212
Carl Worth667173e2010-07-28 12:33:56 -07002213 case 51:
2214
2215/* Line 1455 of yacc.c */
Eric Anholtd4a04f32010-07-28 16:58:39 -07002216#line 378 "glcpp/glcpp-parse.y"
2217 { (yyval.token_list) = NULL; ;}
2218 break;
2219
2220 case 53:
2221
2222/* Line 1455 of yacc.c */
2223#line 383 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07002224 {
2225 yyerror (& (yylsp[(1) - (2)]), parser, "Invalid tokens after #");
2226 ;}
2227 break;
2228
Eric Anholtd4a04f32010-07-28 16:58:39 -07002229 case 54:
Carl Worth667173e2010-07-28 12:33:56 -07002230
2231/* Line 1455 of yacc.c */
Eric Anholtd4a04f32010-07-28 16:58:39 -07002232#line 389 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07002233 { (yyval.token_list) = NULL; ;}
2234 break;
2235
Carl Worth667173e2010-07-28 12:33:56 -07002236 case 57:
2237
2238/* Line 1455 of yacc.c */
Eric Anholtd4a04f32010-07-28 16:58:39 -07002239#line 395 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07002240 {
Eric Anholtd4a04f32010-07-28 16:58:39 -07002241 glcpp_warning(&(yylsp[(1) - (1)]), parser, "extra tokens at end of directive");
2242 ;}
2243 break;
2244
2245 case 58:
2246
2247/* Line 1455 of yacc.c */
2248#line 402 "glcpp/glcpp-parse.y"
2249 {
2250 int v = hash_table_find (parser->defines, (yyvsp[(2) - (2)].str)) ? 1 : 0;
Carl Worth667173e2010-07-28 12:33:56 -07002251 (yyval.token) = _token_create_ival (parser, INTEGER, v);
2252 ;}
2253 break;
2254
2255 case 59:
2256
2257/* Line 1455 of yacc.c */
Carl Worth667173e2010-07-28 12:33:56 -07002258#line 406 "glcpp/glcpp-parse.y"
2259 {
Eric Anholtd4a04f32010-07-28 16:58:39 -07002260 int v = hash_table_find (parser->defines, (yyvsp[(3) - (4)].str)) ? 1 : 0;
2261 (yyval.token) = _token_create_ival (parser, INTEGER, v);
Carl Worth667173e2010-07-28 12:33:56 -07002262 ;}
2263 break;
2264
2265 case 61:
2266
2267/* Line 1455 of yacc.c */
Eric Anholtd4a04f32010-07-28 16:58:39 -07002268#line 415 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07002269 {
2270 parser->space_tokens = 1;
2271 (yyval.token_list) = _token_list_create (parser);
2272 _token_list_append ((yyval.token_list), (yyvsp[(1) - (1)].token));
2273 talloc_unlink (parser, (yyvsp[(1) - (1)].token));
2274 ;}
2275 break;
2276
2277 case 62:
2278
2279/* Line 1455 of yacc.c */
Eric Anholtd4a04f32010-07-28 16:58:39 -07002280#line 421 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07002281 {
2282 (yyval.token_list) = (yyvsp[(1) - (2)].token_list);
2283 _token_list_append ((yyval.token_list), (yyvsp[(2) - (2)].token));
2284 talloc_unlink (parser, (yyvsp[(2) - (2)].token));
2285 ;}
2286 break;
2287
2288 case 63:
2289
2290/* Line 1455 of yacc.c */
Eric Anholtd4a04f32010-07-28 16:58:39 -07002291#line 429 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07002292 {
Eric Anholtd4a04f32010-07-28 16:58:39 -07002293 parser->space_tokens = 1;
2294 (yyval.token_list) = _token_list_create (parser);
2295 _token_list_append ((yyval.token_list), (yyvsp[(1) - (1)].token));
2296 talloc_unlink (parser, (yyvsp[(1) - (1)].token));
Carl Worth667173e2010-07-28 12:33:56 -07002297 ;}
2298 break;
2299
2300 case 64:
2301
2302/* Line 1455 of yacc.c */
Eric Anholtd4a04f32010-07-28 16:58:39 -07002303#line 435 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07002304 {
Eric Anholtd4a04f32010-07-28 16:58:39 -07002305 (yyval.token_list) = (yyvsp[(1) - (2)].token_list);
2306 _token_list_append ((yyval.token_list), (yyvsp[(2) - (2)].token));
2307 talloc_unlink (parser, (yyvsp[(2) - (2)].token));
Carl Worth667173e2010-07-28 12:33:56 -07002308 ;}
2309 break;
2310
2311 case 65:
2312
2313/* Line 1455 of yacc.c */
Eric Anholtd4a04f32010-07-28 16:58:39 -07002314#line 443 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07002315 {
Eric Anholtd4a04f32010-07-28 16:58:39 -07002316 (yyval.token) = _token_create_str (parser, IDENTIFIER, (yyvsp[(1) - (1)].str));
Carl Worth667173e2010-07-28 12:33:56 -07002317 (yyval.token)->location = yylloc;
2318 ;}
2319 break;
2320
2321 case 66:
2322
2323/* Line 1455 of yacc.c */
Eric Anholtd4a04f32010-07-28 16:58:39 -07002324#line 447 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07002325 {
Eric Anholtd4a04f32010-07-28 16:58:39 -07002326 (yyval.token) = _token_create_str (parser, INTEGER_STRING, (yyvsp[(1) - (1)].str));
Carl Worth667173e2010-07-28 12:33:56 -07002327 (yyval.token)->location = yylloc;
2328 ;}
2329 break;
2330
2331 case 67:
2332
2333/* Line 1455 of yacc.c */
Eric Anholtd4a04f32010-07-28 16:58:39 -07002334#line 451 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07002335 {
Eric Anholtd4a04f32010-07-28 16:58:39 -07002336 (yyval.token) = _token_create_ival (parser, (yyvsp[(1) - (1)].ival), (yyvsp[(1) - (1)].ival));
Carl Worth667173e2010-07-28 12:33:56 -07002337 (yyval.token)->location = yylloc;
2338 ;}
2339 break;
2340
2341 case 68:
2342
2343/* Line 1455 of yacc.c */
Eric Anholtd4a04f32010-07-28 16:58:39 -07002344#line 455 "glcpp/glcpp-parse.y"
2345 {
2346 (yyval.token) = _token_create_str (parser, OTHER, (yyvsp[(1) - (1)].str));
2347 (yyval.token)->location = yylloc;
2348 ;}
Carl Worth667173e2010-07-28 12:33:56 -07002349 break;
2350
2351 case 69:
2352
2353/* Line 1455 of yacc.c */
Eric Anholtd4a04f32010-07-28 16:58:39 -07002354#line 459 "glcpp/glcpp-parse.y"
2355 {
2356 (yyval.token) = _token_create_ival (parser, SPACE, SPACE);
2357 (yyval.token)->location = yylloc;
2358 ;}
Carl Worth667173e2010-07-28 12:33:56 -07002359 break;
2360
2361 case 70:
2362
2363/* Line 1455 of yacc.c */
Eric Anholtd4a04f32010-07-28 16:58:39 -07002364#line 466 "glcpp/glcpp-parse.y"
2365 { (yyval.ival) = '['; ;}
Carl Worth667173e2010-07-28 12:33:56 -07002366 break;
2367
2368 case 71:
2369
2370/* Line 1455 of yacc.c */
Eric Anholtd4a04f32010-07-28 16:58:39 -07002371#line 467 "glcpp/glcpp-parse.y"
2372 { (yyval.ival) = ']'; ;}
Carl Worth667173e2010-07-28 12:33:56 -07002373 break;
2374
2375 case 72:
2376
2377/* Line 1455 of yacc.c */
Eric Anholtd4a04f32010-07-28 16:58:39 -07002378#line 468 "glcpp/glcpp-parse.y"
2379 { (yyval.ival) = '('; ;}
Carl Worth667173e2010-07-28 12:33:56 -07002380 break;
2381
2382 case 73:
2383
2384/* Line 1455 of yacc.c */
Eric Anholtd4a04f32010-07-28 16:58:39 -07002385#line 469 "glcpp/glcpp-parse.y"
2386 { (yyval.ival) = ')'; ;}
Carl Worth667173e2010-07-28 12:33:56 -07002387 break;
2388
2389 case 74:
2390
2391/* Line 1455 of yacc.c */
Eric Anholtd4a04f32010-07-28 16:58:39 -07002392#line 470 "glcpp/glcpp-parse.y"
2393 { (yyval.ival) = '{'; ;}
Carl Worth667173e2010-07-28 12:33:56 -07002394 break;
2395
2396 case 75:
2397
2398/* Line 1455 of yacc.c */
Eric Anholtd4a04f32010-07-28 16:58:39 -07002399#line 471 "glcpp/glcpp-parse.y"
2400 { (yyval.ival) = '}'; ;}
Carl Worth667173e2010-07-28 12:33:56 -07002401 break;
2402
2403 case 76:
2404
2405/* Line 1455 of yacc.c */
Eric Anholtd4a04f32010-07-28 16:58:39 -07002406#line 472 "glcpp/glcpp-parse.y"
2407 { (yyval.ival) = '.'; ;}
Carl Worth667173e2010-07-28 12:33:56 -07002408 break;
2409
2410 case 77:
2411
2412/* Line 1455 of yacc.c */
Eric Anholtd4a04f32010-07-28 16:58:39 -07002413#line 473 "glcpp/glcpp-parse.y"
2414 { (yyval.ival) = '&'; ;}
Carl Worth667173e2010-07-28 12:33:56 -07002415 break;
2416
2417 case 78:
2418
2419/* Line 1455 of yacc.c */
Eric Anholtd4a04f32010-07-28 16:58:39 -07002420#line 474 "glcpp/glcpp-parse.y"
2421 { (yyval.ival) = '*'; ;}
Carl Worth667173e2010-07-28 12:33:56 -07002422 break;
2423
2424 case 79:
2425
2426/* Line 1455 of yacc.c */
Eric Anholtd4a04f32010-07-28 16:58:39 -07002427#line 475 "glcpp/glcpp-parse.y"
2428 { (yyval.ival) = '+'; ;}
Carl Worth667173e2010-07-28 12:33:56 -07002429 break;
2430
2431 case 80:
2432
2433/* Line 1455 of yacc.c */
Eric Anholtd4a04f32010-07-28 16:58:39 -07002434#line 476 "glcpp/glcpp-parse.y"
2435 { (yyval.ival) = '-'; ;}
Carl Worth667173e2010-07-28 12:33:56 -07002436 break;
2437
2438 case 81:
2439
2440/* Line 1455 of yacc.c */
Eric Anholtd4a04f32010-07-28 16:58:39 -07002441#line 477 "glcpp/glcpp-parse.y"
2442 { (yyval.ival) = '~'; ;}
Carl Worth667173e2010-07-28 12:33:56 -07002443 break;
2444
2445 case 82:
2446
2447/* Line 1455 of yacc.c */
Eric Anholtd4a04f32010-07-28 16:58:39 -07002448#line 478 "glcpp/glcpp-parse.y"
2449 { (yyval.ival) = '!'; ;}
Carl Worth667173e2010-07-28 12:33:56 -07002450 break;
2451
2452 case 83:
2453
2454/* Line 1455 of yacc.c */
Eric Anholtd4a04f32010-07-28 16:58:39 -07002455#line 479 "glcpp/glcpp-parse.y"
2456 { (yyval.ival) = '/'; ;}
Carl Worth667173e2010-07-28 12:33:56 -07002457 break;
2458
2459 case 84:
2460
2461/* Line 1455 of yacc.c */
Eric Anholtd4a04f32010-07-28 16:58:39 -07002462#line 480 "glcpp/glcpp-parse.y"
2463 { (yyval.ival) = '%'; ;}
Carl Worth667173e2010-07-28 12:33:56 -07002464 break;
2465
2466 case 85:
2467
2468/* Line 1455 of yacc.c */
Eric Anholtd4a04f32010-07-28 16:58:39 -07002469#line 481 "glcpp/glcpp-parse.y"
2470 { (yyval.ival) = LEFT_SHIFT; ;}
Carl Worth667173e2010-07-28 12:33:56 -07002471 break;
2472
2473 case 86:
2474
2475/* Line 1455 of yacc.c */
Eric Anholtd4a04f32010-07-28 16:58:39 -07002476#line 482 "glcpp/glcpp-parse.y"
2477 { (yyval.ival) = RIGHT_SHIFT; ;}
Carl Worth667173e2010-07-28 12:33:56 -07002478 break;
2479
2480 case 87:
2481
2482/* Line 1455 of yacc.c */
Eric Anholtd4a04f32010-07-28 16:58:39 -07002483#line 483 "glcpp/glcpp-parse.y"
2484 { (yyval.ival) = '<'; ;}
Carl Worth667173e2010-07-28 12:33:56 -07002485 break;
2486
2487 case 88:
2488
2489/* Line 1455 of yacc.c */
Eric Anholtd4a04f32010-07-28 16:58:39 -07002490#line 484 "glcpp/glcpp-parse.y"
2491 { (yyval.ival) = '>'; ;}
Carl Worth667173e2010-07-28 12:33:56 -07002492 break;
2493
2494 case 89:
2495
2496/* Line 1455 of yacc.c */
Eric Anholtd4a04f32010-07-28 16:58:39 -07002497#line 485 "glcpp/glcpp-parse.y"
2498 { (yyval.ival) = LESS_OR_EQUAL; ;}
Carl Worth667173e2010-07-28 12:33:56 -07002499 break;
2500
2501 case 90:
2502
2503/* Line 1455 of yacc.c */
Eric Anholtd4a04f32010-07-28 16:58:39 -07002504#line 486 "glcpp/glcpp-parse.y"
2505 { (yyval.ival) = GREATER_OR_EQUAL; ;}
Carl Worth667173e2010-07-28 12:33:56 -07002506 break;
2507
2508 case 91:
2509
2510/* Line 1455 of yacc.c */
Eric Anholtd4a04f32010-07-28 16:58:39 -07002511#line 487 "glcpp/glcpp-parse.y"
2512 { (yyval.ival) = EQUAL; ;}
Carl Worth667173e2010-07-28 12:33:56 -07002513 break;
2514
2515 case 92:
2516
2517/* Line 1455 of yacc.c */
Eric Anholtd4a04f32010-07-28 16:58:39 -07002518#line 488 "glcpp/glcpp-parse.y"
2519 { (yyval.ival) = NOT_EQUAL; ;}
Carl Worth667173e2010-07-28 12:33:56 -07002520 break;
2521
2522 case 93:
2523
2524/* Line 1455 of yacc.c */
Eric Anholtd4a04f32010-07-28 16:58:39 -07002525#line 489 "glcpp/glcpp-parse.y"
2526 { (yyval.ival) = '^'; ;}
Carl Worth667173e2010-07-28 12:33:56 -07002527 break;
2528
2529 case 94:
2530
2531/* Line 1455 of yacc.c */
Eric Anholtd4a04f32010-07-28 16:58:39 -07002532#line 490 "glcpp/glcpp-parse.y"
2533 { (yyval.ival) = '|'; ;}
Carl Worth667173e2010-07-28 12:33:56 -07002534 break;
2535
2536 case 95:
2537
2538/* Line 1455 of yacc.c */
Eric Anholtd4a04f32010-07-28 16:58:39 -07002539#line 491 "glcpp/glcpp-parse.y"
2540 { (yyval.ival) = AND; ;}
Carl Worth667173e2010-07-28 12:33:56 -07002541 break;
2542
2543 case 96:
2544
2545/* Line 1455 of yacc.c */
Eric Anholtd4a04f32010-07-28 16:58:39 -07002546#line 492 "glcpp/glcpp-parse.y"
2547 { (yyval.ival) = OR; ;}
Carl Worth667173e2010-07-28 12:33:56 -07002548 break;
2549
2550 case 97:
2551
2552/* Line 1455 of yacc.c */
Eric Anholtd4a04f32010-07-28 16:58:39 -07002553#line 493 "glcpp/glcpp-parse.y"
2554 { (yyval.ival) = ';'; ;}
Carl Worth667173e2010-07-28 12:33:56 -07002555 break;
2556
2557 case 98:
2558
2559/* Line 1455 of yacc.c */
Eric Anholtd4a04f32010-07-28 16:58:39 -07002560#line 494 "glcpp/glcpp-parse.y"
2561 { (yyval.ival) = ','; ;}
2562 break;
2563
2564 case 99:
2565
2566/* Line 1455 of yacc.c */
2567#line 495 "glcpp/glcpp-parse.y"
2568 { (yyval.ival) = '='; ;}
2569 break;
2570
2571 case 100:
2572
2573/* Line 1455 of yacc.c */
2574#line 496 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07002575 { (yyval.ival) = PASTE; ;}
2576 break;
2577
2578
2579
2580/* Line 1455 of yacc.c */
Eric Anholtd4a04f32010-07-28 16:58:39 -07002581#line 2582 "glcpp/glcpp-parse.c"
Carl Worth667173e2010-07-28 12:33:56 -07002582 default: break;
2583 }
2584 YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
2585
2586 YYPOPSTACK (yylen);
2587 yylen = 0;
2588 YY_STACK_PRINT (yyss, yyssp);
2589
2590 *++yyvsp = yyval;
2591 *++yylsp = yyloc;
2592
2593 /* Now `shift' the result of the reduction. Determine what state
2594 that goes to, based on the state we popped back to and the rule
2595 number reduced by. */
2596
2597 yyn = yyr1[yyn];
2598
2599 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
2600 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
2601 yystate = yytable[yystate];
2602 else
2603 yystate = yydefgoto[yyn - YYNTOKENS];
2604
2605 goto yynewstate;
2606
2607
2608/*------------------------------------.
2609| yyerrlab -- here on detecting error |
2610`------------------------------------*/
2611yyerrlab:
2612 /* If not already recovering from an error, report this error. */
2613 if (!yyerrstatus)
2614 {
2615 ++yynerrs;
2616#if ! YYERROR_VERBOSE
2617 yyerror (&yylloc, parser, YY_("syntax error"));
2618#else
2619 {
2620 YYSIZE_T yysize = yysyntax_error (0, yystate, yychar);
2621 if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM)
2622 {
2623 YYSIZE_T yyalloc = 2 * yysize;
2624 if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM))
2625 yyalloc = YYSTACK_ALLOC_MAXIMUM;
2626 if (yymsg != yymsgbuf)
2627 YYSTACK_FREE (yymsg);
2628 yymsg = (char *) YYSTACK_ALLOC (yyalloc);
2629 if (yymsg)
2630 yymsg_alloc = yyalloc;
2631 else
2632 {
2633 yymsg = yymsgbuf;
2634 yymsg_alloc = sizeof yymsgbuf;
2635 }
2636 }
2637
2638 if (0 < yysize && yysize <= yymsg_alloc)
2639 {
2640 (void) yysyntax_error (yymsg, yystate, yychar);
2641 yyerror (&yylloc, parser, yymsg);
2642 }
2643 else
2644 {
2645 yyerror (&yylloc, parser, YY_("syntax error"));
2646 if (yysize != 0)
2647 goto yyexhaustedlab;
2648 }
2649 }
2650#endif
2651 }
2652
2653 yyerror_range[0] = yylloc;
2654
2655 if (yyerrstatus == 3)
2656 {
2657 /* If just tried and failed to reuse lookahead token after an
2658 error, discard it. */
2659
2660 if (yychar <= YYEOF)
2661 {
2662 /* Return failure if at end of input. */
2663 if (yychar == YYEOF)
2664 YYABORT;
2665 }
2666 else
2667 {
2668 yydestruct ("Error: discarding",
2669 yytoken, &yylval, &yylloc, parser);
2670 yychar = YYEMPTY;
2671 }
2672 }
2673
2674 /* Else will try to reuse lookahead token after shifting the error
2675 token. */
2676 goto yyerrlab1;
2677
2678
2679/*---------------------------------------------------.
2680| yyerrorlab -- error raised explicitly by YYERROR. |
2681`---------------------------------------------------*/
2682yyerrorlab:
2683
2684 /* Pacify compilers like GCC when the user code never invokes
2685 YYERROR and the label yyerrorlab therefore never appears in user
2686 code. */
2687 if (/*CONSTCOND*/ 0)
2688 goto yyerrorlab;
2689
2690 yyerror_range[0] = yylsp[1-yylen];
2691 /* Do not reclaim the symbols of the rule which action triggered
2692 this YYERROR. */
2693 YYPOPSTACK (yylen);
2694 yylen = 0;
2695 YY_STACK_PRINT (yyss, yyssp);
2696 yystate = *yyssp;
2697 goto yyerrlab1;
2698
2699
2700/*-------------------------------------------------------------.
2701| yyerrlab1 -- common code for both syntax error and YYERROR. |
2702`-------------------------------------------------------------*/
2703yyerrlab1:
2704 yyerrstatus = 3; /* Each real token shifted decrements this. */
2705
2706 for (;;)
2707 {
2708 yyn = yypact[yystate];
2709 if (yyn != YYPACT_NINF)
2710 {
2711 yyn += YYTERROR;
2712 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
2713 {
2714 yyn = yytable[yyn];
2715 if (0 < yyn)
2716 break;
2717 }
2718 }
2719
2720 /* Pop the current state because it cannot handle the error token. */
2721 if (yyssp == yyss)
2722 YYABORT;
2723
2724 yyerror_range[0] = *yylsp;
2725 yydestruct ("Error: popping",
2726 yystos[yystate], yyvsp, yylsp, parser);
2727 YYPOPSTACK (1);
2728 yystate = *yyssp;
2729 YY_STACK_PRINT (yyss, yyssp);
2730 }
2731
2732 *++yyvsp = yylval;
2733
2734 yyerror_range[1] = yylloc;
2735 /* Using YYLLOC is tempting, but would change the location of
2736 the lookahead. YYLOC is available though. */
2737 YYLLOC_DEFAULT (yyloc, (yyerror_range - 1), 2);
2738 *++yylsp = yyloc;
2739
2740 /* Shift the error token. */
2741 YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
2742
2743 yystate = yyn;
2744 goto yynewstate;
2745
2746
2747/*-------------------------------------.
2748| yyacceptlab -- YYACCEPT comes here. |
2749`-------------------------------------*/
2750yyacceptlab:
2751 yyresult = 0;
2752 goto yyreturn;
2753
2754/*-----------------------------------.
2755| yyabortlab -- YYABORT comes here. |
2756`-----------------------------------*/
2757yyabortlab:
2758 yyresult = 1;
2759 goto yyreturn;
2760
2761#if !defined(yyoverflow) || YYERROR_VERBOSE
2762/*-------------------------------------------------.
2763| yyexhaustedlab -- memory exhaustion comes here. |
2764`-------------------------------------------------*/
2765yyexhaustedlab:
2766 yyerror (&yylloc, parser, YY_("memory exhausted"));
2767 yyresult = 2;
2768 /* Fall through. */
2769#endif
2770
2771yyreturn:
2772 if (yychar != YYEMPTY)
2773 yydestruct ("Cleanup: discarding lookahead",
2774 yytoken, &yylval, &yylloc, parser);
2775 /* Do not reclaim the symbols of the rule which action triggered
2776 this YYABORT or YYACCEPT. */
2777 YYPOPSTACK (yylen);
2778 YY_STACK_PRINT (yyss, yyssp);
2779 while (yyssp != yyss)
2780 {
2781 yydestruct ("Cleanup: popping",
2782 yystos[*yyssp], yyvsp, yylsp, parser);
2783 YYPOPSTACK (1);
2784 }
2785#ifndef yyoverflow
2786 if (yyss != yyssa)
2787 YYSTACK_FREE (yyss);
2788#endif
2789#if YYERROR_VERBOSE
2790 if (yymsg != yymsgbuf)
2791 YYSTACK_FREE (yymsg);
2792#endif
2793 /* Make sure YYID is used. */
2794 return YYID (yyresult);
2795}
2796
2797
2798
2799/* Line 1675 of yacc.c */
Eric Anholtd4a04f32010-07-28 16:58:39 -07002800#line 499 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07002801
2802
2803string_list_t *
2804_string_list_create (void *ctx)
2805{
2806 string_list_t *list;
2807
2808 list = xtalloc (ctx, string_list_t);
2809 list->head = NULL;
2810 list->tail = NULL;
2811
2812 return list;
2813}
2814
2815void
2816_string_list_append_item (string_list_t *list, const char *str)
2817{
2818 string_node_t *node;
2819
2820 node = xtalloc (list, string_node_t);
2821 node->str = xtalloc_strdup (node, str);
2822
2823 node->next = NULL;
2824
2825 if (list->head == NULL) {
2826 list->head = node;
2827 } else {
2828 list->tail->next = node;
2829 }
2830
2831 list->tail = node;
2832}
2833
2834int
2835_string_list_contains (string_list_t *list, const char *member, int *index)
2836{
2837 string_node_t *node;
2838 int i;
2839
2840 if (list == NULL)
2841 return 0;
2842
2843 for (i = 0, node = list->head; node; i++, node = node->next) {
2844 if (strcmp (node->str, member) == 0) {
2845 if (index)
2846 *index = i;
2847 return 1;
2848 }
2849 }
2850
2851 return 0;
2852}
2853
2854int
2855_string_list_length (string_list_t *list)
2856{
2857 int length = 0;
2858 string_node_t *node;
2859
2860 if (list == NULL)
2861 return 0;
2862
2863 for (node = list->head; node; node = node->next)
2864 length++;
2865
2866 return length;
2867}
2868
2869argument_list_t *
2870_argument_list_create (void *ctx)
2871{
2872 argument_list_t *list;
2873
2874 list = xtalloc (ctx, argument_list_t);
2875 list->head = NULL;
2876 list->tail = NULL;
2877
2878 return list;
2879}
2880
2881void
2882_argument_list_append (argument_list_t *list, token_list_t *argument)
2883{
2884 argument_node_t *node;
2885
2886 node = xtalloc (list, argument_node_t);
2887 node->argument = argument;
2888
2889 node->next = NULL;
2890
2891 if (list->head == NULL) {
2892 list->head = node;
2893 } else {
2894 list->tail->next = node;
2895 }
2896
2897 list->tail = node;
2898}
2899
2900int
2901_argument_list_length (argument_list_t *list)
2902{
2903 int length = 0;
2904 argument_node_t *node;
2905
2906 if (list == NULL)
2907 return 0;
2908
2909 for (node = list->head; node; node = node->next)
2910 length++;
2911
2912 return length;
2913}
2914
2915token_list_t *
2916_argument_list_member_at (argument_list_t *list, int index)
2917{
2918 argument_node_t *node;
2919 int i;
2920
2921 if (list == NULL)
2922 return NULL;
2923
2924 node = list->head;
2925 for (i = 0; i < index; i++) {
2926 node = node->next;
2927 if (node == NULL)
2928 break;
2929 }
2930
2931 if (node)
2932 return node->argument;
2933
2934 return NULL;
2935}
2936
2937/* Note: This function talloc_steal()s the str pointer. */
2938token_t *
2939_token_create_str (void *ctx, int type, char *str)
2940{
2941 token_t *token;
2942
2943 token = xtalloc (ctx, token_t);
2944 token->type = type;
2945 token->value.str = talloc_steal (token, str);
2946
2947 return token;
2948}
2949
2950token_t *
2951_token_create_ival (void *ctx, int type, int ival)
2952{
2953 token_t *token;
2954
2955 token = xtalloc (ctx, token_t);
2956 token->type = type;
2957 token->value.ival = ival;
2958
2959 return token;
2960}
2961
2962token_list_t *
2963_token_list_create (void *ctx)
2964{
2965 token_list_t *list;
2966
2967 list = xtalloc (ctx, token_list_t);
2968 list->head = NULL;
2969 list->tail = NULL;
2970 list->non_space_tail = NULL;
2971
2972 return list;
2973}
2974
2975void
2976_token_list_append (token_list_t *list, token_t *token)
2977{
2978 token_node_t *node;
2979
2980 node = xtalloc (list, token_node_t);
2981 node->token = xtalloc_reference (list, token);
2982
2983 node->next = NULL;
2984
2985 if (list->head == NULL) {
2986 list->head = node;
2987 } else {
2988 list->tail->next = node;
2989 }
2990
2991 list->tail = node;
2992 if (token->type != SPACE)
2993 list->non_space_tail = node;
2994}
2995
2996void
2997_token_list_append_list (token_list_t *list, token_list_t *tail)
2998{
2999 if (tail == NULL || tail->head == NULL)
3000 return;
3001
3002 if (list->head == NULL) {
3003 list->head = tail->head;
3004 } else {
3005 list->tail->next = tail->head;
3006 }
3007
3008 list->tail = tail->tail;
3009 list->non_space_tail = tail->non_space_tail;
3010}
3011
3012static token_list_t *
3013_token_list_copy (void *ctx, token_list_t *other)
3014{
3015 token_list_t *copy;
3016 token_node_t *node;
3017
3018 if (other == NULL)
3019 return NULL;
3020
3021 copy = _token_list_create (ctx);
3022 for (node = other->head; node; node = node->next)
3023 _token_list_append (copy, node->token);
3024
3025 return copy;
3026}
3027
3028static void
3029_token_list_trim_trailing_space (token_list_t *list)
3030{
3031 token_node_t *tail, *next;
3032
3033 if (list->non_space_tail) {
3034 tail = list->non_space_tail->next;
3035 list->non_space_tail->next = NULL;
3036 list->tail = list->non_space_tail;
3037
3038 while (tail) {
3039 next = tail->next;
3040 talloc_free (tail);
3041 tail = next;
3042 }
3043 }
3044}
3045
3046static void
3047_token_print (char **out, token_t *token)
3048{
3049 if (token->type < 256) {
3050 glcpp_printf (*out, "%c", token->type);
3051 return;
3052 }
3053
3054 switch (token->type) {
3055 case INTEGER:
Eric Anholt8605c292010-07-28 16:53:51 -07003056 glcpp_printf (*out, "%" PRIiMAX, token->value.ival);
Carl Worth667173e2010-07-28 12:33:56 -07003057 break;
3058 case IDENTIFIER:
3059 case INTEGER_STRING:
3060 case OTHER:
3061 glcpp_print (*out, token->value.str);
3062 break;
3063 case SPACE:
3064 glcpp_print (*out, " ");
3065 break;
3066 case LEFT_SHIFT:
3067 glcpp_print (*out, "<<");
3068 break;
3069 case RIGHT_SHIFT:
3070 glcpp_print (*out, ">>");
3071 break;
3072 case LESS_OR_EQUAL:
3073 glcpp_print (*out, "<=");
3074 break;
3075 case GREATER_OR_EQUAL:
3076 glcpp_print (*out, ">=");
3077 break;
3078 case EQUAL:
3079 glcpp_print (*out, "==");
3080 break;
3081 case NOT_EQUAL:
3082 glcpp_print (*out, "!=");
3083 break;
3084 case AND:
3085 glcpp_print (*out, "&&");
3086 break;
3087 case OR:
3088 glcpp_print (*out, "||");
3089 break;
3090 case PASTE:
3091 glcpp_print (*out, "##");
3092 break;
3093 case COMMA_FINAL:
3094 glcpp_print (*out, ",");
3095 break;
3096 case PLACEHOLDER:
3097 /* Nothing to print. */
3098 break;
3099 default:
3100 assert(!"Error: Don't know how to print token.");
3101 break;
3102 }
3103}
3104
3105/* Return a new token (talloc()ed off of 'token') formed by pasting
3106 * 'token' and 'other'. Note that this function may return 'token' or
3107 * 'other' directly rather than allocating anything new.
3108 *
3109 * Caution: Only very cursory error-checking is performed to see if
3110 * the final result is a valid single token. */
3111static token_t *
3112_token_paste (glcpp_parser_t *parser, token_t *token, token_t *other)
3113{
3114 token_t *combined = NULL;
3115
3116 /* Pasting a placeholder onto anything makes no change. */
3117 if (other->type == PLACEHOLDER)
3118 return token;
3119
3120 /* When 'token' is a placeholder, just return 'other'. */
3121 if (token->type == PLACEHOLDER)
3122 return other;
3123
3124 /* A very few single-character punctuators can be combined
3125 * with another to form a multi-character punctuator. */
3126 switch (token->type) {
3127 case '<':
3128 if (other->type == '<')
3129 combined = _token_create_ival (token, LEFT_SHIFT, LEFT_SHIFT);
3130 else if (other->type == '=')
3131 combined = _token_create_ival (token, LESS_OR_EQUAL, LESS_OR_EQUAL);
3132 break;
3133 case '>':
3134 if (other->type == '>')
3135 combined = _token_create_ival (token, RIGHT_SHIFT, RIGHT_SHIFT);
3136 else if (other->type == '=')
3137 combined = _token_create_ival (token, GREATER_OR_EQUAL, GREATER_OR_EQUAL);
3138 break;
3139 case '=':
3140 if (other->type == '=')
3141 combined = _token_create_ival (token, EQUAL, EQUAL);
3142 break;
3143 case '!':
3144 if (other->type == '=')
3145 combined = _token_create_ival (token, NOT_EQUAL, NOT_EQUAL);
3146 break;
3147 case '&':
3148 if (other->type == '&')
3149 combined = _token_create_ival (token, AND, AND);
3150 break;
3151 case '|':
3152 if (other->type == '|')
3153 combined = _token_create_ival (token, OR, OR);
3154 break;
3155 }
3156
3157 if (combined != NULL) {
3158 /* Inherit the location from the first token */
3159 combined->location = token->location;
3160 return combined;
3161 }
3162
3163 /* Two string-valued tokens can usually just be mashed
3164 * together.
3165 *
3166 * XXX: This isn't actually legitimate. Several things here
3167 * should result in a diagnostic since the result cannot be a
3168 * valid, single pre-processing token. For example, pasting
3169 * "123" and "abc" is not legal, but we don't catch that
3170 * here. */
3171 if ((token->type == IDENTIFIER || token->type == OTHER || token->type == INTEGER_STRING) &&
3172 (other->type == IDENTIFIER || other->type == OTHER || other->type == INTEGER_STRING))
3173 {
3174 char *str;
3175
3176 str = xtalloc_asprintf (token, "%s%s",
3177 token->value.str, other->value.str);
3178 combined = _token_create_str (token, token->type, str);
3179 combined->location = token->location;
3180 return combined;
3181 }
3182
3183 glcpp_error (&token->location, parser, "");
3184 glcpp_print (parser->info_log, "Pasting \"");
3185 _token_print (&parser->info_log, token);
3186 glcpp_print (parser->info_log, "\" and \"");
3187 _token_print (&parser->info_log, other);
3188 glcpp_print (parser->info_log, "\" does not give a valid preprocessing token.\n");
3189
3190 return token;
3191}
3192
3193static void
3194_token_list_print (glcpp_parser_t *parser, token_list_t *list)
3195{
3196 token_node_t *node;
3197
3198 if (list == NULL)
3199 return;
3200
3201 for (node = list->head; node; node = node->next)
3202 _token_print (&parser->output, node->token);
3203}
3204
3205void
3206yyerror (YYLTYPE *locp, glcpp_parser_t *parser, const char *error)
3207{
3208 glcpp_error(locp, parser, "%s", error);
3209}
3210
Eric Anholtd4a04f32010-07-28 16:58:39 -07003211static void add_builtin_define(glcpp_parser_t *parser,
3212 const char *name, int value)
3213{
3214 token_t *tok;
3215 token_list_t *list;
3216
3217 tok = _token_create_ival (parser, INTEGER, value);
3218
3219 list = _token_list_create(parser);
3220 _token_list_append(list, tok);
3221 _define_object_macro(parser, NULL, name, list);
3222
3223 talloc_unlink(parser, tok);
3224}
3225
Carl Worth667173e2010-07-28 12:33:56 -07003226glcpp_parser_t *
3227glcpp_parser_create (const struct gl_extensions *extensions)
3228{
3229 glcpp_parser_t *parser;
Eric Anholtd4a04f32010-07-28 16:58:39 -07003230 int language_version;
Carl Worth667173e2010-07-28 12:33:56 -07003231
3232 parser = xtalloc (NULL, glcpp_parser_t);
3233
3234 glcpp_lex_init_extra (parser, &parser->scanner);
3235 parser->defines = hash_table_ctor (32, hash_table_string_hash,
3236 hash_table_string_compare);
3237 parser->active = NULL;
3238 parser->lexing_if = 0;
3239 parser->space_tokens = 1;
3240 parser->newline_as_space = 0;
3241 parser->in_control_line = 0;
3242 parser->paren_count = 0;
3243
3244 parser->skip_stack = NULL;
3245
3246 parser->lex_from_list = NULL;
3247 parser->lex_from_node = NULL;
3248
3249 parser->output = talloc_strdup(parser, "");
3250 parser->info_log = talloc_strdup(parser, "");
3251 parser->error = 0;
3252
3253 /* Add pre-defined macros. */
Eric Anholtd4a04f32010-07-28 16:58:39 -07003254 add_builtin_define(parser, "GL_ARB_draw_buffers", 1);
3255 add_builtin_define(parser, "GL_ARB_texture_rectangle", 1);
Carl Worth667173e2010-07-28 12:33:56 -07003256
Eric Anholtd4a04f32010-07-28 16:58:39 -07003257 if (extensions != NULL) {
3258 if (extensions->EXT_texture_array) {
3259 add_builtin_define(parser, "GL_EXT_texture_array", 1);
3260 }
Carl Worth667173e2010-07-28 12:33:56 -07003261
Eric Anholtd4a04f32010-07-28 16:58:39 -07003262 if (extensions->ARB_fragment_coord_conventions)
3263 add_builtin_define(parser, "GL_ARB_fragment_coord_conventions",
3264 1);
Carl Worth667173e2010-07-28 12:33:56 -07003265 }
3266
Eric Anholtd4a04f32010-07-28 16:58:39 -07003267 language_version = 110;
3268 if (extensions && extensions->ARB_shading_language_120) {
3269 language_version = 120;
Eric Anholt0c7b37c2010-07-28 14:58:31 -07003270 }
Eric Anholtd4a04f32010-07-28 16:58:39 -07003271 add_builtin_define(parser, "__VERSION__", language_version);
Carl Worth667173e2010-07-28 12:33:56 -07003272
3273 return parser;
3274}
3275
3276int
3277glcpp_parser_parse (glcpp_parser_t *parser)
3278{
3279 return yyparse (parser);
3280}
3281
3282void
3283glcpp_parser_destroy (glcpp_parser_t *parser)
3284{
3285 if (parser->skip_stack)
3286 glcpp_error (&parser->skip_stack->loc, parser, "Unterminated #if\n");
3287 glcpp_lex_destroy (parser->scanner);
3288 hash_table_dtor (parser->defines);
3289 talloc_free (parser);
3290}
3291
3292typedef enum function_status
3293{
3294 FUNCTION_STATUS_SUCCESS,
3295 FUNCTION_NOT_A_FUNCTION,
3296 FUNCTION_UNBALANCED_PARENTHESES
3297} function_status_t;
3298
3299/* Find a set of function-like macro arguments by looking for a
3300 * balanced set of parentheses.
3301 *
3302 * When called, 'node' should be the opening-parenthesis token, (or
3303 * perhaps preceeding SPACE tokens). Upon successful return *last will
3304 * be the last consumed node, (corresponding to the closing right
3305 * parenthesis).
3306 *
3307 * Return values:
3308 *
3309 * FUNCTION_STATUS_SUCCESS:
3310 *
3311 * Successfully parsed a set of function arguments.
3312 *
3313 * FUNCTION_NOT_A_FUNCTION:
3314 *
3315 * Macro name not followed by a '('. This is not an error, but
3316 * simply that the macro name should be treated as a non-macro.
3317 *
3318 * FUNCTION_UNBALANCED_PARENTHESES
3319 *
3320 * Macro name is not followed by a balanced set of parentheses.
3321 */
3322static function_status_t
3323_arguments_parse (argument_list_t *arguments,
3324 token_node_t *node,
3325 token_node_t **last)
3326{
3327 token_list_t *argument;
3328 int paren_count;
3329
3330 node = node->next;
3331
3332 /* Ignore whitespace before first parenthesis. */
3333 while (node && node->token->type == SPACE)
3334 node = node->next;
3335
3336 if (node == NULL || node->token->type != '(')
3337 return FUNCTION_NOT_A_FUNCTION;
3338
3339 node = node->next;
3340
3341 argument = _token_list_create (arguments);
3342 _argument_list_append (arguments, argument);
3343
3344 for (paren_count = 1; node; node = node->next) {
3345 if (node->token->type == '(')
3346 {
3347 paren_count++;
3348 }
3349 else if (node->token->type == ')')
3350 {
3351 paren_count--;
3352 if (paren_count == 0)
3353 break;
3354 }
3355
3356 if (node->token->type == ',' &&
3357 paren_count == 1)
3358 {
3359 _token_list_trim_trailing_space (argument);
3360 argument = _token_list_create (arguments);
3361 _argument_list_append (arguments, argument);
3362 }
3363 else {
3364 if (argument->head == NULL) {
3365 /* Don't treat initial whitespace as
3366 * part of the arguement. */
3367 if (node->token->type == SPACE)
3368 continue;
3369 }
3370 _token_list_append (argument, node->token);
3371 }
3372 }
3373
3374 if (paren_count)
3375 return FUNCTION_UNBALANCED_PARENTHESES;
3376
3377 *last = node;
3378
3379 return FUNCTION_STATUS_SUCCESS;
3380}
3381
3382static token_list_t *
3383_token_list_create_with_one_space (void *ctx)
3384{
3385 token_list_t *list;
3386 token_t *space;
3387
3388 list = _token_list_create (ctx);
3389 space = _token_create_ival (list, SPACE, SPACE);
3390 _token_list_append (list, space);
3391
3392 return list;
3393}
3394
3395/* This is a helper function that's essentially part of the
3396 * implementation of _glcpp_parser_expand_node. It shouldn't be called
3397 * except for by that function.
3398 *
3399 * Returns NULL if node is a simple token with no expansion, (that is,
3400 * although 'node' corresponds to an identifier defined as a
3401 * function-like macro, it is not followed with a parenthesized
3402 * argument list).
3403 *
3404 * Compute the complete expansion of node (which is a function-like
3405 * macro) and subsequent nodes which are arguments.
3406 *
3407 * Returns the token list that results from the expansion and sets
3408 * *last to the last node in the list that was consumed by the
3409 * expansion. Specifically, *last will be set as follows: as the
3410 * token of the closing right parenthesis.
3411 */
3412static token_list_t *
3413_glcpp_parser_expand_function (glcpp_parser_t *parser,
3414 token_node_t *node,
3415 token_node_t **last)
3416
3417{
3418 macro_t *macro;
3419 const char *identifier;
3420 argument_list_t *arguments;
3421 function_status_t status;
3422 token_list_t *substituted;
3423 int parameter_index;
3424
3425 identifier = node->token->value.str;
3426
3427 macro = hash_table_find (parser->defines, identifier);
3428
3429 assert (macro->is_function);
3430
3431 arguments = _argument_list_create (parser);
3432 status = _arguments_parse (arguments, node, last);
3433
3434 switch (status) {
3435 case FUNCTION_STATUS_SUCCESS:
3436 break;
3437 case FUNCTION_NOT_A_FUNCTION:
3438 return NULL;
3439 case FUNCTION_UNBALANCED_PARENTHESES:
3440 glcpp_error (&node->token->location, parser, "Macro %s call has unbalanced parentheses\n", identifier);
3441 return NULL;
3442 }
3443
3444 /* Replace a macro defined as empty with a SPACE token. */
3445 if (macro->replacements == NULL) {
3446 talloc_free (arguments);
3447 return _token_list_create_with_one_space (parser);
3448 }
3449
3450 if (! ((_argument_list_length (arguments) ==
3451 _string_list_length (macro->parameters)) ||
3452 (_string_list_length (macro->parameters) == 0 &&
3453 _argument_list_length (arguments) == 1 &&
3454 arguments->head->argument->head == NULL)))
3455 {
3456 glcpp_error (&node->token->location, parser,
3457 "Error: macro %s invoked with %d arguments (expected %d)\n",
3458 identifier,
3459 _argument_list_length (arguments),
3460 _string_list_length (macro->parameters));
3461 return NULL;
3462 }
3463
3464 /* Perform argument substitution on the replacement list. */
3465 substituted = _token_list_create (arguments);
3466
3467 for (node = macro->replacements->head; node; node = node->next)
3468 {
3469 if (node->token->type == IDENTIFIER &&
3470 _string_list_contains (macro->parameters,
3471 node->token->value.str,
3472 &parameter_index))
3473 {
3474 token_list_t *argument;
3475 argument = _argument_list_member_at (arguments,
3476 parameter_index);
3477 /* Before substituting, we expand the argument
3478 * tokens, or append a placeholder token for
3479 * an empty argument. */
3480 if (argument->head) {
3481 token_list_t *expanded_argument;
3482 expanded_argument = _token_list_copy (parser,
3483 argument);
3484 _glcpp_parser_expand_token_list (parser,
3485 expanded_argument);
3486 _token_list_append_list (substituted,
3487 expanded_argument);
3488 } else {
3489 token_t *new_token;
3490
3491 new_token = _token_create_ival (substituted,
3492 PLACEHOLDER,
3493 PLACEHOLDER);
3494 _token_list_append (substituted, new_token);
3495 }
3496 } else {
3497 _token_list_append (substituted, node->token);
3498 }
3499 }
3500
3501 /* After argument substitution, and before further expansion
3502 * below, implement token pasting. */
3503
3504 _token_list_trim_trailing_space (substituted);
3505
3506 node = substituted->head;
3507 while (node)
3508 {
3509 token_node_t *next_non_space;
3510
3511 /* Look ahead for a PASTE token, skipping space. */
3512 next_non_space = node->next;
3513 while (next_non_space && next_non_space->token->type == SPACE)
3514 next_non_space = next_non_space->next;
3515
3516 if (next_non_space == NULL)
3517 break;
3518
3519 if (next_non_space->token->type != PASTE) {
3520 node = next_non_space;
3521 continue;
3522 }
3523
3524 /* Now find the next non-space token after the PASTE. */
3525 next_non_space = next_non_space->next;
3526 while (next_non_space && next_non_space->token->type == SPACE)
3527 next_non_space = next_non_space->next;
3528
3529 if (next_non_space == NULL) {
3530 yyerror (&node->token->location, parser, "'##' cannot appear at either end of a macro expansion\n");
3531 return NULL;
3532 }
3533
3534 node->token = _token_paste (parser, node->token, next_non_space->token);
3535 node->next = next_non_space->next;
3536 if (next_non_space == substituted->tail)
3537 substituted->tail = node;
3538
3539 node = node->next;
3540 }
3541
3542 substituted->non_space_tail = substituted->tail;
3543
3544 return substituted;
3545}
3546
3547/* Compute the complete expansion of node, (and subsequent nodes after
3548 * 'node' in the case that 'node' is a function-like macro and
3549 * subsequent nodes are arguments).
3550 *
3551 * Returns NULL if node is a simple token with no expansion.
3552 *
3553 * Otherwise, returns the token list that results from the expansion
3554 * and sets *last to the last node in the list that was consumed by
3555 * the expansion. Specifically, *last will be set as follows:
3556 *
3557 * As 'node' in the case of object-like macro expansion.
3558 *
3559 * As the token of the closing right parenthesis in the case of
3560 * function-like macro expansion.
3561 */
3562static token_list_t *
3563_glcpp_parser_expand_node (glcpp_parser_t *parser,
3564 token_node_t *node,
3565 token_node_t **last)
3566{
3567 token_t *token = node->token;
3568 const char *identifier;
3569 macro_t *macro;
3570
3571 /* We only expand identifiers */
3572 if (token->type != IDENTIFIER) {
3573 /* We change any COMMA into a COMMA_FINAL to prevent
3574 * it being mistaken for an argument separator
3575 * later. */
3576 if (token->type == ',') {
3577 token->type = COMMA_FINAL;
3578 token->value.ival = COMMA_FINAL;
3579 }
3580
3581 return NULL;
3582 }
3583
3584 /* Look up this identifier in the hash table. */
3585 identifier = token->value.str;
3586 macro = hash_table_find (parser->defines, identifier);
3587
3588 /* Not a macro, so no expansion needed. */
3589 if (macro == NULL)
3590 return NULL;
3591
3592 /* Finally, don't expand this macro if we're already actively
3593 * expanding it, (to avoid infinite recursion). */
3594 if (_active_list_contains (parser->active, identifier)) {
3595 /* We change the token type here from IDENTIFIER to
3596 * OTHER to prevent any future expansion of this
3597 * unexpanded token. */
3598 char *str;
3599 token_list_t *expansion;
3600 token_t *final;
3601
3602 str = xtalloc_strdup (parser, token->value.str);
3603 final = _token_create_str (parser, OTHER, str);
3604 expansion = _token_list_create (parser);
3605 _token_list_append (expansion, final);
3606 *last = node;
3607 return expansion;
3608 }
3609
3610 if (! macro->is_function)
3611 {
3612 *last = node;
3613
3614 /* Replace a macro defined as empty with a SPACE token. */
3615 if (macro->replacements == NULL)
3616 return _token_list_create_with_one_space (parser);
3617
3618 return _token_list_copy (parser, macro->replacements);
3619 }
3620
3621 return _glcpp_parser_expand_function (parser, node, last);
3622}
3623
3624/* Push a new identifier onto the active list, returning the new list.
3625 *
3626 * Here, 'marker' is the token node that appears in the list after the
3627 * expansion of 'identifier'. That is, when the list iterator begins
3628 * examinging 'marker', then it is time to pop this node from the
3629 * active stack.
3630 */
3631active_list_t *
3632_active_list_push (active_list_t *list,
3633 const char *identifier,
3634 token_node_t *marker)
3635{
3636 active_list_t *node;
3637
3638 node = xtalloc (list, active_list_t);
3639 node->identifier = xtalloc_strdup (node, identifier);
3640 node->marker = marker;
3641 node->next = list;
3642
3643 return node;
3644}
3645
3646active_list_t *
3647_active_list_pop (active_list_t *list)
3648{
3649 active_list_t *node = list;
3650
3651 if (node == NULL)
3652 return NULL;
3653
3654 node = list->next;
3655 talloc_free (list);
3656
3657 return node;
3658}
3659
3660int
3661_active_list_contains (active_list_t *list, const char *identifier)
3662{
3663 active_list_t *node;
3664
3665 if (list == NULL)
3666 return 0;
3667
3668 for (node = list; node; node = node->next)
3669 if (strcmp (node->identifier, identifier) == 0)
3670 return 1;
3671
3672 return 0;
3673}
3674
3675/* Walk over the token list replacing nodes with their expansion.
3676 * Whenever nodes are expanded the walking will walk over the new
3677 * nodes, continuing to expand as necessary. The results are placed in
3678 * 'list' itself;
3679 */
3680static void
3681_glcpp_parser_expand_token_list (glcpp_parser_t *parser,
3682 token_list_t *list)
3683{
3684 token_node_t *node_prev;
3685 token_node_t *node, *last = NULL;
3686 token_list_t *expansion;
3687
3688 if (list == NULL)
3689 return;
3690
3691 _token_list_trim_trailing_space (list);
3692
3693 node_prev = NULL;
3694 node = list->head;
3695
3696 while (node) {
3697
3698 while (parser->active && parser->active->marker == node)
3699 parser->active = _active_list_pop (parser->active);
3700
3701 /* Find the expansion for node, which will replace all
3702 * nodes from node to last, inclusive. */
3703 expansion = _glcpp_parser_expand_node (parser, node, &last);
3704 if (expansion) {
3705 token_node_t *n;
3706
3707 for (n = node; n != last->next; n = n->next)
3708 while (parser->active &&
3709 parser->active->marker == n)
3710 {
3711 parser->active = _active_list_pop (parser->active);
3712 }
3713
3714 parser->active = _active_list_push (parser->active,
3715 node->token->value.str,
3716 last->next);
3717
3718 /* Splice expansion into list, supporting a
3719 * simple deletion if the expansion is
3720 * empty. */
3721 if (expansion->head) {
3722 if (node_prev)
3723 node_prev->next = expansion->head;
3724 else
3725 list->head = expansion->head;
3726 expansion->tail->next = last->next;
3727 if (last == list->tail)
3728 list->tail = expansion->tail;
3729 } else {
3730 if (node_prev)
3731 node_prev->next = last->next;
3732 else
3733 list->head = last->next;
3734 if (last == list->tail)
3735 list->tail = NULL;
3736 }
3737 } else {
3738 node_prev = node;
3739 }
3740 node = node_prev ? node_prev->next : list->head;
3741 }
3742
3743 while (parser->active)
3744 parser->active = _active_list_pop (parser->active);
3745
3746 list->non_space_tail = list->tail;
3747}
3748
3749void
3750_glcpp_parser_print_expanded_token_list (glcpp_parser_t *parser,
3751 token_list_t *list)
3752{
3753 if (list == NULL)
3754 return;
3755
3756 _glcpp_parser_expand_token_list (parser, list);
3757
3758 _token_list_trim_trailing_space (list);
3759
3760 _token_list_print (parser, list);
3761}
3762
3763static void
3764_check_for_reserved_macro_name (glcpp_parser_t *parser, YYLTYPE *loc,
3765 const char *identifier)
3766{
3767 /* According to the GLSL specification, macro names starting with "__"
3768 * or "GL_" are reserved for future use. So, don't allow them.
3769 */
3770 if (strncmp(identifier, "__", 2) == 0) {
3771 glcpp_error (loc, parser, "Macro names starting with \"__\" are reserved.\n");
3772 }
3773 if (strncmp(identifier, "GL_", 3) == 0) {
3774 glcpp_error (loc, parser, "Macro names starting with \"GL_\" are reserved.\n");
3775 }
3776}
3777
3778void
3779_define_object_macro (glcpp_parser_t *parser,
3780 YYLTYPE *loc,
3781 const char *identifier,
3782 token_list_t *replacements)
3783{
3784 macro_t *macro;
3785
3786 if (loc != NULL)
3787 _check_for_reserved_macro_name(parser, loc, identifier);
3788
3789 macro = xtalloc (parser, macro_t);
3790
3791 macro->is_function = 0;
3792 macro->parameters = NULL;
3793 macro->identifier = talloc_strdup (macro, identifier);
3794 macro->replacements = talloc_steal (macro, replacements);
3795
3796 hash_table_insert (parser->defines, macro, identifier);
3797}
3798
3799void
3800_define_function_macro (glcpp_parser_t *parser,
3801 YYLTYPE *loc,
3802 const char *identifier,
3803 string_list_t *parameters,
3804 token_list_t *replacements)
3805{
3806 macro_t *macro;
3807
3808 _check_for_reserved_macro_name(parser, loc, identifier);
3809
3810 macro = xtalloc (parser, macro_t);
3811
3812 macro->is_function = 1;
3813 macro->parameters = talloc_steal (macro, parameters);
3814 macro->identifier = talloc_strdup (macro, identifier);
3815 macro->replacements = talloc_steal (macro, replacements);
3816
3817 hash_table_insert (parser->defines, macro, identifier);
3818}
3819
3820static int
3821glcpp_parser_lex (YYSTYPE *yylval, YYLTYPE *yylloc, glcpp_parser_t *parser)
3822{
3823 token_node_t *node;
3824 int ret;
3825
3826 if (parser->lex_from_list == NULL) {
3827 ret = glcpp_lex (yylval, yylloc, parser->scanner);
3828
3829 /* XXX: This ugly block of code exists for the sole
3830 * purpose of converting a NEWLINE token into a SPACE
3831 * token, but only in the case where we have seen a
3832 * function-like macro name, but have not yet seen its
3833 * closing parenthesis.
3834 *
3835 * There's perhaps a more compact way to do this with
3836 * mid-rule actions in the grammar.
3837 *
3838 * I'm definitely not pleased with the complexity of
3839 * this code here.
3840 */
3841 if (parser->newline_as_space)
3842 {
3843 if (ret == '(') {
3844 parser->paren_count++;
3845 } else if (ret == ')') {
3846 parser->paren_count--;
3847 if (parser->paren_count == 0)
3848 parser->newline_as_space = 0;
3849 } else if (ret == NEWLINE) {
3850 ret = SPACE;
3851 } else if (ret != SPACE) {
3852 if (parser->paren_count == 0)
3853 parser->newline_as_space = 0;
3854 }
3855 }
3856 else if (parser->in_control_line)
3857 {
3858 if (ret == NEWLINE)
3859 parser->in_control_line = 0;
3860 }
3861 else if (ret == HASH_DEFINE_OBJ || ret == HASH_DEFINE_FUNC ||
3862 ret == HASH_UNDEF || ret == HASH_IF ||
3863 ret == HASH_IFDEF || ret == HASH_IFNDEF ||
3864 ret == HASH_ELIF || ret == HASH_ELSE ||
3865 ret == HASH_ENDIF || ret == HASH)
3866 {
3867 parser->in_control_line = 1;
3868 }
3869 else if (ret == IDENTIFIER)
3870 {
3871 macro_t *macro;
3872 macro = hash_table_find (parser->defines,
3873 yylval->str);
3874 if (macro && macro->is_function) {
3875 parser->newline_as_space = 1;
3876 parser->paren_count = 0;
3877 }
3878 }
3879
3880 return ret;
3881 }
3882
3883 node = parser->lex_from_node;
3884
3885 if (node == NULL) {
3886 talloc_free (parser->lex_from_list);
3887 parser->lex_from_list = NULL;
3888 return NEWLINE;
3889 }
3890
3891 *yylval = node->token->value;
3892 ret = node->token->type;
3893
3894 parser->lex_from_node = node->next;
3895
3896 return ret;
3897}
3898
3899static void
3900glcpp_parser_lex_from (glcpp_parser_t *parser, token_list_t *list)
3901{
3902 token_node_t *node;
3903
3904 assert (parser->lex_from_list == NULL);
3905
3906 /* Copy list, eliminating any space tokens. */
3907 parser->lex_from_list = _token_list_create (parser);
3908
3909 for (node = list->head; node; node = node->next) {
3910 if (node->token->type == SPACE)
3911 continue;
3912 _token_list_append (parser->lex_from_list, node->token);
3913 }
3914
3915 talloc_free (list);
3916
3917 parser->lex_from_node = parser->lex_from_list->head;
3918
3919 /* It's possible the list consisted of nothing but whitespace. */
3920 if (parser->lex_from_node == NULL) {
3921 talloc_free (parser->lex_from_list);
3922 parser->lex_from_list = NULL;
3923 }
3924}
3925
3926static void
3927_glcpp_parser_skip_stack_push_if (glcpp_parser_t *parser, YYLTYPE *loc,
3928 int condition)
3929{
3930 skip_type_t current = SKIP_NO_SKIP;
3931 skip_node_t *node;
3932
3933 if (parser->skip_stack)
3934 current = parser->skip_stack->type;
3935
3936 node = xtalloc (parser, skip_node_t);
3937 node->loc = *loc;
3938
3939 if (current == SKIP_NO_SKIP) {
3940 if (condition)
3941 node->type = SKIP_NO_SKIP;
3942 else
3943 node->type = SKIP_TO_ELSE;
3944 } else {
3945 node->type = SKIP_TO_ENDIF;
3946 }
3947
3948 node->next = parser->skip_stack;
3949 parser->skip_stack = node;
3950}
3951
3952static void
3953_glcpp_parser_skip_stack_change_if (glcpp_parser_t *parser, YYLTYPE *loc,
3954 const char *type, int condition)
3955{
3956 if (parser->skip_stack == NULL) {
3957 glcpp_error (loc, parser, "%s without #if\n", type);
3958 return;
3959 }
3960
3961 if (parser->skip_stack->type == SKIP_TO_ELSE) {
3962 if (condition)
3963 parser->skip_stack->type = SKIP_NO_SKIP;
3964 } else {
3965 parser->skip_stack->type = SKIP_TO_ENDIF;
3966 }
3967}
3968
3969static void
3970_glcpp_parser_skip_stack_pop (glcpp_parser_t *parser, YYLTYPE *loc)
3971{
3972 skip_node_t *node;
3973
3974 if (parser->skip_stack == NULL) {
3975 glcpp_error (loc, parser, "#endif without #if\n");
3976 return;
3977 }
3978
3979 node = parser->skip_stack;
3980 parser->skip_stack = node->next;
3981 talloc_free (node);
3982}
3983