blob: 2c04d7d71bd54d94db318c0c191a1154ca45695d [file] [log] [blame]
Carl Worth9751b4e2010-08-17 23:22:42 -07001
2/* A Bison parser, made by GNU Bison 2.4.1. */
Carl Worth667173e2010-07-28 12:33:56 -07003
4/* Skeleton implementation for Bison's Yacc-like parsers in C
5
Carl Worth9751b4e2010-08-17 23:22:42 -07006 Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
7 Free Software Foundation, Inc.
Carl Worth667173e2010-07-28 12:33:56 -07008
9 This program is free software: you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation, either version 3 of the License, or
12 (at your option) any later version.
13
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with this program. If not, see <http://www.gnu.org/licenses/>. */
21
22/* As a special exception, you may create a larger work that contains
23 part or all of the Bison parser skeleton and distribute that work
24 under terms of your choice, so long as that work isn't itself a
25 parser generator using the skeleton or a modified version thereof
26 as a parser skeleton. Alternatively, if you modify or redistribute
27 the parser skeleton itself, you may (at your option) remove this
28 special exception, which will cause the skeleton and the resulting
29 Bison output files to be licensed under the GNU General Public
30 License without this special exception.
31
32 This special exception was added by the Free Software Foundation in
33 version 2.2 of Bison. */
34
35/* C LALR(1) parser skeleton written by Richard Stallman, by
36 simplifying the original so-called "semantic" parser. */
37
38/* All symbols defined below should begin with yy or YY, to avoid
39 infringing on user name space. This should be done even for local
40 variables, as they might otherwise be expanded by user macros.
41 There are some unavoidable exceptions within include files to
42 define necessary library symbols; they are noted "INFRINGES ON
43 USER NAME SPACE" below. */
44
45/* Identify Bison output. */
46#define YYBISON 1
47
48/* Bison version. */
Carl Worth9751b4e2010-08-17 23:22:42 -070049#define YYBISON_VERSION "2.4.1"
Carl Worth667173e2010-07-28 12:33:56 -070050
51/* Skeleton name. */
52#define YYSKELETON_NAME "yacc.c"
53
54/* Pure parsers. */
55#define YYPURE 1
56
57/* Push parsers. */
58#define YYPUSH 0
59
60/* Pull parsers. */
61#define YYPULL 1
62
63/* Using locations. */
64#define YYLSP_NEEDED 1
65
66
67
68/* Copy the first part of user declarations. */
69
70/* Line 189 of yacc.c */
71#line 1 "glcpp/glcpp-parse.y"
72
73/*
74 * Copyright © 2010 Intel Corporation
75 *
76 * Permission is hereby granted, free of charge, to any person obtaining a
77 * copy of this software and associated documentation files (the "Software"),
78 * to deal in the Software without restriction, including without limitation
79 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
80 * and/or sell copies of the Software, and to permit persons to whom the
81 * Software is furnished to do so, subject to the following conditions:
82 *
83 * The above copyright notice and this permission notice (including the next
84 * paragraph) shall be included in all copies or substantial portions of the
85 * Software.
86 *
87 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
88 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
89 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
90 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
91 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
92 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
93 * DEALINGS IN THE SOFTWARE.
94 */
95
96#include <stdio.h>
97#include <stdlib.h>
Ian Romanick188f60f2010-08-12 10:07:05 -070098#include <string.h>
Carl Worth667173e2010-07-28 12:33:56 -070099#include <assert.h>
José Fonseca93493792010-08-14 16:01:24 +0100100#include <inttypes.h>
Carl Worth667173e2010-07-28 12:33:56 -0700101
102#include "glcpp.h"
103#include "main/mtypes.h"
104
105#define glcpp_print(stream, str) stream = talloc_strdup_append(stream, str)
Kenneth Graunkec55aa422010-08-13 17:16:43 -0700106#define glcpp_printf(stream, fmt, args, ...) \
Carl Worth667173e2010-07-28 12:33:56 -0700107 stream = talloc_asprintf_append(stream, fmt, args)
108
109static void
110yyerror (YYLTYPE *locp, glcpp_parser_t *parser, const char *error);
111
112static void
113_define_object_macro (glcpp_parser_t *parser,
114 YYLTYPE *loc,
115 const char *macro,
116 token_list_t *replacements);
117
118static void
119_define_function_macro (glcpp_parser_t *parser,
120 YYLTYPE *loc,
121 const char *macro,
122 string_list_t *parameters,
123 token_list_t *replacements);
124
125static string_list_t *
126_string_list_create (void *ctx);
127
128static void
129_string_list_append_item (string_list_t *list, const char *str);
130
131static int
132_string_list_contains (string_list_t *list, const char *member, int *index);
133
134static int
135_string_list_length (string_list_t *list);
136
Carl Worth9751b4e2010-08-17 23:22:42 -0700137static int
138_string_list_equal (string_list_t *a, string_list_t *b);
139
Carl Worth667173e2010-07-28 12:33:56 -0700140static argument_list_t *
141_argument_list_create (void *ctx);
142
143static void
144_argument_list_append (argument_list_t *list, token_list_t *argument);
145
146static int
147_argument_list_length (argument_list_t *list);
148
149static token_list_t *
150_argument_list_member_at (argument_list_t *list, int index);
151
152/* Note: This function talloc_steal()s the str pointer. */
153static token_t *
154_token_create_str (void *ctx, int type, char *str);
155
156static token_t *
157_token_create_ival (void *ctx, int type, int ival);
158
159static token_list_t *
160_token_list_create (void *ctx);
161
162/* Note: This function adds a talloc_reference() to token.
163 *
164 * You may want to talloc_unlink any current reference if you no
165 * longer need it. */
166static void
167_token_list_append (token_list_t *list, token_t *token);
168
169static void
170_token_list_append_list (token_list_t *list, token_list_t *tail);
171
Carl Worth9751b4e2010-08-17 23:22:42 -0700172static int
173_token_list_equal_ignoring_space (token_list_t *a, token_list_t *b);
174
Carl Worth667173e2010-07-28 12:33:56 -0700175static active_list_t *
176_active_list_push (active_list_t *list,
177 const char *identifier,
178 token_node_t *marker);
179
180static active_list_t *
181_active_list_pop (active_list_t *list);
182
183int
184_active_list_contains (active_list_t *list, const char *identifier);
185
186static void
Kenneth Graunke16b4eed2010-08-04 16:10:03 -0700187_glcpp_parser_expand_if (glcpp_parser_t *parser, int type, token_list_t *list);
188
189static void
Carl Worth667173e2010-07-28 12:33:56 -0700190_glcpp_parser_expand_token_list (glcpp_parser_t *parser,
191 token_list_t *list);
192
193static void
194_glcpp_parser_print_expanded_token_list (glcpp_parser_t *parser,
195 token_list_t *list);
196
197static void
198_glcpp_parser_skip_stack_push_if (glcpp_parser_t *parser, YYLTYPE *loc,
199 int condition);
200
201static void
202_glcpp_parser_skip_stack_change_if (glcpp_parser_t *parser, YYLTYPE *loc,
203 const char *type, int condition);
204
205static void
206_glcpp_parser_skip_stack_pop (glcpp_parser_t *parser, YYLTYPE *loc);
207
208#define yylex glcpp_parser_lex
209
210static int
211glcpp_parser_lex (YYSTYPE *yylval, YYLTYPE *yylloc, glcpp_parser_t *parser);
212
213static void
214glcpp_parser_lex_from (glcpp_parser_t *parser, token_list_t *list);
215
Eric Anholtd4a04f32010-07-28 16:58:39 -0700216static void
217add_builtin_define(glcpp_parser_t *parser, const char *name, int value);
218
Carl Worth667173e2010-07-28 12:33:56 -0700219
220
221/* Line 189 of yacc.c */
Carl Worth9751b4e2010-08-17 23:22:42 -0700222#line 223 "glcpp/glcpp-parse.c"
Carl Worth667173e2010-07-28 12:33:56 -0700223
224/* Enabling traces. */
225#ifndef YYDEBUG
226# define YYDEBUG 0
227#endif
228
229/* Enabling verbose error messages. */
230#ifdef YYERROR_VERBOSE
231# undef YYERROR_VERBOSE
232# define YYERROR_VERBOSE 1
233#else
234# define YYERROR_VERBOSE 1
235#endif
236
237/* Enabling the token table. */
238#ifndef YYTOKEN_TABLE
239# define YYTOKEN_TABLE 0
240#endif
241
242
243/* Tokens. */
244#ifndef YYTOKENTYPE
245# define YYTOKENTYPE
246 /* Put the tokens into the symbol table, so that GDB and other debuggers
247 know about them. */
248 enum yytokentype {
249 COMMA_FINAL = 258,
250 DEFINED = 259,
251 ELIF_EXPANDED = 260,
252 HASH = 261,
253 HASH_DEFINE_FUNC = 262,
254 HASH_DEFINE_OBJ = 263,
255 HASH_ELIF = 264,
256 HASH_ELSE = 265,
257 HASH_ENDIF = 266,
258 HASH_IF = 267,
259 HASH_IFDEF = 268,
260 HASH_IFNDEF = 269,
261 HASH_UNDEF = 270,
Eric Anholtd4a04f32010-07-28 16:58:39 -0700262 HASH_VERSION = 271,
263 IDENTIFIER = 272,
264 IF_EXPANDED = 273,
265 INTEGER = 274,
266 INTEGER_STRING = 275,
267 NEWLINE = 276,
268 OTHER = 277,
269 PLACEHOLDER = 278,
270 SPACE = 279,
271 PASTE = 280,
272 OR = 281,
273 AND = 282,
274 NOT_EQUAL = 283,
275 EQUAL = 284,
276 GREATER_OR_EQUAL = 285,
277 LESS_OR_EQUAL = 286,
278 RIGHT_SHIFT = 287,
279 LEFT_SHIFT = 288,
280 UNARY = 289
Carl Worth667173e2010-07-28 12:33:56 -0700281 };
282#endif
283
284
285
286#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
287
288# define yystype YYSTYPE /* obsolescent; will be withdrawn */
289# define YYSTYPE_IS_DECLARED 1
290#endif
291
292#if ! defined YYLTYPE && ! defined YYLTYPE_IS_DECLARED
293typedef struct YYLTYPE
294{
295 int first_line;
296 int first_column;
297 int last_line;
298 int last_column;
299} YYLTYPE;
300# define yyltype YYLTYPE /* obsolescent; will be withdrawn */
301# define YYLTYPE_IS_DECLARED 1
302# define YYLTYPE_IS_TRIVIAL 1
303#endif
304
305
306/* Copy the second part of user declarations. */
307
308
309/* Line 264 of yacc.c */
Carl Worth9751b4e2010-08-17 23:22:42 -0700310#line 311 "glcpp/glcpp-parse.c"
Carl Worth667173e2010-07-28 12:33:56 -0700311
312#ifdef short
313# undef short
314#endif
315
316#ifdef YYTYPE_UINT8
317typedef YYTYPE_UINT8 yytype_uint8;
318#else
319typedef unsigned char yytype_uint8;
320#endif
321
322#ifdef YYTYPE_INT8
323typedef YYTYPE_INT8 yytype_int8;
324#elif (defined __STDC__ || defined __C99__FUNC__ \
325 || defined __cplusplus || defined _MSC_VER)
326typedef signed char yytype_int8;
327#else
328typedef short int yytype_int8;
329#endif
330
331#ifdef YYTYPE_UINT16
332typedef YYTYPE_UINT16 yytype_uint16;
333#else
334typedef unsigned short int yytype_uint16;
335#endif
336
337#ifdef YYTYPE_INT16
338typedef YYTYPE_INT16 yytype_int16;
339#else
340typedef short int yytype_int16;
341#endif
342
343#ifndef YYSIZE_T
344# ifdef __SIZE_TYPE__
345# define YYSIZE_T __SIZE_TYPE__
346# elif defined size_t
347# define YYSIZE_T size_t
348# elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \
349 || defined __cplusplus || defined _MSC_VER)
350# include <stddef.h> /* INFRINGES ON USER NAME SPACE */
351# define YYSIZE_T size_t
352# else
353# define YYSIZE_T unsigned int
354# endif
355#endif
356
357#define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
358
359#ifndef YY_
Carl Worth9751b4e2010-08-17 23:22:42 -0700360# if YYENABLE_NLS
Carl Worth667173e2010-07-28 12:33:56 -0700361# if ENABLE_NLS
362# include <libintl.h> /* INFRINGES ON USER NAME SPACE */
363# define YY_(msgid) dgettext ("bison-runtime", msgid)
364# endif
365# endif
366# ifndef YY_
367# define YY_(msgid) msgid
368# endif
369#endif
370
371/* Suppress unused-variable warnings by "using" E. */
372#if ! defined lint || defined __GNUC__
373# define YYUSE(e) ((void) (e))
374#else
375# define YYUSE(e) /* empty */
376#endif
377
378/* Identity function, used to suppress warnings about constant conditions. */
379#ifndef lint
380# define YYID(n) (n)
381#else
382#if (defined __STDC__ || defined __C99__FUNC__ \
383 || defined __cplusplus || defined _MSC_VER)
384static int
385YYID (int yyi)
386#else
387static int
388YYID (yyi)
389 int yyi;
390#endif
391{
392 return yyi;
393}
394#endif
395
396#if ! defined yyoverflow || YYERROR_VERBOSE
397
398/* The parser invokes alloca or malloc; define the necessary symbols. */
399
400# ifdef YYSTACK_USE_ALLOCA
401# if YYSTACK_USE_ALLOCA
402# ifdef __GNUC__
403# define YYSTACK_ALLOC __builtin_alloca
404# elif defined __BUILTIN_VA_ARG_INCR
405# include <alloca.h> /* INFRINGES ON USER NAME SPACE */
406# elif defined _AIX
407# define YYSTACK_ALLOC __alloca
408# elif defined _MSC_VER
409# include <malloc.h> /* INFRINGES ON USER NAME SPACE */
410# define alloca _alloca
411# else
412# define YYSTACK_ALLOC alloca
413# if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
414 || defined __cplusplus || defined _MSC_VER)
415# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
416# ifndef _STDLIB_H
417# define _STDLIB_H 1
418# endif
419# endif
420# endif
421# endif
422# endif
423
424# ifdef YYSTACK_ALLOC
425 /* Pacify GCC's `empty if-body' warning. */
426# define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0))
427# ifndef YYSTACK_ALLOC_MAXIMUM
428 /* The OS might guarantee only one guard page at the bottom of the stack,
429 and a page size can be as small as 4096 bytes. So we cannot safely
430 invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
431 to allow for a few compiler-allocated temporary stack slots. */
432# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
433# endif
434# else
435# define YYSTACK_ALLOC YYMALLOC
436# define YYSTACK_FREE YYFREE
437# ifndef YYSTACK_ALLOC_MAXIMUM
438# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
439# endif
440# if (defined __cplusplus && ! defined _STDLIB_H \
441 && ! ((defined YYMALLOC || defined malloc) \
442 && (defined YYFREE || defined free)))
443# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
444# ifndef _STDLIB_H
445# define _STDLIB_H 1
446# endif
447# endif
448# ifndef YYMALLOC
449# define YYMALLOC malloc
450# if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
451 || defined __cplusplus || defined _MSC_VER)
452void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
453# endif
454# endif
455# ifndef YYFREE
456# define YYFREE free
457# if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
458 || defined __cplusplus || defined _MSC_VER)
459void free (void *); /* INFRINGES ON USER NAME SPACE */
460# endif
461# endif
462# endif
463#endif /* ! defined yyoverflow || YYERROR_VERBOSE */
464
465
466#if (! defined yyoverflow \
467 && (! defined __cplusplus \
468 || (defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL \
469 && defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
470
471/* A type that is properly aligned for any stack member. */
472union yyalloc
473{
474 yytype_int16 yyss_alloc;
475 YYSTYPE yyvs_alloc;
476 YYLTYPE yyls_alloc;
477};
478
479/* The size of the maximum gap between one aligned stack and the next. */
480# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
481
482/* The size of an array large to enough to hold all stacks, each with
483 N elements. */
484# define YYSTACK_BYTES(N) \
485 ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE) + sizeof (YYLTYPE)) \
486 + 2 * YYSTACK_GAP_MAXIMUM)
487
488/* Copy COUNT objects from FROM to TO. The source and destination do
489 not overlap. */
490# ifndef YYCOPY
491# if defined __GNUC__ && 1 < __GNUC__
492# define YYCOPY(To, From, Count) \
493 __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
494# else
495# define YYCOPY(To, From, Count) \
496 do \
497 { \
498 YYSIZE_T yyi; \
499 for (yyi = 0; yyi < (Count); yyi++) \
500 (To)[yyi] = (From)[yyi]; \
501 } \
502 while (YYID (0))
503# endif
504# endif
505
506/* Relocate STACK from its old location to the new one. The
507 local variables YYSIZE and YYSTACKSIZE give the old and new number of
508 elements in the stack, and YYPTR gives the new location of the
509 stack. Advance YYPTR to a properly aligned location for the next
510 stack. */
511# define YYSTACK_RELOCATE(Stack_alloc, Stack) \
512 do \
513 { \
514 YYSIZE_T yynewbytes; \
515 YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \
516 Stack = &yyptr->Stack_alloc; \
517 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
518 yyptr += yynewbytes / sizeof (*yyptr); \
519 } \
520 while (YYID (0))
521
522#endif
523
524/* YYFINAL -- State number of the termination state. */
525#define YYFINAL 2
526/* YYLAST -- Last index in YYTABLE. */
Carl Worth6b9e7b02010-08-11 14:00:21 -0700527#define YYLAST 606
Carl Worth667173e2010-07-28 12:33:56 -0700528
529/* YYNTOKENS -- Number of terminals. */
Eric Anholtd4a04f32010-07-28 16:58:39 -0700530#define YYNTOKENS 57
Carl Worth667173e2010-07-28 12:33:56 -0700531/* YYNNTS -- Number of nonterminals. */
Eric Anholtd4a04f32010-07-28 16:58:39 -0700532#define YYNNTS 17
Carl Worth667173e2010-07-28 12:33:56 -0700533/* YYNRULES -- Number of rules. */
Carl Worth6b9e7b02010-08-11 14:00:21 -0700534#define YYNRULES 101
Carl Worth667173e2010-07-28 12:33:56 -0700535/* YYNRULES -- Number of states. */
Carl Worth6b9e7b02010-08-11 14:00:21 -0700536#define YYNSTATES 162
Carl Worth667173e2010-07-28 12:33:56 -0700537
538/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
539#define YYUNDEFTOK 2
Eric Anholtd4a04f32010-07-28 16:58:39 -0700540#define YYMAXUTOK 289
Carl Worth667173e2010-07-28 12:33:56 -0700541
542#define YYTRANSLATE(YYX) \
543 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
544
545/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
546static const yytype_uint8 yytranslate[] =
547{
548 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
549 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
550 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
Eric Anholtd4a04f32010-07-28 16:58:39 -0700551 2, 2, 2, 47, 2, 2, 2, 43, 30, 2,
552 45, 46, 41, 39, 49, 40, 54, 42, 2, 2,
553 2, 2, 2, 2, 2, 2, 2, 2, 2, 55,
554 33, 56, 34, 2, 2, 2, 2, 2, 2, 2,
Carl Worth667173e2010-07-28 12:33:56 -0700555 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
556 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
Eric Anholtd4a04f32010-07-28 16:58:39 -0700557 2, 50, 2, 51, 29, 2, 2, 2, 2, 2,
Carl Worth667173e2010-07-28 12:33:56 -0700558 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
559 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
Eric Anholtd4a04f32010-07-28 16:58:39 -0700560 2, 2, 2, 52, 28, 53, 48, 2, 2, 2,
Carl Worth667173e2010-07-28 12:33:56 -0700561 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
562 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
563 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
564 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
565 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
566 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
567 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
568 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
569 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
570 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
571 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
572 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
573 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
574 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
575 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
Eric Anholtd4a04f32010-07-28 16:58:39 -0700576 25, 26, 27, 31, 32, 35, 36, 37, 38, 44
Carl Worth667173e2010-07-28 12:33:56 -0700577};
578
579#if YYDEBUG
580/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
581 YYRHS. */
582static const yytype_uint16 yyprhs[] =
583{
584 0, 0, 3, 4, 7, 9, 11, 13, 16, 20,
Carl Worth6b9e7b02010-08-11 14:00:21 -0700585 24, 29, 36, 44, 48, 52, 55, 60, 65, 69,
586 72, 75, 78, 82, 85, 87, 89, 91, 95, 99,
587 103, 107, 111, 115, 119, 123, 127, 131, 135, 139,
588 143, 147, 151, 155, 159, 163, 166, 169, 172, 175,
589 179, 181, 185, 187, 190, 193, 194, 196, 197, 199,
590 202, 207, 209, 211, 214, 216, 219, 221, 223, 225,
591 227, 229, 231, 233, 235, 237, 239, 241, 243, 245,
592 247, 249, 251, 253, 255, 257, 259, 261, 263, 265,
593 267, 269, 271, 273, 275, 277, 279, 281, 283, 285,
594 287, 289
Carl Worth667173e2010-07-28 12:33:56 -0700595};
596
597/* YYRHS -- A `-1'-separated list of the rules' RHS. */
598static const yytype_int8 yyrhs[] =
599{
Eric Anholtd4a04f32010-07-28 16:58:39 -0700600 58, 0, -1, -1, 58, 59, -1, 61, -1, 65,
601 -1, 60, -1, 6, 66, -1, 18, 63, 21, -1,
602 5, 63, 21, -1, 8, 17, 67, 21, -1, 7,
603 17, 45, 46, 67, 21, -1, 7, 17, 45, 64,
604 46, 67, 21, -1, 15, 17, 21, -1, 12, 70,
Carl Worth6b9e7b02010-08-11 14:00:21 -0700605 21, -1, 12, 21, -1, 13, 17, 68, 21, -1,
606 14, 17, 68, 21, -1, 9, 70, 21, -1, 9,
607 21, -1, 10, 21, -1, 11, 21, -1, 16, 62,
608 21, -1, 6, 21, -1, 20, -1, 19, -1, 62,
609 -1, 63, 26, 63, -1, 63, 27, 63, -1, 63,
610 28, 63, -1, 63, 29, 63, -1, 63, 30, 63,
611 -1, 63, 31, 63, -1, 63, 32, 63, -1, 63,
612 35, 63, -1, 63, 36, 63, -1, 63, 34, 63,
613 -1, 63, 33, 63, -1, 63, 37, 63, -1, 63,
614 38, 63, -1, 63, 40, 63, -1, 63, 39, 63,
615 -1, 63, 43, 63, -1, 63, 42, 63, -1, 63,
616 41, 63, -1, 47, 63, -1, 48, 63, -1, 40,
617 63, -1, 39, 63, -1, 45, 63, 46, -1, 17,
618 -1, 64, 49, 17, -1, 21, -1, 71, 21, -1,
619 71, 21, -1, -1, 71, -1, -1, 71, -1, 4,
620 17, -1, 4, 45, 17, 46, -1, 72, -1, 69,
621 -1, 70, 69, -1, 72, -1, 71, 72, -1, 17,
622 -1, 20, -1, 73, -1, 22, -1, 24, -1, 50,
623 -1, 51, -1, 45, -1, 46, -1, 52, -1, 53,
624 -1, 54, -1, 30, -1, 41, -1, 39, -1, 40,
625 -1, 48, -1, 47, -1, 42, -1, 43, -1, 38,
626 -1, 37, -1, 33, -1, 34, -1, 36, -1, 35,
627 -1, 32, -1, 31, -1, 29, -1, 28, -1, 27,
628 -1, 26, -1, 55, -1, 49, -1, 56, -1, 25,
629 -1
Carl Worth667173e2010-07-28 12:33:56 -0700630};
631
632/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
633static const yytype_uint16 yyrline[] =
634{
Carl Worth9751b4e2010-08-17 23:22:42 -0700635 0, 187, 187, 189, 193, 196, 201, 202, 206, 209,
636 215, 218, 221, 224, 232, 251, 261, 266, 271, 290,
637 305, 308, 311, 320, 324, 333, 338, 339, 342, 345,
638 348, 351, 354, 357, 360, 363, 366, 369, 372, 375,
639 378, 381, 384, 387, 390, 393, 396, 399, 402, 405,
640 411, 416, 424, 425, 429, 435, 436, 439, 441, 448,
641 452, 456, 461, 467, 475, 481, 489, 493, 497, 501,
642 505, 512, 513, 514, 515, 516, 517, 518, 519, 520,
643 521, 522, 523, 524, 525, 526, 527, 528, 529, 530,
644 531, 532, 533, 534, 535, 536, 537, 538, 539, 540,
645 541, 542
Carl Worth667173e2010-07-28 12:33:56 -0700646};
647#endif
648
649#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
650/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
651 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
652static const char *const yytname[] =
653{
654 "$end", "error", "$undefined", "COMMA_FINAL", "DEFINED",
655 "ELIF_EXPANDED", "HASH", "HASH_DEFINE_FUNC", "HASH_DEFINE_OBJ",
656 "HASH_ELIF", "HASH_ELSE", "HASH_ENDIF", "HASH_IF", "HASH_IFDEF",
Eric Anholtd4a04f32010-07-28 16:58:39 -0700657 "HASH_IFNDEF", "HASH_UNDEF", "HASH_VERSION", "IDENTIFIER", "IF_EXPANDED",
658 "INTEGER", "INTEGER_STRING", "NEWLINE", "OTHER", "PLACEHOLDER", "SPACE",
659 "PASTE", "OR", "AND", "'|'", "'^'", "'&'", "NOT_EQUAL", "EQUAL", "'<'",
660 "'>'", "GREATER_OR_EQUAL", "LESS_OR_EQUAL", "RIGHT_SHIFT", "LEFT_SHIFT",
661 "'+'", "'-'", "'*'", "'/'", "'%'", "UNARY", "'('", "')'", "'!'", "'~'",
662 "','", "'['", "']'", "'{'", "'}'", "'.'", "';'", "'='", "$accept",
663 "input", "line", "expanded_line", "control_line", "integer_constant",
664 "expression", "identifier_list", "text_line", "non_directive",
665 "replacement_list", "junk", "conditional_token", "conditional_tokens",
666 "pp_tokens", "preprocessing_token", "operator", 0
Carl Worth667173e2010-07-28 12:33:56 -0700667};
668#endif
669
670# ifdef YYPRINT
671/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
672 token YYLEX-NUM. */
673static const yytype_uint16 yytoknum[] =
674{
675 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
676 265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
Eric Anholtd4a04f32010-07-28 16:58:39 -0700677 275, 276, 277, 278, 279, 280, 281, 282, 124, 94,
678 38, 283, 284, 60, 62, 285, 286, 287, 288, 43,
679 45, 42, 47, 37, 289, 40, 41, 33, 126, 44,
680 91, 93, 123, 125, 46, 59, 61
Carl Worth667173e2010-07-28 12:33:56 -0700681};
682# endif
683
684/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
685static const yytype_uint8 yyr1[] =
686{
Eric Anholtd4a04f32010-07-28 16:58:39 -0700687 0, 57, 58, 58, 59, 59, 59, 59, 60, 60,
Carl Worth667173e2010-07-28 12:33:56 -0700688 61, 61, 61, 61, 61, 61, 61, 61, 61, 61,
Carl Worth6b9e7b02010-08-11 14:00:21 -0700689 61, 61, 61, 61, 62, 62, 63, 63, 63, 63,
Eric Anholtd4a04f32010-07-28 16:58:39 -0700690 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
Carl Worth6b9e7b02010-08-11 14:00:21 -0700691 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
692 64, 64, 65, 65, 66, 67, 67, 68, 68, 69,
693 69, 69, 70, 70, 71, 71, 72, 72, 72, 72,
694 72, 73, 73, 73, 73, 73, 73, 73, 73, 73,
Eric Anholtd4a04f32010-07-28 16:58:39 -0700695 73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
696 73, 73, 73, 73, 73, 73, 73, 73, 73, 73,
Carl Worth6b9e7b02010-08-11 14:00:21 -0700697 73, 73
Carl Worth667173e2010-07-28 12:33:56 -0700698};
699
700/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
701static const yytype_uint8 yyr2[] =
702{
703 0, 2, 0, 2, 1, 1, 1, 2, 3, 3,
Carl Worth6b9e7b02010-08-11 14:00:21 -0700704 4, 6, 7, 3, 3, 2, 4, 4, 3, 2,
705 2, 2, 3, 2, 1, 1, 1, 3, 3, 3,
Carl Worth667173e2010-07-28 12:33:56 -0700706 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
Carl Worth6b9e7b02010-08-11 14:00:21 -0700707 3, 3, 3, 3, 3, 2, 2, 2, 2, 3,
708 1, 3, 1, 2, 2, 0, 1, 0, 1, 2,
709 4, 1, 1, 2, 1, 2, 1, 1, 1, 1,
Carl Worth667173e2010-07-28 12:33:56 -0700710 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
711 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
Eric Anholtd4a04f32010-07-28 16:58:39 -0700712 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
Carl Worth6b9e7b02010-08-11 14:00:21 -0700713 1, 1
Carl Worth667173e2010-07-28 12:33:56 -0700714};
715
716/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
717 STATE-NUM when YYTABLE doesn't specify something else to do. Zero
718 means the default is an error. */
719static const yytype_uint8 yydefact[] =
720{
721 2, 0, 1, 0, 0, 0, 0, 0, 0, 0,
Carl Worth6b9e7b02010-08-11 14:00:21 -0700722 0, 0, 0, 0, 0, 66, 0, 67, 52, 69,
723 70, 101, 97, 96, 95, 94, 78, 93, 92, 88,
724 89, 91, 90, 87, 86, 80, 81, 79, 84, 85,
725 73, 74, 83, 82, 99, 71, 72, 75, 76, 77,
726 98, 100, 3, 6, 4, 5, 0, 64, 68, 25,
727 24, 0, 0, 0, 0, 0, 26, 0, 23, 7,
728 0, 0, 55, 0, 19, 62, 0, 61, 20, 21,
729 15, 0, 57, 57, 0, 0, 0, 53, 65, 48,
730 47, 0, 45, 46, 9, 0, 0, 0, 0, 0,
Eric Anholtd4a04f32010-07-28 16:58:39 -0700731 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
Carl Worth6b9e7b02010-08-11 14:00:21 -0700732 0, 0, 0, 54, 0, 0, 56, 59, 0, 18,
733 63, 14, 0, 58, 0, 13, 22, 8, 49, 27,
734 28, 29, 30, 31, 32, 33, 37, 36, 34, 35,
735 38, 39, 41, 40, 44, 43, 42, 50, 55, 0,
736 10, 0, 16, 17, 0, 55, 0, 60, 11, 0,
737 51, 12
Carl Worth667173e2010-07-28 12:33:56 -0700738};
739
740/* YYDEFGOTO[NTERM-NUM]. */
741static const yytype_int16 yydefgoto[] =
742{
Carl Worth6b9e7b02010-08-11 14:00:21 -0700743 -1, 1, 52, 53, 54, 66, 67, 149, 55, 69,
744 115, 122, 75, 76, 116, 57, 58
Carl Worth667173e2010-07-28 12:33:56 -0700745};
746
747/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
748 STATE-NUM. */
Carl Worth6b9e7b02010-08-11 14:00:21 -0700749#define YYPACT_NINF -147
Carl Worth667173e2010-07-28 12:33:56 -0700750static const yytype_int16 yypact[] =
751{
Carl Worth6b9e7b02010-08-11 14:00:21 -0700752 -147, 112, -147, 28, -10, 55, 62, 152, -15, 59,
753 192, 85, 86, 87, 51, -147, 28, -147, -147, -147,
754 -147, -147, -147, -147, -147, -147, -147, -147, -147, -147,
755 -147, -147, -147, -147, -147, -147, -147, -147, -147, -147,
756 -147, -147, -147, -147, -147, -147, -147, -147, -147, -147,
757 -147, -147, -147, -147, -147, -147, 312, -147, -147, -147,
758 -147, 28, 28, 28, 28, 28, -147, 428, -147, -147,
759 352, 63, 392, 17, -147, -147, 232, -147, -147, -147,
760 -147, 272, 392, 392, 84, 89, 451, -147, -147, -147,
761 -147, 469, -147, -147, -147, 28, 28, 28, 28, 28,
762 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
763 28, 28, 28, -147, 60, 90, 392, -147, 96, -147,
764 -147, -147, 93, 392, 94, -147, -147, -147, -147, 489,
765 505, 520, 534, 547, 558, 558, 18, 18, 18, 18,
766 563, 563, 23, 23, -147, -147, -147, -147, 392, 32,
767 -147, 61, -147, -147, 110, 392, 118, -147, -147, 149,
768 -147, -147
Carl Worth667173e2010-07-28 12:33:56 -0700769};
770
771/* YYPGOTO[NTERM-NUM]. */
Eric Anholtd4a04f32010-07-28 16:58:39 -0700772static const yytype_int16 yypgoto[] =
Carl Worth667173e2010-07-28 12:33:56 -0700773{
Carl Worth6b9e7b02010-08-11 14:00:21 -0700774 -147, -147, -147, -147, -147, 157, -11, -147, -147, -147,
775 -146, 92, -68, 200, 0, -7, -147
Carl Worth667173e2010-07-28 12:33:56 -0700776};
777
778/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
779 positive, shift that token. If negative, reduce the rule which
780 number is the opposite. If zero, do what YYDEFACT says.
781 If YYTABLE_NINF, syntax error. */
782#define YYTABLE_NINF -1
783static const yytype_uint8 yytable[] =
784{
Carl Worth6b9e7b02010-08-11 14:00:21 -0700785 77, 56, 154, 77, 70, 86, 78, 15, 120, 159,
786 17, 68, 19, 120, 20, 21, 22, 23, 24, 25,
Carl Worth667173e2010-07-28 12:33:56 -0700787 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
Carl Worth6b9e7b02010-08-11 14:00:21 -0700788 36, 37, 38, 39, 117, 40, 41, 42, 43, 44,
789 45, 46, 47, 48, 49, 50, 51, 59, 60, 88,
790 89, 90, 91, 92, 93, 106, 107, 108, 109, 110,
791 111, 112, 118, 88, 110, 111, 112, 61, 62, 77,
792 59, 60, 71, 63, 77, 64, 65, 147, 155, 72,
793 79, 156, 123, 123, 129, 130, 131, 132, 133, 134,
Eric Anholtd4a04f32010-07-28 16:58:39 -0700794 135, 136, 137, 138, 139, 140, 141, 142, 143, 144,
Carl Worth6b9e7b02010-08-11 14:00:21 -0700795 145, 146, 82, 83, 84, 125, 148, 157, 114, 88,
796 126, 150, 2, 151, 152, 153, 88, 3, 4, 5,
797 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
798 16, 158, 17, 18, 19, 160, 20, 21, 22, 23,
799 24, 25, 26, 27, 28, 29, 30, 31, 32, 33,
800 34, 35, 36, 37, 38, 39, 73, 40, 41, 42,
801 43, 44, 45, 46, 47, 48, 49, 50, 51, 15,
802 161, 85, 17, 74, 19, 124, 20, 21, 22, 23,
803 24, 25, 26, 27, 28, 29, 30, 31, 32, 33,
804 34, 35, 36, 37, 38, 39, 73, 40, 41, 42,
805 43, 44, 45, 46, 47, 48, 49, 50, 51, 15,
806 81, 0, 17, 80, 19, 0, 20, 21, 22, 23,
807 24, 25, 26, 27, 28, 29, 30, 31, 32, 33,
808 34, 35, 36, 37, 38, 39, 73, 40, 41, 42,
809 43, 44, 45, 46, 47, 48, 49, 50, 51, 15,
810 0, 0, 17, 119, 19, 0, 20, 21, 22, 23,
811 24, 25, 26, 27, 28, 29, 30, 31, 32, 33,
812 34, 35, 36, 37, 38, 39, 73, 40, 41, 42,
813 43, 44, 45, 46, 47, 48, 49, 50, 51, 15,
814 0, 0, 17, 121, 19, 0, 20, 21, 22, 23,
815 24, 25, 26, 27, 28, 29, 30, 31, 32, 33,
816 34, 35, 36, 37, 38, 39, 0, 40, 41, 42,
817 43, 44, 45, 46, 47, 48, 49, 50, 51, 15,
818 0, 0, 17, 87, 19, 0, 20, 21, 22, 23,
819 24, 25, 26, 27, 28, 29, 30, 31, 32, 33,
820 34, 35, 36, 37, 38, 39, 0, 40, 41, 42,
821 43, 44, 45, 46, 47, 48, 49, 50, 51, 15,
822 0, 0, 17, 113, 19, 0, 20, 21, 22, 23,
823 24, 25, 26, 27, 28, 29, 30, 31, 32, 33,
824 34, 35, 36, 37, 38, 39, 0, 40, 41, 42,
825 43, 44, 45, 46, 47, 48, 49, 50, 51, 15,
826 0, 0, 17, 0, 19, 0, 20, 21, 22, 23,
827 24, 25, 26, 27, 28, 29, 30, 31, 32, 33,
828 34, 35, 36, 37, 38, 39, 0, 40, 41, 42,
829 43, 44, 45, 46, 47, 48, 49, 50, 51, 94,
830 0, 0, 0, 0, 95, 96, 97, 98, 99, 100,
Eric Anholtd4a04f32010-07-28 16:58:39 -0700831 101, 102, 103, 104, 105, 106, 107, 108, 109, 110,
Carl Worth6b9e7b02010-08-11 14:00:21 -0700832 111, 112, 127, 0, 0, 0, 0, 95, 96, 97,
833 98, 99, 100, 101, 102, 103, 104, 105, 106, 107,
834 108, 109, 110, 111, 112, 95, 96, 97, 98, 99,
835 100, 101, 102, 103, 104, 105, 106, 107, 108, 109,
836 110, 111, 112, 0, 0, 128, 96, 97, 98, 99,
837 100, 101, 102, 103, 104, 105, 106, 107, 108, 109,
838 110, 111, 112, 97, 98, 99, 100, 101, 102, 103,
839 104, 105, 106, 107, 108, 109, 110, 111, 112, 98,
840 99, 100, 101, 102, 103, 104, 105, 106, 107, 108,
841 109, 110, 111, 112, 99, 100, 101, 102, 103, 104,
842 105, 106, 107, 108, 109, 110, 111, 112, 100, 101,
843 102, 103, 104, 105, 106, 107, 108, 109, 110, 111,
844 112, 102, 103, 104, 105, 106, 107, 108, 109, 110,
845 111, 112, 108, 109, 110, 111, 112
Carl Worth667173e2010-07-28 12:33:56 -0700846};
847
848static const yytype_int16 yycheck[] =
849{
Carl Worth6b9e7b02010-08-11 14:00:21 -0700850 7, 1, 148, 10, 4, 16, 21, 17, 76, 155,
851 20, 21, 22, 81, 24, 25, 26, 27, 28, 29,
Carl Worth667173e2010-07-28 12:33:56 -0700852 30, 31, 32, 33, 34, 35, 36, 37, 38, 39,
Eric Anholtd4a04f32010-07-28 16:58:39 -0700853 40, 41, 42, 43, 17, 45, 46, 47, 48, 49,
Carl Worth6b9e7b02010-08-11 14:00:21 -0700854 50, 51, 52, 53, 54, 55, 56, 19, 20, 56,
Eric Anholtd4a04f32010-07-28 16:58:39 -0700855 61, 62, 63, 64, 65, 37, 38, 39, 40, 41,
Carl Worth6b9e7b02010-08-11 14:00:21 -0700856 42, 43, 45, 70, 41, 42, 43, 39, 40, 76,
857 19, 20, 17, 45, 81, 47, 48, 17, 46, 17,
858 21, 49, 82, 83, 95, 96, 97, 98, 99, 100,
Eric Anholtd4a04f32010-07-28 16:58:39 -0700859 101, 102, 103, 104, 105, 106, 107, 108, 109, 110,
Carl Worth6b9e7b02010-08-11 14:00:21 -0700860 111, 112, 17, 17, 17, 21, 46, 46, 45, 116,
861 21, 21, 0, 17, 21, 21, 123, 5, 6, 7,
862 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
863 18, 21, 20, 21, 22, 17, 24, 25, 26, 27,
Carl Worth667173e2010-07-28 12:33:56 -0700864 28, 29, 30, 31, 32, 33, 34, 35, 36, 37,
Carl Worth6b9e7b02010-08-11 14:00:21 -0700865 38, 39, 40, 41, 42, 43, 4, 45, 46, 47,
866 48, 49, 50, 51, 52, 53, 54, 55, 56, 17,
867 21, 14, 20, 21, 22, 83, 24, 25, 26, 27,
Eric Anholtd4a04f32010-07-28 16:58:39 -0700868 28, 29, 30, 31, 32, 33, 34, 35, 36, 37,
Carl Worth6b9e7b02010-08-11 14:00:21 -0700869 38, 39, 40, 41, 42, 43, 4, 45, 46, 47,
870 48, 49, 50, 51, 52, 53, 54, 55, 56, 17,
871 10, -1, 20, 21, 22, -1, 24, 25, 26, 27,
872 28, 29, 30, 31, 32, 33, 34, 35, 36, 37,
873 38, 39, 40, 41, 42, 43, 4, 45, 46, 47,
874 48, 49, 50, 51, 52, 53, 54, 55, 56, 17,
875 -1, -1, 20, 21, 22, -1, 24, 25, 26, 27,
876 28, 29, 30, 31, 32, 33, 34, 35, 36, 37,
877 38, 39, 40, 41, 42, 43, 4, 45, 46, 47,
878 48, 49, 50, 51, 52, 53, 54, 55, 56, 17,
879 -1, -1, 20, 21, 22, -1, 24, 25, 26, 27,
880 28, 29, 30, 31, 32, 33, 34, 35, 36, 37,
881 38, 39, 40, 41, 42, 43, -1, 45, 46, 47,
882 48, 49, 50, 51, 52, 53, 54, 55, 56, 17,
883 -1, -1, 20, 21, 22, -1, 24, 25, 26, 27,
884 28, 29, 30, 31, 32, 33, 34, 35, 36, 37,
885 38, 39, 40, 41, 42, 43, -1, 45, 46, 47,
886 48, 49, 50, 51, 52, 53, 54, 55, 56, 17,
887 -1, -1, 20, 21, 22, -1, 24, 25, 26, 27,
888 28, 29, 30, 31, 32, 33, 34, 35, 36, 37,
889 38, 39, 40, 41, 42, 43, -1, 45, 46, 47,
890 48, 49, 50, 51, 52, 53, 54, 55, 56, 17,
891 -1, -1, 20, -1, 22, -1, 24, 25, 26, 27,
892 28, 29, 30, 31, 32, 33, 34, 35, 36, 37,
893 38, 39, 40, 41, 42, 43, -1, 45, 46, 47,
894 48, 49, 50, 51, 52, 53, 54, 55, 56, 21,
895 -1, -1, -1, -1, 26, 27, 28, 29, 30, 31,
Carl Worth667173e2010-07-28 12:33:56 -0700896 32, 33, 34, 35, 36, 37, 38, 39, 40, 41,
Carl Worth6b9e7b02010-08-11 14:00:21 -0700897 42, 43, 21, -1, -1, -1, -1, 26, 27, 28,
898 29, 30, 31, 32, 33, 34, 35, 36, 37, 38,
899 39, 40, 41, 42, 43, 26, 27, 28, 29, 30,
900 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
901 41, 42, 43, -1, -1, 46, 27, 28, 29, 30,
902 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
903 41, 42, 43, 28, 29, 30, 31, 32, 33, 34,
904 35, 36, 37, 38, 39, 40, 41, 42, 43, 29,
905 30, 31, 32, 33, 34, 35, 36, 37, 38, 39,
906 40, 41, 42, 43, 30, 31, 32, 33, 34, 35,
907 36, 37, 38, 39, 40, 41, 42, 43, 31, 32,
Eric Anholtd4a04f32010-07-28 16:58:39 -0700908 33, 34, 35, 36, 37, 38, 39, 40, 41, 42,
Carl Worth6b9e7b02010-08-11 14:00:21 -0700909 43, 33, 34, 35, 36, 37, 38, 39, 40, 41,
910 42, 43, 39, 40, 41, 42, 43
Carl Worth667173e2010-07-28 12:33:56 -0700911};
912
913/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
914 symbol of state STATE-NUM. */
915static const yytype_uint8 yystos[] =
916{
Eric Anholtd4a04f32010-07-28 16:58:39 -0700917 0, 58, 0, 5, 6, 7, 8, 9, 10, 11,
918 12, 13, 14, 15, 16, 17, 18, 20, 21, 22,
Carl Worth667173e2010-07-28 12:33:56 -0700919 24, 25, 26, 27, 28, 29, 30, 31, 32, 33,
Eric Anholtd4a04f32010-07-28 16:58:39 -0700920 34, 35, 36, 37, 38, 39, 40, 41, 42, 43,
Carl Worth667173e2010-07-28 12:33:56 -0700921 45, 46, 47, 48, 49, 50, 51, 52, 53, 54,
Eric Anholtd4a04f32010-07-28 16:58:39 -0700922 55, 56, 59, 60, 61, 65, 71, 72, 73, 19,
923 20, 39, 40, 45, 47, 48, 62, 63, 21, 66,
924 71, 17, 17, 4, 21, 69, 70, 72, 21, 21,
Carl Worth6b9e7b02010-08-11 14:00:21 -0700925 21, 70, 17, 17, 17, 62, 63, 21, 72, 63,
926 63, 63, 63, 63, 21, 26, 27, 28, 29, 30,
927 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
928 41, 42, 43, 21, 45, 67, 71, 17, 45, 21,
929 69, 21, 68, 71, 68, 21, 21, 21, 46, 63,
Eric Anholtd4a04f32010-07-28 16:58:39 -0700930 63, 63, 63, 63, 63, 63, 63, 63, 63, 63,
Carl Worth6b9e7b02010-08-11 14:00:21 -0700931 63, 63, 63, 63, 63, 63, 63, 17, 46, 64,
932 21, 17, 21, 21, 67, 46, 49, 46, 21, 67,
933 17, 21
Carl Worth667173e2010-07-28 12:33:56 -0700934};
935
936#define yyerrok (yyerrstatus = 0)
937#define yyclearin (yychar = YYEMPTY)
938#define YYEMPTY (-2)
939#define YYEOF 0
940
941#define YYACCEPT goto yyacceptlab
942#define YYABORT goto yyabortlab
943#define YYERROR goto yyerrorlab
944
945
946/* Like YYERROR except do call yyerror. This remains here temporarily
947 to ease the transition to the new meaning of YYERROR, for GCC.
Carl Worth9751b4e2010-08-17 23:22:42 -0700948 Once GCC version 2 has supplanted version 1, this can go. */
Carl Worth667173e2010-07-28 12:33:56 -0700949
950#define YYFAIL goto yyerrlab
951
952#define YYRECOVERING() (!!yyerrstatus)
953
954#define YYBACKUP(Token, Value) \
955do \
956 if (yychar == YYEMPTY && yylen == 1) \
957 { \
958 yychar = (Token); \
959 yylval = (Value); \
960 yytoken = YYTRANSLATE (yychar); \
961 YYPOPSTACK (1); \
962 goto yybackup; \
963 } \
964 else \
965 { \
966 yyerror (&yylloc, parser, YY_("syntax error: cannot back up")); \
967 YYERROR; \
968 } \
969while (YYID (0))
970
971
972#define YYTERROR 1
973#define YYERRCODE 256
974
975
976/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
977 If N is 0, then set CURRENT to the empty location which ends
978 the previous symbol: RHS[0] (always defined). */
979
980#define YYRHSLOC(Rhs, K) ((Rhs)[K])
981#ifndef YYLLOC_DEFAULT
982# define YYLLOC_DEFAULT(Current, Rhs, N) \
983 do \
984 if (YYID (N)) \
985 { \
986 (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
987 (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
988 (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
989 (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
990 } \
991 else \
992 { \
993 (Current).first_line = (Current).last_line = \
994 YYRHSLOC (Rhs, 0).last_line; \
995 (Current).first_column = (Current).last_column = \
996 YYRHSLOC (Rhs, 0).last_column; \
997 } \
998 while (YYID (0))
999#endif
1000
1001
1002/* YY_LOCATION_PRINT -- Print the location on the stream.
1003 This macro was not mandated originally: define only if we know
1004 we won't break user code: when these are the locations we know. */
1005
1006#ifndef YY_LOCATION_PRINT
Carl Worth9751b4e2010-08-17 23:22:42 -07001007# if YYLTYPE_IS_TRIVIAL
Carl Worth667173e2010-07-28 12:33:56 -07001008# define YY_LOCATION_PRINT(File, Loc) \
1009 fprintf (File, "%d.%d-%d.%d", \
1010 (Loc).first_line, (Loc).first_column, \
1011 (Loc).last_line, (Loc).last_column)
1012# else
1013# define YY_LOCATION_PRINT(File, Loc) ((void) 0)
1014# endif
1015#endif
1016
1017
1018/* YYLEX -- calling `yylex' with the right arguments. */
1019
1020#ifdef YYLEX_PARAM
1021# define YYLEX yylex (&yylval, &yylloc, YYLEX_PARAM)
1022#else
1023# define YYLEX yylex (&yylval, &yylloc, parser)
1024#endif
1025
1026/* Enable debugging if requested. */
1027#if YYDEBUG
1028
1029# ifndef YYFPRINTF
1030# include <stdio.h> /* INFRINGES ON USER NAME SPACE */
1031# define YYFPRINTF fprintf
1032# endif
1033
1034# define YYDPRINTF(Args) \
1035do { \
1036 if (yydebug) \
1037 YYFPRINTF Args; \
1038} while (YYID (0))
1039
1040# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
1041do { \
1042 if (yydebug) \
1043 { \
1044 YYFPRINTF (stderr, "%s ", Title); \
1045 yy_symbol_print (stderr, \
1046 Type, Value, Location, parser); \
1047 YYFPRINTF (stderr, "\n"); \
1048 } \
1049} while (YYID (0))
1050
1051
1052/*--------------------------------.
1053| Print this symbol on YYOUTPUT. |
1054`--------------------------------*/
1055
1056/*ARGSUSED*/
1057#if (defined __STDC__ || defined __C99__FUNC__ \
1058 || defined __cplusplus || defined _MSC_VER)
1059static void
1060yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, YYLTYPE const * const yylocationp, glcpp_parser_t *parser)
1061#else
1062static void
1063yy_symbol_value_print (yyoutput, yytype, yyvaluep, yylocationp, parser)
1064 FILE *yyoutput;
1065 int yytype;
1066 YYSTYPE const * const yyvaluep;
1067 YYLTYPE const * const yylocationp;
1068 glcpp_parser_t *parser;
1069#endif
1070{
1071 if (!yyvaluep)
1072 return;
1073 YYUSE (yylocationp);
1074 YYUSE (parser);
1075# ifdef YYPRINT
1076 if (yytype < YYNTOKENS)
1077 YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
1078# else
1079 YYUSE (yyoutput);
1080# endif
1081 switch (yytype)
1082 {
1083 default:
1084 break;
1085 }
1086}
1087
1088
1089/*--------------------------------.
1090| Print this symbol on YYOUTPUT. |
1091`--------------------------------*/
1092
1093#if (defined __STDC__ || defined __C99__FUNC__ \
1094 || defined __cplusplus || defined _MSC_VER)
1095static void
1096yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, YYLTYPE const * const yylocationp, glcpp_parser_t *parser)
1097#else
1098static void
1099yy_symbol_print (yyoutput, yytype, yyvaluep, yylocationp, parser)
1100 FILE *yyoutput;
1101 int yytype;
1102 YYSTYPE const * const yyvaluep;
1103 YYLTYPE const * const yylocationp;
1104 glcpp_parser_t *parser;
1105#endif
1106{
1107 if (yytype < YYNTOKENS)
1108 YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
1109 else
1110 YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
1111
1112 YY_LOCATION_PRINT (yyoutput, *yylocationp);
1113 YYFPRINTF (yyoutput, ": ");
1114 yy_symbol_value_print (yyoutput, yytype, yyvaluep, yylocationp, parser);
1115 YYFPRINTF (yyoutput, ")");
1116}
1117
1118/*------------------------------------------------------------------.
1119| yy_stack_print -- Print the state stack from its BOTTOM up to its |
1120| TOP (included). |
1121`------------------------------------------------------------------*/
1122
1123#if (defined __STDC__ || defined __C99__FUNC__ \
1124 || defined __cplusplus || defined _MSC_VER)
1125static void
1126yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop)
1127#else
1128static void
1129yy_stack_print (yybottom, yytop)
1130 yytype_int16 *yybottom;
1131 yytype_int16 *yytop;
1132#endif
1133{
1134 YYFPRINTF (stderr, "Stack now");
1135 for (; yybottom <= yytop; yybottom++)
1136 {
1137 int yybot = *yybottom;
1138 YYFPRINTF (stderr, " %d", yybot);
1139 }
1140 YYFPRINTF (stderr, "\n");
1141}
1142
1143# define YY_STACK_PRINT(Bottom, Top) \
1144do { \
1145 if (yydebug) \
1146 yy_stack_print ((Bottom), (Top)); \
1147} while (YYID (0))
1148
1149
1150/*------------------------------------------------.
1151| Report that the YYRULE is going to be reduced. |
1152`------------------------------------------------*/
1153
1154#if (defined __STDC__ || defined __C99__FUNC__ \
1155 || defined __cplusplus || defined _MSC_VER)
1156static void
1157yy_reduce_print (YYSTYPE *yyvsp, YYLTYPE *yylsp, int yyrule, glcpp_parser_t *parser)
1158#else
1159static void
1160yy_reduce_print (yyvsp, yylsp, yyrule, parser)
1161 YYSTYPE *yyvsp;
1162 YYLTYPE *yylsp;
1163 int yyrule;
1164 glcpp_parser_t *parser;
1165#endif
1166{
1167 int yynrhs = yyr2[yyrule];
1168 int yyi;
1169 unsigned long int yylno = yyrline[yyrule];
1170 YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
1171 yyrule - 1, yylno);
1172 /* The symbols being reduced. */
1173 for (yyi = 0; yyi < yynrhs; yyi++)
1174 {
1175 YYFPRINTF (stderr, " $%d = ", yyi + 1);
1176 yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
1177 &(yyvsp[(yyi + 1) - (yynrhs)])
1178 , &(yylsp[(yyi + 1) - (yynrhs)]) , parser);
1179 YYFPRINTF (stderr, "\n");
1180 }
1181}
1182
1183# define YY_REDUCE_PRINT(Rule) \
1184do { \
1185 if (yydebug) \
1186 yy_reduce_print (yyvsp, yylsp, Rule, parser); \
1187} while (YYID (0))
1188
1189/* Nonzero means print parse trace. It is left uninitialized so that
1190 multiple parsers can coexist. */
1191int yydebug;
1192#else /* !YYDEBUG */
1193# define YYDPRINTF(Args)
1194# define YY_SYMBOL_PRINT(Title, Type, Value, Location)
1195# define YY_STACK_PRINT(Bottom, Top)
1196# define YY_REDUCE_PRINT(Rule)
1197#endif /* !YYDEBUG */
1198
1199
1200/* YYINITDEPTH -- initial size of the parser's stacks. */
1201#ifndef YYINITDEPTH
1202# define YYINITDEPTH 200
1203#endif
1204
1205/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
1206 if the built-in stack extension method is used).
1207
1208 Do not make this value too large; the results are undefined if
1209 YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
1210 evaluated with infinite-precision integer arithmetic. */
1211
1212#ifndef YYMAXDEPTH
1213# define YYMAXDEPTH 10000
1214#endif
1215
1216
1217
1218#if YYERROR_VERBOSE
1219
1220# ifndef yystrlen
1221# if defined __GLIBC__ && defined _STRING_H
1222# define yystrlen strlen
1223# else
1224/* Return the length of YYSTR. */
1225#if (defined __STDC__ || defined __C99__FUNC__ \
1226 || defined __cplusplus || defined _MSC_VER)
1227static YYSIZE_T
1228yystrlen (const char *yystr)
1229#else
1230static YYSIZE_T
1231yystrlen (yystr)
1232 const char *yystr;
1233#endif
1234{
1235 YYSIZE_T yylen;
1236 for (yylen = 0; yystr[yylen]; yylen++)
1237 continue;
1238 return yylen;
1239}
1240# endif
1241# endif
1242
1243# ifndef yystpcpy
1244# if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
1245# define yystpcpy stpcpy
1246# else
1247/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
1248 YYDEST. */
1249#if (defined __STDC__ || defined __C99__FUNC__ \
1250 || defined __cplusplus || defined _MSC_VER)
1251static char *
1252yystpcpy (char *yydest, const char *yysrc)
1253#else
1254static char *
1255yystpcpy (yydest, yysrc)
1256 char *yydest;
1257 const char *yysrc;
1258#endif
1259{
1260 char *yyd = yydest;
1261 const char *yys = yysrc;
1262
1263 while ((*yyd++ = *yys++) != '\0')
1264 continue;
1265
1266 return yyd - 1;
1267}
1268# endif
1269# endif
1270
1271# ifndef yytnamerr
1272/* Copy to YYRES the contents of YYSTR after stripping away unnecessary
1273 quotes and backslashes, so that it's suitable for yyerror. The
1274 heuristic is that double-quoting is unnecessary unless the string
1275 contains an apostrophe, a comma, or backslash (other than
1276 backslash-backslash). YYSTR is taken from yytname. If YYRES is
1277 null, do not copy; instead, return the length of what the result
1278 would have been. */
1279static YYSIZE_T
1280yytnamerr (char *yyres, const char *yystr)
1281{
1282 if (*yystr == '"')
1283 {
1284 YYSIZE_T yyn = 0;
1285 char const *yyp = yystr;
1286
1287 for (;;)
1288 switch (*++yyp)
1289 {
1290 case '\'':
1291 case ',':
1292 goto do_not_strip_quotes;
1293
1294 case '\\':
1295 if (*++yyp != '\\')
1296 goto do_not_strip_quotes;
1297 /* Fall through. */
1298 default:
1299 if (yyres)
1300 yyres[yyn] = *yyp;
1301 yyn++;
1302 break;
1303
1304 case '"':
1305 if (yyres)
1306 yyres[yyn] = '\0';
1307 return yyn;
1308 }
1309 do_not_strip_quotes: ;
1310 }
1311
1312 if (! yyres)
1313 return yystrlen (yystr);
1314
1315 return yystpcpy (yyres, yystr) - yyres;
1316}
1317# endif
1318
1319/* Copy into YYRESULT an error message about the unexpected token
1320 YYCHAR while in state YYSTATE. Return the number of bytes copied,
1321 including the terminating null byte. If YYRESULT is null, do not
1322 copy anything; just return the number of bytes that would be
1323 copied. As a special case, return 0 if an ordinary "syntax error"
1324 message will do. Return YYSIZE_MAXIMUM if overflow occurs during
1325 size calculation. */
1326static YYSIZE_T
1327yysyntax_error (char *yyresult, int yystate, int yychar)
1328{
1329 int yyn = yypact[yystate];
1330
1331 if (! (YYPACT_NINF < yyn && yyn <= YYLAST))
1332 return 0;
1333 else
1334 {
1335 int yytype = YYTRANSLATE (yychar);
1336 YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]);
1337 YYSIZE_T yysize = yysize0;
1338 YYSIZE_T yysize1;
1339 int yysize_overflow = 0;
1340 enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
1341 char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
1342 int yyx;
1343
1344# if 0
1345 /* This is so xgettext sees the translatable formats that are
1346 constructed on the fly. */
1347 YY_("syntax error, unexpected %s");
1348 YY_("syntax error, unexpected %s, expecting %s");
1349 YY_("syntax error, unexpected %s, expecting %s or %s");
1350 YY_("syntax error, unexpected %s, expecting %s or %s or %s");
1351 YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s");
1352# endif
1353 char *yyfmt;
1354 char const *yyf;
1355 static char const yyunexpected[] = "syntax error, unexpected %s";
1356 static char const yyexpecting[] = ", expecting %s";
1357 static char const yyor[] = " or %s";
1358 char yyformat[sizeof yyunexpected
1359 + sizeof yyexpecting - 1
1360 + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2)
1361 * (sizeof yyor - 1))];
1362 char const *yyprefix = yyexpecting;
1363
1364 /* Start YYX at -YYN if negative to avoid negative indexes in
1365 YYCHECK. */
1366 int yyxbegin = yyn < 0 ? -yyn : 0;
1367
1368 /* Stay within bounds of both yycheck and yytname. */
1369 int yychecklim = YYLAST - yyn + 1;
1370 int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
1371 int yycount = 1;
1372
1373 yyarg[0] = yytname[yytype];
1374 yyfmt = yystpcpy (yyformat, yyunexpected);
1375
1376 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
1377 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
1378 {
1379 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
1380 {
1381 yycount = 1;
1382 yysize = yysize0;
1383 yyformat[sizeof yyunexpected - 1] = '\0';
1384 break;
1385 }
1386 yyarg[yycount++] = yytname[yyx];
1387 yysize1 = yysize + yytnamerr (0, yytname[yyx]);
1388 yysize_overflow |= (yysize1 < yysize);
1389 yysize = yysize1;
1390 yyfmt = yystpcpy (yyfmt, yyprefix);
1391 yyprefix = yyor;
1392 }
1393
1394 yyf = YY_(yyformat);
1395 yysize1 = yysize + yystrlen (yyf);
1396 yysize_overflow |= (yysize1 < yysize);
1397 yysize = yysize1;
1398
1399 if (yysize_overflow)
1400 return YYSIZE_MAXIMUM;
1401
1402 if (yyresult)
1403 {
1404 /* Avoid sprintf, as that infringes on the user's name space.
1405 Don't have undefined behavior even if the translation
1406 produced a string with the wrong number of "%s"s. */
1407 char *yyp = yyresult;
1408 int yyi = 0;
1409 while ((*yyp = *yyf) != '\0')
1410 {
1411 if (*yyp == '%' && yyf[1] == 's' && yyi < yycount)
1412 {
1413 yyp += yytnamerr (yyp, yyarg[yyi++]);
1414 yyf += 2;
1415 }
1416 else
1417 {
1418 yyp++;
1419 yyf++;
1420 }
1421 }
1422 }
1423 return yysize;
1424 }
1425}
1426#endif /* YYERROR_VERBOSE */
1427
1428
1429/*-----------------------------------------------.
1430| Release the memory associated to this symbol. |
1431`-----------------------------------------------*/
1432
1433/*ARGSUSED*/
1434#if (defined __STDC__ || defined __C99__FUNC__ \
1435 || defined __cplusplus || defined _MSC_VER)
1436static void
1437yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, YYLTYPE *yylocationp, glcpp_parser_t *parser)
1438#else
1439static void
1440yydestruct (yymsg, yytype, yyvaluep, yylocationp, parser)
1441 const char *yymsg;
1442 int yytype;
1443 YYSTYPE *yyvaluep;
1444 YYLTYPE *yylocationp;
1445 glcpp_parser_t *parser;
1446#endif
1447{
1448 YYUSE (yyvaluep);
1449 YYUSE (yylocationp);
1450 YYUSE (parser);
1451
1452 if (!yymsg)
1453 yymsg = "Deleting";
1454 YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
1455
1456 switch (yytype)
1457 {
1458
1459 default:
1460 break;
1461 }
1462}
1463
1464/* Prevent warnings from -Wmissing-prototypes. */
1465#ifdef YYPARSE_PARAM
1466#if defined __STDC__ || defined __cplusplus
1467int yyparse (void *YYPARSE_PARAM);
1468#else
1469int yyparse ();
1470#endif
1471#else /* ! YYPARSE_PARAM */
1472#if defined __STDC__ || defined __cplusplus
1473int yyparse (glcpp_parser_t *parser);
1474#else
1475int yyparse ();
1476#endif
1477#endif /* ! YYPARSE_PARAM */
1478
1479
1480
1481
1482
1483/*-------------------------.
1484| yyparse or yypush_parse. |
1485`-------------------------*/
1486
1487#ifdef YYPARSE_PARAM
1488#if (defined __STDC__ || defined __C99__FUNC__ \
1489 || defined __cplusplus || defined _MSC_VER)
1490int
1491yyparse (void *YYPARSE_PARAM)
1492#else
1493int
1494yyparse (YYPARSE_PARAM)
1495 void *YYPARSE_PARAM;
1496#endif
1497#else /* ! YYPARSE_PARAM */
1498#if (defined __STDC__ || defined __C99__FUNC__ \
1499 || defined __cplusplus || defined _MSC_VER)
1500int
1501yyparse (glcpp_parser_t *parser)
1502#else
1503int
1504yyparse (parser)
1505 glcpp_parser_t *parser;
1506#endif
1507#endif
1508{
1509/* The lookahead symbol. */
1510int yychar;
1511
1512/* The semantic value of the lookahead symbol. */
1513YYSTYPE yylval;
1514
1515/* Location data for the lookahead symbol. */
1516YYLTYPE yylloc;
1517
1518 /* Number of syntax errors so far. */
1519 int yynerrs;
1520
1521 int yystate;
1522 /* Number of tokens to shift before error messages enabled. */
1523 int yyerrstatus;
1524
1525 /* The stacks and their tools:
1526 `yyss': related to states.
1527 `yyvs': related to semantic values.
1528 `yyls': related to locations.
1529
1530 Refer to the stacks thru separate pointers, to allow yyoverflow
1531 to reallocate them elsewhere. */
1532
1533 /* The state stack. */
1534 yytype_int16 yyssa[YYINITDEPTH];
1535 yytype_int16 *yyss;
1536 yytype_int16 *yyssp;
1537
1538 /* The semantic value stack. */
1539 YYSTYPE yyvsa[YYINITDEPTH];
1540 YYSTYPE *yyvs;
1541 YYSTYPE *yyvsp;
1542
1543 /* The location stack. */
1544 YYLTYPE yylsa[YYINITDEPTH];
1545 YYLTYPE *yyls;
1546 YYLTYPE *yylsp;
1547
1548 /* The locations where the error started and ended. */
Carl Worth9751b4e2010-08-17 23:22:42 -07001549 YYLTYPE yyerror_range[2];
Carl Worth667173e2010-07-28 12:33:56 -07001550
1551 YYSIZE_T yystacksize;
1552
1553 int yyn;
1554 int yyresult;
1555 /* Lookahead token as an internal (translated) token number. */
1556 int yytoken;
1557 /* The variables used to return semantic value and location from the
1558 action routines. */
1559 YYSTYPE yyval;
1560 YYLTYPE yyloc;
1561
1562#if YYERROR_VERBOSE
1563 /* Buffer for error messages, and its allocated size. */
1564 char yymsgbuf[128];
1565 char *yymsg = yymsgbuf;
1566 YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
1567#endif
1568
1569#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N), yylsp -= (N))
1570
1571 /* The number of symbols on the RHS of the reduced rule.
1572 Keep to zero when no symbol should be popped. */
1573 int yylen = 0;
1574
1575 yytoken = 0;
1576 yyss = yyssa;
1577 yyvs = yyvsa;
1578 yyls = yylsa;
1579 yystacksize = YYINITDEPTH;
1580
1581 YYDPRINTF ((stderr, "Starting parse\n"));
1582
1583 yystate = 0;
1584 yyerrstatus = 0;
1585 yynerrs = 0;
1586 yychar = YYEMPTY; /* Cause a token to be read. */
1587
1588 /* Initialize stack pointers.
1589 Waste one element of value and location stack
1590 so that they stay on the same level as the state stack.
1591 The wasted elements are never initialized. */
1592 yyssp = yyss;
1593 yyvsp = yyvs;
1594 yylsp = yyls;
1595
Carl Worth9751b4e2010-08-17 23:22:42 -07001596#if YYLTYPE_IS_TRIVIAL
Carl Worth667173e2010-07-28 12:33:56 -07001597 /* Initialize the default location before parsing starts. */
1598 yylloc.first_line = yylloc.last_line = 1;
1599 yylloc.first_column = yylloc.last_column = 1;
1600#endif
1601
Carl Worthe29cd392010-08-10 16:59:20 -07001602/* User initialization code. */
1603
Carl Worth9751b4e2010-08-17 23:22:42 -07001604/* Line 1242 of yacc.c */
1605#line 154 "glcpp/glcpp-parse.y"
Carl Worthe29cd392010-08-10 16:59:20 -07001606{
1607 yylloc.first_line = 1;
1608 yylloc.first_column = 1;
1609 yylloc.last_line = 1;
1610 yylloc.last_column = 1;
1611 yylloc.source = 0;
1612}
1613
Carl Worth9751b4e2010-08-17 23:22:42 -07001614/* Line 1242 of yacc.c */
1615#line 1616 "glcpp/glcpp-parse.c"
Carl Worthe29cd392010-08-10 16:59:20 -07001616 yylsp[0] = yylloc;
1617
Carl Worth667173e2010-07-28 12:33:56 -07001618 goto yysetstate;
1619
1620/*------------------------------------------------------------.
1621| yynewstate -- Push a new state, which is found in yystate. |
1622`------------------------------------------------------------*/
1623 yynewstate:
1624 /* In all cases, when you get here, the value and location stacks
1625 have just been pushed. So pushing a state here evens the stacks. */
1626 yyssp++;
1627
1628 yysetstate:
1629 *yyssp = yystate;
1630
1631 if (yyss + yystacksize - 1 <= yyssp)
1632 {
1633 /* Get the current used size of the three stacks, in elements. */
1634 YYSIZE_T yysize = yyssp - yyss + 1;
1635
1636#ifdef yyoverflow
1637 {
1638 /* Give user a chance to reallocate the stack. Use copies of
1639 these so that the &'s don't force the real ones into
1640 memory. */
1641 YYSTYPE *yyvs1 = yyvs;
1642 yytype_int16 *yyss1 = yyss;
1643 YYLTYPE *yyls1 = yyls;
1644
1645 /* Each stack pointer address is followed by the size of the
1646 data in use in that stack, in bytes. This used to be a
1647 conditional around just the two extra args, but that might
1648 be undefined if yyoverflow is a macro. */
1649 yyoverflow (YY_("memory exhausted"),
1650 &yyss1, yysize * sizeof (*yyssp),
1651 &yyvs1, yysize * sizeof (*yyvsp),
1652 &yyls1, yysize * sizeof (*yylsp),
1653 &yystacksize);
1654
1655 yyls = yyls1;
1656 yyss = yyss1;
1657 yyvs = yyvs1;
1658 }
1659#else /* no yyoverflow */
1660# ifndef YYSTACK_RELOCATE
1661 goto yyexhaustedlab;
1662# else
1663 /* Extend the stack our own way. */
1664 if (YYMAXDEPTH <= yystacksize)
1665 goto yyexhaustedlab;
1666 yystacksize *= 2;
1667 if (YYMAXDEPTH < yystacksize)
1668 yystacksize = YYMAXDEPTH;
1669
1670 {
1671 yytype_int16 *yyss1 = yyss;
1672 union yyalloc *yyptr =
1673 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
1674 if (! yyptr)
1675 goto yyexhaustedlab;
1676 YYSTACK_RELOCATE (yyss_alloc, yyss);
1677 YYSTACK_RELOCATE (yyvs_alloc, yyvs);
1678 YYSTACK_RELOCATE (yyls_alloc, yyls);
1679# undef YYSTACK_RELOCATE
1680 if (yyss1 != yyssa)
1681 YYSTACK_FREE (yyss1);
1682 }
1683# endif
1684#endif /* no yyoverflow */
1685
1686 yyssp = yyss + yysize - 1;
1687 yyvsp = yyvs + yysize - 1;
1688 yylsp = yyls + yysize - 1;
1689
1690 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
1691 (unsigned long int) yystacksize));
1692
1693 if (yyss + yystacksize - 1 <= yyssp)
1694 YYABORT;
1695 }
1696
1697 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
1698
1699 if (yystate == YYFINAL)
1700 YYACCEPT;
1701
1702 goto yybackup;
1703
1704/*-----------.
1705| yybackup. |
1706`-----------*/
1707yybackup:
1708
1709 /* Do appropriate processing given the current state. Read a
1710 lookahead token if we need one and don't already have one. */
1711
1712 /* First try to decide what to do without reference to lookahead token. */
1713 yyn = yypact[yystate];
1714 if (yyn == YYPACT_NINF)
1715 goto yydefault;
1716
1717 /* Not known => get a lookahead token if don't already have one. */
1718
1719 /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */
1720 if (yychar == YYEMPTY)
1721 {
1722 YYDPRINTF ((stderr, "Reading a token: "));
1723 yychar = YYLEX;
1724 }
1725
1726 if (yychar <= YYEOF)
1727 {
1728 yychar = yytoken = YYEOF;
1729 YYDPRINTF ((stderr, "Now at end of input.\n"));
1730 }
1731 else
1732 {
1733 yytoken = YYTRANSLATE (yychar);
1734 YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
1735 }
1736
1737 /* If the proper action on seeing token YYTOKEN is to reduce or to
1738 detect an error, take that action. */
1739 yyn += yytoken;
1740 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
1741 goto yydefault;
1742 yyn = yytable[yyn];
1743 if (yyn <= 0)
1744 {
1745 if (yyn == 0 || yyn == YYTABLE_NINF)
1746 goto yyerrlab;
1747 yyn = -yyn;
1748 goto yyreduce;
1749 }
1750
1751 /* Count tokens shifted since error; after three, turn off error
1752 status. */
1753 if (yyerrstatus)
1754 yyerrstatus--;
1755
1756 /* Shift the lookahead token. */
1757 YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
1758
1759 /* Discard the shifted token. */
1760 yychar = YYEMPTY;
1761
1762 yystate = yyn;
1763 *++yyvsp = yylval;
1764 *++yylsp = yylloc;
1765 goto yynewstate;
1766
1767
1768/*-----------------------------------------------------------.
1769| yydefault -- do the default action for the current state. |
1770`-----------------------------------------------------------*/
1771yydefault:
1772 yyn = yydefact[yystate];
1773 if (yyn == 0)
1774 goto yyerrlab;
1775 goto yyreduce;
1776
1777
1778/*-----------------------------.
1779| yyreduce -- Do a reduction. |
1780`-----------------------------*/
1781yyreduce:
1782 /* yyn is the number of a rule to reduce with. */
1783 yylen = yyr2[yyn];
1784
1785 /* If YYLEN is nonzero, implement the default value of the action:
1786 `$$ = $1'.
1787
1788 Otherwise, the following line sets YYVAL to garbage.
1789 This behavior is undocumented and Bison
1790 users should not rely upon it. Assigning to YYVAL
1791 unconditionally makes the parser a bit smaller, and it avoids a
1792 GCC warning that YYVAL may be used uninitialized. */
1793 yyval = yyvsp[1-yylen];
1794
1795 /* Default location. */
1796 YYLLOC_DEFAULT (yyloc, (yylsp - yylen), yylen);
1797 YY_REDUCE_PRINT (yyn);
1798 switch (yyn)
1799 {
1800 case 4:
1801
Carl Worth9751b4e2010-08-17 23:22:42 -07001802/* Line 1455 of yacc.c */
1803#line 193 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07001804 {
1805 glcpp_print(parser->output, "\n");
1806 ;}
1807 break;
1808
1809 case 5:
1810
Carl Worth9751b4e2010-08-17 23:22:42 -07001811/* Line 1455 of yacc.c */
1812#line 196 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07001813 {
1814 _glcpp_parser_print_expanded_token_list (parser, (yyvsp[(1) - (1)].token_list));
1815 glcpp_print(parser->output, "\n");
1816 talloc_free ((yyvsp[(1) - (1)].token_list));
1817 ;}
1818 break;
1819
1820 case 8:
1821
Carl Worth9751b4e2010-08-17 23:22:42 -07001822/* Line 1455 of yacc.c */
1823#line 206 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07001824 {
1825 _glcpp_parser_skip_stack_push_if (parser, & (yylsp[(1) - (3)]), (yyvsp[(2) - (3)].ival));
1826 ;}
1827 break;
1828
1829 case 9:
1830
Carl Worth9751b4e2010-08-17 23:22:42 -07001831/* Line 1455 of yacc.c */
1832#line 209 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07001833 {
1834 _glcpp_parser_skip_stack_change_if (parser, & (yylsp[(1) - (3)]), "elif", (yyvsp[(2) - (3)].ival));
1835 ;}
1836 break;
1837
1838 case 10:
1839
Carl Worth9751b4e2010-08-17 23:22:42 -07001840/* Line 1455 of yacc.c */
1841#line 215 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07001842 {
1843 _define_object_macro (parser, & (yylsp[(2) - (4)]), (yyvsp[(2) - (4)].str), (yyvsp[(3) - (4)].token_list));
1844 ;}
1845 break;
1846
1847 case 11:
1848
Carl Worth9751b4e2010-08-17 23:22:42 -07001849/* Line 1455 of yacc.c */
1850#line 218 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07001851 {
1852 _define_function_macro (parser, & (yylsp[(2) - (6)]), (yyvsp[(2) - (6)].str), NULL, (yyvsp[(5) - (6)].token_list));
1853 ;}
1854 break;
1855
1856 case 12:
1857
Carl Worth9751b4e2010-08-17 23:22:42 -07001858/* Line 1455 of yacc.c */
1859#line 221 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07001860 {
1861 _define_function_macro (parser, & (yylsp[(2) - (7)]), (yyvsp[(2) - (7)].str), (yyvsp[(4) - (7)].string_list), (yyvsp[(6) - (7)].token_list));
1862 ;}
1863 break;
1864
1865 case 13:
1866
Carl Worth9751b4e2010-08-17 23:22:42 -07001867/* Line 1455 of yacc.c */
1868#line 224 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07001869 {
1870 macro_t *macro = hash_table_find (parser->defines, (yyvsp[(2) - (3)].str));
1871 if (macro) {
1872 hash_table_remove (parser->defines, (yyvsp[(2) - (3)].str));
1873 talloc_free (macro);
1874 }
1875 talloc_free ((yyvsp[(2) - (3)].str));
1876 ;}
1877 break;
1878
1879 case 14:
1880
Carl Worth9751b4e2010-08-17 23:22:42 -07001881/* Line 1455 of yacc.c */
1882#line 232 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07001883 {
Carl Worth764e0962010-08-11 12:45:55 -07001884 /* Be careful to only evaluate the 'if' expression if
1885 * we are not skipping. When we are skipping, we
1886 * simply push a new 0-valued 'if' onto the skip
1887 * stack.
1888 *
1889 * This avoids generating diagnostics for invalid
1890 * expressions that are being skipped. */
1891 if (parser->skip_stack == NULL ||
1892 parser->skip_stack->type == SKIP_NO_SKIP)
1893 {
1894 _glcpp_parser_expand_if (parser, IF_EXPANDED, (yyvsp[(2) - (3)].token_list));
1895 }
1896 else
1897 {
Kenneth Graunkef4239872010-08-04 16:24:39 -07001898 _glcpp_parser_skip_stack_push_if (parser, & (yylsp[(1) - (3)]), 0);
1899 parser->skip_stack->type = SKIP_TO_ENDIF;
Kenneth Graunkef4239872010-08-04 16:24:39 -07001900 }
Carl Worth667173e2010-07-28 12:33:56 -07001901 ;}
1902 break;
1903
1904 case 15:
1905
Carl Worth9751b4e2010-08-17 23:22:42 -07001906/* Line 1455 of yacc.c */
1907#line 251 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07001908 {
Carl Worth6b9e7b02010-08-11 14:00:21 -07001909 /* #if without an expression is only an error if we
1910 * are not skipping */
1911 if (parser->skip_stack == NULL ||
1912 parser->skip_stack->type == SKIP_NO_SKIP)
1913 {
1914 glcpp_error(& (yylsp[(1) - (2)]), parser, "#if with no expression");
1915 }
1916 _glcpp_parser_skip_stack_push_if (parser, & (yylsp[(1) - (2)]), 0);
Carl Worth667173e2010-07-28 12:33:56 -07001917 ;}
1918 break;
1919
1920 case 16:
1921
Carl Worth9751b4e2010-08-17 23:22:42 -07001922/* Line 1455 of yacc.c */
1923#line 261 "glcpp/glcpp-parse.y"
Carl Worth6b9e7b02010-08-11 14:00:21 -07001924 {
1925 macro_t *macro = hash_table_find (parser->defines, (yyvsp[(2) - (4)].str));
1926 talloc_free ((yyvsp[(2) - (4)].str));
1927 _glcpp_parser_skip_stack_push_if (parser, & (yylsp[(1) - (4)]), macro != NULL);
1928 ;}
1929 break;
1930
1931 case 17:
1932
Carl Worth9751b4e2010-08-17 23:22:42 -07001933/* Line 1455 of yacc.c */
1934#line 266 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07001935 {
1936 macro_t *macro = hash_table_find (parser->defines, (yyvsp[(2) - (4)].str));
1937 talloc_free ((yyvsp[(2) - (4)].str));
1938 _glcpp_parser_skip_stack_push_if (parser, & (yylsp[(1) - (4)]), macro == NULL);
1939 ;}
1940 break;
1941
Carl Worth6b9e7b02010-08-11 14:00:21 -07001942 case 18:
Carl Worth667173e2010-07-28 12:33:56 -07001943
Carl Worth9751b4e2010-08-17 23:22:42 -07001944/* Line 1455 of yacc.c */
1945#line 271 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07001946 {
Carl Worth764e0962010-08-11 12:45:55 -07001947 /* Be careful to only evaluate the 'elif' expression
1948 * if we are not skipping. When we are skipping, we
1949 * simply change to a 0-valued 'elif' on the skip
1950 * stack.
1951 *
1952 * This avoids generating diagnostics for invalid
1953 * expressions that are being skipped. */
1954 if (parser->skip_stack &&
1955 parser->skip_stack->type == SKIP_TO_ELSE)
1956 {
Kenneth Graunkef4239872010-08-04 16:24:39 -07001957 _glcpp_parser_expand_if (parser, ELIF_EXPANDED, (yyvsp[(2) - (3)].token_list));
Carl Worth764e0962010-08-11 12:45:55 -07001958 }
1959 else
1960 {
1961 _glcpp_parser_skip_stack_change_if (parser, & (yylsp[(1) - (3)]),
1962 "elif", 0);
1963 }
Carl Worth667173e2010-07-28 12:33:56 -07001964 ;}
1965 break;
1966
Carl Worth6b9e7b02010-08-11 14:00:21 -07001967 case 19:
Carl Worth667173e2010-07-28 12:33:56 -07001968
Carl Worth9751b4e2010-08-17 23:22:42 -07001969/* Line 1455 of yacc.c */
1970#line 290 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07001971 {
Carl Worth764e0962010-08-11 12:45:55 -07001972 /* #elif without an expression is an error unless we
1973 * are skipping. */
1974 if (parser->skip_stack &&
1975 parser->skip_stack->type == SKIP_TO_ELSE)
1976 {
Carl Worth624dd582010-08-11 13:50:51 -07001977 glcpp_error(& (yylsp[(1) - (2)]), parser, "#elif with no expression");
Carl Worth667173e2010-07-28 12:33:56 -07001978 }
Carl Worth764e0962010-08-11 12:45:55 -07001979 else
1980 {
1981 _glcpp_parser_skip_stack_change_if (parser, & (yylsp[(1) - (2)]),
1982 "elif", 0);
1983 glcpp_warning(& (yylsp[(1) - (2)]), parser, "ignoring illegal #elif without expression");
1984 }
Carl Worth667173e2010-07-28 12:33:56 -07001985 ;}
1986 break;
1987
Carl Worth667173e2010-07-28 12:33:56 -07001988 case 20:
1989
Carl Worth9751b4e2010-08-17 23:22:42 -07001990/* Line 1455 of yacc.c */
1991#line 305 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07001992 {
Carl Worth6b9e7b02010-08-11 14:00:21 -07001993 _glcpp_parser_skip_stack_change_if (parser, & (yylsp[(1) - (2)]), "else", 1);
Carl Worth667173e2010-07-28 12:33:56 -07001994 ;}
1995 break;
1996
Eric Anholtd4a04f32010-07-28 16:58:39 -07001997 case 21:
Carl Worth667173e2010-07-28 12:33:56 -07001998
Carl Worth9751b4e2010-08-17 23:22:42 -07001999/* Line 1455 of yacc.c */
2000#line 308 "glcpp/glcpp-parse.y"
Carl Worth6b9e7b02010-08-11 14:00:21 -07002001 {
2002 _glcpp_parser_skip_stack_pop (parser, & (yylsp[(1) - (2)]));
2003 ;}
2004 break;
2005
2006 case 22:
2007
Carl Worth9751b4e2010-08-17 23:22:42 -07002008/* Line 1455 of yacc.c */
2009#line 311 "glcpp/glcpp-parse.y"
Eric Anholtd4a04f32010-07-28 16:58:39 -07002010 {
2011 macro_t *macro = hash_table_find (parser->defines, "__VERSION__");
2012 if (macro) {
2013 hash_table_remove (parser->defines, "__VERSION__");
2014 talloc_free (macro);
2015 }
2016 add_builtin_define (parser, "__VERSION__", (yyvsp[(2) - (3)].ival));
Kenneth Graunke2e261452010-08-16 13:43:10 -07002017 glcpp_printf(parser->output, "#version %" PRIiMAX, (yyvsp[(2) - (3)].ival));
Eric Anholtd4a04f32010-07-28 16:58:39 -07002018 ;}
2019 break;
2020
Carl Worth6b9e7b02010-08-11 14:00:21 -07002021 case 24:
Eric Anholtd4a04f32010-07-28 16:58:39 -07002022
Carl Worth9751b4e2010-08-17 23:22:42 -07002023/* Line 1455 of yacc.c */
2024#line 324 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07002025 {
2026 if (strlen ((yyvsp[(1) - (1)].str)) >= 3 && strncmp ((yyvsp[(1) - (1)].str), "0x", 2) == 0) {
2027 (yyval.ival) = strtoll ((yyvsp[(1) - (1)].str) + 2, NULL, 16);
2028 } else if ((yyvsp[(1) - (1)].str)[0] == '0') {
2029 (yyval.ival) = strtoll ((yyvsp[(1) - (1)].str), NULL, 8);
2030 } else {
2031 (yyval.ival) = strtoll ((yyvsp[(1) - (1)].str), NULL, 10);
2032 }
2033 ;}
2034 break;
2035
Carl Worth6b9e7b02010-08-11 14:00:21 -07002036 case 25:
Carl Worth667173e2010-07-28 12:33:56 -07002037
Carl Worth9751b4e2010-08-17 23:22:42 -07002038/* Line 1455 of yacc.c */
2039#line 333 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07002040 {
Eric Anholtd4a04f32010-07-28 16:58:39 -07002041 (yyval.ival) = (yyvsp[(1) - (1)].ival);
Carl Worth667173e2010-07-28 12:33:56 -07002042 ;}
2043 break;
2044
Carl Worth667173e2010-07-28 12:33:56 -07002045 case 27:
2046
Carl Worth9751b4e2010-08-17 23:22:42 -07002047/* Line 1455 of yacc.c */
2048#line 339 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07002049 {
Carl Worth6b9e7b02010-08-11 14:00:21 -07002050 (yyval.ival) = (yyvsp[(1) - (3)].ival) || (yyvsp[(3) - (3)].ival);
Carl Worth667173e2010-07-28 12:33:56 -07002051 ;}
2052 break;
2053
2054 case 28:
2055
Carl Worth9751b4e2010-08-17 23:22:42 -07002056/* Line 1455 of yacc.c */
2057#line 342 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07002058 {
Carl Worth6b9e7b02010-08-11 14:00:21 -07002059 (yyval.ival) = (yyvsp[(1) - (3)].ival) && (yyvsp[(3) - (3)].ival);
Carl Worth667173e2010-07-28 12:33:56 -07002060 ;}
2061 break;
2062
2063 case 29:
2064
Carl Worth9751b4e2010-08-17 23:22:42 -07002065/* Line 1455 of yacc.c */
2066#line 345 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07002067 {
Carl Worth6b9e7b02010-08-11 14:00:21 -07002068 (yyval.ival) = (yyvsp[(1) - (3)].ival) | (yyvsp[(3) - (3)].ival);
Carl Worth667173e2010-07-28 12:33:56 -07002069 ;}
2070 break;
2071
2072 case 30:
2073
Carl Worth9751b4e2010-08-17 23:22:42 -07002074/* Line 1455 of yacc.c */
2075#line 348 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07002076 {
Carl Worth6b9e7b02010-08-11 14:00:21 -07002077 (yyval.ival) = (yyvsp[(1) - (3)].ival) ^ (yyvsp[(3) - (3)].ival);
Carl Worth667173e2010-07-28 12:33:56 -07002078 ;}
2079 break;
2080
2081 case 31:
2082
Carl Worth9751b4e2010-08-17 23:22:42 -07002083/* Line 1455 of yacc.c */
2084#line 351 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07002085 {
Carl Worth6b9e7b02010-08-11 14:00:21 -07002086 (yyval.ival) = (yyvsp[(1) - (3)].ival) & (yyvsp[(3) - (3)].ival);
Carl Worth667173e2010-07-28 12:33:56 -07002087 ;}
2088 break;
2089
2090 case 32:
2091
Carl Worth9751b4e2010-08-17 23:22:42 -07002092/* Line 1455 of yacc.c */
2093#line 354 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07002094 {
Carl Worth6b9e7b02010-08-11 14:00:21 -07002095 (yyval.ival) = (yyvsp[(1) - (3)].ival) != (yyvsp[(3) - (3)].ival);
Carl Worth667173e2010-07-28 12:33:56 -07002096 ;}
2097 break;
2098
2099 case 33:
2100
Carl Worth9751b4e2010-08-17 23:22:42 -07002101/* Line 1455 of yacc.c */
2102#line 357 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07002103 {
Carl Worth6b9e7b02010-08-11 14:00:21 -07002104 (yyval.ival) = (yyvsp[(1) - (3)].ival) == (yyvsp[(3) - (3)].ival);
Carl Worth667173e2010-07-28 12:33:56 -07002105 ;}
2106 break;
2107
2108 case 34:
2109
Carl Worth9751b4e2010-08-17 23:22:42 -07002110/* Line 1455 of yacc.c */
2111#line 360 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07002112 {
Carl Worth6b9e7b02010-08-11 14:00:21 -07002113 (yyval.ival) = (yyvsp[(1) - (3)].ival) >= (yyvsp[(3) - (3)].ival);
Carl Worth667173e2010-07-28 12:33:56 -07002114 ;}
2115 break;
2116
2117 case 35:
2118
Carl Worth9751b4e2010-08-17 23:22:42 -07002119/* Line 1455 of yacc.c */
2120#line 363 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07002121 {
Carl Worth6b9e7b02010-08-11 14:00:21 -07002122 (yyval.ival) = (yyvsp[(1) - (3)].ival) <= (yyvsp[(3) - (3)].ival);
Carl Worth667173e2010-07-28 12:33:56 -07002123 ;}
2124 break;
2125
2126 case 36:
2127
Carl Worth9751b4e2010-08-17 23:22:42 -07002128/* Line 1455 of yacc.c */
2129#line 366 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07002130 {
Carl Worth6b9e7b02010-08-11 14:00:21 -07002131 (yyval.ival) = (yyvsp[(1) - (3)].ival) > (yyvsp[(3) - (3)].ival);
Carl Worth667173e2010-07-28 12:33:56 -07002132 ;}
2133 break;
2134
2135 case 37:
2136
Carl Worth9751b4e2010-08-17 23:22:42 -07002137/* Line 1455 of yacc.c */
2138#line 369 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07002139 {
Carl Worth6b9e7b02010-08-11 14:00:21 -07002140 (yyval.ival) = (yyvsp[(1) - (3)].ival) < (yyvsp[(3) - (3)].ival);
Carl Worth667173e2010-07-28 12:33:56 -07002141 ;}
2142 break;
2143
2144 case 38:
2145
Carl Worth9751b4e2010-08-17 23:22:42 -07002146/* Line 1455 of yacc.c */
2147#line 372 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07002148 {
Carl Worth6b9e7b02010-08-11 14:00:21 -07002149 (yyval.ival) = (yyvsp[(1) - (3)].ival) >> (yyvsp[(3) - (3)].ival);
Carl Worth667173e2010-07-28 12:33:56 -07002150 ;}
2151 break;
2152
2153 case 39:
2154
Carl Worth9751b4e2010-08-17 23:22:42 -07002155/* Line 1455 of yacc.c */
2156#line 375 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07002157 {
Carl Worth6b9e7b02010-08-11 14:00:21 -07002158 (yyval.ival) = (yyvsp[(1) - (3)].ival) << (yyvsp[(3) - (3)].ival);
Carl Worth667173e2010-07-28 12:33:56 -07002159 ;}
2160 break;
2161
2162 case 40:
2163
Carl Worth9751b4e2010-08-17 23:22:42 -07002164/* Line 1455 of yacc.c */
2165#line 378 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07002166 {
Carl Worth6b9e7b02010-08-11 14:00:21 -07002167 (yyval.ival) = (yyvsp[(1) - (3)].ival) - (yyvsp[(3) - (3)].ival);
Carl Worth667173e2010-07-28 12:33:56 -07002168 ;}
2169 break;
2170
2171 case 41:
2172
Carl Worth9751b4e2010-08-17 23:22:42 -07002173/* Line 1455 of yacc.c */
2174#line 381 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07002175 {
Carl Worth6b9e7b02010-08-11 14:00:21 -07002176 (yyval.ival) = (yyvsp[(1) - (3)].ival) + (yyvsp[(3) - (3)].ival);
Carl Worth667173e2010-07-28 12:33:56 -07002177 ;}
2178 break;
2179
2180 case 42:
2181
Carl Worth9751b4e2010-08-17 23:22:42 -07002182/* Line 1455 of yacc.c */
2183#line 384 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07002184 {
Carl Worth6b9e7b02010-08-11 14:00:21 -07002185 (yyval.ival) = (yyvsp[(1) - (3)].ival) % (yyvsp[(3) - (3)].ival);
Carl Worth667173e2010-07-28 12:33:56 -07002186 ;}
2187 break;
2188
2189 case 43:
2190
Carl Worth9751b4e2010-08-17 23:22:42 -07002191/* Line 1455 of yacc.c */
2192#line 387 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07002193 {
Carl Worth6b9e7b02010-08-11 14:00:21 -07002194 (yyval.ival) = (yyvsp[(1) - (3)].ival) / (yyvsp[(3) - (3)].ival);
Carl Worth667173e2010-07-28 12:33:56 -07002195 ;}
2196 break;
2197
2198 case 44:
2199
Carl Worth9751b4e2010-08-17 23:22:42 -07002200/* Line 1455 of yacc.c */
2201#line 390 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07002202 {
Carl Worth6b9e7b02010-08-11 14:00:21 -07002203 (yyval.ival) = (yyvsp[(1) - (3)].ival) * (yyvsp[(3) - (3)].ival);
Carl Worth667173e2010-07-28 12:33:56 -07002204 ;}
2205 break;
2206
2207 case 45:
2208
Carl Worth9751b4e2010-08-17 23:22:42 -07002209/* Line 1455 of yacc.c */
2210#line 393 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07002211 {
Carl Worth6b9e7b02010-08-11 14:00:21 -07002212 (yyval.ival) = ! (yyvsp[(2) - (2)].ival);
Carl Worth667173e2010-07-28 12:33:56 -07002213 ;}
2214 break;
2215
2216 case 46:
2217
Carl Worth9751b4e2010-08-17 23:22:42 -07002218/* Line 1455 of yacc.c */
2219#line 396 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07002220 {
Carl Worth6b9e7b02010-08-11 14:00:21 -07002221 (yyval.ival) = ~ (yyvsp[(2) - (2)].ival);
Carl Worth667173e2010-07-28 12:33:56 -07002222 ;}
2223 break;
2224
2225 case 47:
2226
Carl Worth9751b4e2010-08-17 23:22:42 -07002227/* Line 1455 of yacc.c */
2228#line 399 "glcpp/glcpp-parse.y"
Eric Anholtd4a04f32010-07-28 16:58:39 -07002229 {
Carl Worth6b9e7b02010-08-11 14:00:21 -07002230 (yyval.ival) = - (yyvsp[(2) - (2)].ival);
Eric Anholtd4a04f32010-07-28 16:58:39 -07002231 ;}
2232 break;
2233
2234 case 48:
2235
Carl Worth9751b4e2010-08-17 23:22:42 -07002236/* Line 1455 of yacc.c */
2237#line 402 "glcpp/glcpp-parse.y"
Eric Anholtd4a04f32010-07-28 16:58:39 -07002238 {
Carl Worth6b9e7b02010-08-11 14:00:21 -07002239 (yyval.ival) = + (yyvsp[(2) - (2)].ival);
Eric Anholtd4a04f32010-07-28 16:58:39 -07002240 ;}
2241 break;
2242
2243 case 49:
2244
Carl Worth9751b4e2010-08-17 23:22:42 -07002245/* Line 1455 of yacc.c */
2246#line 405 "glcpp/glcpp-parse.y"
Carl Worth6b9e7b02010-08-11 14:00:21 -07002247 {
2248 (yyval.ival) = (yyvsp[(2) - (3)].ival);
2249 ;}
2250 break;
2251
2252 case 50:
2253
Carl Worth9751b4e2010-08-17 23:22:42 -07002254/* Line 1455 of yacc.c */
2255#line 411 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07002256 {
2257 (yyval.string_list) = _string_list_create (parser);
2258 _string_list_append_item ((yyval.string_list), (yyvsp[(1) - (1)].str));
2259 talloc_steal ((yyval.string_list), (yyvsp[(1) - (1)].str));
2260 ;}
2261 break;
2262
Carl Worth6b9e7b02010-08-11 14:00:21 -07002263 case 51:
Carl Worth667173e2010-07-28 12:33:56 -07002264
Carl Worth9751b4e2010-08-17 23:22:42 -07002265/* Line 1455 of yacc.c */
2266#line 416 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07002267 {
2268 (yyval.string_list) = (yyvsp[(1) - (3)].string_list);
2269 _string_list_append_item ((yyval.string_list), (yyvsp[(3) - (3)].str));
2270 talloc_steal ((yyval.string_list), (yyvsp[(3) - (3)].str));
2271 ;}
2272 break;
2273
Carl Worth6b9e7b02010-08-11 14:00:21 -07002274 case 52:
Carl Worth667173e2010-07-28 12:33:56 -07002275
Carl Worth9751b4e2010-08-17 23:22:42 -07002276/* Line 1455 of yacc.c */
2277#line 424 "glcpp/glcpp-parse.y"
Eric Anholtd4a04f32010-07-28 16:58:39 -07002278 { (yyval.token_list) = NULL; ;}
2279 break;
2280
Eric Anholtd4a04f32010-07-28 16:58:39 -07002281 case 54:
Carl Worth667173e2010-07-28 12:33:56 -07002282
Carl Worth9751b4e2010-08-17 23:22:42 -07002283/* Line 1455 of yacc.c */
2284#line 429 "glcpp/glcpp-parse.y"
Carl Worth6b9e7b02010-08-11 14:00:21 -07002285 {
2286 yyerror (& (yylsp[(1) - (2)]), parser, "Invalid tokens after #");
2287 ;}
Carl Worth667173e2010-07-28 12:33:56 -07002288 break;
2289
Carl Worth6b9e7b02010-08-11 14:00:21 -07002290 case 55:
Carl Worth667173e2010-07-28 12:33:56 -07002291
Carl Worth9751b4e2010-08-17 23:22:42 -07002292/* Line 1455 of yacc.c */
2293#line 435 "glcpp/glcpp-parse.y"
Carl Worth6b9e7b02010-08-11 14:00:21 -07002294 { (yyval.token_list) = NULL; ;}
Eric Anholtd4a04f32010-07-28 16:58:39 -07002295 break;
2296
2297 case 58:
2298
Carl Worth9751b4e2010-08-17 23:22:42 -07002299/* Line 1455 of yacc.c */
2300#line 441 "glcpp/glcpp-parse.y"
Eric Anholtd4a04f32010-07-28 16:58:39 -07002301 {
Carl Worth6b9e7b02010-08-11 14:00:21 -07002302 glcpp_warning(&(yylsp[(1) - (1)]), parser, "extra tokens at end of directive");
Carl Worth667173e2010-07-28 12:33:56 -07002303 ;}
2304 break;
2305
2306 case 59:
2307
Carl Worth9751b4e2010-08-17 23:22:42 -07002308/* Line 1455 of yacc.c */
2309#line 448 "glcpp/glcpp-parse.y"
Carl Worth6b9e7b02010-08-11 14:00:21 -07002310 {
2311 int v = hash_table_find (parser->defines, (yyvsp[(2) - (2)].str)) ? 1 : 0;
2312 (yyval.token) = _token_create_ival (parser, INTEGER, v);
2313 ;}
2314 break;
2315
2316 case 60:
2317
Carl Worth9751b4e2010-08-17 23:22:42 -07002318/* Line 1455 of yacc.c */
2319#line 452 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07002320 {
Eric Anholtd4a04f32010-07-28 16:58:39 -07002321 int v = hash_table_find (parser->defines, (yyvsp[(3) - (4)].str)) ? 1 : 0;
2322 (yyval.token) = _token_create_ival (parser, INTEGER, v);
Carl Worth667173e2010-07-28 12:33:56 -07002323 ;}
2324 break;
2325
Carl Worth6b9e7b02010-08-11 14:00:21 -07002326 case 62:
Carl Worth667173e2010-07-28 12:33:56 -07002327
Carl Worth9751b4e2010-08-17 23:22:42 -07002328/* Line 1455 of yacc.c */
2329#line 461 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07002330 {
Eric Anholtd4a04f32010-07-28 16:58:39 -07002331 parser->space_tokens = 1;
2332 (yyval.token_list) = _token_list_create (parser);
2333 _token_list_append ((yyval.token_list), (yyvsp[(1) - (1)].token));
2334 talloc_unlink (parser, (yyvsp[(1) - (1)].token));
Carl Worth667173e2010-07-28 12:33:56 -07002335 ;}
2336 break;
2337
Kenneth Graunkef4239872010-08-04 16:24:39 -07002338 case 63:
Carl Worth667173e2010-07-28 12:33:56 -07002339
Carl Worth9751b4e2010-08-17 23:22:42 -07002340/* Line 1455 of yacc.c */
2341#line 467 "glcpp/glcpp-parse.y"
Carl Worth6b9e7b02010-08-11 14:00:21 -07002342 {
2343 (yyval.token_list) = (yyvsp[(1) - (2)].token_list);
2344 _token_list_append ((yyval.token_list), (yyvsp[(2) - (2)].token));
2345 talloc_unlink (parser, (yyvsp[(2) - (2)].token));
2346 ;}
2347 break;
2348
2349 case 64:
2350
Carl Worth9751b4e2010-08-17 23:22:42 -07002351/* Line 1455 of yacc.c */
2352#line 475 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07002353 {
Kenneth Graunkef4239872010-08-04 16:24:39 -07002354 parser->space_tokens = 1;
2355 (yyval.token_list) = _token_list_create (parser);
2356 _token_list_append ((yyval.token_list), (yyvsp[(1) - (1)].token));
2357 talloc_unlink (parser, (yyvsp[(1) - (1)].token));
2358 ;}
2359 break;
2360
Carl Worth6b9e7b02010-08-11 14:00:21 -07002361 case 65:
Kenneth Graunkef4239872010-08-04 16:24:39 -07002362
Carl Worth9751b4e2010-08-17 23:22:42 -07002363/* Line 1455 of yacc.c */
2364#line 481 "glcpp/glcpp-parse.y"
Kenneth Graunkef4239872010-08-04 16:24:39 -07002365 {
2366 (yyval.token_list) = (yyvsp[(1) - (2)].token_list);
2367 _token_list_append ((yyval.token_list), (yyvsp[(2) - (2)].token));
2368 talloc_unlink (parser, (yyvsp[(2) - (2)].token));
2369 ;}
2370 break;
2371
Carl Worth667173e2010-07-28 12:33:56 -07002372 case 66:
2373
Carl Worth9751b4e2010-08-17 23:22:42 -07002374/* Line 1455 of yacc.c */
2375#line 489 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07002376 {
Carl Worth6b9e7b02010-08-11 14:00:21 -07002377 (yyval.token) = _token_create_str (parser, IDENTIFIER, (yyvsp[(1) - (1)].str));
Carl Worth667173e2010-07-28 12:33:56 -07002378 (yyval.token)->location = yylloc;
2379 ;}
2380 break;
2381
2382 case 67:
2383
Carl Worth9751b4e2010-08-17 23:22:42 -07002384/* Line 1455 of yacc.c */
2385#line 493 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07002386 {
Carl Worth6b9e7b02010-08-11 14:00:21 -07002387 (yyval.token) = _token_create_str (parser, INTEGER_STRING, (yyvsp[(1) - (1)].str));
Carl Worth667173e2010-07-28 12:33:56 -07002388 (yyval.token)->location = yylloc;
2389 ;}
2390 break;
2391
2392 case 68:
2393
Carl Worth9751b4e2010-08-17 23:22:42 -07002394/* Line 1455 of yacc.c */
2395#line 497 "glcpp/glcpp-parse.y"
Eric Anholtd4a04f32010-07-28 16:58:39 -07002396 {
Carl Worth6b9e7b02010-08-11 14:00:21 -07002397 (yyval.token) = _token_create_ival (parser, (yyvsp[(1) - (1)].ival), (yyvsp[(1) - (1)].ival));
Eric Anholtd4a04f32010-07-28 16:58:39 -07002398 (yyval.token)->location = yylloc;
2399 ;}
Carl Worth667173e2010-07-28 12:33:56 -07002400 break;
2401
2402 case 69:
2403
Carl Worth9751b4e2010-08-17 23:22:42 -07002404/* Line 1455 of yacc.c */
2405#line 501 "glcpp/glcpp-parse.y"
Eric Anholtd4a04f32010-07-28 16:58:39 -07002406 {
Carl Worth6b9e7b02010-08-11 14:00:21 -07002407 (yyval.token) = _token_create_str (parser, OTHER, (yyvsp[(1) - (1)].str));
Eric Anholtd4a04f32010-07-28 16:58:39 -07002408 (yyval.token)->location = yylloc;
2409 ;}
Carl Worth667173e2010-07-28 12:33:56 -07002410 break;
2411
2412 case 70:
2413
Carl Worth9751b4e2010-08-17 23:22:42 -07002414/* Line 1455 of yacc.c */
2415#line 505 "glcpp/glcpp-parse.y"
Carl Worth6b9e7b02010-08-11 14:00:21 -07002416 {
2417 (yyval.token) = _token_create_ival (parser, SPACE, SPACE);
2418 (yyval.token)->location = yylloc;
2419 ;}
Carl Worth667173e2010-07-28 12:33:56 -07002420 break;
2421
2422 case 71:
2423
Carl Worth9751b4e2010-08-17 23:22:42 -07002424/* Line 1455 of yacc.c */
2425#line 512 "glcpp/glcpp-parse.y"
Carl Worth6b9e7b02010-08-11 14:00:21 -07002426 { (yyval.ival) = '['; ;}
Carl Worth667173e2010-07-28 12:33:56 -07002427 break;
2428
2429 case 72:
2430
Carl Worth9751b4e2010-08-17 23:22:42 -07002431/* Line 1455 of yacc.c */
2432#line 513 "glcpp/glcpp-parse.y"
Carl Worth6b9e7b02010-08-11 14:00:21 -07002433 { (yyval.ival) = ']'; ;}
Carl Worth667173e2010-07-28 12:33:56 -07002434 break;
2435
2436 case 73:
2437
Carl Worth9751b4e2010-08-17 23:22:42 -07002438/* Line 1455 of yacc.c */
2439#line 514 "glcpp/glcpp-parse.y"
Carl Worth6b9e7b02010-08-11 14:00:21 -07002440 { (yyval.ival) = '('; ;}
Carl Worth667173e2010-07-28 12:33:56 -07002441 break;
2442
2443 case 74:
2444
Carl Worth9751b4e2010-08-17 23:22:42 -07002445/* Line 1455 of yacc.c */
2446#line 515 "glcpp/glcpp-parse.y"
Carl Worth6b9e7b02010-08-11 14:00:21 -07002447 { (yyval.ival) = ')'; ;}
Carl Worth667173e2010-07-28 12:33:56 -07002448 break;
2449
2450 case 75:
2451
Carl Worth9751b4e2010-08-17 23:22:42 -07002452/* Line 1455 of yacc.c */
2453#line 516 "glcpp/glcpp-parse.y"
Carl Worth6b9e7b02010-08-11 14:00:21 -07002454 { (yyval.ival) = '{'; ;}
Carl Worth667173e2010-07-28 12:33:56 -07002455 break;
2456
2457 case 76:
2458
Carl Worth9751b4e2010-08-17 23:22:42 -07002459/* Line 1455 of yacc.c */
2460#line 517 "glcpp/glcpp-parse.y"
Carl Worth6b9e7b02010-08-11 14:00:21 -07002461 { (yyval.ival) = '}'; ;}
Carl Worth667173e2010-07-28 12:33:56 -07002462 break;
2463
2464 case 77:
2465
Carl Worth9751b4e2010-08-17 23:22:42 -07002466/* Line 1455 of yacc.c */
2467#line 518 "glcpp/glcpp-parse.y"
Carl Worth6b9e7b02010-08-11 14:00:21 -07002468 { (yyval.ival) = '.'; ;}
Carl Worth667173e2010-07-28 12:33:56 -07002469 break;
2470
2471 case 78:
2472
Carl Worth9751b4e2010-08-17 23:22:42 -07002473/* Line 1455 of yacc.c */
2474#line 519 "glcpp/glcpp-parse.y"
Carl Worth6b9e7b02010-08-11 14:00:21 -07002475 { (yyval.ival) = '&'; ;}
Carl Worth667173e2010-07-28 12:33:56 -07002476 break;
2477
2478 case 79:
2479
Carl Worth9751b4e2010-08-17 23:22:42 -07002480/* Line 1455 of yacc.c */
2481#line 520 "glcpp/glcpp-parse.y"
Carl Worth6b9e7b02010-08-11 14:00:21 -07002482 { (yyval.ival) = '*'; ;}
Carl Worth667173e2010-07-28 12:33:56 -07002483 break;
2484
2485 case 80:
2486
Carl Worth9751b4e2010-08-17 23:22:42 -07002487/* Line 1455 of yacc.c */
2488#line 521 "glcpp/glcpp-parse.y"
Carl Worth6b9e7b02010-08-11 14:00:21 -07002489 { (yyval.ival) = '+'; ;}
Carl Worth667173e2010-07-28 12:33:56 -07002490 break;
2491
2492 case 81:
2493
Carl Worth9751b4e2010-08-17 23:22:42 -07002494/* Line 1455 of yacc.c */
2495#line 522 "glcpp/glcpp-parse.y"
Carl Worth6b9e7b02010-08-11 14:00:21 -07002496 { (yyval.ival) = '-'; ;}
Carl Worth667173e2010-07-28 12:33:56 -07002497 break;
2498
2499 case 82:
2500
Carl Worth9751b4e2010-08-17 23:22:42 -07002501/* Line 1455 of yacc.c */
2502#line 523 "glcpp/glcpp-parse.y"
Carl Worth6b9e7b02010-08-11 14:00:21 -07002503 { (yyval.ival) = '~'; ;}
Carl Worth667173e2010-07-28 12:33:56 -07002504 break;
2505
2506 case 83:
2507
Carl Worth9751b4e2010-08-17 23:22:42 -07002508/* Line 1455 of yacc.c */
2509#line 524 "glcpp/glcpp-parse.y"
Carl Worth6b9e7b02010-08-11 14:00:21 -07002510 { (yyval.ival) = '!'; ;}
Carl Worth667173e2010-07-28 12:33:56 -07002511 break;
2512
2513 case 84:
2514
Carl Worth9751b4e2010-08-17 23:22:42 -07002515/* Line 1455 of yacc.c */
2516#line 525 "glcpp/glcpp-parse.y"
Carl Worth6b9e7b02010-08-11 14:00:21 -07002517 { (yyval.ival) = '/'; ;}
Carl Worth667173e2010-07-28 12:33:56 -07002518 break;
2519
2520 case 85:
2521
Carl Worth9751b4e2010-08-17 23:22:42 -07002522/* Line 1455 of yacc.c */
2523#line 526 "glcpp/glcpp-parse.y"
Carl Worth6b9e7b02010-08-11 14:00:21 -07002524 { (yyval.ival) = '%'; ;}
Carl Worth667173e2010-07-28 12:33:56 -07002525 break;
2526
2527 case 86:
2528
Carl Worth9751b4e2010-08-17 23:22:42 -07002529/* Line 1455 of yacc.c */
2530#line 527 "glcpp/glcpp-parse.y"
Carl Worth6b9e7b02010-08-11 14:00:21 -07002531 { (yyval.ival) = LEFT_SHIFT; ;}
Carl Worth667173e2010-07-28 12:33:56 -07002532 break;
2533
2534 case 87:
2535
Carl Worth9751b4e2010-08-17 23:22:42 -07002536/* Line 1455 of yacc.c */
2537#line 528 "glcpp/glcpp-parse.y"
Carl Worth6b9e7b02010-08-11 14:00:21 -07002538 { (yyval.ival) = RIGHT_SHIFT; ;}
Carl Worth667173e2010-07-28 12:33:56 -07002539 break;
2540
2541 case 88:
2542
Carl Worth9751b4e2010-08-17 23:22:42 -07002543/* Line 1455 of yacc.c */
2544#line 529 "glcpp/glcpp-parse.y"
Carl Worth6b9e7b02010-08-11 14:00:21 -07002545 { (yyval.ival) = '<'; ;}
Carl Worth667173e2010-07-28 12:33:56 -07002546 break;
2547
2548 case 89:
2549
Carl Worth9751b4e2010-08-17 23:22:42 -07002550/* Line 1455 of yacc.c */
2551#line 530 "glcpp/glcpp-parse.y"
Carl Worth6b9e7b02010-08-11 14:00:21 -07002552 { (yyval.ival) = '>'; ;}
Carl Worth667173e2010-07-28 12:33:56 -07002553 break;
2554
2555 case 90:
2556
Carl Worth9751b4e2010-08-17 23:22:42 -07002557/* Line 1455 of yacc.c */
2558#line 531 "glcpp/glcpp-parse.y"
Carl Worth6b9e7b02010-08-11 14:00:21 -07002559 { (yyval.ival) = LESS_OR_EQUAL; ;}
Carl Worth667173e2010-07-28 12:33:56 -07002560 break;
2561
2562 case 91:
2563
Carl Worth9751b4e2010-08-17 23:22:42 -07002564/* Line 1455 of yacc.c */
2565#line 532 "glcpp/glcpp-parse.y"
Carl Worth6b9e7b02010-08-11 14:00:21 -07002566 { (yyval.ival) = GREATER_OR_EQUAL; ;}
Carl Worth667173e2010-07-28 12:33:56 -07002567 break;
2568
2569 case 92:
2570
Carl Worth9751b4e2010-08-17 23:22:42 -07002571/* Line 1455 of yacc.c */
2572#line 533 "glcpp/glcpp-parse.y"
Carl Worth6b9e7b02010-08-11 14:00:21 -07002573 { (yyval.ival) = EQUAL; ;}
Carl Worth667173e2010-07-28 12:33:56 -07002574 break;
2575
2576 case 93:
2577
Carl Worth9751b4e2010-08-17 23:22:42 -07002578/* Line 1455 of yacc.c */
2579#line 534 "glcpp/glcpp-parse.y"
Carl Worth6b9e7b02010-08-11 14:00:21 -07002580 { (yyval.ival) = NOT_EQUAL; ;}
Carl Worth667173e2010-07-28 12:33:56 -07002581 break;
2582
2583 case 94:
2584
Carl Worth9751b4e2010-08-17 23:22:42 -07002585/* Line 1455 of yacc.c */
2586#line 535 "glcpp/glcpp-parse.y"
Carl Worth6b9e7b02010-08-11 14:00:21 -07002587 { (yyval.ival) = '^'; ;}
Carl Worth667173e2010-07-28 12:33:56 -07002588 break;
2589
2590 case 95:
2591
Carl Worth9751b4e2010-08-17 23:22:42 -07002592/* Line 1455 of yacc.c */
2593#line 536 "glcpp/glcpp-parse.y"
Carl Worth6b9e7b02010-08-11 14:00:21 -07002594 { (yyval.ival) = '|'; ;}
Carl Worth667173e2010-07-28 12:33:56 -07002595 break;
2596
2597 case 96:
2598
Carl Worth9751b4e2010-08-17 23:22:42 -07002599/* Line 1455 of yacc.c */
2600#line 537 "glcpp/glcpp-parse.y"
Carl Worth6b9e7b02010-08-11 14:00:21 -07002601 { (yyval.ival) = AND; ;}
Carl Worth667173e2010-07-28 12:33:56 -07002602 break;
2603
2604 case 97:
2605
Carl Worth9751b4e2010-08-17 23:22:42 -07002606/* Line 1455 of yacc.c */
2607#line 538 "glcpp/glcpp-parse.y"
Carl Worth6b9e7b02010-08-11 14:00:21 -07002608 { (yyval.ival) = OR; ;}
Carl Worth667173e2010-07-28 12:33:56 -07002609 break;
2610
2611 case 98:
2612
Carl Worth9751b4e2010-08-17 23:22:42 -07002613/* Line 1455 of yacc.c */
2614#line 539 "glcpp/glcpp-parse.y"
Carl Worth6b9e7b02010-08-11 14:00:21 -07002615 { (yyval.ival) = ';'; ;}
Eric Anholtd4a04f32010-07-28 16:58:39 -07002616 break;
2617
2618 case 99:
2619
Carl Worth9751b4e2010-08-17 23:22:42 -07002620/* Line 1455 of yacc.c */
2621#line 540 "glcpp/glcpp-parse.y"
Carl Worth6b9e7b02010-08-11 14:00:21 -07002622 { (yyval.ival) = ','; ;}
Eric Anholtd4a04f32010-07-28 16:58:39 -07002623 break;
2624
2625 case 100:
2626
Carl Worth9751b4e2010-08-17 23:22:42 -07002627/* Line 1455 of yacc.c */
2628#line 541 "glcpp/glcpp-parse.y"
Carl Worth6b9e7b02010-08-11 14:00:21 -07002629 { (yyval.ival) = '='; ;}
2630 break;
2631
2632 case 101:
2633
Carl Worth9751b4e2010-08-17 23:22:42 -07002634/* Line 1455 of yacc.c */
2635#line 542 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07002636 { (yyval.ival) = PASTE; ;}
2637 break;
2638
2639
2640
Carl Worth9751b4e2010-08-17 23:22:42 -07002641/* Line 1455 of yacc.c */
2642#line 2643 "glcpp/glcpp-parse.c"
Carl Worth667173e2010-07-28 12:33:56 -07002643 default: break;
2644 }
2645 YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
2646
2647 YYPOPSTACK (yylen);
2648 yylen = 0;
2649 YY_STACK_PRINT (yyss, yyssp);
2650
2651 *++yyvsp = yyval;
2652 *++yylsp = yyloc;
2653
2654 /* Now `shift' the result of the reduction. Determine what state
2655 that goes to, based on the state we popped back to and the rule
2656 number reduced by. */
2657
2658 yyn = yyr1[yyn];
2659
2660 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
2661 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
2662 yystate = yytable[yystate];
2663 else
2664 yystate = yydefgoto[yyn - YYNTOKENS];
2665
2666 goto yynewstate;
2667
2668
2669/*------------------------------------.
2670| yyerrlab -- here on detecting error |
2671`------------------------------------*/
2672yyerrlab:
2673 /* If not already recovering from an error, report this error. */
2674 if (!yyerrstatus)
2675 {
2676 ++yynerrs;
2677#if ! YYERROR_VERBOSE
2678 yyerror (&yylloc, parser, YY_("syntax error"));
2679#else
2680 {
2681 YYSIZE_T yysize = yysyntax_error (0, yystate, yychar);
2682 if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM)
2683 {
2684 YYSIZE_T yyalloc = 2 * yysize;
2685 if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM))
2686 yyalloc = YYSTACK_ALLOC_MAXIMUM;
2687 if (yymsg != yymsgbuf)
2688 YYSTACK_FREE (yymsg);
2689 yymsg = (char *) YYSTACK_ALLOC (yyalloc);
2690 if (yymsg)
2691 yymsg_alloc = yyalloc;
2692 else
2693 {
2694 yymsg = yymsgbuf;
2695 yymsg_alloc = sizeof yymsgbuf;
2696 }
2697 }
2698
2699 if (0 < yysize && yysize <= yymsg_alloc)
2700 {
2701 (void) yysyntax_error (yymsg, yystate, yychar);
2702 yyerror (&yylloc, parser, yymsg);
2703 }
2704 else
2705 {
2706 yyerror (&yylloc, parser, YY_("syntax error"));
2707 if (yysize != 0)
2708 goto yyexhaustedlab;
2709 }
2710 }
2711#endif
2712 }
2713
Carl Worth9751b4e2010-08-17 23:22:42 -07002714 yyerror_range[0] = yylloc;
Carl Worth667173e2010-07-28 12:33:56 -07002715
2716 if (yyerrstatus == 3)
2717 {
2718 /* If just tried and failed to reuse lookahead token after an
2719 error, discard it. */
2720
2721 if (yychar <= YYEOF)
2722 {
2723 /* Return failure if at end of input. */
2724 if (yychar == YYEOF)
2725 YYABORT;
2726 }
2727 else
2728 {
2729 yydestruct ("Error: discarding",
2730 yytoken, &yylval, &yylloc, parser);
2731 yychar = YYEMPTY;
2732 }
2733 }
2734
2735 /* Else will try to reuse lookahead token after shifting the error
2736 token. */
2737 goto yyerrlab1;
2738
2739
2740/*---------------------------------------------------.
2741| yyerrorlab -- error raised explicitly by YYERROR. |
2742`---------------------------------------------------*/
2743yyerrorlab:
2744
2745 /* Pacify compilers like GCC when the user code never invokes
2746 YYERROR and the label yyerrorlab therefore never appears in user
2747 code. */
2748 if (/*CONSTCOND*/ 0)
2749 goto yyerrorlab;
2750
Carl Worth9751b4e2010-08-17 23:22:42 -07002751 yyerror_range[0] = yylsp[1-yylen];
Carl Worth667173e2010-07-28 12:33:56 -07002752 /* Do not reclaim the symbols of the rule which action triggered
2753 this YYERROR. */
2754 YYPOPSTACK (yylen);
2755 yylen = 0;
2756 YY_STACK_PRINT (yyss, yyssp);
2757 yystate = *yyssp;
2758 goto yyerrlab1;
2759
2760
2761/*-------------------------------------------------------------.
2762| yyerrlab1 -- common code for both syntax error and YYERROR. |
2763`-------------------------------------------------------------*/
2764yyerrlab1:
2765 yyerrstatus = 3; /* Each real token shifted decrements this. */
2766
2767 for (;;)
2768 {
2769 yyn = yypact[yystate];
2770 if (yyn != YYPACT_NINF)
2771 {
2772 yyn += YYTERROR;
2773 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
2774 {
2775 yyn = yytable[yyn];
2776 if (0 < yyn)
2777 break;
2778 }
2779 }
2780
2781 /* Pop the current state because it cannot handle the error token. */
2782 if (yyssp == yyss)
2783 YYABORT;
2784
Carl Worth9751b4e2010-08-17 23:22:42 -07002785 yyerror_range[0] = *yylsp;
Carl Worth667173e2010-07-28 12:33:56 -07002786 yydestruct ("Error: popping",
2787 yystos[yystate], yyvsp, yylsp, parser);
2788 YYPOPSTACK (1);
2789 yystate = *yyssp;
2790 YY_STACK_PRINT (yyss, yyssp);
2791 }
2792
2793 *++yyvsp = yylval;
2794
Carl Worth9751b4e2010-08-17 23:22:42 -07002795 yyerror_range[1] = yylloc;
Carl Worth667173e2010-07-28 12:33:56 -07002796 /* Using YYLLOC is tempting, but would change the location of
2797 the lookahead. YYLOC is available though. */
Carl Worth9751b4e2010-08-17 23:22:42 -07002798 YYLLOC_DEFAULT (yyloc, (yyerror_range - 1), 2);
Carl Worth667173e2010-07-28 12:33:56 -07002799 *++yylsp = yyloc;
2800
2801 /* Shift the error token. */
2802 YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
2803
2804 yystate = yyn;
2805 goto yynewstate;
2806
2807
2808/*-------------------------------------.
2809| yyacceptlab -- YYACCEPT comes here. |
2810`-------------------------------------*/
2811yyacceptlab:
2812 yyresult = 0;
2813 goto yyreturn;
2814
2815/*-----------------------------------.
2816| yyabortlab -- YYABORT comes here. |
2817`-----------------------------------*/
2818yyabortlab:
2819 yyresult = 1;
2820 goto yyreturn;
2821
2822#if !defined(yyoverflow) || YYERROR_VERBOSE
2823/*-------------------------------------------------.
2824| yyexhaustedlab -- memory exhaustion comes here. |
2825`-------------------------------------------------*/
2826yyexhaustedlab:
2827 yyerror (&yylloc, parser, YY_("memory exhausted"));
2828 yyresult = 2;
2829 /* Fall through. */
2830#endif
2831
2832yyreturn:
2833 if (yychar != YYEMPTY)
2834 yydestruct ("Cleanup: discarding lookahead",
2835 yytoken, &yylval, &yylloc, parser);
2836 /* Do not reclaim the symbols of the rule which action triggered
2837 this YYABORT or YYACCEPT. */
2838 YYPOPSTACK (yylen);
2839 YY_STACK_PRINT (yyss, yyssp);
2840 while (yyssp != yyss)
2841 {
2842 yydestruct ("Cleanup: popping",
2843 yystos[*yyssp], yyvsp, yylsp, parser);
2844 YYPOPSTACK (1);
2845 }
2846#ifndef yyoverflow
2847 if (yyss != yyssa)
2848 YYSTACK_FREE (yyss);
2849#endif
2850#if YYERROR_VERBOSE
2851 if (yymsg != yymsgbuf)
2852 YYSTACK_FREE (yymsg);
2853#endif
2854 /* Make sure YYID is used. */
2855 return YYID (yyresult);
2856}
2857
2858
2859
Carl Worth9751b4e2010-08-17 23:22:42 -07002860/* Line 1675 of yacc.c */
2861#line 545 "glcpp/glcpp-parse.y"
Carl Worth667173e2010-07-28 12:33:56 -07002862
2863
2864string_list_t *
2865_string_list_create (void *ctx)
2866{
2867 string_list_t *list;
2868
Kenneth Graunke0ef79a52010-08-03 20:25:13 -07002869 list = talloc (ctx, string_list_t);
Carl Worth667173e2010-07-28 12:33:56 -07002870 list->head = NULL;
2871 list->tail = NULL;
2872
2873 return list;
2874}
2875
2876void
2877_string_list_append_item (string_list_t *list, const char *str)
2878{
2879 string_node_t *node;
2880
Kenneth Graunke0ef79a52010-08-03 20:25:13 -07002881 node = talloc (list, string_node_t);
2882 node->str = talloc_strdup (node, str);
Carl Worth667173e2010-07-28 12:33:56 -07002883
2884 node->next = NULL;
2885
2886 if (list->head == NULL) {
2887 list->head = node;
2888 } else {
2889 list->tail->next = node;
2890 }
2891
2892 list->tail = node;
2893}
2894
2895int
2896_string_list_contains (string_list_t *list, const char *member, int *index)
2897{
2898 string_node_t *node;
2899 int i;
2900
2901 if (list == NULL)
2902 return 0;
2903
2904 for (i = 0, node = list->head; node; i++, node = node->next) {
2905 if (strcmp (node->str, member) == 0) {
2906 if (index)
2907 *index = i;
2908 return 1;
2909 }
2910 }
2911
2912 return 0;
2913}
2914
2915int
2916_string_list_length (string_list_t *list)
2917{
2918 int length = 0;
2919 string_node_t *node;
2920
2921 if (list == NULL)
2922 return 0;
2923
2924 for (node = list->head; node; node = node->next)
2925 length++;
2926
2927 return length;
2928}
2929
Carl Worth9751b4e2010-08-17 23:22:42 -07002930int
2931_string_list_equal (string_list_t *a, string_list_t *b)
2932{
2933 string_node_t *node_a, *node_b;
2934
2935 if (a == NULL && b == NULL)
2936 return 1;
2937
2938 if (a == NULL || b == NULL)
2939 return 0;
2940
2941 for (node_a = a->head, node_b = b->head;
2942 node_a && node_b;
2943 node_a = node_a->next, node_b = node_b->next)
2944 {
2945 if (strcmp (node_a->str, node_b->str))
2946 return 0;
2947 }
2948
2949 /* Catch the case of lists being different lengths, (which
2950 * would cause the loop above to terminate after the shorter
2951 * list). */
2952 return node_a == node_b;
2953}
2954
Carl Worth667173e2010-07-28 12:33:56 -07002955argument_list_t *
2956_argument_list_create (void *ctx)
2957{
2958 argument_list_t *list;
2959
Kenneth Graunke0ef79a52010-08-03 20:25:13 -07002960 list = talloc (ctx, argument_list_t);
Carl Worth667173e2010-07-28 12:33:56 -07002961 list->head = NULL;
2962 list->tail = NULL;
2963
2964 return list;
2965}
2966
2967void
2968_argument_list_append (argument_list_t *list, token_list_t *argument)
2969{
2970 argument_node_t *node;
2971
Kenneth Graunke0ef79a52010-08-03 20:25:13 -07002972 node = talloc (list, argument_node_t);
Carl Worth667173e2010-07-28 12:33:56 -07002973 node->argument = argument;
2974
2975 node->next = NULL;
2976
2977 if (list->head == NULL) {
2978 list->head = node;
2979 } else {
2980 list->tail->next = node;
2981 }
2982
2983 list->tail = node;
2984}
2985
2986int
2987_argument_list_length (argument_list_t *list)
2988{
2989 int length = 0;
2990 argument_node_t *node;
2991
2992 if (list == NULL)
2993 return 0;
2994
2995 for (node = list->head; node; node = node->next)
2996 length++;
2997
2998 return length;
2999}
3000
3001token_list_t *
3002_argument_list_member_at (argument_list_t *list, int index)
3003{
3004 argument_node_t *node;
3005 int i;
3006
3007 if (list == NULL)
3008 return NULL;
3009
3010 node = list->head;
3011 for (i = 0; i < index; i++) {
3012 node = node->next;
3013 if (node == NULL)
3014 break;
3015 }
3016
3017 if (node)
3018 return node->argument;
3019
3020 return NULL;
3021}
3022
3023/* Note: This function talloc_steal()s the str pointer. */
3024token_t *
3025_token_create_str (void *ctx, int type, char *str)
3026{
3027 token_t *token;
3028
Kenneth Graunke0ef79a52010-08-03 20:25:13 -07003029 token = talloc (ctx, token_t);
Carl Worth667173e2010-07-28 12:33:56 -07003030 token->type = type;
3031 token->value.str = talloc_steal (token, str);
3032
3033 return token;
3034}
3035
3036token_t *
3037_token_create_ival (void *ctx, int type, int ival)
3038{
3039 token_t *token;
3040
Kenneth Graunke0ef79a52010-08-03 20:25:13 -07003041 token = talloc (ctx, token_t);
Carl Worth667173e2010-07-28 12:33:56 -07003042 token->type = type;
3043 token->value.ival = ival;
3044
3045 return token;
3046}
3047
3048token_list_t *
3049_token_list_create (void *ctx)
3050{
3051 token_list_t *list;
3052
Kenneth Graunke0ef79a52010-08-03 20:25:13 -07003053 list = talloc (ctx, token_list_t);
Carl Worth667173e2010-07-28 12:33:56 -07003054 list->head = NULL;
3055 list->tail = NULL;
3056 list->non_space_tail = NULL;
3057
3058 return list;
3059}
3060
3061void
3062_token_list_append (token_list_t *list, token_t *token)
3063{
3064 token_node_t *node;
3065
Kenneth Graunke0ef79a52010-08-03 20:25:13 -07003066 node = talloc (list, token_node_t);
3067 node->token = talloc_reference (list, token);
Carl Worth667173e2010-07-28 12:33:56 -07003068
3069 node->next = NULL;
3070
3071 if (list->head == NULL) {
3072 list->head = node;
3073 } else {
3074 list->tail->next = node;
3075 }
3076
3077 list->tail = node;
3078 if (token->type != SPACE)
3079 list->non_space_tail = node;
3080}
3081
3082void
3083_token_list_append_list (token_list_t *list, token_list_t *tail)
3084{
3085 if (tail == NULL || tail->head == NULL)
3086 return;
3087
3088 if (list->head == NULL) {
3089 list->head = tail->head;
3090 } else {
3091 list->tail->next = tail->head;
3092 }
3093
3094 list->tail = tail->tail;
3095 list->non_space_tail = tail->non_space_tail;
3096}
3097
3098static token_list_t *
3099_token_list_copy (void *ctx, token_list_t *other)
3100{
3101 token_list_t *copy;
3102 token_node_t *node;
3103
3104 if (other == NULL)
3105 return NULL;
3106
3107 copy = _token_list_create (ctx);
3108 for (node = other->head; node; node = node->next)
3109 _token_list_append (copy, node->token);
3110
3111 return copy;
3112}
3113
3114static void
3115_token_list_trim_trailing_space (token_list_t *list)
3116{
3117 token_node_t *tail, *next;
3118
3119 if (list->non_space_tail) {
3120 tail = list->non_space_tail->next;
3121 list->non_space_tail->next = NULL;
3122 list->tail = list->non_space_tail;
3123
3124 while (tail) {
3125 next = tail->next;
3126 talloc_free (tail);
3127 tail = next;
3128 }
3129 }
3130}
3131
Carl Worth9751b4e2010-08-17 23:22:42 -07003132int
3133_token_list_equal_ignoring_space (token_list_t *a, token_list_t *b)
3134{
3135 token_node_t *node_a, *node_b;
3136
3137 node_a = a->head;
3138 node_b = b->head;
3139
3140 while (1)
3141 {
3142 if (node_a == NULL && node_b == NULL)
3143 break;
3144
3145 if (node_a == NULL || node_b == NULL)
3146 return 0;
3147
3148 if (node_a->token->type == SPACE) {
3149 node_a = node_a->next;
3150 continue;
3151 }
3152
3153 if (node_b->token->type == SPACE) {
3154 node_b = node_b->next;
3155 continue;
3156 }
3157
3158 if (node_a->token->type != node_b->token->type)
3159 return 0;
3160
3161 switch (node_a->token->type) {
3162 case INTEGER:
3163 if (node_a->token->value.ival !=
3164 node_b->token->value.ival)
3165 {
3166 return 0;
3167 }
3168 break;
3169 case IDENTIFIER:
3170 case INTEGER_STRING:
3171 case OTHER:
3172 if (strcmp (node_a->token->value.str,
3173 node_b->token->value.str))
3174 {
3175 return 0;
3176 }
3177 break;
3178 }
3179
3180 node_a = node_a->next;
3181 node_b = node_b->next;
3182 }
3183
3184 return 1;
3185}
3186
Carl Worth667173e2010-07-28 12:33:56 -07003187static void
3188_token_print (char **out, token_t *token)
3189{
3190 if (token->type < 256) {
3191 glcpp_printf (*out, "%c", token->type);
3192 return;
3193 }
3194
3195 switch (token->type) {
3196 case INTEGER:
Eric Anholt8605c292010-07-28 16:53:51 -07003197 glcpp_printf (*out, "%" PRIiMAX, token->value.ival);
Carl Worth667173e2010-07-28 12:33:56 -07003198 break;
3199 case IDENTIFIER:
3200 case INTEGER_STRING:
3201 case OTHER:
3202 glcpp_print (*out, token->value.str);
3203 break;
3204 case SPACE:
3205 glcpp_print (*out, " ");
3206 break;
3207 case LEFT_SHIFT:
3208 glcpp_print (*out, "<<");
3209 break;
3210 case RIGHT_SHIFT:
3211 glcpp_print (*out, ">>");
3212 break;
3213 case LESS_OR_EQUAL:
3214 glcpp_print (*out, "<=");
3215 break;
3216 case GREATER_OR_EQUAL:
3217 glcpp_print (*out, ">=");
3218 break;
3219 case EQUAL:
3220 glcpp_print (*out, "==");
3221 break;
3222 case NOT_EQUAL:
3223 glcpp_print (*out, "!=");
3224 break;
3225 case AND:
3226 glcpp_print (*out, "&&");
3227 break;
3228 case OR:
3229 glcpp_print (*out, "||");
3230 break;
3231 case PASTE:
3232 glcpp_print (*out, "##");
3233 break;
3234 case COMMA_FINAL:
3235 glcpp_print (*out, ",");
3236 break;
3237 case PLACEHOLDER:
3238 /* Nothing to print. */
3239 break;
3240 default:
3241 assert(!"Error: Don't know how to print token.");
3242 break;
3243 }
3244}
3245
3246/* Return a new token (talloc()ed off of 'token') formed by pasting
3247 * 'token' and 'other'. Note that this function may return 'token' or
3248 * 'other' directly rather than allocating anything new.
3249 *
3250 * Caution: Only very cursory error-checking is performed to see if
3251 * the final result is a valid single token. */
3252static token_t *
3253_token_paste (glcpp_parser_t *parser, token_t *token, token_t *other)
3254{
3255 token_t *combined = NULL;
3256
3257 /* Pasting a placeholder onto anything makes no change. */
3258 if (other->type == PLACEHOLDER)
3259 return token;
3260
3261 /* When 'token' is a placeholder, just return 'other'. */
3262 if (token->type == PLACEHOLDER)
3263 return other;
3264
3265 /* A very few single-character punctuators can be combined
3266 * with another to form a multi-character punctuator. */
3267 switch (token->type) {
3268 case '<':
3269 if (other->type == '<')
3270 combined = _token_create_ival (token, LEFT_SHIFT, LEFT_SHIFT);
3271 else if (other->type == '=')
3272 combined = _token_create_ival (token, LESS_OR_EQUAL, LESS_OR_EQUAL);
3273 break;
3274 case '>':
3275 if (other->type == '>')
3276 combined = _token_create_ival (token, RIGHT_SHIFT, RIGHT_SHIFT);
3277 else if (other->type == '=')
3278 combined = _token_create_ival (token, GREATER_OR_EQUAL, GREATER_OR_EQUAL);
3279 break;
3280 case '=':
3281 if (other->type == '=')
3282 combined = _token_create_ival (token, EQUAL, EQUAL);
3283 break;
3284 case '!':
3285 if (other->type == '=')
3286 combined = _token_create_ival (token, NOT_EQUAL, NOT_EQUAL);
3287 break;
3288 case '&':
3289 if (other->type == '&')
3290 combined = _token_create_ival (token, AND, AND);
3291 break;
3292 case '|':
3293 if (other->type == '|')
3294 combined = _token_create_ival (token, OR, OR);
3295 break;
3296 }
3297
3298 if (combined != NULL) {
3299 /* Inherit the location from the first token */
3300 combined->location = token->location;
3301 return combined;
3302 }
3303
3304 /* Two string-valued tokens can usually just be mashed
3305 * together.
3306 *
3307 * XXX: This isn't actually legitimate. Several things here
3308 * should result in a diagnostic since the result cannot be a
3309 * valid, single pre-processing token. For example, pasting
3310 * "123" and "abc" is not legal, but we don't catch that
3311 * here. */
3312 if ((token->type == IDENTIFIER || token->type == OTHER || token->type == INTEGER_STRING) &&
3313 (other->type == IDENTIFIER || other->type == OTHER || other->type == INTEGER_STRING))
3314 {
3315 char *str;
3316
Kenneth Graunke0ef79a52010-08-03 20:25:13 -07003317 str = talloc_asprintf (token, "%s%s", token->value.str,
3318 other->value.str);
Carl Worth667173e2010-07-28 12:33:56 -07003319 combined = _token_create_str (token, token->type, str);
3320 combined->location = token->location;
3321 return combined;
3322 }
3323
3324 glcpp_error (&token->location, parser, "");
3325 glcpp_print (parser->info_log, "Pasting \"");
3326 _token_print (&parser->info_log, token);
3327 glcpp_print (parser->info_log, "\" and \"");
3328 _token_print (&parser->info_log, other);
3329 glcpp_print (parser->info_log, "\" does not give a valid preprocessing token.\n");
3330
3331 return token;
3332}
3333
3334static void
3335_token_list_print (glcpp_parser_t *parser, token_list_t *list)
3336{
3337 token_node_t *node;
3338
3339 if (list == NULL)
3340 return;
3341
3342 for (node = list->head; node; node = node->next)
3343 _token_print (&parser->output, node->token);
3344}
3345
3346void
3347yyerror (YYLTYPE *locp, glcpp_parser_t *parser, const char *error)
3348{
3349 glcpp_error(locp, parser, "%s", error);
3350}
3351
Eric Anholtd4a04f32010-07-28 16:58:39 -07003352static void add_builtin_define(glcpp_parser_t *parser,
3353 const char *name, int value)
3354{
3355 token_t *tok;
3356 token_list_t *list;
3357
3358 tok = _token_create_ival (parser, INTEGER, value);
3359
3360 list = _token_list_create(parser);
3361 _token_list_append(list, tok);
3362 _define_object_macro(parser, NULL, name, list);
3363
3364 talloc_unlink(parser, tok);
3365}
3366
Carl Worth667173e2010-07-28 12:33:56 -07003367glcpp_parser_t *
3368glcpp_parser_create (const struct gl_extensions *extensions)
3369{
3370 glcpp_parser_t *parser;
Eric Anholtd4a04f32010-07-28 16:58:39 -07003371 int language_version;
Carl Worth667173e2010-07-28 12:33:56 -07003372
Kenneth Graunke0ef79a52010-08-03 20:25:13 -07003373 parser = talloc (NULL, glcpp_parser_t);
Carl Worth667173e2010-07-28 12:33:56 -07003374
3375 glcpp_lex_init_extra (parser, &parser->scanner);
3376 parser->defines = hash_table_ctor (32, hash_table_string_hash,
3377 hash_table_string_compare);
3378 parser->active = NULL;
3379 parser->lexing_if = 0;
3380 parser->space_tokens = 1;
3381 parser->newline_as_space = 0;
3382 parser->in_control_line = 0;
3383 parser->paren_count = 0;
3384
3385 parser->skip_stack = NULL;
3386
3387 parser->lex_from_list = NULL;
3388 parser->lex_from_node = NULL;
3389
3390 parser->output = talloc_strdup(parser, "");
3391 parser->info_log = talloc_strdup(parser, "");
3392 parser->error = 0;
3393
3394 /* Add pre-defined macros. */
Eric Anholtd4a04f32010-07-28 16:58:39 -07003395 add_builtin_define(parser, "GL_ARB_draw_buffers", 1);
3396 add_builtin_define(parser, "GL_ARB_texture_rectangle", 1);
Carl Worth667173e2010-07-28 12:33:56 -07003397
Eric Anholtd4a04f32010-07-28 16:58:39 -07003398 if (extensions != NULL) {
3399 if (extensions->EXT_texture_array) {
3400 add_builtin_define(parser, "GL_EXT_texture_array", 1);
3401 }
Carl Worth667173e2010-07-28 12:33:56 -07003402
Eric Anholtd4a04f32010-07-28 16:58:39 -07003403 if (extensions->ARB_fragment_coord_conventions)
3404 add_builtin_define(parser, "GL_ARB_fragment_coord_conventions",
3405 1);
Carl Worth667173e2010-07-28 12:33:56 -07003406 }
3407
Eric Anholtd4a04f32010-07-28 16:58:39 -07003408 language_version = 110;
Eric Anholtd4a04f32010-07-28 16:58:39 -07003409 add_builtin_define(parser, "__VERSION__", language_version);
Carl Worth667173e2010-07-28 12:33:56 -07003410
3411 return parser;
3412}
3413
3414int
3415glcpp_parser_parse (glcpp_parser_t *parser)
3416{
3417 return yyparse (parser);
3418}
3419
3420void
3421glcpp_parser_destroy (glcpp_parser_t *parser)
3422{
Carl Worth667173e2010-07-28 12:33:56 -07003423 glcpp_lex_destroy (parser->scanner);
3424 hash_table_dtor (parser->defines);
3425 talloc_free (parser);
3426}
3427
3428typedef enum function_status
3429{
3430 FUNCTION_STATUS_SUCCESS,
3431 FUNCTION_NOT_A_FUNCTION,
3432 FUNCTION_UNBALANCED_PARENTHESES
3433} function_status_t;
3434
3435/* Find a set of function-like macro arguments by looking for a
3436 * balanced set of parentheses.
3437 *
3438 * When called, 'node' should be the opening-parenthesis token, (or
3439 * perhaps preceeding SPACE tokens). Upon successful return *last will
3440 * be the last consumed node, (corresponding to the closing right
3441 * parenthesis).
3442 *
3443 * Return values:
3444 *
3445 * FUNCTION_STATUS_SUCCESS:
3446 *
3447 * Successfully parsed a set of function arguments.
3448 *
3449 * FUNCTION_NOT_A_FUNCTION:
3450 *
3451 * Macro name not followed by a '('. This is not an error, but
3452 * simply that the macro name should be treated as a non-macro.
3453 *
3454 * FUNCTION_UNBALANCED_PARENTHESES
3455 *
3456 * Macro name is not followed by a balanced set of parentheses.
3457 */
3458static function_status_t
3459_arguments_parse (argument_list_t *arguments,
3460 token_node_t *node,
3461 token_node_t **last)
3462{
3463 token_list_t *argument;
3464 int paren_count;
3465
3466 node = node->next;
3467
3468 /* Ignore whitespace before first parenthesis. */
3469 while (node && node->token->type == SPACE)
3470 node = node->next;
3471
3472 if (node == NULL || node->token->type != '(')
3473 return FUNCTION_NOT_A_FUNCTION;
3474
3475 node = node->next;
3476
3477 argument = _token_list_create (arguments);
3478 _argument_list_append (arguments, argument);
3479
3480 for (paren_count = 1; node; node = node->next) {
3481 if (node->token->type == '(')
3482 {
3483 paren_count++;
3484 }
3485 else if (node->token->type == ')')
3486 {
3487 paren_count--;
3488 if (paren_count == 0)
3489 break;
3490 }
3491
3492 if (node->token->type == ',' &&
3493 paren_count == 1)
3494 {
3495 _token_list_trim_trailing_space (argument);
3496 argument = _token_list_create (arguments);
3497 _argument_list_append (arguments, argument);
3498 }
3499 else {
3500 if (argument->head == NULL) {
3501 /* Don't treat initial whitespace as
3502 * part of the arguement. */
3503 if (node->token->type == SPACE)
3504 continue;
3505 }
3506 _token_list_append (argument, node->token);
3507 }
3508 }
3509
3510 if (paren_count)
3511 return FUNCTION_UNBALANCED_PARENTHESES;
3512
3513 *last = node;
3514
3515 return FUNCTION_STATUS_SUCCESS;
3516}
3517
3518static token_list_t *
3519_token_list_create_with_one_space (void *ctx)
3520{
3521 token_list_t *list;
3522 token_t *space;
3523
3524 list = _token_list_create (ctx);
3525 space = _token_create_ival (list, SPACE, SPACE);
3526 _token_list_append (list, space);
3527
3528 return list;
3529}
3530
Kenneth Graunke16b4eed2010-08-04 16:10:03 -07003531static void
3532_glcpp_parser_expand_if (glcpp_parser_t *parser, int type, token_list_t *list)
3533{
3534 token_list_t *expanded;
3535 token_t *token;
3536
3537 expanded = _token_list_create (parser);
3538 token = _token_create_ival (parser, type, type);
3539 _token_list_append (expanded, token);
3540 _glcpp_parser_expand_token_list (parser, list);
3541 _token_list_append_list (expanded, list);
3542 glcpp_parser_lex_from (parser, expanded);
3543}
3544
Carl Worth667173e2010-07-28 12:33:56 -07003545/* This is a helper function that's essentially part of the
3546 * implementation of _glcpp_parser_expand_node. It shouldn't be called
3547 * except for by that function.
3548 *
3549 * Returns NULL if node is a simple token with no expansion, (that is,
3550 * although 'node' corresponds to an identifier defined as a
3551 * function-like macro, it is not followed with a parenthesized
3552 * argument list).
3553 *
3554 * Compute the complete expansion of node (which is a function-like
3555 * macro) and subsequent nodes which are arguments.
3556 *
3557 * Returns the token list that results from the expansion and sets
3558 * *last to the last node in the list that was consumed by the
3559 * expansion. Specifically, *last will be set as follows: as the
3560 * token of the closing right parenthesis.
3561 */
3562static token_list_t *
3563_glcpp_parser_expand_function (glcpp_parser_t *parser,
3564 token_node_t *node,
3565 token_node_t **last)
3566
3567{
3568 macro_t *macro;
3569 const char *identifier;
3570 argument_list_t *arguments;
3571 function_status_t status;
3572 token_list_t *substituted;
3573 int parameter_index;
3574
3575 identifier = node->token->value.str;
3576
3577 macro = hash_table_find (parser->defines, identifier);
3578
3579 assert (macro->is_function);
3580
3581 arguments = _argument_list_create (parser);
3582 status = _arguments_parse (arguments, node, last);
3583
3584 switch (status) {
3585 case FUNCTION_STATUS_SUCCESS:
3586 break;
3587 case FUNCTION_NOT_A_FUNCTION:
3588 return NULL;
3589 case FUNCTION_UNBALANCED_PARENTHESES:
3590 glcpp_error (&node->token->location, parser, "Macro %s call has unbalanced parentheses\n", identifier);
3591 return NULL;
3592 }
3593
3594 /* Replace a macro defined as empty with a SPACE token. */
3595 if (macro->replacements == NULL) {
3596 talloc_free (arguments);
3597 return _token_list_create_with_one_space (parser);
3598 }
3599
3600 if (! ((_argument_list_length (arguments) ==
3601 _string_list_length (macro->parameters)) ||
3602 (_string_list_length (macro->parameters) == 0 &&
3603 _argument_list_length (arguments) == 1 &&
3604 arguments->head->argument->head == NULL)))
3605 {
3606 glcpp_error (&node->token->location, parser,
3607 "Error: macro %s invoked with %d arguments (expected %d)\n",
3608 identifier,
3609 _argument_list_length (arguments),
3610 _string_list_length (macro->parameters));
3611 return NULL;
3612 }
3613
3614 /* Perform argument substitution on the replacement list. */
3615 substituted = _token_list_create (arguments);
3616
3617 for (node = macro->replacements->head; node; node = node->next)
3618 {
3619 if (node->token->type == IDENTIFIER &&
3620 _string_list_contains (macro->parameters,
3621 node->token->value.str,
3622 &parameter_index))
3623 {
3624 token_list_t *argument;
3625 argument = _argument_list_member_at (arguments,
3626 parameter_index);
3627 /* Before substituting, we expand the argument
3628 * tokens, or append a placeholder token for
3629 * an empty argument. */
3630 if (argument->head) {
3631 token_list_t *expanded_argument;
3632 expanded_argument = _token_list_copy (parser,
3633 argument);
3634 _glcpp_parser_expand_token_list (parser,
3635 expanded_argument);
3636 _token_list_append_list (substituted,
3637 expanded_argument);
3638 } else {
3639 token_t *new_token;
3640
3641 new_token = _token_create_ival (substituted,
3642 PLACEHOLDER,
3643 PLACEHOLDER);
3644 _token_list_append (substituted, new_token);
3645 }
3646 } else {
3647 _token_list_append (substituted, node->token);
3648 }
3649 }
3650
3651 /* After argument substitution, and before further expansion
3652 * below, implement token pasting. */
3653
3654 _token_list_trim_trailing_space (substituted);
3655
3656 node = substituted->head;
3657 while (node)
3658 {
3659 token_node_t *next_non_space;
3660
3661 /* Look ahead for a PASTE token, skipping space. */
3662 next_non_space = node->next;
3663 while (next_non_space && next_non_space->token->type == SPACE)
3664 next_non_space = next_non_space->next;
3665
3666 if (next_non_space == NULL)
3667 break;
3668
3669 if (next_non_space->token->type != PASTE) {
3670 node = next_non_space;
3671 continue;
3672 }
3673
3674 /* Now find the next non-space token after the PASTE. */
3675 next_non_space = next_non_space->next;
3676 while (next_non_space && next_non_space->token->type == SPACE)
3677 next_non_space = next_non_space->next;
3678
3679 if (next_non_space == NULL) {
3680 yyerror (&node->token->location, parser, "'##' cannot appear at either end of a macro expansion\n");
3681 return NULL;
3682 }
3683
3684 node->token = _token_paste (parser, node->token, next_non_space->token);
3685 node->next = next_non_space->next;
3686 if (next_non_space == substituted->tail)
3687 substituted->tail = node;
3688
3689 node = node->next;
3690 }
3691
3692 substituted->non_space_tail = substituted->tail;
3693
3694 return substituted;
3695}
3696
3697/* Compute the complete expansion of node, (and subsequent nodes after
3698 * 'node' in the case that 'node' is a function-like macro and
3699 * subsequent nodes are arguments).
3700 *
3701 * Returns NULL if node is a simple token with no expansion.
3702 *
3703 * Otherwise, returns the token list that results from the expansion
3704 * and sets *last to the last node in the list that was consumed by
3705 * the expansion. Specifically, *last will be set as follows:
3706 *
3707 * As 'node' in the case of object-like macro expansion.
3708 *
3709 * As the token of the closing right parenthesis in the case of
3710 * function-like macro expansion.
3711 */
3712static token_list_t *
3713_glcpp_parser_expand_node (glcpp_parser_t *parser,
3714 token_node_t *node,
3715 token_node_t **last)
3716{
3717 token_t *token = node->token;
3718 const char *identifier;
3719 macro_t *macro;
3720
3721 /* We only expand identifiers */
3722 if (token->type != IDENTIFIER) {
3723 /* We change any COMMA into a COMMA_FINAL to prevent
3724 * it being mistaken for an argument separator
3725 * later. */
3726 if (token->type == ',') {
3727 token->type = COMMA_FINAL;
3728 token->value.ival = COMMA_FINAL;
3729 }
3730
3731 return NULL;
3732 }
3733
3734 /* Look up this identifier in the hash table. */
3735 identifier = token->value.str;
3736 macro = hash_table_find (parser->defines, identifier);
3737
3738 /* Not a macro, so no expansion needed. */
3739 if (macro == NULL)
3740 return NULL;
3741
3742 /* Finally, don't expand this macro if we're already actively
3743 * expanding it, (to avoid infinite recursion). */
3744 if (_active_list_contains (parser->active, identifier)) {
3745 /* We change the token type here from IDENTIFIER to
3746 * OTHER to prevent any future expansion of this
3747 * unexpanded token. */
3748 char *str;
3749 token_list_t *expansion;
3750 token_t *final;
3751
Kenneth Graunke0ef79a52010-08-03 20:25:13 -07003752 str = talloc_strdup (parser, token->value.str);
Carl Worth667173e2010-07-28 12:33:56 -07003753 final = _token_create_str (parser, OTHER, str);
3754 expansion = _token_list_create (parser);
3755 _token_list_append (expansion, final);
3756 *last = node;
3757 return expansion;
3758 }
3759
3760 if (! macro->is_function)
3761 {
3762 *last = node;
3763
3764 /* Replace a macro defined as empty with a SPACE token. */
3765 if (macro->replacements == NULL)
3766 return _token_list_create_with_one_space (parser);
3767
3768 return _token_list_copy (parser, macro->replacements);
3769 }
3770
3771 return _glcpp_parser_expand_function (parser, node, last);
3772}
3773
3774/* Push a new identifier onto the active list, returning the new list.
3775 *
3776 * Here, 'marker' is the token node that appears in the list after the
3777 * expansion of 'identifier'. That is, when the list iterator begins
3778 * examinging 'marker', then it is time to pop this node from the
3779 * active stack.
3780 */
3781active_list_t *
3782_active_list_push (active_list_t *list,
3783 const char *identifier,
3784 token_node_t *marker)
3785{
3786 active_list_t *node;
3787
Kenneth Graunke0ef79a52010-08-03 20:25:13 -07003788 node = talloc (list, active_list_t);
3789 node->identifier = talloc_strdup (node, identifier);
Carl Worth667173e2010-07-28 12:33:56 -07003790 node->marker = marker;
3791 node->next = list;
3792
3793 return node;
3794}
3795
3796active_list_t *
3797_active_list_pop (active_list_t *list)
3798{
3799 active_list_t *node = list;
3800
3801 if (node == NULL)
3802 return NULL;
3803
3804 node = list->next;
3805 talloc_free (list);
3806
3807 return node;
3808}
3809
3810int
3811_active_list_contains (active_list_t *list, const char *identifier)
3812{
3813 active_list_t *node;
3814
3815 if (list == NULL)
3816 return 0;
3817
3818 for (node = list; node; node = node->next)
3819 if (strcmp (node->identifier, identifier) == 0)
3820 return 1;
3821
3822 return 0;
3823}
3824
3825/* Walk over the token list replacing nodes with their expansion.
3826 * Whenever nodes are expanded the walking will walk over the new
3827 * nodes, continuing to expand as necessary. The results are placed in
3828 * 'list' itself;
3829 */
3830static void
3831_glcpp_parser_expand_token_list (glcpp_parser_t *parser,
3832 token_list_t *list)
3833{
3834 token_node_t *node_prev;
3835 token_node_t *node, *last = NULL;
3836 token_list_t *expansion;
3837
3838 if (list == NULL)
3839 return;
3840
3841 _token_list_trim_trailing_space (list);
3842
3843 node_prev = NULL;
3844 node = list->head;
3845
3846 while (node) {
3847
3848 while (parser->active && parser->active->marker == node)
3849 parser->active = _active_list_pop (parser->active);
3850
3851 /* Find the expansion for node, which will replace all
3852 * nodes from node to last, inclusive. */
3853 expansion = _glcpp_parser_expand_node (parser, node, &last);
3854 if (expansion) {
3855 token_node_t *n;
3856
3857 for (n = node; n != last->next; n = n->next)
3858 while (parser->active &&
3859 parser->active->marker == n)
3860 {
3861 parser->active = _active_list_pop (parser->active);
3862 }
3863
3864 parser->active = _active_list_push (parser->active,
3865 node->token->value.str,
3866 last->next);
3867
3868 /* Splice expansion into list, supporting a
3869 * simple deletion if the expansion is
3870 * empty. */
3871 if (expansion->head) {
3872 if (node_prev)
3873 node_prev->next = expansion->head;
3874 else
3875 list->head = expansion->head;
3876 expansion->tail->next = last->next;
3877 if (last == list->tail)
3878 list->tail = expansion->tail;
3879 } else {
3880 if (node_prev)
3881 node_prev->next = last->next;
3882 else
3883 list->head = last->next;
3884 if (last == list->tail)
3885 list->tail = NULL;
3886 }
3887 } else {
3888 node_prev = node;
3889 }
3890 node = node_prev ? node_prev->next : list->head;
3891 }
3892
3893 while (parser->active)
3894 parser->active = _active_list_pop (parser->active);
3895
3896 list->non_space_tail = list->tail;
3897}
3898
3899void
3900_glcpp_parser_print_expanded_token_list (glcpp_parser_t *parser,
3901 token_list_t *list)
3902{
3903 if (list == NULL)
3904 return;
3905
3906 _glcpp_parser_expand_token_list (parser, list);
3907
3908 _token_list_trim_trailing_space (list);
3909
3910 _token_list_print (parser, list);
3911}
3912
3913static void
3914_check_for_reserved_macro_name (glcpp_parser_t *parser, YYLTYPE *loc,
3915 const char *identifier)
3916{
3917 /* According to the GLSL specification, macro names starting with "__"
3918 * or "GL_" are reserved for future use. So, don't allow them.
3919 */
3920 if (strncmp(identifier, "__", 2) == 0) {
3921 glcpp_error (loc, parser, "Macro names starting with \"__\" are reserved.\n");
3922 }
3923 if (strncmp(identifier, "GL_", 3) == 0) {
3924 glcpp_error (loc, parser, "Macro names starting with \"GL_\" are reserved.\n");
3925 }
3926}
3927
Carl Worth9751b4e2010-08-17 23:22:42 -07003928static int
3929_macro_equal (macro_t *a, macro_t *b)
3930{
3931 if (a->is_function != b->is_function)
3932 return 0;
3933
3934 if (a->is_function) {
3935 if (! _string_list_equal (a->parameters, b->parameters))
3936 return 0;
3937 }
3938
3939 return _token_list_equal_ignoring_space (a->replacements,
3940 b->replacements);
3941}
3942
Carl Worth667173e2010-07-28 12:33:56 -07003943void
3944_define_object_macro (glcpp_parser_t *parser,
3945 YYLTYPE *loc,
3946 const char *identifier,
3947 token_list_t *replacements)
3948{
Carl Worth9751b4e2010-08-17 23:22:42 -07003949 macro_t *macro, *previous;
Carl Worth667173e2010-07-28 12:33:56 -07003950
3951 if (loc != NULL)
3952 _check_for_reserved_macro_name(parser, loc, identifier);
3953
Kenneth Graunke0ef79a52010-08-03 20:25:13 -07003954 macro = talloc (parser, macro_t);
Carl Worth667173e2010-07-28 12:33:56 -07003955
3956 macro->is_function = 0;
3957 macro->parameters = NULL;
3958 macro->identifier = talloc_strdup (macro, identifier);
3959 macro->replacements = talloc_steal (macro, replacements);
3960
Carl Worth9751b4e2010-08-17 23:22:42 -07003961 previous = hash_table_find (parser->defines, identifier);
3962 if (previous) {
3963 if (_macro_equal (macro, previous)) {
3964 talloc_free (macro);
3965 return;
3966 }
3967 glcpp_error (loc, parser, "Redefinition of macro %s\n",
3968 identifier);
3969 }
3970
Carl Worth667173e2010-07-28 12:33:56 -07003971 hash_table_insert (parser->defines, macro, identifier);
3972}
3973
3974void
3975_define_function_macro (glcpp_parser_t *parser,
3976 YYLTYPE *loc,
3977 const char *identifier,
3978 string_list_t *parameters,
3979 token_list_t *replacements)
3980{
Carl Worth9751b4e2010-08-17 23:22:42 -07003981 macro_t *macro, *previous;
Carl Worth667173e2010-07-28 12:33:56 -07003982
3983 _check_for_reserved_macro_name(parser, loc, identifier);
3984
Kenneth Graunke0ef79a52010-08-03 20:25:13 -07003985 macro = talloc (parser, macro_t);
Carl Worth667173e2010-07-28 12:33:56 -07003986
3987 macro->is_function = 1;
3988 macro->parameters = talloc_steal (macro, parameters);
3989 macro->identifier = talloc_strdup (macro, identifier);
3990 macro->replacements = talloc_steal (macro, replacements);
3991
Carl Worth9751b4e2010-08-17 23:22:42 -07003992 previous = hash_table_find (parser->defines, identifier);
3993 if (previous) {
3994 if (_macro_equal (macro, previous)) {
3995 talloc_free (macro);
3996 return;
3997 }
3998 glcpp_error (loc, parser, "Redefinition of macro %s\n",
3999 identifier);
4000 }
4001
Carl Worth667173e2010-07-28 12:33:56 -07004002 hash_table_insert (parser->defines, macro, identifier);
4003}
4004
4005static int
4006glcpp_parser_lex (YYSTYPE *yylval, YYLTYPE *yylloc, glcpp_parser_t *parser)
4007{
4008 token_node_t *node;
4009 int ret;
4010
4011 if (parser->lex_from_list == NULL) {
4012 ret = glcpp_lex (yylval, yylloc, parser->scanner);
4013
4014 /* XXX: This ugly block of code exists for the sole
4015 * purpose of converting a NEWLINE token into a SPACE
4016 * token, but only in the case where we have seen a
4017 * function-like macro name, but have not yet seen its
4018 * closing parenthesis.
4019 *
4020 * There's perhaps a more compact way to do this with
4021 * mid-rule actions in the grammar.
4022 *
4023 * I'm definitely not pleased with the complexity of
4024 * this code here.
4025 */
4026 if (parser->newline_as_space)
4027 {
4028 if (ret == '(') {
4029 parser->paren_count++;
4030 } else if (ret == ')') {
4031 parser->paren_count--;
4032 if (parser->paren_count == 0)
4033 parser->newline_as_space = 0;
4034 } else if (ret == NEWLINE) {
4035 ret = SPACE;
4036 } else if (ret != SPACE) {
4037 if (parser->paren_count == 0)
4038 parser->newline_as_space = 0;
4039 }
4040 }
4041 else if (parser->in_control_line)
4042 {
4043 if (ret == NEWLINE)
4044 parser->in_control_line = 0;
4045 }
4046 else if (ret == HASH_DEFINE_OBJ || ret == HASH_DEFINE_FUNC ||
4047 ret == HASH_UNDEF || ret == HASH_IF ||
4048 ret == HASH_IFDEF || ret == HASH_IFNDEF ||
4049 ret == HASH_ELIF || ret == HASH_ELSE ||
4050 ret == HASH_ENDIF || ret == HASH)
4051 {
4052 parser->in_control_line = 1;
4053 }
4054 else if (ret == IDENTIFIER)
4055 {
4056 macro_t *macro;
4057 macro = hash_table_find (parser->defines,
4058 yylval->str);
4059 if (macro && macro->is_function) {
4060 parser->newline_as_space = 1;
4061 parser->paren_count = 0;
4062 }
4063 }
4064
4065 return ret;
4066 }
4067
4068 node = parser->lex_from_node;
4069
4070 if (node == NULL) {
4071 talloc_free (parser->lex_from_list);
4072 parser->lex_from_list = NULL;
4073 return NEWLINE;
4074 }
4075
4076 *yylval = node->token->value;
4077 ret = node->token->type;
4078
4079 parser->lex_from_node = node->next;
4080
4081 return ret;
4082}
4083
4084static void
4085glcpp_parser_lex_from (glcpp_parser_t *parser, token_list_t *list)
4086{
4087 token_node_t *node;
4088
4089 assert (parser->lex_from_list == NULL);
4090
4091 /* Copy list, eliminating any space tokens. */
4092 parser->lex_from_list = _token_list_create (parser);
4093
4094 for (node = list->head; node; node = node->next) {
4095 if (node->token->type == SPACE)
4096 continue;
4097 _token_list_append (parser->lex_from_list, node->token);
4098 }
4099
4100 talloc_free (list);
4101
4102 parser->lex_from_node = parser->lex_from_list->head;
4103
4104 /* It's possible the list consisted of nothing but whitespace. */
4105 if (parser->lex_from_node == NULL) {
4106 talloc_free (parser->lex_from_list);
4107 parser->lex_from_list = NULL;
4108 }
4109}
4110
4111static void
4112_glcpp_parser_skip_stack_push_if (glcpp_parser_t *parser, YYLTYPE *loc,
4113 int condition)
4114{
4115 skip_type_t current = SKIP_NO_SKIP;
4116 skip_node_t *node;
4117
4118 if (parser->skip_stack)
4119 current = parser->skip_stack->type;
4120
Kenneth Graunke0ef79a52010-08-03 20:25:13 -07004121 node = talloc (parser, skip_node_t);
Carl Worth667173e2010-07-28 12:33:56 -07004122 node->loc = *loc;
4123
4124 if (current == SKIP_NO_SKIP) {
4125 if (condition)
4126 node->type = SKIP_NO_SKIP;
4127 else
4128 node->type = SKIP_TO_ELSE;
4129 } else {
4130 node->type = SKIP_TO_ENDIF;
4131 }
4132
4133 node->next = parser->skip_stack;
4134 parser->skip_stack = node;
4135}
4136
4137static void
4138_glcpp_parser_skip_stack_change_if (glcpp_parser_t *parser, YYLTYPE *loc,
4139 const char *type, int condition)
4140{
4141 if (parser->skip_stack == NULL) {
4142 glcpp_error (loc, parser, "%s without #if\n", type);
4143 return;
4144 }
4145
4146 if (parser->skip_stack->type == SKIP_TO_ELSE) {
4147 if (condition)
4148 parser->skip_stack->type = SKIP_NO_SKIP;
4149 } else {
4150 parser->skip_stack->type = SKIP_TO_ENDIF;
4151 }
4152}
4153
4154static void
4155_glcpp_parser_skip_stack_pop (glcpp_parser_t *parser, YYLTYPE *loc)
4156{
4157 skip_node_t *node;
4158
4159 if (parser->skip_stack == NULL) {
4160 glcpp_error (loc, parser, "#endif without #if\n");
4161 return;
4162 }
4163
4164 node = parser->skip_stack;
4165 parser->skip_stack = node->next;
4166 talloc_free (node);
4167}
4168