~ubuntu-branches/ubuntu/natty/mesa/natty-proposed

« back to all changes in this revision

Viewing changes to src/glsl/glcpp/glcpp-parse.c

  • Committer: Bazaar Package Importer
  • Author(s): Robert Hooker, Robert Hooker, Christopher James Halse Rogers
  • Date: 2010-09-14 08:55:40 UTC
  • mfrom: (1.2.28 upstream)
  • Revision ID: james.westby@ubuntu.com-20100914085540-m4fpl0hdjlfd4jgz
Tags: 7.9~git20100909-0ubuntu1
[ Robert Hooker ]
* New upstream git snapshot up to commit 94118fe2d4b1e5 (LP: #631413)
* New features include ATI HD5xxx series support in r600, and a vastly
  improved glsl compiler.
* Remove pre-generated .pc's, use the ones generated at build time
  instead.
* Remove all references to mesa-utils now that its no longer shipped
  with the mesa source.
* Disable the experimental ARB_fragment_shader option by default on
  i915, it exposes incomplete functionality that breaks KDE compositing
  among other things. It can be enabled via driconf still. (LP: #628930).

[ Christopher James Halse Rogers ]
* debian/patches/04_osmesa_version.diff:
  - Refresh for new upstream
* Bugs fixed in this release:
  - Fixes severe rendering corruption in Unity on radeon (LP: #628727,
    LP: #596292, LP: #599741, LP: #630315, LP: #613694, LP: #599741).
  - Also fixes rendering in gnome-shell (LP: #578619).
  - Flickering in OpenGL apps on radeon (LP: #626943, LP: #610541).
  - Provides preliminary support for new intel chips (LP: #601052).
* debian/rules:
  - Update configure flags to match upstream reshuffling.
  - Explicitly remove gallium DRI drivers that we don't want to ship.
* Update debian/gbp.conf for this Maverick-specific packaging
* libegl1-mesa-dri-x11,kms: There are no longer separate kms or x11 drivers
  for EGL, libegl1-mesa-drivers now contains a single driver that provides
  both backends.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* A Bison parser, made by GNU Bison 2.4.3.  */
 
2
 
 
3
/* Skeleton implementation for Bison's Yacc-like parsers in C
 
4
   
 
5
      Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
 
6
   2009, 2010 Free Software Foundation, Inc.
 
7
   
 
8
   This program is free software: you can redistribute it and/or modify
 
9
   it under the terms of the GNU General Public License as published by
 
10
   the Free Software Foundation, either version 3 of the License, or
 
11
   (at your option) any later version.
 
12
   
 
13
   This program is distributed in the hope that it will be useful,
 
14
   but WITHOUT ANY WARRANTY; without even the implied warranty of
 
15
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
16
   GNU General Public License for more details.
 
17
   
 
18
   You should have received a copy of the GNU General Public License
 
19
   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
20
 
 
21
/* As a special exception, you may create a larger work that contains
 
22
   part or all of the Bison parser skeleton and distribute that work
 
23
   under terms of your choice, so long as that work isn't itself a
 
24
   parser generator using the skeleton or a modified version thereof
 
25
   as a parser skeleton.  Alternatively, if you modify or redistribute
 
26
   the parser skeleton itself, you may (at your option) remove this
 
27
   special exception, which will cause the skeleton and the resulting
 
28
   Bison output files to be licensed under the GNU General Public
 
29
   License without this special exception.
 
30
   
 
31
   This special exception was added by the Free Software Foundation in
 
32
   version 2.2 of Bison.  */
 
33
 
 
34
/* C LALR(1) parser skeleton written by Richard Stallman, by
 
35
   simplifying the original so-called "semantic" parser.  */
 
36
 
 
37
/* All symbols defined below should begin with yy or YY, to avoid
 
38
   infringing on user name space.  This should be done even for local
 
39
   variables, as they might otherwise be expanded by user macros.
 
40
   There are some unavoidable exceptions within include files to
 
41
   define necessary library symbols; they are noted "INFRINGES ON
 
42
   USER NAME SPACE" below.  */
 
43
 
 
44
/* Identify Bison output.  */
 
45
#define YYBISON 1
 
46
 
 
47
/* Bison version.  */
 
48
#define YYBISON_VERSION "2.4.3"
 
49
 
 
50
/* Skeleton name.  */
 
51
#define YYSKELETON_NAME "yacc.c"
 
52
 
 
53
/* Pure parsers.  */
 
54
#define YYPURE 1
 
55
 
 
56
/* Push parsers.  */
 
57
#define YYPUSH 0
 
58
 
 
59
/* Pull parsers.  */
 
60
#define YYPULL 1
 
61
 
 
62
/* Using locations.  */
 
63
#define YYLSP_NEEDED 1
 
64
 
 
65
 
 
66
 
 
67
/* Copy the first part of user declarations.  */
 
68
 
 
69
/* Line 189 of yacc.c  */
 
70
#line 1 "glcpp/glcpp-parse.y"
 
71
 
 
72
/*
 
73
 * Copyright © 2010 Intel Corporation
 
74
 *
 
75
 * Permission is hereby granted, free of charge, to any person obtaining a
 
76
 * copy of this software and associated documentation files (the "Software"),
 
77
 * to deal in the Software without restriction, including without limitation
 
78
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
 
79
 * and/or sell copies of the Software, and to permit persons to whom the
 
80
 * Software is furnished to do so, subject to the following conditions:
 
81
 *
 
82
 * The above copyright notice and this permission notice (including the next
 
83
 * paragraph) shall be included in all copies or substantial portions of the
 
84
 * Software.
 
85
 *
 
86
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 
87
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 
88
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
 
89
 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 
90
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 
91
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
 
92
 * DEALINGS IN THE SOFTWARE.
 
93
 */
 
94
 
 
95
#include <stdio.h>
 
96
#include <stdlib.h>
 
97
#include <string.h>
 
98
#include <assert.h>
 
99
#include <inttypes.h>
 
100
 
 
101
#include "glcpp.h"
 
102
#include "main/core.h" /* for struct gl_extensions */
 
103
#include "main/mtypes.h" /* for gl_api enum */
 
104
 
 
105
#define glcpp_print(stream, str) stream = talloc_strdup_append(stream, str)
 
106
#define glcpp_printf(stream, fmt, args, ...) \
 
107
        stream = talloc_asprintf_append(stream, fmt, args)
 
108
 
 
109
static void
 
110
yyerror (YYLTYPE *locp, glcpp_parser_t *parser, const char *error);
 
111
 
 
112
static void
 
113
_define_object_macro (glcpp_parser_t *parser,
 
114
                      YYLTYPE *loc,
 
115
                      const char *macro,
 
116
                      token_list_t *replacements);
 
117
 
 
118
static 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
 
 
125
static string_list_t *
 
126
_string_list_create (void *ctx);
 
127
 
 
128
static void
 
129
_string_list_append_item (string_list_t *list, const char *str);
 
130
 
 
131
static int
 
132
_string_list_contains (string_list_t *list, const char *member, int *index);
 
133
 
 
134
static int
 
135
_string_list_length (string_list_t *list);
 
136
 
 
137
static int
 
138
_string_list_equal (string_list_t *a, string_list_t *b);
 
139
 
 
140
static argument_list_t *
 
141
_argument_list_create (void *ctx);
 
142
 
 
143
static void
 
144
_argument_list_append (argument_list_t *list, token_list_t *argument);
 
145
 
 
146
static int
 
147
_argument_list_length (argument_list_t *list);
 
148
 
 
149
static 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. */
 
153
static token_t *
 
154
_token_create_str (void *ctx, int type, char *str);
 
155
 
 
156
static token_t *
 
157
_token_create_ival (void *ctx, int type, int ival);
 
158
 
 
159
static 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. */
 
166
static void
 
167
_token_list_append (token_list_t *list, token_t *token);
 
168
 
 
169
static void
 
170
_token_list_append_list (token_list_t *list, token_list_t *tail);
 
171
 
 
172
static int
 
173
_token_list_equal_ignoring_space (token_list_t *a, token_list_t *b);
 
174
 
 
175
static active_list_t *
 
176
_active_list_push (active_list_t *list,
 
177
                   const char *identifier,
 
178
                   token_node_t *marker);
 
179
 
 
180
static active_list_t *
 
181
_active_list_pop (active_list_t *list);
 
182
 
 
183
int
 
184
_active_list_contains (active_list_t *list, const char *identifier);
 
185
 
 
186
static void
 
187
_glcpp_parser_expand_if (glcpp_parser_t *parser, int type, token_list_t *list);
 
188
 
 
189
static void
 
190
_glcpp_parser_expand_token_list (glcpp_parser_t *parser,
 
191
                                 token_list_t *list);
 
192
 
 
193
static void
 
194
_glcpp_parser_print_expanded_token_list (glcpp_parser_t *parser,
 
195
                                         token_list_t *list);
 
196
 
 
197
static void
 
198
_glcpp_parser_skip_stack_push_if (glcpp_parser_t *parser, YYLTYPE *loc,
 
199
                                  int condition);
 
200
 
 
201
static void
 
202
_glcpp_parser_skip_stack_change_if (glcpp_parser_t *parser, YYLTYPE *loc,
 
203
                                    const char *type, int condition);
 
204
 
 
205
static void
 
206
_glcpp_parser_skip_stack_pop (glcpp_parser_t *parser, YYLTYPE *loc);
 
207
 
 
208
#define yylex glcpp_parser_lex
 
209
 
 
210
static int
 
211
glcpp_parser_lex (YYSTYPE *yylval, YYLTYPE *yylloc, glcpp_parser_t *parser);
 
212
 
 
213
static void
 
214
glcpp_parser_lex_from (glcpp_parser_t *parser, token_list_t *list);
 
215
 
 
216
static void
 
217
add_builtin_define(glcpp_parser_t *parser, const char *name, int value);
 
218
 
 
219
 
 
220
 
 
221
/* Line 189 of yacc.c  */
 
222
#line 223 "glcpp/glcpp-parse.c"
 
223
 
 
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,
 
262
     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
 
281
   };
 
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
 
293
typedef 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  */
 
310
#line 311 "glcpp/glcpp-parse.c"
 
311
 
 
312
#ifdef short
 
313
# undef short
 
314
#endif
 
315
 
 
316
#ifdef YYTYPE_UINT8
 
317
typedef YYTYPE_UINT8 yytype_uint8;
 
318
#else
 
319
typedef unsigned char yytype_uint8;
 
320
#endif
 
321
 
 
322
#ifdef YYTYPE_INT8
 
323
typedef YYTYPE_INT8 yytype_int8;
 
324
#elif (defined __STDC__ || defined __C99__FUNC__ \
 
325
     || defined __cplusplus || defined _MSC_VER)
 
326
typedef signed char yytype_int8;
 
327
#else
 
328
typedef short int yytype_int8;
 
329
#endif
 
330
 
 
331
#ifdef YYTYPE_UINT16
 
332
typedef YYTYPE_UINT16 yytype_uint16;
 
333
#else
 
334
typedef unsigned short int yytype_uint16;
 
335
#endif
 
336
 
 
337
#ifdef YYTYPE_INT16
 
338
typedef YYTYPE_INT16 yytype_int16;
 
339
#else
 
340
typedef 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_
 
360
# if defined YYENABLE_NLS && YYENABLE_NLS
 
361
#  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)
 
384
static int
 
385
YYID (int yyi)
 
386
#else
 
387
static int
 
388
YYID (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)
 
452
void *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)
 
459
void 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.  */
 
472
union 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.  */
 
527
#define YYLAST   606
 
528
 
 
529
/* YYNTOKENS -- Number of terminals.  */
 
530
#define YYNTOKENS  57
 
531
/* YYNNTS -- Number of nonterminals.  */
 
532
#define YYNNTS  17
 
533
/* YYNRULES -- Number of rules.  */
 
534
#define YYNRULES  101
 
535
/* YYNRULES -- Number of states.  */
 
536
#define YYNSTATES  162
 
537
 
 
538
/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX.  */
 
539
#define YYUNDEFTOK  2
 
540
#define YYMAXUTOK   289
 
541
 
 
542
#define YYTRANSLATE(YYX)                                                \
 
543
  ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
 
544
 
 
545
/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX.  */
 
546
static 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,
 
551
       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,
 
555
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
 
556
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
 
557
       2,    50,     2,    51,    29,     2,     2,     2,     2,     2,
 
558
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
 
559
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
 
560
       2,     2,     2,    52,    28,    53,    48,     2,     2,     2,
 
561
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
 
562
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
 
563
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
 
564
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
 
565
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
 
566
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
 
567
       2,     2,     2,     2,     2,     2,     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,
 
576
      25,    26,    27,    31,    32,    35,    36,    37,    38,    44
 
577
};
 
578
 
 
579
#if YYDEBUG
 
580
/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
 
581
   YYRHS.  */
 
582
static const yytype_uint16 yyprhs[] =
 
583
{
 
584
       0,     0,     3,     4,     7,     9,    11,    13,    16,    20,
 
585
      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
 
595
};
 
596
 
 
597
/* YYRHS -- A `-1'-separated list of the rules' RHS.  */
 
598
static const yytype_int8 yyrhs[] =
 
599
{
 
600
      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,
 
605
      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
 
630
};
 
631
 
 
632
/* YYRLINE[YYN] -- source line where rule number YYN was defined.  */
 
633
static const yytype_uint16 yyrline[] =
 
634
{
 
635
       0,   188,   188,   190,   194,   197,   202,   203,   207,   210,
 
636
     216,   219,   222,   225,   233,   252,   262,   267,   272,   291,
 
637
     306,   309,   312,   325,   329,   338,   343,   344,   347,   350,
 
638
     353,   356,   359,   362,   365,   368,   371,   374,   377,   380,
 
639
     383,   386,   389,   392,   395,   398,   401,   404,   407,   410,
 
640
     416,   421,   429,   430,   434,   440,   441,   444,   446,   453,
 
641
     457,   461,   466,   472,   480,   486,   494,   498,   502,   506,
 
642
     510,   517,   518,   519,   520,   521,   522,   523,   524,   525,
 
643
     526,   527,   528,   529,   530,   531,   532,   533,   534,   535,
 
644
     536,   537,   538,   539,   540,   541,   542,   543,   544,   545,
 
645
     546,   547
 
646
};
 
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.  */
 
652
static 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",
 
657
  "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
 
667
};
 
668
#endif
 
669
 
 
670
# ifdef YYPRINT
 
671
/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
 
672
   token YYLEX-NUM.  */
 
673
static 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,
 
677
     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
 
681
};
 
682
# endif
 
683
 
 
684
/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives.  */
 
685
static const yytype_uint8 yyr1[] =
 
686
{
 
687
       0,    57,    58,    58,    59,    59,    59,    59,    60,    60,
 
688
      61,    61,    61,    61,    61,    61,    61,    61,    61,    61,
 
689
      61,    61,    61,    61,    62,    62,    63,    63,    63,    63,
 
690
      63,    63,    63,    63,    63,    63,    63,    63,    63,    63,
 
691
      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,
 
695
      73,    73,    73,    73,    73,    73,    73,    73,    73,    73,
 
696
      73,    73,    73,    73,    73,    73,    73,    73,    73,    73,
 
697
      73,    73
 
698
};
 
699
 
 
700
/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN.  */
 
701
static const yytype_uint8 yyr2[] =
 
702
{
 
703
       0,     2,     0,     2,     1,     1,     1,     2,     3,     3,
 
704
       4,     6,     7,     3,     3,     2,     4,     4,     3,     2,
 
705
       2,     2,     3,     2,     1,     1,     1,     3,     3,     3,
 
706
       3,     3,     3,     3,     3,     3,     3,     3,     3,     3,
 
707
       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,
 
710
       1,     1,     1,     1,     1,     1,     1,     1,     1,     1,
 
711
       1,     1,     1,     1,     1,     1,     1,     1,     1,     1,
 
712
       1,     1,     1,     1,     1,     1,     1,     1,     1,     1,
 
713
       1,     1
 
714
};
 
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.  */
 
719
static const yytype_uint8 yydefact[] =
 
720
{
 
721
       2,     0,     1,     0,     0,     0,     0,     0,     0,     0,
 
722
       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,
 
731
       0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
 
732
       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
 
738
};
 
739
 
 
740
/* YYDEFGOTO[NTERM-NUM].  */
 
741
static const yytype_int16 yydefgoto[] =
 
742
{
 
743
      -1,     1,    52,    53,    54,    66,    67,   149,    55,    69,
 
744
     115,   122,    75,    76,   116,    57,    58
 
745
};
 
746
 
 
747
/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
 
748
   STATE-NUM.  */
 
749
#define YYPACT_NINF -147
 
750
static const yytype_int16 yypact[] =
 
751
{
 
752
    -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
 
769
};
 
770
 
 
771
/* YYPGOTO[NTERM-NUM].  */
 
772
static const yytype_int16 yypgoto[] =
 
773
{
 
774
    -147,  -147,  -147,  -147,  -147,   157,   -11,  -147,  -147,  -147,
 
775
    -146,    92,   -68,   200,     0,    -7,  -147
 
776
};
 
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
 
783
static const yytype_uint8 yytable[] =
 
784
{
 
785
      77,    56,   154,    77,    70,    86,    78,    15,   120,   159,
 
786
      17,    68,    19,   120,    20,    21,    22,    23,    24,    25,
 
787
      26,    27,    28,    29,    30,    31,    32,    33,    34,    35,
 
788
      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,
 
794
     135,   136,   137,   138,   139,   140,   141,   142,   143,   144,
 
795
     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,
 
831
     101,   102,   103,   104,   105,   106,   107,   108,   109,   110,
 
832
     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
 
846
};
 
847
 
 
848
static const yytype_int16 yycheck[] =
 
849
{
 
850
       7,     1,   148,    10,     4,    16,    21,    17,    76,   155,
 
851
      20,    21,    22,    81,    24,    25,    26,    27,    28,    29,
 
852
      30,    31,    32,    33,    34,    35,    36,    37,    38,    39,
 
853
      40,    41,    42,    43,    17,    45,    46,    47,    48,    49,
 
854
      50,    51,    52,    53,    54,    55,    56,    19,    20,    56,
 
855
      61,    62,    63,    64,    65,    37,    38,    39,    40,    41,
 
856
      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,
 
859
     101,   102,   103,   104,   105,   106,   107,   108,   109,   110,
 
860
     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,
 
864
      28,    29,    30,    31,    32,    33,    34,    35,    36,    37,
 
865
      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,
 
868
      28,    29,    30,    31,    32,    33,    34,    35,    36,    37,
 
869
      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,
 
896
      32,    33,    34,    35,    36,    37,    38,    39,    40,    41,
 
897
      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,
 
908
      33,    34,    35,    36,    37,    38,    39,    40,    41,    42,
 
909
      43,    33,    34,    35,    36,    37,    38,    39,    40,    41,
 
910
      42,    43,    39,    40,    41,    42,    43
 
911
};
 
912
 
 
913
/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
 
914
   symbol of state STATE-NUM.  */
 
915
static const yytype_uint8 yystos[] =
 
916
{
 
917
       0,    58,     0,     5,     6,     7,     8,     9,    10,    11,
 
918
      12,    13,    14,    15,    16,    17,    18,    20,    21,    22,
 
919
      24,    25,    26,    27,    28,    29,    30,    31,    32,    33,
 
920
      34,    35,    36,    37,    38,    39,    40,    41,    42,    43,
 
921
      45,    46,    47,    48,    49,    50,    51,    52,    53,    54,
 
922
      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,
 
925
      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,
 
930
      63,    63,    63,    63,    63,    63,    63,    63,    63,    63,
 
931
      63,    63,    63,    63,    63,    63,    63,    17,    46,    64,
 
932
      21,    17,    21,    21,    67,    46,    49,    46,    21,    67,
 
933
      17,    21
 
934
};
 
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.
 
948
   Once GCC version 2 has supplanted version 1, this can go.  However,
 
949
   YYFAIL appears to be in use.  Nevertheless, it is formally deprecated
 
950
   in Bison 2.4.2's NEWS entry, where a plan to phase it out is
 
951
   discussed.  */
 
952
 
 
953
#define YYFAIL          goto yyerrlab
 
954
#if defined YYFAIL
 
955
  /* This is here to suppress warnings from the GCC cpp's
 
956
     -Wunused-macros.  Normally we don't worry about that warning, but
 
957
     some users do, and we want to make it easy for users to remove
 
958
     YYFAIL uses, which will produce warnings from Bison 2.5.  */
 
959
#endif
 
960
 
 
961
#define YYRECOVERING()  (!!yyerrstatus)
 
962
 
 
963
#define YYBACKUP(Token, Value)                                  \
 
964
do                                                              \
 
965
  if (yychar == YYEMPTY && yylen == 1)                          \
 
966
    {                                                           \
 
967
      yychar = (Token);                                         \
 
968
      yylval = (Value);                                         \
 
969
      yytoken = YYTRANSLATE (yychar);                           \
 
970
      YYPOPSTACK (1);                                           \
 
971
      goto yybackup;                                            \
 
972
    }                                                           \
 
973
  else                                                          \
 
974
    {                                                           \
 
975
      yyerror (&yylloc, parser, YY_("syntax error: cannot back up")); \
 
976
      YYERROR;                                                  \
 
977
    }                                                           \
 
978
while (YYID (0))
 
979
 
 
980
 
 
981
#define YYTERROR        1
 
982
#define YYERRCODE       256
 
983
 
 
984
 
 
985
/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
 
986
   If N is 0, then set CURRENT to the empty location which ends
 
987
   the previous symbol: RHS[0] (always defined).  */
 
988
 
 
989
#define YYRHSLOC(Rhs, K) ((Rhs)[K])
 
990
#ifndef YYLLOC_DEFAULT
 
991
# define YYLLOC_DEFAULT(Current, Rhs, N)                                \
 
992
    do                                                                  \
 
993
      if (YYID (N))                                                    \
 
994
        {                                                               \
 
995
          (Current).first_line   = YYRHSLOC (Rhs, 1).first_line;        \
 
996
          (Current).first_column = YYRHSLOC (Rhs, 1).first_column;      \
 
997
          (Current).last_line    = YYRHSLOC (Rhs, N).last_line;         \
 
998
          (Current).last_column  = YYRHSLOC (Rhs, N).last_column;       \
 
999
        }                                                               \
 
1000
      else                                                              \
 
1001
        {                                                               \
 
1002
          (Current).first_line   = (Current).last_line   =              \
 
1003
            YYRHSLOC (Rhs, 0).last_line;                                \
 
1004
          (Current).first_column = (Current).last_column =              \
 
1005
            YYRHSLOC (Rhs, 0).last_column;                              \
 
1006
        }                                                               \
 
1007
    while (YYID (0))
 
1008
#endif
 
1009
 
 
1010
 
 
1011
/* YY_LOCATION_PRINT -- Print the location on the stream.
 
1012
   This macro was not mandated originally: define only if we know
 
1013
   we won't break user code: when these are the locations we know.  */
 
1014
 
 
1015
#ifndef YY_LOCATION_PRINT
 
1016
# if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL
 
1017
#  define YY_LOCATION_PRINT(File, Loc)                  \
 
1018
     fprintf (File, "%d.%d-%d.%d",                      \
 
1019
              (Loc).first_line, (Loc).first_column,     \
 
1020
              (Loc).last_line,  (Loc).last_column)
 
1021
# else
 
1022
#  define YY_LOCATION_PRINT(File, Loc) ((void) 0)
 
1023
# endif
 
1024
#endif
 
1025
 
 
1026
 
 
1027
/* YYLEX -- calling `yylex' with the right arguments.  */
 
1028
 
 
1029
#ifdef YYLEX_PARAM
 
1030
# define YYLEX yylex (&yylval, &yylloc, YYLEX_PARAM)
 
1031
#else
 
1032
# define YYLEX yylex (&yylval, &yylloc, parser)
 
1033
#endif
 
1034
 
 
1035
/* Enable debugging if requested.  */
 
1036
#if YYDEBUG
 
1037
 
 
1038
# ifndef YYFPRINTF
 
1039
#  include <stdio.h> /* INFRINGES ON USER NAME SPACE */
 
1040
#  define YYFPRINTF fprintf
 
1041
# endif
 
1042
 
 
1043
# define YYDPRINTF(Args)                        \
 
1044
do {                                            \
 
1045
  if (yydebug)                                  \
 
1046
    YYFPRINTF Args;                             \
 
1047
} while (YYID (0))
 
1048
 
 
1049
# define YY_SYMBOL_PRINT(Title, Type, Value, Location)                    \
 
1050
do {                                                                      \
 
1051
  if (yydebug)                                                            \
 
1052
    {                                                                     \
 
1053
      YYFPRINTF (stderr, "%s ", Title);                                   \
 
1054
      yy_symbol_print (stderr,                                            \
 
1055
                  Type, Value, Location, parser); \
 
1056
      YYFPRINTF (stderr, "\n");                                           \
 
1057
    }                                                                     \
 
1058
} while (YYID (0))
 
1059
 
 
1060
 
 
1061
/*--------------------------------.
 
1062
| Print this symbol on YYOUTPUT.  |
 
1063
`--------------------------------*/
 
1064
 
 
1065
/*ARGSUSED*/
 
1066
#if (defined __STDC__ || defined __C99__FUNC__ \
 
1067
     || defined __cplusplus || defined _MSC_VER)
 
1068
static void
 
1069
yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, YYLTYPE const * const yylocationp, glcpp_parser_t *parser)
 
1070
#else
 
1071
static void
 
1072
yy_symbol_value_print (yyoutput, yytype, yyvaluep, yylocationp, parser)
 
1073
    FILE *yyoutput;
 
1074
    int yytype;
 
1075
    YYSTYPE const * const yyvaluep;
 
1076
    YYLTYPE const * const yylocationp;
 
1077
    glcpp_parser_t *parser;
 
1078
#endif
 
1079
{
 
1080
  if (!yyvaluep)
 
1081
    return;
 
1082
  YYUSE (yylocationp);
 
1083
  YYUSE (parser);
 
1084
# ifdef YYPRINT
 
1085
  if (yytype < YYNTOKENS)
 
1086
    YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
 
1087
# else
 
1088
  YYUSE (yyoutput);
 
1089
# endif
 
1090
  switch (yytype)
 
1091
    {
 
1092
      default:
 
1093
        break;
 
1094
    }
 
1095
}
 
1096
 
 
1097
 
 
1098
/*--------------------------------.
 
1099
| Print this symbol on YYOUTPUT.  |
 
1100
`--------------------------------*/
 
1101
 
 
1102
#if (defined __STDC__ || defined __C99__FUNC__ \
 
1103
     || defined __cplusplus || defined _MSC_VER)
 
1104
static void
 
1105
yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, YYLTYPE const * const yylocationp, glcpp_parser_t *parser)
 
1106
#else
 
1107
static void
 
1108
yy_symbol_print (yyoutput, yytype, yyvaluep, yylocationp, parser)
 
1109
    FILE *yyoutput;
 
1110
    int yytype;
 
1111
    YYSTYPE const * const yyvaluep;
 
1112
    YYLTYPE const * const yylocationp;
 
1113
    glcpp_parser_t *parser;
 
1114
#endif
 
1115
{
 
1116
  if (yytype < YYNTOKENS)
 
1117
    YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
 
1118
  else
 
1119
    YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
 
1120
 
 
1121
  YY_LOCATION_PRINT (yyoutput, *yylocationp);
 
1122
  YYFPRINTF (yyoutput, ": ");
 
1123
  yy_symbol_value_print (yyoutput, yytype, yyvaluep, yylocationp, parser);
 
1124
  YYFPRINTF (yyoutput, ")");
 
1125
}
 
1126
 
 
1127
/*------------------------------------------------------------------.
 
1128
| yy_stack_print -- Print the state stack from its BOTTOM up to its |
 
1129
| TOP (included).                                                   |
 
1130
`------------------------------------------------------------------*/
 
1131
 
 
1132
#if (defined __STDC__ || defined __C99__FUNC__ \
 
1133
     || defined __cplusplus || defined _MSC_VER)
 
1134
static void
 
1135
yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop)
 
1136
#else
 
1137
static void
 
1138
yy_stack_print (yybottom, yytop)
 
1139
    yytype_int16 *yybottom;
 
1140
    yytype_int16 *yytop;
 
1141
#endif
 
1142
{
 
1143
  YYFPRINTF (stderr, "Stack now");
 
1144
  for (; yybottom <= yytop; yybottom++)
 
1145
    {
 
1146
      int yybot = *yybottom;
 
1147
      YYFPRINTF (stderr, " %d", yybot);
 
1148
    }
 
1149
  YYFPRINTF (stderr, "\n");
 
1150
}
 
1151
 
 
1152
# define YY_STACK_PRINT(Bottom, Top)                            \
 
1153
do {                                                            \
 
1154
  if (yydebug)                                                  \
 
1155
    yy_stack_print ((Bottom), (Top));                           \
 
1156
} while (YYID (0))
 
1157
 
 
1158
 
 
1159
/*------------------------------------------------.
 
1160
| Report that the YYRULE is going to be reduced.  |
 
1161
`------------------------------------------------*/
 
1162
 
 
1163
#if (defined __STDC__ || defined __C99__FUNC__ \
 
1164
     || defined __cplusplus || defined _MSC_VER)
 
1165
static void
 
1166
yy_reduce_print (YYSTYPE *yyvsp, YYLTYPE *yylsp, int yyrule, glcpp_parser_t *parser)
 
1167
#else
 
1168
static void
 
1169
yy_reduce_print (yyvsp, yylsp, yyrule, parser)
 
1170
    YYSTYPE *yyvsp;
 
1171
    YYLTYPE *yylsp;
 
1172
    int yyrule;
 
1173
    glcpp_parser_t *parser;
 
1174
#endif
 
1175
{
 
1176
  int yynrhs = yyr2[yyrule];
 
1177
  int yyi;
 
1178
  unsigned long int yylno = yyrline[yyrule];
 
1179
  YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
 
1180
             yyrule - 1, yylno);
 
1181
  /* The symbols being reduced.  */
 
1182
  for (yyi = 0; yyi < yynrhs; yyi++)
 
1183
    {
 
1184
      YYFPRINTF (stderr, "   $%d = ", yyi + 1);
 
1185
      yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
 
1186
                       &(yyvsp[(yyi + 1) - (yynrhs)])
 
1187
                       , &(yylsp[(yyi + 1) - (yynrhs)])                , parser);
 
1188
      YYFPRINTF (stderr, "\n");
 
1189
    }
 
1190
}
 
1191
 
 
1192
# define YY_REDUCE_PRINT(Rule)          \
 
1193
do {                                    \
 
1194
  if (yydebug)                          \
 
1195
    yy_reduce_print (yyvsp, yylsp, Rule, parser); \
 
1196
} while (YYID (0))
 
1197
 
 
1198
/* Nonzero means print parse trace.  It is left uninitialized so that
 
1199
   multiple parsers can coexist.  */
 
1200
int yydebug;
 
1201
#else /* !YYDEBUG */
 
1202
# define YYDPRINTF(Args)
 
1203
# define YY_SYMBOL_PRINT(Title, Type, Value, Location)
 
1204
# define YY_STACK_PRINT(Bottom, Top)
 
1205
# define YY_REDUCE_PRINT(Rule)
 
1206
#endif /* !YYDEBUG */
 
1207
 
 
1208
 
 
1209
/* YYINITDEPTH -- initial size of the parser's stacks.  */
 
1210
#ifndef YYINITDEPTH
 
1211
# define YYINITDEPTH 200
 
1212
#endif
 
1213
 
 
1214
/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
 
1215
   if the built-in stack extension method is used).
 
1216
 
 
1217
   Do not make this value too large; the results are undefined if
 
1218
   YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
 
1219
   evaluated with infinite-precision integer arithmetic.  */
 
1220
 
 
1221
#ifndef YYMAXDEPTH
 
1222
# define YYMAXDEPTH 10000
 
1223
#endif
 
1224
 
 
1225
 
 
1226
 
 
1227
#if YYERROR_VERBOSE
 
1228
 
 
1229
# ifndef yystrlen
 
1230
#  if defined __GLIBC__ && defined _STRING_H
 
1231
#   define yystrlen strlen
 
1232
#  else
 
1233
/* Return the length of YYSTR.  */
 
1234
#if (defined __STDC__ || defined __C99__FUNC__ \
 
1235
     || defined __cplusplus || defined _MSC_VER)
 
1236
static YYSIZE_T
 
1237
yystrlen (const char *yystr)
 
1238
#else
 
1239
static YYSIZE_T
 
1240
yystrlen (yystr)
 
1241
    const char *yystr;
 
1242
#endif
 
1243
{
 
1244
  YYSIZE_T yylen;
 
1245
  for (yylen = 0; yystr[yylen]; yylen++)
 
1246
    continue;
 
1247
  return yylen;
 
1248
}
 
1249
#  endif
 
1250
# endif
 
1251
 
 
1252
# ifndef yystpcpy
 
1253
#  if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
 
1254
#   define yystpcpy stpcpy
 
1255
#  else
 
1256
/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
 
1257
   YYDEST.  */
 
1258
#if (defined __STDC__ || defined __C99__FUNC__ \
 
1259
     || defined __cplusplus || defined _MSC_VER)
 
1260
static char *
 
1261
yystpcpy (char *yydest, const char *yysrc)
 
1262
#else
 
1263
static char *
 
1264
yystpcpy (yydest, yysrc)
 
1265
    char *yydest;
 
1266
    const char *yysrc;
 
1267
#endif
 
1268
{
 
1269
  char *yyd = yydest;
 
1270
  const char *yys = yysrc;
 
1271
 
 
1272
  while ((*yyd++ = *yys++) != '\0')
 
1273
    continue;
 
1274
 
 
1275
  return yyd - 1;
 
1276
}
 
1277
#  endif
 
1278
# endif
 
1279
 
 
1280
# ifndef yytnamerr
 
1281
/* Copy to YYRES the contents of YYSTR after stripping away unnecessary
 
1282
   quotes and backslashes, so that it's suitable for yyerror.  The
 
1283
   heuristic is that double-quoting is unnecessary unless the string
 
1284
   contains an apostrophe, a comma, or backslash (other than
 
1285
   backslash-backslash).  YYSTR is taken from yytname.  If YYRES is
 
1286
   null, do not copy; instead, return the length of what the result
 
1287
   would have been.  */
 
1288
static YYSIZE_T
 
1289
yytnamerr (char *yyres, const char *yystr)
 
1290
{
 
1291
  if (*yystr == '"')
 
1292
    {
 
1293
      YYSIZE_T yyn = 0;
 
1294
      char const *yyp = yystr;
 
1295
 
 
1296
      for (;;)
 
1297
        switch (*++yyp)
 
1298
          {
 
1299
          case '\'':
 
1300
          case ',':
 
1301
            goto do_not_strip_quotes;
 
1302
 
 
1303
          case '\\':
 
1304
            if (*++yyp != '\\')
 
1305
              goto do_not_strip_quotes;
 
1306
            /* Fall through.  */
 
1307
          default:
 
1308
            if (yyres)
 
1309
              yyres[yyn] = *yyp;
 
1310
            yyn++;
 
1311
            break;
 
1312
 
 
1313
          case '"':
 
1314
            if (yyres)
 
1315
              yyres[yyn] = '\0';
 
1316
            return yyn;
 
1317
          }
 
1318
    do_not_strip_quotes: ;
 
1319
    }
 
1320
 
 
1321
  if (! yyres)
 
1322
    return yystrlen (yystr);
 
1323
 
 
1324
  return yystpcpy (yyres, yystr) - yyres;
 
1325
}
 
1326
# endif
 
1327
 
 
1328
/* Copy into YYRESULT an error message about the unexpected token
 
1329
   YYCHAR while in state YYSTATE.  Return the number of bytes copied,
 
1330
   including the terminating null byte.  If YYRESULT is null, do not
 
1331
   copy anything; just return the number of bytes that would be
 
1332
   copied.  As a special case, return 0 if an ordinary "syntax error"
 
1333
   message will do.  Return YYSIZE_MAXIMUM if overflow occurs during
 
1334
   size calculation.  */
 
1335
static YYSIZE_T
 
1336
yysyntax_error (char *yyresult, int yystate, int yychar)
 
1337
{
 
1338
  int yyn = yypact[yystate];
 
1339
 
 
1340
  if (! (YYPACT_NINF < yyn && yyn <= YYLAST))
 
1341
    return 0;
 
1342
  else
 
1343
    {
 
1344
      int yytype = YYTRANSLATE (yychar);
 
1345
      YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]);
 
1346
      YYSIZE_T yysize = yysize0;
 
1347
      YYSIZE_T yysize1;
 
1348
      int yysize_overflow = 0;
 
1349
      enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
 
1350
      char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
 
1351
      int yyx;
 
1352
 
 
1353
# if 0
 
1354
      /* This is so xgettext sees the translatable formats that are
 
1355
         constructed on the fly.  */
 
1356
      YY_("syntax error, unexpected %s");
 
1357
      YY_("syntax error, unexpected %s, expecting %s");
 
1358
      YY_("syntax error, unexpected %s, expecting %s or %s");
 
1359
      YY_("syntax error, unexpected %s, expecting %s or %s or %s");
 
1360
      YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s");
 
1361
# endif
 
1362
      char *yyfmt;
 
1363
      char const *yyf;
 
1364
      static char const yyunexpected[] = "syntax error, unexpected %s";
 
1365
      static char const yyexpecting[] = ", expecting %s";
 
1366
      static char const yyor[] = " or %s";
 
1367
      char yyformat[sizeof yyunexpected
 
1368
                    + sizeof yyexpecting - 1
 
1369
                    + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2)
 
1370
                       * (sizeof yyor - 1))];
 
1371
      char const *yyprefix = yyexpecting;
 
1372
 
 
1373
      /* Start YYX at -YYN if negative to avoid negative indexes in
 
1374
         YYCHECK.  */
 
1375
      int yyxbegin = yyn < 0 ? -yyn : 0;
 
1376
 
 
1377
      /* Stay within bounds of both yycheck and yytname.  */
 
1378
      int yychecklim = YYLAST - yyn + 1;
 
1379
      int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
 
1380
      int yycount = 1;
 
1381
 
 
1382
      yyarg[0] = yytname[yytype];
 
1383
      yyfmt = yystpcpy (yyformat, yyunexpected);
 
1384
 
 
1385
      for (yyx = yyxbegin; yyx < yyxend; ++yyx)
 
1386
        if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
 
1387
          {
 
1388
            if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
 
1389
              {
 
1390
                yycount = 1;
 
1391
                yysize = yysize0;
 
1392
                yyformat[sizeof yyunexpected - 1] = '\0';
 
1393
                break;
 
1394
              }
 
1395
            yyarg[yycount++] = yytname[yyx];
 
1396
            yysize1 = yysize + yytnamerr (0, yytname[yyx]);
 
1397
            yysize_overflow |= (yysize1 < yysize);
 
1398
            yysize = yysize1;
 
1399
            yyfmt = yystpcpy (yyfmt, yyprefix);
 
1400
            yyprefix = yyor;
 
1401
          }
 
1402
 
 
1403
      yyf = YY_(yyformat);
 
1404
      yysize1 = yysize + yystrlen (yyf);
 
1405
      yysize_overflow |= (yysize1 < yysize);
 
1406
      yysize = yysize1;
 
1407
 
 
1408
      if (yysize_overflow)
 
1409
        return YYSIZE_MAXIMUM;
 
1410
 
 
1411
      if (yyresult)
 
1412
        {
 
1413
          /* Avoid sprintf, as that infringes on the user's name space.
 
1414
             Don't have undefined behavior even if the translation
 
1415
             produced a string with the wrong number of "%s"s.  */
 
1416
          char *yyp = yyresult;
 
1417
          int yyi = 0;
 
1418
          while ((*yyp = *yyf) != '\0')
 
1419
            {
 
1420
              if (*yyp == '%' && yyf[1] == 's' && yyi < yycount)
 
1421
                {
 
1422
                  yyp += yytnamerr (yyp, yyarg[yyi++]);
 
1423
                  yyf += 2;
 
1424
                }
 
1425
              else
 
1426
                {
 
1427
                  yyp++;
 
1428
                  yyf++;
 
1429
                }
 
1430
            }
 
1431
        }
 
1432
      return yysize;
 
1433
    }
 
1434
}
 
1435
#endif /* YYERROR_VERBOSE */
 
1436
 
 
1437
 
 
1438
/*-----------------------------------------------.
 
1439
| Release the memory associated to this symbol.  |
 
1440
`-----------------------------------------------*/
 
1441
 
 
1442
/*ARGSUSED*/
 
1443
#if (defined __STDC__ || defined __C99__FUNC__ \
 
1444
     || defined __cplusplus || defined _MSC_VER)
 
1445
static void
 
1446
yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, YYLTYPE *yylocationp, glcpp_parser_t *parser)
 
1447
#else
 
1448
static void
 
1449
yydestruct (yymsg, yytype, yyvaluep, yylocationp, parser)
 
1450
    const char *yymsg;
 
1451
    int yytype;
 
1452
    YYSTYPE *yyvaluep;
 
1453
    YYLTYPE *yylocationp;
 
1454
    glcpp_parser_t *parser;
 
1455
#endif
 
1456
{
 
1457
  YYUSE (yyvaluep);
 
1458
  YYUSE (yylocationp);
 
1459
  YYUSE (parser);
 
1460
 
 
1461
  if (!yymsg)
 
1462
    yymsg = "Deleting";
 
1463
  YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
 
1464
 
 
1465
  switch (yytype)
 
1466
    {
 
1467
 
 
1468
      default:
 
1469
        break;
 
1470
    }
 
1471
}
 
1472
 
 
1473
/* Prevent warnings from -Wmissing-prototypes.  */
 
1474
#ifdef YYPARSE_PARAM
 
1475
#if defined __STDC__ || defined __cplusplus
 
1476
int yyparse (void *YYPARSE_PARAM);
 
1477
#else
 
1478
int yyparse ();
 
1479
#endif
 
1480
#else /* ! YYPARSE_PARAM */
 
1481
#if defined __STDC__ || defined __cplusplus
 
1482
int yyparse (glcpp_parser_t *parser);
 
1483
#else
 
1484
int yyparse ();
 
1485
#endif
 
1486
#endif /* ! YYPARSE_PARAM */
 
1487
 
 
1488
 
 
1489
 
 
1490
 
 
1491
 
 
1492
/*-------------------------.
 
1493
| yyparse or yypush_parse.  |
 
1494
`-------------------------*/
 
1495
 
 
1496
#ifdef YYPARSE_PARAM
 
1497
#if (defined __STDC__ || defined __C99__FUNC__ \
 
1498
     || defined __cplusplus || defined _MSC_VER)
 
1499
int
 
1500
yyparse (void *YYPARSE_PARAM)
 
1501
#else
 
1502
int
 
1503
yyparse (YYPARSE_PARAM)
 
1504
    void *YYPARSE_PARAM;
 
1505
#endif
 
1506
#else /* ! YYPARSE_PARAM */
 
1507
#if (defined __STDC__ || defined __C99__FUNC__ \
 
1508
     || defined __cplusplus || defined _MSC_VER)
 
1509
int
 
1510
yyparse (glcpp_parser_t *parser)
 
1511
#else
 
1512
int
 
1513
yyparse (parser)
 
1514
    glcpp_parser_t *parser;
 
1515
#endif
 
1516
#endif
 
1517
{
 
1518
/* The lookahead symbol.  */
 
1519
int yychar;
 
1520
 
 
1521
/* The semantic value of the lookahead symbol.  */
 
1522
YYSTYPE yylval;
 
1523
 
 
1524
/* Location data for the lookahead symbol.  */
 
1525
YYLTYPE yylloc;
 
1526
 
 
1527
    /* Number of syntax errors so far.  */
 
1528
    int yynerrs;
 
1529
 
 
1530
    int yystate;
 
1531
    /* Number of tokens to shift before error messages enabled.  */
 
1532
    int yyerrstatus;
 
1533
 
 
1534
    /* The stacks and their tools:
 
1535
       `yyss': related to states.
 
1536
       `yyvs': related to semantic values.
 
1537
       `yyls': related to locations.
 
1538
 
 
1539
       Refer to the stacks thru separate pointers, to allow yyoverflow
 
1540
       to reallocate them elsewhere.  */
 
1541
 
 
1542
    /* The state stack.  */
 
1543
    yytype_int16 yyssa[YYINITDEPTH];
 
1544
    yytype_int16 *yyss;
 
1545
    yytype_int16 *yyssp;
 
1546
 
 
1547
    /* The semantic value stack.  */
 
1548
    YYSTYPE yyvsa[YYINITDEPTH];
 
1549
    YYSTYPE *yyvs;
 
1550
    YYSTYPE *yyvsp;
 
1551
 
 
1552
    /* The location stack.  */
 
1553
    YYLTYPE yylsa[YYINITDEPTH];
 
1554
    YYLTYPE *yyls;
 
1555
    YYLTYPE *yylsp;
 
1556
 
 
1557
    /* The locations where the error started and ended.  */
 
1558
    YYLTYPE yyerror_range[3];
 
1559
 
 
1560
    YYSIZE_T yystacksize;
 
1561
 
 
1562
  int yyn;
 
1563
  int yyresult;
 
1564
  /* Lookahead token as an internal (translated) token number.  */
 
1565
  int yytoken;
 
1566
  /* The variables used to return semantic value and location from the
 
1567
     action routines.  */
 
1568
  YYSTYPE yyval;
 
1569
  YYLTYPE yyloc;
 
1570
 
 
1571
#if YYERROR_VERBOSE
 
1572
  /* Buffer for error messages, and its allocated size.  */
 
1573
  char yymsgbuf[128];
 
1574
  char *yymsg = yymsgbuf;
 
1575
  YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
 
1576
#endif
 
1577
 
 
1578
#define YYPOPSTACK(N)   (yyvsp -= (N), yyssp -= (N), yylsp -= (N))
 
1579
 
 
1580
  /* The number of symbols on the RHS of the reduced rule.
 
1581
     Keep to zero when no symbol should be popped.  */
 
1582
  int yylen = 0;
 
1583
 
 
1584
  yytoken = 0;
 
1585
  yyss = yyssa;
 
1586
  yyvs = yyvsa;
 
1587
  yyls = yylsa;
 
1588
  yystacksize = YYINITDEPTH;
 
1589
 
 
1590
  YYDPRINTF ((stderr, "Starting parse\n"));
 
1591
 
 
1592
  yystate = 0;
 
1593
  yyerrstatus = 0;
 
1594
  yynerrs = 0;
 
1595
  yychar = YYEMPTY; /* Cause a token to be read.  */
 
1596
 
 
1597
  /* Initialize stack pointers.
 
1598
     Waste one element of value and location stack
 
1599
     so that they stay on the same level as the state stack.
 
1600
     The wasted elements are never initialized.  */
 
1601
  yyssp = yyss;
 
1602
  yyvsp = yyvs;
 
1603
  yylsp = yyls;
 
1604
 
 
1605
#if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL
 
1606
  /* Initialize the default location before parsing starts.  */
 
1607
  yylloc.first_line   = yylloc.last_line   = 1;
 
1608
  yylloc.first_column = yylloc.last_column = 1;
 
1609
#endif
 
1610
 
 
1611
/* User initialization code.  */
 
1612
 
 
1613
/* Line 1251 of yacc.c  */
 
1614
#line 155 "glcpp/glcpp-parse.y"
 
1615
{
 
1616
        yylloc.first_line = 1;
 
1617
        yylloc.first_column = 1;
 
1618
        yylloc.last_line = 1;
 
1619
        yylloc.last_column = 1;
 
1620
        yylloc.source = 0;
 
1621
}
 
1622
 
 
1623
/* Line 1251 of yacc.c  */
 
1624
#line 1625 "glcpp/glcpp-parse.c"
 
1625
  yylsp[0] = yylloc;
 
1626
 
 
1627
  goto yysetstate;
 
1628
 
 
1629
/*------------------------------------------------------------.
 
1630
| yynewstate -- Push a new state, which is found in yystate.  |
 
1631
`------------------------------------------------------------*/
 
1632
 yynewstate:
 
1633
  /* In all cases, when you get here, the value and location stacks
 
1634
     have just been pushed.  So pushing a state here evens the stacks.  */
 
1635
  yyssp++;
 
1636
 
 
1637
 yysetstate:
 
1638
  *yyssp = yystate;
 
1639
 
 
1640
  if (yyss + yystacksize - 1 <= yyssp)
 
1641
    {
 
1642
      /* Get the current used size of the three stacks, in elements.  */
 
1643
      YYSIZE_T yysize = yyssp - yyss + 1;
 
1644
 
 
1645
#ifdef yyoverflow
 
1646
      {
 
1647
        /* Give user a chance to reallocate the stack.  Use copies of
 
1648
           these so that the &'s don't force the real ones into
 
1649
           memory.  */
 
1650
        YYSTYPE *yyvs1 = yyvs;
 
1651
        yytype_int16 *yyss1 = yyss;
 
1652
        YYLTYPE *yyls1 = yyls;
 
1653
 
 
1654
        /* Each stack pointer address is followed by the size of the
 
1655
           data in use in that stack, in bytes.  This used to be a
 
1656
           conditional around just the two extra args, but that might
 
1657
           be undefined if yyoverflow is a macro.  */
 
1658
        yyoverflow (YY_("memory exhausted"),
 
1659
                    &yyss1, yysize * sizeof (*yyssp),
 
1660
                    &yyvs1, yysize * sizeof (*yyvsp),
 
1661
                    &yyls1, yysize * sizeof (*yylsp),
 
1662
                    &yystacksize);
 
1663
 
 
1664
        yyls = yyls1;
 
1665
        yyss = yyss1;
 
1666
        yyvs = yyvs1;
 
1667
      }
 
1668
#else /* no yyoverflow */
 
1669
# ifndef YYSTACK_RELOCATE
 
1670
      goto yyexhaustedlab;
 
1671
# else
 
1672
      /* Extend the stack our own way.  */
 
1673
      if (YYMAXDEPTH <= yystacksize)
 
1674
        goto yyexhaustedlab;
 
1675
      yystacksize *= 2;
 
1676
      if (YYMAXDEPTH < yystacksize)
 
1677
        yystacksize = YYMAXDEPTH;
 
1678
 
 
1679
      {
 
1680
        yytype_int16 *yyss1 = yyss;
 
1681
        union yyalloc *yyptr =
 
1682
          (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
 
1683
        if (! yyptr)
 
1684
          goto yyexhaustedlab;
 
1685
        YYSTACK_RELOCATE (yyss_alloc, yyss);
 
1686
        YYSTACK_RELOCATE (yyvs_alloc, yyvs);
 
1687
        YYSTACK_RELOCATE (yyls_alloc, yyls);
 
1688
#  undef YYSTACK_RELOCATE
 
1689
        if (yyss1 != yyssa)
 
1690
          YYSTACK_FREE (yyss1);
 
1691
      }
 
1692
# endif
 
1693
#endif /* no yyoverflow */
 
1694
 
 
1695
      yyssp = yyss + yysize - 1;
 
1696
      yyvsp = yyvs + yysize - 1;
 
1697
      yylsp = yyls + yysize - 1;
 
1698
 
 
1699
      YYDPRINTF ((stderr, "Stack size increased to %lu\n",
 
1700
                  (unsigned long int) yystacksize));
 
1701
 
 
1702
      if (yyss + yystacksize - 1 <= yyssp)
 
1703
        YYABORT;
 
1704
    }
 
1705
 
 
1706
  YYDPRINTF ((stderr, "Entering state %d\n", yystate));
 
1707
 
 
1708
  if (yystate == YYFINAL)
 
1709
    YYACCEPT;
 
1710
 
 
1711
  goto yybackup;
 
1712
 
 
1713
/*-----------.
 
1714
| yybackup.  |
 
1715
`-----------*/
 
1716
yybackup:
 
1717
 
 
1718
  /* Do appropriate processing given the current state.  Read a
 
1719
     lookahead token if we need one and don't already have one.  */
 
1720
 
 
1721
  /* First try to decide what to do without reference to lookahead token.  */
 
1722
  yyn = yypact[yystate];
 
1723
  if (yyn == YYPACT_NINF)
 
1724
    goto yydefault;
 
1725
 
 
1726
  /* Not known => get a lookahead token if don't already have one.  */
 
1727
 
 
1728
  /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol.  */
 
1729
  if (yychar == YYEMPTY)
 
1730
    {
 
1731
      YYDPRINTF ((stderr, "Reading a token: "));
 
1732
      yychar = YYLEX;
 
1733
    }
 
1734
 
 
1735
  if (yychar <= YYEOF)
 
1736
    {
 
1737
      yychar = yytoken = YYEOF;
 
1738
      YYDPRINTF ((stderr, "Now at end of input.\n"));
 
1739
    }
 
1740
  else
 
1741
    {
 
1742
      yytoken = YYTRANSLATE (yychar);
 
1743
      YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
 
1744
    }
 
1745
 
 
1746
  /* If the proper action on seeing token YYTOKEN is to reduce or to
 
1747
     detect an error, take that action.  */
 
1748
  yyn += yytoken;
 
1749
  if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
 
1750
    goto yydefault;
 
1751
  yyn = yytable[yyn];
 
1752
  if (yyn <= 0)
 
1753
    {
 
1754
      if (yyn == 0 || yyn == YYTABLE_NINF)
 
1755
        goto yyerrlab;
 
1756
      yyn = -yyn;
 
1757
      goto yyreduce;
 
1758
    }
 
1759
 
 
1760
  /* Count tokens shifted since error; after three, turn off error
 
1761
     status.  */
 
1762
  if (yyerrstatus)
 
1763
    yyerrstatus--;
 
1764
 
 
1765
  /* Shift the lookahead token.  */
 
1766
  YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
 
1767
 
 
1768
  /* Discard the shifted token.  */
 
1769
  yychar = YYEMPTY;
 
1770
 
 
1771
  yystate = yyn;
 
1772
  *++yyvsp = yylval;
 
1773
  *++yylsp = yylloc;
 
1774
  goto yynewstate;
 
1775
 
 
1776
 
 
1777
/*-----------------------------------------------------------.
 
1778
| yydefault -- do the default action for the current state.  |
 
1779
`-----------------------------------------------------------*/
 
1780
yydefault:
 
1781
  yyn = yydefact[yystate];
 
1782
  if (yyn == 0)
 
1783
    goto yyerrlab;
 
1784
  goto yyreduce;
 
1785
 
 
1786
 
 
1787
/*-----------------------------.
 
1788
| yyreduce -- Do a reduction.  |
 
1789
`-----------------------------*/
 
1790
yyreduce:
 
1791
  /* yyn is the number of a rule to reduce with.  */
 
1792
  yylen = yyr2[yyn];
 
1793
 
 
1794
  /* If YYLEN is nonzero, implement the default value of the action:
 
1795
     `$$ = $1'.
 
1796
 
 
1797
     Otherwise, the following line sets YYVAL to garbage.
 
1798
     This behavior is undocumented and Bison
 
1799
     users should not rely upon it.  Assigning to YYVAL
 
1800
     unconditionally makes the parser a bit smaller, and it avoids a
 
1801
     GCC warning that YYVAL may be used uninitialized.  */
 
1802
  yyval = yyvsp[1-yylen];
 
1803
 
 
1804
  /* Default location.  */
 
1805
  YYLLOC_DEFAULT (yyloc, (yylsp - yylen), yylen);
 
1806
  YY_REDUCE_PRINT (yyn);
 
1807
  switch (yyn)
 
1808
    {
 
1809
        case 4:
 
1810
 
 
1811
/* Line 1464 of yacc.c  */
 
1812
#line 194 "glcpp/glcpp-parse.y"
 
1813
    {
 
1814
                glcpp_print(parser->output, "\n");
 
1815
        ;}
 
1816
    break;
 
1817
 
 
1818
  case 5:
 
1819
 
 
1820
/* Line 1464 of yacc.c  */
 
1821
#line 197 "glcpp/glcpp-parse.y"
 
1822
    {
 
1823
                _glcpp_parser_print_expanded_token_list (parser, (yyvsp[(1) - (1)].token_list));
 
1824
                glcpp_print(parser->output, "\n");
 
1825
                talloc_free ((yyvsp[(1) - (1)].token_list));
 
1826
        ;}
 
1827
    break;
 
1828
 
 
1829
  case 8:
 
1830
 
 
1831
/* Line 1464 of yacc.c  */
 
1832
#line 207 "glcpp/glcpp-parse.y"
 
1833
    {
 
1834
                _glcpp_parser_skip_stack_push_if (parser, & (yylsp[(1) - (3)]), (yyvsp[(2) - (3)].ival));
 
1835
        ;}
 
1836
    break;
 
1837
 
 
1838
  case 9:
 
1839
 
 
1840
/* Line 1464 of yacc.c  */
 
1841
#line 210 "glcpp/glcpp-parse.y"
 
1842
    {
 
1843
                _glcpp_parser_skip_stack_change_if (parser, & (yylsp[(1) - (3)]), "elif", (yyvsp[(2) - (3)].ival));
 
1844
        ;}
 
1845
    break;
 
1846
 
 
1847
  case 10:
 
1848
 
 
1849
/* Line 1464 of yacc.c  */
 
1850
#line 216 "glcpp/glcpp-parse.y"
 
1851
    {
 
1852
                _define_object_macro (parser, & (yylsp[(2) - (4)]), (yyvsp[(2) - (4)].str), (yyvsp[(3) - (4)].token_list));
 
1853
        ;}
 
1854
    break;
 
1855
 
 
1856
  case 11:
 
1857
 
 
1858
/* Line 1464 of yacc.c  */
 
1859
#line 219 "glcpp/glcpp-parse.y"
 
1860
    {
 
1861
                _define_function_macro (parser, & (yylsp[(2) - (6)]), (yyvsp[(2) - (6)].str), NULL, (yyvsp[(5) - (6)].token_list));
 
1862
        ;}
 
1863
    break;
 
1864
 
 
1865
  case 12:
 
1866
 
 
1867
/* Line 1464 of yacc.c  */
 
1868
#line 222 "glcpp/glcpp-parse.y"
 
1869
    {
 
1870
                _define_function_macro (parser, & (yylsp[(2) - (7)]), (yyvsp[(2) - (7)].str), (yyvsp[(4) - (7)].string_list), (yyvsp[(6) - (7)].token_list));
 
1871
        ;}
 
1872
    break;
 
1873
 
 
1874
  case 13:
 
1875
 
 
1876
/* Line 1464 of yacc.c  */
 
1877
#line 225 "glcpp/glcpp-parse.y"
 
1878
    {
 
1879
                macro_t *macro = hash_table_find (parser->defines, (yyvsp[(2) - (3)].str));
 
1880
                if (macro) {
 
1881
                        hash_table_remove (parser->defines, (yyvsp[(2) - (3)].str));
 
1882
                        talloc_free (macro);
 
1883
                }
 
1884
                talloc_free ((yyvsp[(2) - (3)].str));
 
1885
        ;}
 
1886
    break;
 
1887
 
 
1888
  case 14:
 
1889
 
 
1890
/* Line 1464 of yacc.c  */
 
1891
#line 233 "glcpp/glcpp-parse.y"
 
1892
    {
 
1893
                /* Be careful to only evaluate the 'if' expression if
 
1894
                 * we are not skipping. When we are skipping, we
 
1895
                 * simply push a new 0-valued 'if' onto the skip
 
1896
                 * stack.
 
1897
                 *
 
1898
                 * This avoids generating diagnostics for invalid
 
1899
                 * expressions that are being skipped. */
 
1900
                if (parser->skip_stack == NULL ||
 
1901
                    parser->skip_stack->type == SKIP_NO_SKIP)
 
1902
                {
 
1903
                        _glcpp_parser_expand_if (parser, IF_EXPANDED, (yyvsp[(2) - (3)].token_list));
 
1904
                }       
 
1905
                else
 
1906
                {
 
1907
                        _glcpp_parser_skip_stack_push_if (parser, & (yylsp[(1) - (3)]), 0);
 
1908
                        parser->skip_stack->type = SKIP_TO_ENDIF;
 
1909
                }
 
1910
        ;}
 
1911
    break;
 
1912
 
 
1913
  case 15:
 
1914
 
 
1915
/* Line 1464 of yacc.c  */
 
1916
#line 252 "glcpp/glcpp-parse.y"
 
1917
    {
 
1918
                /* #if without an expression is only an error if we
 
1919
                 *  are not skipping */
 
1920
                if (parser->skip_stack == NULL ||
 
1921
                    parser->skip_stack->type == SKIP_NO_SKIP)
 
1922
                {
 
1923
                        glcpp_error(& (yylsp[(1) - (2)]), parser, "#if with no expression");
 
1924
                }       
 
1925
                _glcpp_parser_skip_stack_push_if (parser, & (yylsp[(1) - (2)]), 0);
 
1926
        ;}
 
1927
    break;
 
1928
 
 
1929
  case 16:
 
1930
 
 
1931
/* Line 1464 of yacc.c  */
 
1932
#line 262 "glcpp/glcpp-parse.y"
 
1933
    {
 
1934
                macro_t *macro = hash_table_find (parser->defines, (yyvsp[(2) - (4)].str));
 
1935
                talloc_free ((yyvsp[(2) - (4)].str));
 
1936
                _glcpp_parser_skip_stack_push_if (parser, & (yylsp[(1) - (4)]), macro != NULL);
 
1937
        ;}
 
1938
    break;
 
1939
 
 
1940
  case 17:
 
1941
 
 
1942
/* Line 1464 of yacc.c  */
 
1943
#line 267 "glcpp/glcpp-parse.y"
 
1944
    {
 
1945
                macro_t *macro = hash_table_find (parser->defines, (yyvsp[(2) - (4)].str));
 
1946
                talloc_free ((yyvsp[(2) - (4)].str));
 
1947
                _glcpp_parser_skip_stack_push_if (parser, & (yylsp[(1) - (4)]), macro == NULL);
 
1948
        ;}
 
1949
    break;
 
1950
 
 
1951
  case 18:
 
1952
 
 
1953
/* Line 1464 of yacc.c  */
 
1954
#line 272 "glcpp/glcpp-parse.y"
 
1955
    {
 
1956
                /* Be careful to only evaluate the 'elif' expression
 
1957
                 * if we are not skipping. When we are skipping, we
 
1958
                 * simply change to a 0-valued 'elif' on the skip
 
1959
                 * stack.
 
1960
                 *
 
1961
                 * This avoids generating diagnostics for invalid
 
1962
                 * expressions that are being skipped. */
 
1963
                if (parser->skip_stack &&
 
1964
                    parser->skip_stack->type == SKIP_TO_ELSE)
 
1965
                {
 
1966
                        _glcpp_parser_expand_if (parser, ELIF_EXPANDED, (yyvsp[(2) - (3)].token_list));
 
1967
                }
 
1968
                else
 
1969
                {
 
1970
                        _glcpp_parser_skip_stack_change_if (parser, & (yylsp[(1) - (3)]),
 
1971
                                                            "elif", 0);
 
1972
                }
 
1973
        ;}
 
1974
    break;
 
1975
 
 
1976
  case 19:
 
1977
 
 
1978
/* Line 1464 of yacc.c  */
 
1979
#line 291 "glcpp/glcpp-parse.y"
 
1980
    {
 
1981
                /* #elif without an expression is an error unless we
 
1982
                 * are skipping. */
 
1983
                if (parser->skip_stack &&
 
1984
                    parser->skip_stack->type == SKIP_TO_ELSE)
 
1985
                {
 
1986
                        glcpp_error(& (yylsp[(1) - (2)]), parser, "#elif with no expression");
 
1987
                }
 
1988
                else
 
1989
                {
 
1990
                        _glcpp_parser_skip_stack_change_if (parser, & (yylsp[(1) - (2)]),
 
1991
                                                            "elif", 0);
 
1992
                        glcpp_warning(& (yylsp[(1) - (2)]), parser, "ignoring illegal #elif without expression");
 
1993
                }
 
1994
        ;}
 
1995
    break;
 
1996
 
 
1997
  case 20:
 
1998
 
 
1999
/* Line 1464 of yacc.c  */
 
2000
#line 306 "glcpp/glcpp-parse.y"
 
2001
    {
 
2002
                _glcpp_parser_skip_stack_change_if (parser, & (yylsp[(1) - (2)]), "else", 1);
 
2003
        ;}
 
2004
    break;
 
2005
 
 
2006
  case 21:
 
2007
 
 
2008
/* Line 1464 of yacc.c  */
 
2009
#line 309 "glcpp/glcpp-parse.y"
 
2010
    {
 
2011
                _glcpp_parser_skip_stack_pop (parser, & (yylsp[(1) - (2)]));
 
2012
        ;}
 
2013
    break;
 
2014
 
 
2015
  case 22:
 
2016
 
 
2017
/* Line 1464 of yacc.c  */
 
2018
#line 312 "glcpp/glcpp-parse.y"
 
2019
    {
 
2020
                macro_t *macro = hash_table_find (parser->defines, "__VERSION__");
 
2021
                if (macro) {
 
2022
                        hash_table_remove (parser->defines, "__VERSION__");
 
2023
                        talloc_free (macro);
 
2024
                }
 
2025
                add_builtin_define (parser, "__VERSION__", (yyvsp[(2) - (3)].ival));
 
2026
 
 
2027
                if ((yyvsp[(2) - (3)].ival) == 100)
 
2028
                        add_builtin_define (parser, "GL_ES", 1);
 
2029
 
 
2030
                glcpp_printf(parser->output, "#version %" PRIiMAX, (yyvsp[(2) - (3)].ival));
 
2031
        ;}
 
2032
    break;
 
2033
 
 
2034
  case 24:
 
2035
 
 
2036
/* Line 1464 of yacc.c  */
 
2037
#line 329 "glcpp/glcpp-parse.y"
 
2038
    {
 
2039
                if (strlen ((yyvsp[(1) - (1)].str)) >= 3 && strncmp ((yyvsp[(1) - (1)].str), "0x", 2) == 0) {
 
2040
                        (yyval.ival) = strtoll ((yyvsp[(1) - (1)].str) + 2, NULL, 16);
 
2041
                } else if ((yyvsp[(1) - (1)].str)[0] == '0') {
 
2042
                        (yyval.ival) = strtoll ((yyvsp[(1) - (1)].str), NULL, 8);
 
2043
                } else {
 
2044
                        (yyval.ival) = strtoll ((yyvsp[(1) - (1)].str), NULL, 10);
 
2045
                }
 
2046
        ;}
 
2047
    break;
 
2048
 
 
2049
  case 25:
 
2050
 
 
2051
/* Line 1464 of yacc.c  */
 
2052
#line 338 "glcpp/glcpp-parse.y"
 
2053
    {
 
2054
                (yyval.ival) = (yyvsp[(1) - (1)].ival);
 
2055
        ;}
 
2056
    break;
 
2057
 
 
2058
  case 27:
 
2059
 
 
2060
/* Line 1464 of yacc.c  */
 
2061
#line 344 "glcpp/glcpp-parse.y"
 
2062
    {
 
2063
                (yyval.ival) = (yyvsp[(1) - (3)].ival) || (yyvsp[(3) - (3)].ival);
 
2064
        ;}
 
2065
    break;
 
2066
 
 
2067
  case 28:
 
2068
 
 
2069
/* Line 1464 of yacc.c  */
 
2070
#line 347 "glcpp/glcpp-parse.y"
 
2071
    {
 
2072
                (yyval.ival) = (yyvsp[(1) - (3)].ival) && (yyvsp[(3) - (3)].ival);
 
2073
        ;}
 
2074
    break;
 
2075
 
 
2076
  case 29:
 
2077
 
 
2078
/* Line 1464 of yacc.c  */
 
2079
#line 350 "glcpp/glcpp-parse.y"
 
2080
    {
 
2081
                (yyval.ival) = (yyvsp[(1) - (3)].ival) | (yyvsp[(3) - (3)].ival);
 
2082
        ;}
 
2083
    break;
 
2084
 
 
2085
  case 30:
 
2086
 
 
2087
/* Line 1464 of yacc.c  */
 
2088
#line 353 "glcpp/glcpp-parse.y"
 
2089
    {
 
2090
                (yyval.ival) = (yyvsp[(1) - (3)].ival) ^ (yyvsp[(3) - (3)].ival);
 
2091
        ;}
 
2092
    break;
 
2093
 
 
2094
  case 31:
 
2095
 
 
2096
/* Line 1464 of yacc.c  */
 
2097
#line 356 "glcpp/glcpp-parse.y"
 
2098
    {
 
2099
                (yyval.ival) = (yyvsp[(1) - (3)].ival) & (yyvsp[(3) - (3)].ival);
 
2100
        ;}
 
2101
    break;
 
2102
 
 
2103
  case 32:
 
2104
 
 
2105
/* Line 1464 of yacc.c  */
 
2106
#line 359 "glcpp/glcpp-parse.y"
 
2107
    {
 
2108
                (yyval.ival) = (yyvsp[(1) - (3)].ival) != (yyvsp[(3) - (3)].ival);
 
2109
        ;}
 
2110
    break;
 
2111
 
 
2112
  case 33:
 
2113
 
 
2114
/* Line 1464 of yacc.c  */
 
2115
#line 362 "glcpp/glcpp-parse.y"
 
2116
    {
 
2117
                (yyval.ival) = (yyvsp[(1) - (3)].ival) == (yyvsp[(3) - (3)].ival);
 
2118
        ;}
 
2119
    break;
 
2120
 
 
2121
  case 34:
 
2122
 
 
2123
/* Line 1464 of yacc.c  */
 
2124
#line 365 "glcpp/glcpp-parse.y"
 
2125
    {
 
2126
                (yyval.ival) = (yyvsp[(1) - (3)].ival) >= (yyvsp[(3) - (3)].ival);
 
2127
        ;}
 
2128
    break;
 
2129
 
 
2130
  case 35:
 
2131
 
 
2132
/* Line 1464 of yacc.c  */
 
2133
#line 368 "glcpp/glcpp-parse.y"
 
2134
    {
 
2135
                (yyval.ival) = (yyvsp[(1) - (3)].ival) <= (yyvsp[(3) - (3)].ival);
 
2136
        ;}
 
2137
    break;
 
2138
 
 
2139
  case 36:
 
2140
 
 
2141
/* Line 1464 of yacc.c  */
 
2142
#line 371 "glcpp/glcpp-parse.y"
 
2143
    {
 
2144
                (yyval.ival) = (yyvsp[(1) - (3)].ival) > (yyvsp[(3) - (3)].ival);
 
2145
        ;}
 
2146
    break;
 
2147
 
 
2148
  case 37:
 
2149
 
 
2150
/* Line 1464 of yacc.c  */
 
2151
#line 374 "glcpp/glcpp-parse.y"
 
2152
    {
 
2153
                (yyval.ival) = (yyvsp[(1) - (3)].ival) < (yyvsp[(3) - (3)].ival);
 
2154
        ;}
 
2155
    break;
 
2156
 
 
2157
  case 38:
 
2158
 
 
2159
/* Line 1464 of yacc.c  */
 
2160
#line 377 "glcpp/glcpp-parse.y"
 
2161
    {
 
2162
                (yyval.ival) = (yyvsp[(1) - (3)].ival) >> (yyvsp[(3) - (3)].ival);
 
2163
        ;}
 
2164
    break;
 
2165
 
 
2166
  case 39:
 
2167
 
 
2168
/* Line 1464 of yacc.c  */
 
2169
#line 380 "glcpp/glcpp-parse.y"
 
2170
    {
 
2171
                (yyval.ival) = (yyvsp[(1) - (3)].ival) << (yyvsp[(3) - (3)].ival);
 
2172
        ;}
 
2173
    break;
 
2174
 
 
2175
  case 40:
 
2176
 
 
2177
/* Line 1464 of yacc.c  */
 
2178
#line 383 "glcpp/glcpp-parse.y"
 
2179
    {
 
2180
                (yyval.ival) = (yyvsp[(1) - (3)].ival) - (yyvsp[(3) - (3)].ival);
 
2181
        ;}
 
2182
    break;
 
2183
 
 
2184
  case 41:
 
2185
 
 
2186
/* Line 1464 of yacc.c  */
 
2187
#line 386 "glcpp/glcpp-parse.y"
 
2188
    {
 
2189
                (yyval.ival) = (yyvsp[(1) - (3)].ival) + (yyvsp[(3) - (3)].ival);
 
2190
        ;}
 
2191
    break;
 
2192
 
 
2193
  case 42:
 
2194
 
 
2195
/* Line 1464 of yacc.c  */
 
2196
#line 389 "glcpp/glcpp-parse.y"
 
2197
    {
 
2198
                (yyval.ival) = (yyvsp[(1) - (3)].ival) % (yyvsp[(3) - (3)].ival);
 
2199
        ;}
 
2200
    break;
 
2201
 
 
2202
  case 43:
 
2203
 
 
2204
/* Line 1464 of yacc.c  */
 
2205
#line 392 "glcpp/glcpp-parse.y"
 
2206
    {
 
2207
                (yyval.ival) = (yyvsp[(1) - (3)].ival) / (yyvsp[(3) - (3)].ival);
 
2208
        ;}
 
2209
    break;
 
2210
 
 
2211
  case 44:
 
2212
 
 
2213
/* Line 1464 of yacc.c  */
 
2214
#line 395 "glcpp/glcpp-parse.y"
 
2215
    {
 
2216
                (yyval.ival) = (yyvsp[(1) - (3)].ival) * (yyvsp[(3) - (3)].ival);
 
2217
        ;}
 
2218
    break;
 
2219
 
 
2220
  case 45:
 
2221
 
 
2222
/* Line 1464 of yacc.c  */
 
2223
#line 398 "glcpp/glcpp-parse.y"
 
2224
    {
 
2225
                (yyval.ival) = ! (yyvsp[(2) - (2)].ival);
 
2226
        ;}
 
2227
    break;
 
2228
 
 
2229
  case 46:
 
2230
 
 
2231
/* Line 1464 of yacc.c  */
 
2232
#line 401 "glcpp/glcpp-parse.y"
 
2233
    {
 
2234
                (yyval.ival) = ~ (yyvsp[(2) - (2)].ival);
 
2235
        ;}
 
2236
    break;
 
2237
 
 
2238
  case 47:
 
2239
 
 
2240
/* Line 1464 of yacc.c  */
 
2241
#line 404 "glcpp/glcpp-parse.y"
 
2242
    {
 
2243
                (yyval.ival) = - (yyvsp[(2) - (2)].ival);
 
2244
        ;}
 
2245
    break;
 
2246
 
 
2247
  case 48:
 
2248
 
 
2249
/* Line 1464 of yacc.c  */
 
2250
#line 407 "glcpp/glcpp-parse.y"
 
2251
    {
 
2252
                (yyval.ival) = + (yyvsp[(2) - (2)].ival);
 
2253
        ;}
 
2254
    break;
 
2255
 
 
2256
  case 49:
 
2257
 
 
2258
/* Line 1464 of yacc.c  */
 
2259
#line 410 "glcpp/glcpp-parse.y"
 
2260
    {
 
2261
                (yyval.ival) = (yyvsp[(2) - (3)].ival);
 
2262
        ;}
 
2263
    break;
 
2264
 
 
2265
  case 50:
 
2266
 
 
2267
/* Line 1464 of yacc.c  */
 
2268
#line 416 "glcpp/glcpp-parse.y"
 
2269
    {
 
2270
                (yyval.string_list) = _string_list_create (parser);
 
2271
                _string_list_append_item ((yyval.string_list), (yyvsp[(1) - (1)].str));
 
2272
                talloc_steal ((yyval.string_list), (yyvsp[(1) - (1)].str));
 
2273
        ;}
 
2274
    break;
 
2275
 
 
2276
  case 51:
 
2277
 
 
2278
/* Line 1464 of yacc.c  */
 
2279
#line 421 "glcpp/glcpp-parse.y"
 
2280
    {
 
2281
                (yyval.string_list) = (yyvsp[(1) - (3)].string_list);   
 
2282
                _string_list_append_item ((yyval.string_list), (yyvsp[(3) - (3)].str));
 
2283
                talloc_steal ((yyval.string_list), (yyvsp[(3) - (3)].str));
 
2284
        ;}
 
2285
    break;
 
2286
 
 
2287
  case 52:
 
2288
 
 
2289
/* Line 1464 of yacc.c  */
 
2290
#line 429 "glcpp/glcpp-parse.y"
 
2291
    { (yyval.token_list) = NULL; ;}
 
2292
    break;
 
2293
 
 
2294
  case 54:
 
2295
 
 
2296
/* Line 1464 of yacc.c  */
 
2297
#line 434 "glcpp/glcpp-parse.y"
 
2298
    {
 
2299
                yyerror (& (yylsp[(1) - (2)]), parser, "Invalid tokens after #");
 
2300
        ;}
 
2301
    break;
 
2302
 
 
2303
  case 55:
 
2304
 
 
2305
/* Line 1464 of yacc.c  */
 
2306
#line 440 "glcpp/glcpp-parse.y"
 
2307
    { (yyval.token_list) = NULL; ;}
 
2308
    break;
 
2309
 
 
2310
  case 58:
 
2311
 
 
2312
/* Line 1464 of yacc.c  */
 
2313
#line 446 "glcpp/glcpp-parse.y"
 
2314
    {
 
2315
                glcpp_warning(&(yylsp[(1) - (1)]), parser, "extra tokens at end of directive");
 
2316
        ;}
 
2317
    break;
 
2318
 
 
2319
  case 59:
 
2320
 
 
2321
/* Line 1464 of yacc.c  */
 
2322
#line 453 "glcpp/glcpp-parse.y"
 
2323
    {
 
2324
                int v = hash_table_find (parser->defines, (yyvsp[(2) - (2)].str)) ? 1 : 0;
 
2325
                (yyval.token) = _token_create_ival (parser, INTEGER, v);
 
2326
        ;}
 
2327
    break;
 
2328
 
 
2329
  case 60:
 
2330
 
 
2331
/* Line 1464 of yacc.c  */
 
2332
#line 457 "glcpp/glcpp-parse.y"
 
2333
    {
 
2334
                int v = hash_table_find (parser->defines, (yyvsp[(3) - (4)].str)) ? 1 : 0;
 
2335
                (yyval.token) = _token_create_ival (parser, INTEGER, v);
 
2336
        ;}
 
2337
    break;
 
2338
 
 
2339
  case 62:
 
2340
 
 
2341
/* Line 1464 of yacc.c  */
 
2342
#line 466 "glcpp/glcpp-parse.y"
 
2343
    {
 
2344
                parser->space_tokens = 1;
 
2345
                (yyval.token_list) = _token_list_create (parser);
 
2346
                _token_list_append ((yyval.token_list), (yyvsp[(1) - (1)].token));
 
2347
                talloc_unlink (parser, (yyvsp[(1) - (1)].token));
 
2348
        ;}
 
2349
    break;
 
2350
 
 
2351
  case 63:
 
2352
 
 
2353
/* Line 1464 of yacc.c  */
 
2354
#line 472 "glcpp/glcpp-parse.y"
 
2355
    {
 
2356
                (yyval.token_list) = (yyvsp[(1) - (2)].token_list);
 
2357
                _token_list_append ((yyval.token_list), (yyvsp[(2) - (2)].token));
 
2358
                talloc_unlink (parser, (yyvsp[(2) - (2)].token));
 
2359
        ;}
 
2360
    break;
 
2361
 
 
2362
  case 64:
 
2363
 
 
2364
/* Line 1464 of yacc.c  */
 
2365
#line 480 "glcpp/glcpp-parse.y"
 
2366
    {
 
2367
                parser->space_tokens = 1;
 
2368
                (yyval.token_list) = _token_list_create (parser);
 
2369
                _token_list_append ((yyval.token_list), (yyvsp[(1) - (1)].token));
 
2370
                talloc_unlink (parser, (yyvsp[(1) - (1)].token));
 
2371
        ;}
 
2372
    break;
 
2373
 
 
2374
  case 65:
 
2375
 
 
2376
/* Line 1464 of yacc.c  */
 
2377
#line 486 "glcpp/glcpp-parse.y"
 
2378
    {
 
2379
                (yyval.token_list) = (yyvsp[(1) - (2)].token_list);
 
2380
                _token_list_append ((yyval.token_list), (yyvsp[(2) - (2)].token));
 
2381
                talloc_unlink (parser, (yyvsp[(2) - (2)].token));
 
2382
        ;}
 
2383
    break;
 
2384
 
 
2385
  case 66:
 
2386
 
 
2387
/* Line 1464 of yacc.c  */
 
2388
#line 494 "glcpp/glcpp-parse.y"
 
2389
    {
 
2390
                (yyval.token) = _token_create_str (parser, IDENTIFIER, (yyvsp[(1) - (1)].str));
 
2391
                (yyval.token)->location = yylloc;
 
2392
        ;}
 
2393
    break;
 
2394
 
 
2395
  case 67:
 
2396
 
 
2397
/* Line 1464 of yacc.c  */
 
2398
#line 498 "glcpp/glcpp-parse.y"
 
2399
    {
 
2400
                (yyval.token) = _token_create_str (parser, INTEGER_STRING, (yyvsp[(1) - (1)].str));
 
2401
                (yyval.token)->location = yylloc;
 
2402
        ;}
 
2403
    break;
 
2404
 
 
2405
  case 68:
 
2406
 
 
2407
/* Line 1464 of yacc.c  */
 
2408
#line 502 "glcpp/glcpp-parse.y"
 
2409
    {
 
2410
                (yyval.token) = _token_create_ival (parser, (yyvsp[(1) - (1)].ival), (yyvsp[(1) - (1)].ival));
 
2411
                (yyval.token)->location = yylloc;
 
2412
        ;}
 
2413
    break;
 
2414
 
 
2415
  case 69:
 
2416
 
 
2417
/* Line 1464 of yacc.c  */
 
2418
#line 506 "glcpp/glcpp-parse.y"
 
2419
    {
 
2420
                (yyval.token) = _token_create_str (parser, OTHER, (yyvsp[(1) - (1)].str));
 
2421
                (yyval.token)->location = yylloc;
 
2422
        ;}
 
2423
    break;
 
2424
 
 
2425
  case 70:
 
2426
 
 
2427
/* Line 1464 of yacc.c  */
 
2428
#line 510 "glcpp/glcpp-parse.y"
 
2429
    {
 
2430
                (yyval.token) = _token_create_ival (parser, SPACE, SPACE);
 
2431
                (yyval.token)->location = yylloc;
 
2432
        ;}
 
2433
    break;
 
2434
 
 
2435
  case 71:
 
2436
 
 
2437
/* Line 1464 of yacc.c  */
 
2438
#line 517 "glcpp/glcpp-parse.y"
 
2439
    { (yyval.ival) = '['; ;}
 
2440
    break;
 
2441
 
 
2442
  case 72:
 
2443
 
 
2444
/* Line 1464 of yacc.c  */
 
2445
#line 518 "glcpp/glcpp-parse.y"
 
2446
    { (yyval.ival) = ']'; ;}
 
2447
    break;
 
2448
 
 
2449
  case 73:
 
2450
 
 
2451
/* Line 1464 of yacc.c  */
 
2452
#line 519 "glcpp/glcpp-parse.y"
 
2453
    { (yyval.ival) = '('; ;}
 
2454
    break;
 
2455
 
 
2456
  case 74:
 
2457
 
 
2458
/* Line 1464 of yacc.c  */
 
2459
#line 520 "glcpp/glcpp-parse.y"
 
2460
    { (yyval.ival) = ')'; ;}
 
2461
    break;
 
2462
 
 
2463
  case 75:
 
2464
 
 
2465
/* Line 1464 of yacc.c  */
 
2466
#line 521 "glcpp/glcpp-parse.y"
 
2467
    { (yyval.ival) = '{'; ;}
 
2468
    break;
 
2469
 
 
2470
  case 76:
 
2471
 
 
2472
/* Line 1464 of yacc.c  */
 
2473
#line 522 "glcpp/glcpp-parse.y"
 
2474
    { (yyval.ival) = '}'; ;}
 
2475
    break;
 
2476
 
 
2477
  case 77:
 
2478
 
 
2479
/* Line 1464 of yacc.c  */
 
2480
#line 523 "glcpp/glcpp-parse.y"
 
2481
    { (yyval.ival) = '.'; ;}
 
2482
    break;
 
2483
 
 
2484
  case 78:
 
2485
 
 
2486
/* Line 1464 of yacc.c  */
 
2487
#line 524 "glcpp/glcpp-parse.y"
 
2488
    { (yyval.ival) = '&'; ;}
 
2489
    break;
 
2490
 
 
2491
  case 79:
 
2492
 
 
2493
/* Line 1464 of yacc.c  */
 
2494
#line 525 "glcpp/glcpp-parse.y"
 
2495
    { (yyval.ival) = '*'; ;}
 
2496
    break;
 
2497
 
 
2498
  case 80:
 
2499
 
 
2500
/* Line 1464 of yacc.c  */
 
2501
#line 526 "glcpp/glcpp-parse.y"
 
2502
    { (yyval.ival) = '+'; ;}
 
2503
    break;
 
2504
 
 
2505
  case 81:
 
2506
 
 
2507
/* Line 1464 of yacc.c  */
 
2508
#line 527 "glcpp/glcpp-parse.y"
 
2509
    { (yyval.ival) = '-'; ;}
 
2510
    break;
 
2511
 
 
2512
  case 82:
 
2513
 
 
2514
/* Line 1464 of yacc.c  */
 
2515
#line 528 "glcpp/glcpp-parse.y"
 
2516
    { (yyval.ival) = '~'; ;}
 
2517
    break;
 
2518
 
 
2519
  case 83:
 
2520
 
 
2521
/* Line 1464 of yacc.c  */
 
2522
#line 529 "glcpp/glcpp-parse.y"
 
2523
    { (yyval.ival) = '!'; ;}
 
2524
    break;
 
2525
 
 
2526
  case 84:
 
2527
 
 
2528
/* Line 1464 of yacc.c  */
 
2529
#line 530 "glcpp/glcpp-parse.y"
 
2530
    { (yyval.ival) = '/'; ;}
 
2531
    break;
 
2532
 
 
2533
  case 85:
 
2534
 
 
2535
/* Line 1464 of yacc.c  */
 
2536
#line 531 "glcpp/glcpp-parse.y"
 
2537
    { (yyval.ival) = '%'; ;}
 
2538
    break;
 
2539
 
 
2540
  case 86:
 
2541
 
 
2542
/* Line 1464 of yacc.c  */
 
2543
#line 532 "glcpp/glcpp-parse.y"
 
2544
    { (yyval.ival) = LEFT_SHIFT; ;}
 
2545
    break;
 
2546
 
 
2547
  case 87:
 
2548
 
 
2549
/* Line 1464 of yacc.c  */
 
2550
#line 533 "glcpp/glcpp-parse.y"
 
2551
    { (yyval.ival) = RIGHT_SHIFT; ;}
 
2552
    break;
 
2553
 
 
2554
  case 88:
 
2555
 
 
2556
/* Line 1464 of yacc.c  */
 
2557
#line 534 "glcpp/glcpp-parse.y"
 
2558
    { (yyval.ival) = '<'; ;}
 
2559
    break;
 
2560
 
 
2561
  case 89:
 
2562
 
 
2563
/* Line 1464 of yacc.c  */
 
2564
#line 535 "glcpp/glcpp-parse.y"
 
2565
    { (yyval.ival) = '>'; ;}
 
2566
    break;
 
2567
 
 
2568
  case 90:
 
2569
 
 
2570
/* Line 1464 of yacc.c  */
 
2571
#line 536 "glcpp/glcpp-parse.y"
 
2572
    { (yyval.ival) = LESS_OR_EQUAL; ;}
 
2573
    break;
 
2574
 
 
2575
  case 91:
 
2576
 
 
2577
/* Line 1464 of yacc.c  */
 
2578
#line 537 "glcpp/glcpp-parse.y"
 
2579
    { (yyval.ival) = GREATER_OR_EQUAL; ;}
 
2580
    break;
 
2581
 
 
2582
  case 92:
 
2583
 
 
2584
/* Line 1464 of yacc.c  */
 
2585
#line 538 "glcpp/glcpp-parse.y"
 
2586
    { (yyval.ival) = EQUAL; ;}
 
2587
    break;
 
2588
 
 
2589
  case 93:
 
2590
 
 
2591
/* Line 1464 of yacc.c  */
 
2592
#line 539 "glcpp/glcpp-parse.y"
 
2593
    { (yyval.ival) = NOT_EQUAL; ;}
 
2594
    break;
 
2595
 
 
2596
  case 94:
 
2597
 
 
2598
/* Line 1464 of yacc.c  */
 
2599
#line 540 "glcpp/glcpp-parse.y"
 
2600
    { (yyval.ival) = '^'; ;}
 
2601
    break;
 
2602
 
 
2603
  case 95:
 
2604
 
 
2605
/* Line 1464 of yacc.c  */
 
2606
#line 541 "glcpp/glcpp-parse.y"
 
2607
    { (yyval.ival) = '|'; ;}
 
2608
    break;
 
2609
 
 
2610
  case 96:
 
2611
 
 
2612
/* Line 1464 of yacc.c  */
 
2613
#line 542 "glcpp/glcpp-parse.y"
 
2614
    { (yyval.ival) = AND; ;}
 
2615
    break;
 
2616
 
 
2617
  case 97:
 
2618
 
 
2619
/* Line 1464 of yacc.c  */
 
2620
#line 543 "glcpp/glcpp-parse.y"
 
2621
    { (yyval.ival) = OR; ;}
 
2622
    break;
 
2623
 
 
2624
  case 98:
 
2625
 
 
2626
/* Line 1464 of yacc.c  */
 
2627
#line 544 "glcpp/glcpp-parse.y"
 
2628
    { (yyval.ival) = ';'; ;}
 
2629
    break;
 
2630
 
 
2631
  case 99:
 
2632
 
 
2633
/* Line 1464 of yacc.c  */
 
2634
#line 545 "glcpp/glcpp-parse.y"
 
2635
    { (yyval.ival) = ','; ;}
 
2636
    break;
 
2637
 
 
2638
  case 100:
 
2639
 
 
2640
/* Line 1464 of yacc.c  */
 
2641
#line 546 "glcpp/glcpp-parse.y"
 
2642
    { (yyval.ival) = '='; ;}
 
2643
    break;
 
2644
 
 
2645
  case 101:
 
2646
 
 
2647
/* Line 1464 of yacc.c  */
 
2648
#line 547 "glcpp/glcpp-parse.y"
 
2649
    { (yyval.ival) = PASTE; ;}
 
2650
    break;
 
2651
 
 
2652
 
 
2653
 
 
2654
/* Line 1464 of yacc.c  */
 
2655
#line 2656 "glcpp/glcpp-parse.c"
 
2656
      default: break;
 
2657
    }
 
2658
  YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
 
2659
 
 
2660
  YYPOPSTACK (yylen);
 
2661
  yylen = 0;
 
2662
  YY_STACK_PRINT (yyss, yyssp);
 
2663
 
 
2664
  *++yyvsp = yyval;
 
2665
  *++yylsp = yyloc;
 
2666
 
 
2667
  /* Now `shift' the result of the reduction.  Determine what state
 
2668
     that goes to, based on the state we popped back to and the rule
 
2669
     number reduced by.  */
 
2670
 
 
2671
  yyn = yyr1[yyn];
 
2672
 
 
2673
  yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
 
2674
  if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
 
2675
    yystate = yytable[yystate];
 
2676
  else
 
2677
    yystate = yydefgoto[yyn - YYNTOKENS];
 
2678
 
 
2679
  goto yynewstate;
 
2680
 
 
2681
 
 
2682
/*------------------------------------.
 
2683
| yyerrlab -- here on detecting error |
 
2684
`------------------------------------*/
 
2685
yyerrlab:
 
2686
  /* If not already recovering from an error, report this error.  */
 
2687
  if (!yyerrstatus)
 
2688
    {
 
2689
      ++yynerrs;
 
2690
#if ! YYERROR_VERBOSE
 
2691
      yyerror (&yylloc, parser, YY_("syntax error"));
 
2692
#else
 
2693
      {
 
2694
        YYSIZE_T yysize = yysyntax_error (0, yystate, yychar);
 
2695
        if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM)
 
2696
          {
 
2697
            YYSIZE_T yyalloc = 2 * yysize;
 
2698
            if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM))
 
2699
              yyalloc = YYSTACK_ALLOC_MAXIMUM;
 
2700
            if (yymsg != yymsgbuf)
 
2701
              YYSTACK_FREE (yymsg);
 
2702
            yymsg = (char *) YYSTACK_ALLOC (yyalloc);
 
2703
            if (yymsg)
 
2704
              yymsg_alloc = yyalloc;
 
2705
            else
 
2706
              {
 
2707
                yymsg = yymsgbuf;
 
2708
                yymsg_alloc = sizeof yymsgbuf;
 
2709
              }
 
2710
          }
 
2711
 
 
2712
        if (0 < yysize && yysize <= yymsg_alloc)
 
2713
          {
 
2714
            (void) yysyntax_error (yymsg, yystate, yychar);
 
2715
            yyerror (&yylloc, parser, yymsg);
 
2716
          }
 
2717
        else
 
2718
          {
 
2719
            yyerror (&yylloc, parser, YY_("syntax error"));
 
2720
            if (yysize != 0)
 
2721
              goto yyexhaustedlab;
 
2722
          }
 
2723
      }
 
2724
#endif
 
2725
    }
 
2726
 
 
2727
  yyerror_range[1] = yylloc;
 
2728
 
 
2729
  if (yyerrstatus == 3)
 
2730
    {
 
2731
      /* If just tried and failed to reuse lookahead token after an
 
2732
         error, discard it.  */
 
2733
 
 
2734
      if (yychar <= YYEOF)
 
2735
        {
 
2736
          /* Return failure if at end of input.  */
 
2737
          if (yychar == YYEOF)
 
2738
            YYABORT;
 
2739
        }
 
2740
      else
 
2741
        {
 
2742
          yydestruct ("Error: discarding",
 
2743
                      yytoken, &yylval, &yylloc, parser);
 
2744
          yychar = YYEMPTY;
 
2745
        }
 
2746
    }
 
2747
 
 
2748
  /* Else will try to reuse lookahead token after shifting the error
 
2749
     token.  */
 
2750
  goto yyerrlab1;
 
2751
 
 
2752
 
 
2753
/*---------------------------------------------------.
 
2754
| yyerrorlab -- error raised explicitly by YYERROR.  |
 
2755
`---------------------------------------------------*/
 
2756
yyerrorlab:
 
2757
 
 
2758
  /* Pacify compilers like GCC when the user code never invokes
 
2759
     YYERROR and the label yyerrorlab therefore never appears in user
 
2760
     code.  */
 
2761
  if (/*CONSTCOND*/ 0)
 
2762
     goto yyerrorlab;
 
2763
 
 
2764
  yyerror_range[1] = yylsp[1-yylen];
 
2765
  /* Do not reclaim the symbols of the rule which action triggered
 
2766
     this YYERROR.  */
 
2767
  YYPOPSTACK (yylen);
 
2768
  yylen = 0;
 
2769
  YY_STACK_PRINT (yyss, yyssp);
 
2770
  yystate = *yyssp;
 
2771
  goto yyerrlab1;
 
2772
 
 
2773
 
 
2774
/*-------------------------------------------------------------.
 
2775
| yyerrlab1 -- common code for both syntax error and YYERROR.  |
 
2776
`-------------------------------------------------------------*/
 
2777
yyerrlab1:
 
2778
  yyerrstatus = 3;      /* Each real token shifted decrements this.  */
 
2779
 
 
2780
  for (;;)
 
2781
    {
 
2782
      yyn = yypact[yystate];
 
2783
      if (yyn != YYPACT_NINF)
 
2784
        {
 
2785
          yyn += YYTERROR;
 
2786
          if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
 
2787
            {
 
2788
              yyn = yytable[yyn];
 
2789
              if (0 < yyn)
 
2790
                break;
 
2791
            }
 
2792
        }
 
2793
 
 
2794
      /* Pop the current state because it cannot handle the error token.  */
 
2795
      if (yyssp == yyss)
 
2796
        YYABORT;
 
2797
 
 
2798
      yyerror_range[1] = *yylsp;
 
2799
      yydestruct ("Error: popping",
 
2800
                  yystos[yystate], yyvsp, yylsp, parser);
 
2801
      YYPOPSTACK (1);
 
2802
      yystate = *yyssp;
 
2803
      YY_STACK_PRINT (yyss, yyssp);
 
2804
    }
 
2805
 
 
2806
  *++yyvsp = yylval;
 
2807
 
 
2808
  yyerror_range[2] = yylloc;
 
2809
  /* Using YYLLOC is tempting, but would change the location of
 
2810
     the lookahead.  YYLOC is available though.  */
 
2811
  YYLLOC_DEFAULT (yyloc, yyerror_range, 2);
 
2812
  *++yylsp = yyloc;
 
2813
 
 
2814
  /* Shift the error token.  */
 
2815
  YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
 
2816
 
 
2817
  yystate = yyn;
 
2818
  goto yynewstate;
 
2819
 
 
2820
 
 
2821
/*-------------------------------------.
 
2822
| yyacceptlab -- YYACCEPT comes here.  |
 
2823
`-------------------------------------*/
 
2824
yyacceptlab:
 
2825
  yyresult = 0;
 
2826
  goto yyreturn;
 
2827
 
 
2828
/*-----------------------------------.
 
2829
| yyabortlab -- YYABORT comes here.  |
 
2830
`-----------------------------------*/
 
2831
yyabortlab:
 
2832
  yyresult = 1;
 
2833
  goto yyreturn;
 
2834
 
 
2835
#if !defined(yyoverflow) || YYERROR_VERBOSE
 
2836
/*-------------------------------------------------.
 
2837
| yyexhaustedlab -- memory exhaustion comes here.  |
 
2838
`-------------------------------------------------*/
 
2839
yyexhaustedlab:
 
2840
  yyerror (&yylloc, parser, YY_("memory exhausted"));
 
2841
  yyresult = 2;
 
2842
  /* Fall through.  */
 
2843
#endif
 
2844
 
 
2845
yyreturn:
 
2846
  if (yychar != YYEMPTY)
 
2847
     yydestruct ("Cleanup: discarding lookahead",
 
2848
                 yytoken, &yylval, &yylloc, parser);
 
2849
  /* Do not reclaim the symbols of the rule which action triggered
 
2850
     this YYABORT or YYACCEPT.  */
 
2851
  YYPOPSTACK (yylen);
 
2852
  YY_STACK_PRINT (yyss, yyssp);
 
2853
  while (yyssp != yyss)
 
2854
    {
 
2855
      yydestruct ("Cleanup: popping",
 
2856
                  yystos[*yyssp], yyvsp, yylsp, parser);
 
2857
      YYPOPSTACK (1);
 
2858
    }
 
2859
#ifndef yyoverflow
 
2860
  if (yyss != yyssa)
 
2861
    YYSTACK_FREE (yyss);
 
2862
#endif
 
2863
#if YYERROR_VERBOSE
 
2864
  if (yymsg != yymsgbuf)
 
2865
    YYSTACK_FREE (yymsg);
 
2866
#endif
 
2867
  /* Make sure YYID is used.  */
 
2868
  return YYID (yyresult);
 
2869
}
 
2870
 
 
2871
 
 
2872
 
 
2873
/* Line 1684 of yacc.c  */
 
2874
#line 550 "glcpp/glcpp-parse.y"
 
2875
 
 
2876
 
 
2877
string_list_t *
 
2878
_string_list_create (void *ctx)
 
2879
{
 
2880
        string_list_t *list;
 
2881
 
 
2882
        list = talloc (ctx, string_list_t);
 
2883
        list->head = NULL;
 
2884
        list->tail = NULL;
 
2885
 
 
2886
        return list;
 
2887
}
 
2888
 
 
2889
void
 
2890
_string_list_append_item (string_list_t *list, const char *str)
 
2891
{
 
2892
        string_node_t *node;
 
2893
 
 
2894
        node = talloc (list, string_node_t);
 
2895
        node->str = talloc_strdup (node, str);
 
2896
 
 
2897
        node->next = NULL;
 
2898
 
 
2899
        if (list->head == NULL) {
 
2900
                list->head = node;
 
2901
        } else {
 
2902
                list->tail->next = node;
 
2903
        }
 
2904
 
 
2905
        list->tail = node;
 
2906
}
 
2907
 
 
2908
int
 
2909
_string_list_contains (string_list_t *list, const char *member, int *index)
 
2910
{
 
2911
        string_node_t *node;
 
2912
        int i;
 
2913
 
 
2914
        if (list == NULL)
 
2915
                return 0;
 
2916
 
 
2917
        for (i = 0, node = list->head; node; i++, node = node->next) {
 
2918
                if (strcmp (node->str, member) == 0) {
 
2919
                        if (index)
 
2920
                                *index = i;
 
2921
                        return 1;
 
2922
                }
 
2923
        }
 
2924
 
 
2925
        return 0;
 
2926
}
 
2927
 
 
2928
int
 
2929
_string_list_length (string_list_t *list)
 
2930
{
 
2931
        int length = 0;
 
2932
        string_node_t *node;
 
2933
 
 
2934
        if (list == NULL)
 
2935
                return 0;
 
2936
 
 
2937
        for (node = list->head; node; node = node->next)
 
2938
                length++;
 
2939
 
 
2940
        return length;
 
2941
}
 
2942
 
 
2943
int
 
2944
_string_list_equal (string_list_t *a, string_list_t *b)
 
2945
{
 
2946
        string_node_t *node_a, *node_b;
 
2947
 
 
2948
        if (a == NULL && b == NULL)
 
2949
                return 1;
 
2950
 
 
2951
        if (a == NULL || b == NULL)
 
2952
                return 0;
 
2953
 
 
2954
        for (node_a = a->head, node_b = b->head;
 
2955
             node_a && node_b;
 
2956
             node_a = node_a->next, node_b = node_b->next)
 
2957
        {
 
2958
                if (strcmp (node_a->str, node_b->str))
 
2959
                        return 0;
 
2960
        }
 
2961
 
 
2962
        /* Catch the case of lists being different lengths, (which
 
2963
         * would cause the loop above to terminate after the shorter
 
2964
         * list). */
 
2965
        return node_a == node_b;
 
2966
}
 
2967
 
 
2968
argument_list_t *
 
2969
_argument_list_create (void *ctx)
 
2970
{
 
2971
        argument_list_t *list;
 
2972
 
 
2973
        list = talloc (ctx, argument_list_t);
 
2974
        list->head = NULL;
 
2975
        list->tail = NULL;
 
2976
 
 
2977
        return list;
 
2978
}
 
2979
 
 
2980
void
 
2981
_argument_list_append (argument_list_t *list, token_list_t *argument)
 
2982
{
 
2983
        argument_node_t *node;
 
2984
 
 
2985
        node = talloc (list, argument_node_t);
 
2986
        node->argument = argument;
 
2987
 
 
2988
        node->next = NULL;
 
2989
 
 
2990
        if (list->head == NULL) {
 
2991
                list->head = node;
 
2992
        } else {
 
2993
                list->tail->next = node;
 
2994
        }
 
2995
 
 
2996
        list->tail = node;
 
2997
}
 
2998
 
 
2999
int
 
3000
_argument_list_length (argument_list_t *list)
 
3001
{
 
3002
        int length = 0;
 
3003
        argument_node_t *node;
 
3004
 
 
3005
        if (list == NULL)
 
3006
                return 0;
 
3007
 
 
3008
        for (node = list->head; node; node = node->next)
 
3009
                length++;
 
3010
 
 
3011
        return length;
 
3012
}
 
3013
 
 
3014
token_list_t *
 
3015
_argument_list_member_at (argument_list_t *list, int index)
 
3016
{
 
3017
        argument_node_t *node;
 
3018
        int i;
 
3019
 
 
3020
        if (list == NULL)
 
3021
                return NULL;
 
3022
 
 
3023
        node = list->head;
 
3024
        for (i = 0; i < index; i++) {
 
3025
                node = node->next;
 
3026
                if (node == NULL)
 
3027
                        break;
 
3028
        }
 
3029
 
 
3030
        if (node)
 
3031
                return node->argument;
 
3032
 
 
3033
        return NULL;
 
3034
}
 
3035
 
 
3036
/* Note: This function talloc_steal()s the str pointer. */
 
3037
token_t *
 
3038
_token_create_str (void *ctx, int type, char *str)
 
3039
{
 
3040
        token_t *token;
 
3041
 
 
3042
        token = talloc (ctx, token_t);
 
3043
        token->type = type;
 
3044
        token->value.str = talloc_steal (token, str);
 
3045
 
 
3046
        return token;
 
3047
}
 
3048
 
 
3049
token_t *
 
3050
_token_create_ival (void *ctx, int type, int ival)
 
3051
{
 
3052
        token_t *token;
 
3053
 
 
3054
        token = talloc (ctx, token_t);
 
3055
        token->type = type;
 
3056
        token->value.ival = ival;
 
3057
 
 
3058
        return token;
 
3059
}
 
3060
 
 
3061
token_list_t *
 
3062
_token_list_create (void *ctx)
 
3063
{
 
3064
        token_list_t *list;
 
3065
 
 
3066
        list = talloc (ctx, token_list_t);
 
3067
        list->head = NULL;
 
3068
        list->tail = NULL;
 
3069
        list->non_space_tail = NULL;
 
3070
 
 
3071
        return list;
 
3072
}
 
3073
 
 
3074
void
 
3075
_token_list_append (token_list_t *list, token_t *token)
 
3076
{
 
3077
        token_node_t *node;
 
3078
 
 
3079
        node = talloc (list, token_node_t);
 
3080
        node->token = talloc_reference (list, token);
 
3081
 
 
3082
        node->next = NULL;
 
3083
 
 
3084
        if (list->head == NULL) {
 
3085
                list->head = node;
 
3086
        } else {
 
3087
                list->tail->next = node;
 
3088
        }
 
3089
 
 
3090
        list->tail = node;
 
3091
        if (token->type != SPACE)
 
3092
                list->non_space_tail = node;
 
3093
}
 
3094
 
 
3095
void
 
3096
_token_list_append_list (token_list_t *list, token_list_t *tail)
 
3097
{
 
3098
        if (tail == NULL || tail->head == NULL)
 
3099
                return;
 
3100
 
 
3101
        if (list->head == NULL) {
 
3102
                list->head = tail->head;
 
3103
        } else {
 
3104
                list->tail->next = tail->head;
 
3105
        }
 
3106
 
 
3107
        list->tail = tail->tail;
 
3108
        list->non_space_tail = tail->non_space_tail;
 
3109
}
 
3110
 
 
3111
static token_list_t *
 
3112
_token_list_copy (void *ctx, token_list_t *other)
 
3113
{
 
3114
        token_list_t *copy;
 
3115
        token_node_t *node;
 
3116
 
 
3117
        if (other == NULL)
 
3118
                return NULL;
 
3119
 
 
3120
        copy = _token_list_create (ctx);
 
3121
        for (node = other->head; node; node = node->next)
 
3122
                _token_list_append (copy, node->token);
 
3123
 
 
3124
        return copy;
 
3125
}
 
3126
 
 
3127
static void
 
3128
_token_list_trim_trailing_space (token_list_t *list)
 
3129
{
 
3130
        token_node_t *tail, *next;
 
3131
 
 
3132
        if (list->non_space_tail) {
 
3133
                tail = list->non_space_tail->next;
 
3134
                list->non_space_tail->next = NULL;
 
3135
                list->tail = list->non_space_tail;
 
3136
 
 
3137
                while (tail) {
 
3138
                        next = tail->next;
 
3139
                        talloc_free (tail);
 
3140
                        tail = next;
 
3141
                }
 
3142
        }
 
3143
}
 
3144
 
 
3145
int
 
3146
_token_list_equal_ignoring_space (token_list_t *a, token_list_t *b)
 
3147
{
 
3148
        token_node_t *node_a, *node_b;
 
3149
 
 
3150
        node_a = a->head;
 
3151
        node_b = b->head;
 
3152
 
 
3153
        while (1)
 
3154
        {
 
3155
                if (node_a == NULL && node_b == NULL)
 
3156
                        break;
 
3157
 
 
3158
                if (node_a == NULL || node_b == NULL)
 
3159
                        return 0;
 
3160
 
 
3161
                if (node_a->token->type == SPACE) {
 
3162
                        node_a = node_a->next;
 
3163
                        continue;
 
3164
                }
 
3165
 
 
3166
                if (node_b->token->type == SPACE) {
 
3167
                        node_b = node_b->next;
 
3168
                        continue;
 
3169
                }
 
3170
 
 
3171
                if (node_a->token->type != node_b->token->type)
 
3172
                        return 0;
 
3173
 
 
3174
                switch (node_a->token->type) {
 
3175
                case INTEGER:
 
3176
                        if (node_a->token->value.ival != 
 
3177
                            node_b->token->value.ival)
 
3178
                        {
 
3179
                                return 0;
 
3180
                        }
 
3181
                        break;
 
3182
                case IDENTIFIER:
 
3183
                case INTEGER_STRING:
 
3184
                case OTHER:
 
3185
                        if (strcmp (node_a->token->value.str,
 
3186
                                    node_b->token->value.str))
 
3187
                        {
 
3188
                                return 0;
 
3189
                        }
 
3190
                        break;
 
3191
                }
 
3192
 
 
3193
                node_a = node_a->next;
 
3194
                node_b = node_b->next;
 
3195
        }
 
3196
 
 
3197
        return 1;
 
3198
}
 
3199
 
 
3200
static void
 
3201
_token_print (char **out, token_t *token)
 
3202
{
 
3203
        if (token->type < 256) {
 
3204
                glcpp_printf (*out, "%c", token->type);
 
3205
                return;
 
3206
        }
 
3207
 
 
3208
        switch (token->type) {
 
3209
        case INTEGER:
 
3210
                glcpp_printf (*out, "%" PRIiMAX, token->value.ival);
 
3211
                break;
 
3212
        case IDENTIFIER:
 
3213
        case INTEGER_STRING:
 
3214
        case OTHER:
 
3215
                glcpp_print (*out, token->value.str);
 
3216
                break;
 
3217
        case SPACE:
 
3218
                glcpp_print (*out, " ");
 
3219
                break;
 
3220
        case LEFT_SHIFT:
 
3221
                glcpp_print (*out, "<<");
 
3222
                break;
 
3223
        case RIGHT_SHIFT:
 
3224
                glcpp_print (*out, ">>");
 
3225
                break;
 
3226
        case LESS_OR_EQUAL:
 
3227
                glcpp_print (*out, "<=");
 
3228
                break;
 
3229
        case GREATER_OR_EQUAL:
 
3230
                glcpp_print (*out, ">=");
 
3231
                break;
 
3232
        case EQUAL:
 
3233
                glcpp_print (*out, "==");
 
3234
                break;
 
3235
        case NOT_EQUAL:
 
3236
                glcpp_print (*out, "!=");
 
3237
                break;
 
3238
        case AND:
 
3239
                glcpp_print (*out, "&&");
 
3240
                break;
 
3241
        case OR:
 
3242
                glcpp_print (*out, "||");
 
3243
                break;
 
3244
        case PASTE:
 
3245
                glcpp_print (*out, "##");
 
3246
                break;
 
3247
        case COMMA_FINAL:
 
3248
                glcpp_print (*out, ",");
 
3249
                break;
 
3250
        case PLACEHOLDER:
 
3251
                /* Nothing to print. */
 
3252
                break;
 
3253
        default:
 
3254
                assert(!"Error: Don't know how to print token.");
 
3255
                break;
 
3256
        }
 
3257
}
 
3258
 
 
3259
/* Return a new token (talloc()ed off of 'token') formed by pasting
 
3260
 * 'token' and 'other'. Note that this function may return 'token' or
 
3261
 * 'other' directly rather than allocating anything new.
 
3262
 *
 
3263
 * Caution: Only very cursory error-checking is performed to see if
 
3264
 * the final result is a valid single token. */
 
3265
static token_t *
 
3266
_token_paste (glcpp_parser_t *parser, token_t *token, token_t *other)
 
3267
{
 
3268
        token_t *combined = NULL;
 
3269
 
 
3270
        /* Pasting a placeholder onto anything makes no change. */
 
3271
        if (other->type == PLACEHOLDER)
 
3272
                return token;
 
3273
 
 
3274
        /* When 'token' is a placeholder, just return 'other'. */
 
3275
        if (token->type == PLACEHOLDER)
 
3276
                return other;
 
3277
 
 
3278
        /* A very few single-character punctuators can be combined
 
3279
         * with another to form a multi-character punctuator. */
 
3280
        switch (token->type) {
 
3281
        case '<':
 
3282
                if (other->type == '<')
 
3283
                        combined = _token_create_ival (token, LEFT_SHIFT, LEFT_SHIFT);
 
3284
                else if (other->type == '=')
 
3285
                        combined = _token_create_ival (token, LESS_OR_EQUAL, LESS_OR_EQUAL);
 
3286
                break;
 
3287
        case '>':
 
3288
                if (other->type == '>')
 
3289
                        combined = _token_create_ival (token, RIGHT_SHIFT, RIGHT_SHIFT);
 
3290
                else if (other->type == '=')
 
3291
                        combined = _token_create_ival (token, GREATER_OR_EQUAL, GREATER_OR_EQUAL);
 
3292
                break;
 
3293
        case '=':
 
3294
                if (other->type == '=')
 
3295
                        combined = _token_create_ival (token, EQUAL, EQUAL);
 
3296
                break;
 
3297
        case '!':
 
3298
                if (other->type == '=')
 
3299
                        combined = _token_create_ival (token, NOT_EQUAL, NOT_EQUAL);
 
3300
                break;
 
3301
        case '&':
 
3302
                if (other->type == '&')
 
3303
                        combined = _token_create_ival (token, AND, AND);
 
3304
                break;
 
3305
        case '|':
 
3306
                if (other->type == '|')
 
3307
                        combined = _token_create_ival (token, OR, OR);
 
3308
                break;
 
3309
        }
 
3310
 
 
3311
        if (combined != NULL) {
 
3312
                /* Inherit the location from the first token */
 
3313
                combined->location = token->location;
 
3314
                return combined;
 
3315
        }
 
3316
 
 
3317
        /* Two string-valued tokens can usually just be mashed
 
3318
         * together.
 
3319
         *
 
3320
         * XXX: This isn't actually legitimate. Several things here
 
3321
         * should result in a diagnostic since the result cannot be a
 
3322
         * valid, single pre-processing token. For example, pasting
 
3323
         * "123" and "abc" is not legal, but we don't catch that
 
3324
         * here. */
 
3325
        if ((token->type == IDENTIFIER || token->type == OTHER || token->type == INTEGER_STRING) &&
 
3326
            (other->type == IDENTIFIER || other->type == OTHER || other->type == INTEGER_STRING))
 
3327
        {
 
3328
                char *str;
 
3329
 
 
3330
                str = talloc_asprintf (token, "%s%s", token->value.str,
 
3331
                                       other->value.str);
 
3332
                combined = _token_create_str (token, token->type, str);
 
3333
                combined->location = token->location;
 
3334
                return combined;
 
3335
        }
 
3336
 
 
3337
        glcpp_error (&token->location, parser, "");
 
3338
        glcpp_print (parser->info_log, "Pasting \"");
 
3339
        _token_print (&parser->info_log, token);
 
3340
        glcpp_print (parser->info_log, "\" and \"");
 
3341
        _token_print (&parser->info_log, other);
 
3342
        glcpp_print (parser->info_log, "\" does not give a valid preprocessing token.\n");
 
3343
 
 
3344
        return token;
 
3345
}
 
3346
 
 
3347
static void
 
3348
_token_list_print (glcpp_parser_t *parser, token_list_t *list)
 
3349
{
 
3350
        token_node_t *node;
 
3351
 
 
3352
        if (list == NULL)
 
3353
                return;
 
3354
 
 
3355
        for (node = list->head; node; node = node->next)
 
3356
                _token_print (&parser->output, node->token);
 
3357
}
 
3358
 
 
3359
void
 
3360
yyerror (YYLTYPE *locp, glcpp_parser_t *parser, const char *error)
 
3361
{
 
3362
        glcpp_error(locp, parser, "%s", error);
 
3363
}
 
3364
 
 
3365
static void add_builtin_define(glcpp_parser_t *parser,
 
3366
                               const char *name, int value)
 
3367
{
 
3368
   token_t *tok;
 
3369
   token_list_t *list;
 
3370
 
 
3371
   tok = _token_create_ival (parser, INTEGER, value);
 
3372
 
 
3373
   list = _token_list_create(parser);
 
3374
   _token_list_append(list, tok);
 
3375
   _define_object_macro(parser, NULL, name, list);
 
3376
 
 
3377
   talloc_unlink(parser, tok);
 
3378
}
 
3379
 
 
3380
glcpp_parser_t *
 
3381
glcpp_parser_create (const struct gl_extensions *extensions, int api)
 
3382
{
 
3383
        glcpp_parser_t *parser;
 
3384
        int language_version;
 
3385
 
 
3386
        parser = talloc (NULL, glcpp_parser_t);
 
3387
 
 
3388
        glcpp_lex_init_extra (parser, &parser->scanner);
 
3389
        parser->defines = hash_table_ctor (32, hash_table_string_hash,
 
3390
                                           hash_table_string_compare);
 
3391
        parser->active = NULL;
 
3392
        parser->lexing_if = 0;
 
3393
        parser->space_tokens = 1;
 
3394
        parser->newline_as_space = 0;
 
3395
        parser->in_control_line = 0;
 
3396
        parser->paren_count = 0;
 
3397
 
 
3398
        parser->skip_stack = NULL;
 
3399
 
 
3400
        parser->lex_from_list = NULL;
 
3401
        parser->lex_from_node = NULL;
 
3402
 
 
3403
        parser->output = talloc_strdup(parser, "");
 
3404
        parser->info_log = talloc_strdup(parser, "");
 
3405
        parser->error = 0;
 
3406
 
 
3407
        /* Add pre-defined macros. */
 
3408
        add_builtin_define(parser, "GL_ARB_draw_buffers", 1);
 
3409
        add_builtin_define(parser, "GL_ARB_texture_rectangle", 1);
 
3410
 
 
3411
        if (api == API_OPENGLES2)
 
3412
                add_builtin_define(parser, "GL_ES", 1);
 
3413
 
 
3414
        if (extensions != NULL) {
 
3415
           if (extensions->EXT_texture_array) {
 
3416
              add_builtin_define(parser, "GL_EXT_texture_array", 1);
 
3417
           }
 
3418
 
 
3419
           if (extensions->ARB_fragment_coord_conventions)
 
3420
              add_builtin_define(parser, "GL_ARB_fragment_coord_conventions",
 
3421
                                 1);
 
3422
        }
 
3423
 
 
3424
        language_version = 110;
 
3425
        add_builtin_define(parser, "__VERSION__", language_version);
 
3426
 
 
3427
        return parser;
 
3428
}
 
3429
 
 
3430
int
 
3431
glcpp_parser_parse (glcpp_parser_t *parser)
 
3432
{
 
3433
        return yyparse (parser);
 
3434
}
 
3435
 
 
3436
void
 
3437
glcpp_parser_destroy (glcpp_parser_t *parser)
 
3438
{
 
3439
        glcpp_lex_destroy (parser->scanner);
 
3440
        hash_table_dtor (parser->defines);
 
3441
        talloc_free (parser);
 
3442
}
 
3443
 
 
3444
typedef enum function_status
 
3445
{
 
3446
        FUNCTION_STATUS_SUCCESS,
 
3447
        FUNCTION_NOT_A_FUNCTION,
 
3448
        FUNCTION_UNBALANCED_PARENTHESES
 
3449
} function_status_t;
 
3450
 
 
3451
/* Find a set of function-like macro arguments by looking for a
 
3452
 * balanced set of parentheses.
 
3453
 *
 
3454
 * When called, 'node' should be the opening-parenthesis token, (or
 
3455
 * perhaps preceeding SPACE tokens). Upon successful return *last will
 
3456
 * be the last consumed node, (corresponding to the closing right
 
3457
 * parenthesis).
 
3458
 *
 
3459
 * Return values:
 
3460
 *
 
3461
 *   FUNCTION_STATUS_SUCCESS:
 
3462
 *
 
3463
 *      Successfully parsed a set of function arguments.        
 
3464
 *
 
3465
 *   FUNCTION_NOT_A_FUNCTION:
 
3466
 *
 
3467
 *      Macro name not followed by a '('. This is not an error, but
 
3468
 *      simply that the macro name should be treated as a non-macro.
 
3469
 *
 
3470
 *   FUNCTION_UNBALANCED_PARENTHESES
 
3471
 *
 
3472
 *      Macro name is not followed by a balanced set of parentheses.
 
3473
 */
 
3474
static function_status_t
 
3475
_arguments_parse (argument_list_t *arguments,
 
3476
                  token_node_t *node,
 
3477
                  token_node_t **last)
 
3478
{
 
3479
        token_list_t *argument;
 
3480
        int paren_count;
 
3481
 
 
3482
        node = node->next;
 
3483
 
 
3484
        /* Ignore whitespace before first parenthesis. */
 
3485
        while (node && node->token->type == SPACE)
 
3486
                node = node->next;
 
3487
 
 
3488
        if (node == NULL || node->token->type != '(')
 
3489
                return FUNCTION_NOT_A_FUNCTION;
 
3490
 
 
3491
        node = node->next;
 
3492
 
 
3493
        argument = _token_list_create (arguments);
 
3494
        _argument_list_append (arguments, argument);
 
3495
 
 
3496
        for (paren_count = 1; node; node = node->next) {
 
3497
                if (node->token->type == '(')
 
3498
                {
 
3499
                        paren_count++;
 
3500
                }
 
3501
                else if (node->token->type == ')')
 
3502
                {
 
3503
                        paren_count--;
 
3504
                        if (paren_count == 0)
 
3505
                                break;
 
3506
                }
 
3507
 
 
3508
                if (node->token->type == ',' &&
 
3509
                         paren_count == 1)
 
3510
                {
 
3511
                        _token_list_trim_trailing_space (argument);
 
3512
                        argument = _token_list_create (arguments);
 
3513
                        _argument_list_append (arguments, argument);
 
3514
                }
 
3515
                else {
 
3516
                        if (argument->head == NULL) {
 
3517
                                /* Don't treat initial whitespace as
 
3518
                                 * part of the arguement. */
 
3519
                                if (node->token->type == SPACE)
 
3520
                                        continue;
 
3521
                        }
 
3522
                        _token_list_append (argument, node->token);
 
3523
                }
 
3524
        }
 
3525
 
 
3526
        if (paren_count)
 
3527
                return FUNCTION_UNBALANCED_PARENTHESES;
 
3528
 
 
3529
        *last = node;
 
3530
 
 
3531
        return FUNCTION_STATUS_SUCCESS;
 
3532
}
 
3533
 
 
3534
static token_list_t *
 
3535
_token_list_create_with_one_space (void *ctx)
 
3536
{
 
3537
        token_list_t *list;
 
3538
        token_t *space;
 
3539
 
 
3540
        list = _token_list_create (ctx);
 
3541
        space = _token_create_ival (list, SPACE, SPACE);
 
3542
        _token_list_append (list, space);
 
3543
 
 
3544
        return list;
 
3545
}
 
3546
 
 
3547
static void
 
3548
_glcpp_parser_expand_if (glcpp_parser_t *parser, int type, token_list_t *list)
 
3549
{
 
3550
        token_list_t *expanded;
 
3551
        token_t *token;
 
3552
 
 
3553
        expanded = _token_list_create (parser);
 
3554
        token = _token_create_ival (parser, type, type);
 
3555
        _token_list_append (expanded, token);
 
3556
        _glcpp_parser_expand_token_list (parser, list);
 
3557
        _token_list_append_list (expanded, list);
 
3558
        glcpp_parser_lex_from (parser, expanded);
 
3559
}
 
3560
 
 
3561
/* This is a helper function that's essentially part of the
 
3562
 * implementation of _glcpp_parser_expand_node. It shouldn't be called
 
3563
 * except for by that function.
 
3564
 *
 
3565
 * Returns NULL if node is a simple token with no expansion, (that is,
 
3566
 * although 'node' corresponds to an identifier defined as a
 
3567
 * function-like macro, it is not followed with a parenthesized
 
3568
 * argument list).
 
3569
 *
 
3570
 * Compute the complete expansion of node (which is a function-like
 
3571
 * macro) and subsequent nodes which are arguments.
 
3572
 *
 
3573
 * Returns the token list that results from the expansion and sets
 
3574
 * *last to the last node in the list that was consumed by the
 
3575
 * expansion. Specifically, *last will be set as follows: as the
 
3576
 * token of the closing right parenthesis.
 
3577
 */
 
3578
static token_list_t *
 
3579
_glcpp_parser_expand_function (glcpp_parser_t *parser,
 
3580
                               token_node_t *node,
 
3581
                               token_node_t **last)
 
3582
                               
 
3583
{
 
3584
        macro_t *macro;
 
3585
        const char *identifier;
 
3586
        argument_list_t *arguments;
 
3587
        function_status_t status;
 
3588
        token_list_t *substituted;
 
3589
        int parameter_index;
 
3590
 
 
3591
        identifier = node->token->value.str;
 
3592
 
 
3593
        macro = hash_table_find (parser->defines, identifier);
 
3594
 
 
3595
        assert (macro->is_function);
 
3596
 
 
3597
        arguments = _argument_list_create (parser);
 
3598
        status = _arguments_parse (arguments, node, last);
 
3599
 
 
3600
        switch (status) {
 
3601
        case FUNCTION_STATUS_SUCCESS:
 
3602
                break;
 
3603
        case FUNCTION_NOT_A_FUNCTION:
 
3604
                return NULL;
 
3605
        case FUNCTION_UNBALANCED_PARENTHESES:
 
3606
                glcpp_error (&node->token->location, parser, "Macro %s call has unbalanced parentheses\n", identifier);
 
3607
                return NULL;
 
3608
        }
 
3609
 
 
3610
        /* Replace a macro defined as empty with a SPACE token. */
 
3611
        if (macro->replacements == NULL) {
 
3612
                talloc_free (arguments);
 
3613
                return _token_list_create_with_one_space (parser);
 
3614
        }
 
3615
 
 
3616
        if (! ((_argument_list_length (arguments) == 
 
3617
                _string_list_length (macro->parameters)) ||
 
3618
               (_string_list_length (macro->parameters) == 0 &&
 
3619
                _argument_list_length (arguments) == 1 &&
 
3620
                arguments->head->argument->head == NULL)))
 
3621
        {
 
3622
                glcpp_error (&node->token->location, parser,
 
3623
                              "Error: macro %s invoked with %d arguments (expected %d)\n",
 
3624
                              identifier,
 
3625
                              _argument_list_length (arguments),
 
3626
                              _string_list_length (macro->parameters));
 
3627
                return NULL;
 
3628
        }
 
3629
 
 
3630
        /* Perform argument substitution on the replacement list. */
 
3631
        substituted = _token_list_create (arguments);
 
3632
 
 
3633
        for (node = macro->replacements->head; node; node = node->next)
 
3634
        {
 
3635
                if (node->token->type == IDENTIFIER &&
 
3636
                    _string_list_contains (macro->parameters,
 
3637
                                           node->token->value.str,
 
3638
                                           &parameter_index))
 
3639
                {
 
3640
                        token_list_t *argument;
 
3641
                        argument = _argument_list_member_at (arguments,
 
3642
                                                             parameter_index);
 
3643
                        /* Before substituting, we expand the argument
 
3644
                         * tokens, or append a placeholder token for
 
3645
                         * an empty argument. */
 
3646
                        if (argument->head) {
 
3647
                                token_list_t *expanded_argument;
 
3648
                                expanded_argument = _token_list_copy (parser,
 
3649
                                                                      argument);
 
3650
                                _glcpp_parser_expand_token_list (parser,
 
3651
                                                                 expanded_argument);
 
3652
                                _token_list_append_list (substituted,
 
3653
                                                         expanded_argument);
 
3654
                        } else {
 
3655
                                token_t *new_token;
 
3656
 
 
3657
                                new_token = _token_create_ival (substituted,
 
3658
                                                                PLACEHOLDER,
 
3659
                                                                PLACEHOLDER);
 
3660
                                _token_list_append (substituted, new_token);
 
3661
                        }
 
3662
                } else {
 
3663
                        _token_list_append (substituted, node->token);
 
3664
                }
 
3665
        }
 
3666
 
 
3667
        /* After argument substitution, and before further expansion
 
3668
         * below, implement token pasting. */
 
3669
 
 
3670
        _token_list_trim_trailing_space (substituted);
 
3671
 
 
3672
        node = substituted->head;
 
3673
        while (node)
 
3674
        {
 
3675
                token_node_t *next_non_space;
 
3676
 
 
3677
                /* Look ahead for a PASTE token, skipping space. */
 
3678
                next_non_space = node->next;
 
3679
                while (next_non_space && next_non_space->token->type == SPACE)
 
3680
                        next_non_space = next_non_space->next;
 
3681
 
 
3682
                if (next_non_space == NULL)
 
3683
                        break;
 
3684
 
 
3685
                if (next_non_space->token->type != PASTE) {
 
3686
                        node = next_non_space;
 
3687
                        continue;
 
3688
                }
 
3689
 
 
3690
                /* Now find the next non-space token after the PASTE. */
 
3691
                next_non_space = next_non_space->next;
 
3692
                while (next_non_space && next_non_space->token->type == SPACE)
 
3693
                        next_non_space = next_non_space->next;
 
3694
 
 
3695
                if (next_non_space == NULL) {
 
3696
                        yyerror (&node->token->location, parser, "'##' cannot appear at either end of a macro expansion\n");
 
3697
                        return NULL;
 
3698
                }
 
3699
 
 
3700
                node->token = _token_paste (parser, node->token, next_non_space->token);
 
3701
                node->next = next_non_space->next;
 
3702
                if (next_non_space == substituted->tail)
 
3703
                        substituted->tail = node;
 
3704
 
 
3705
                node = node->next;
 
3706
        }
 
3707
 
 
3708
        substituted->non_space_tail = substituted->tail;
 
3709
 
 
3710
        return substituted;
 
3711
}
 
3712
 
 
3713
/* Compute the complete expansion of node, (and subsequent nodes after
 
3714
 * 'node' in the case that 'node' is a function-like macro and
 
3715
 * subsequent nodes are arguments).
 
3716
 *
 
3717
 * Returns NULL if node is a simple token with no expansion.
 
3718
 *
 
3719
 * Otherwise, returns the token list that results from the expansion
 
3720
 * and sets *last to the last node in the list that was consumed by
 
3721
 * the expansion. Specifically, *last will be set as follows:
 
3722
 *
 
3723
 *      As 'node' in the case of object-like macro expansion.
 
3724
 *
 
3725
 *      As the token of the closing right parenthesis in the case of
 
3726
 *      function-like macro expansion.
 
3727
 */
 
3728
static token_list_t *
 
3729
_glcpp_parser_expand_node (glcpp_parser_t *parser,
 
3730
                           token_node_t *node,
 
3731
                           token_node_t **last)
 
3732
{
 
3733
        token_t *token = node->token;
 
3734
        const char *identifier;
 
3735
        macro_t *macro;
 
3736
 
 
3737
        /* We only expand identifiers */
 
3738
        if (token->type != IDENTIFIER) {
 
3739
                /* We change any COMMA into a COMMA_FINAL to prevent
 
3740
                 * it being mistaken for an argument separator
 
3741
                 * later. */
 
3742
                if (token->type == ',') {
 
3743
                        token->type = COMMA_FINAL;
 
3744
                        token->value.ival = COMMA_FINAL;
 
3745
                }
 
3746
 
 
3747
                return NULL;
 
3748
        }
 
3749
 
 
3750
        /* Look up this identifier in the hash table. */
 
3751
        identifier = token->value.str;
 
3752
        macro = hash_table_find (parser->defines, identifier);
 
3753
 
 
3754
        /* Not a macro, so no expansion needed. */
 
3755
        if (macro == NULL)
 
3756
                return NULL;
 
3757
 
 
3758
        /* Finally, don't expand this macro if we're already actively
 
3759
         * expanding it, (to avoid infinite recursion). */
 
3760
        if (_active_list_contains (parser->active, identifier)) {
 
3761
                /* We change the token type here from IDENTIFIER to
 
3762
                 * OTHER to prevent any future expansion of this
 
3763
                 * unexpanded token. */
 
3764
                char *str;
 
3765
                token_list_t *expansion;
 
3766
                token_t *final;
 
3767
 
 
3768
                str = talloc_strdup (parser, token->value.str);
 
3769
                final = _token_create_str (parser, OTHER, str);
 
3770
                expansion = _token_list_create (parser);
 
3771
                _token_list_append (expansion, final);
 
3772
                *last = node;
 
3773
                return expansion;
 
3774
        }
 
3775
 
 
3776
        if (! macro->is_function)
 
3777
        {
 
3778
                *last = node;
 
3779
 
 
3780
                /* Replace a macro defined as empty with a SPACE token. */
 
3781
                if (macro->replacements == NULL)
 
3782
                        return _token_list_create_with_one_space (parser);
 
3783
 
 
3784
                return _token_list_copy (parser, macro->replacements);
 
3785
        }
 
3786
 
 
3787
        return _glcpp_parser_expand_function (parser, node, last);
 
3788
}
 
3789
 
 
3790
/* Push a new identifier onto the active list, returning the new list.
 
3791
 *
 
3792
 * Here, 'marker' is the token node that appears in the list after the
 
3793
 * expansion of 'identifier'. That is, when the list iterator begins
 
3794
 * examinging 'marker', then it is time to pop this node from the
 
3795
 * active stack.
 
3796
 */
 
3797
active_list_t *
 
3798
_active_list_push (active_list_t *list,
 
3799
                   const char *identifier,
 
3800
                   token_node_t *marker)
 
3801
{
 
3802
        active_list_t *node;
 
3803
 
 
3804
        node = talloc (list, active_list_t);
 
3805
        node->identifier = talloc_strdup (node, identifier);
 
3806
        node->marker = marker;
 
3807
        node->next = list;
 
3808
 
 
3809
        return node;
 
3810
}
 
3811
 
 
3812
active_list_t *
 
3813
_active_list_pop (active_list_t *list)
 
3814
{
 
3815
        active_list_t *node = list;
 
3816
 
 
3817
        if (node == NULL)
 
3818
                return NULL;
 
3819
 
 
3820
        node = list->next;
 
3821
        talloc_free (list);
 
3822
 
 
3823
        return node;
 
3824
}
 
3825
 
 
3826
int
 
3827
_active_list_contains (active_list_t *list, const char *identifier)
 
3828
{
 
3829
        active_list_t *node;
 
3830
 
 
3831
        if (list == NULL)
 
3832
                return 0;
 
3833
 
 
3834
        for (node = list; node; node = node->next)
 
3835
                if (strcmp (node->identifier, identifier) == 0)
 
3836
                        return 1;
 
3837
 
 
3838
        return 0;
 
3839
}
 
3840
 
 
3841
/* Walk over the token list replacing nodes with their expansion.
 
3842
 * Whenever nodes are expanded the walking will walk over the new
 
3843
 * nodes, continuing to expand as necessary. The results are placed in
 
3844
 * 'list' itself;
 
3845
 */
 
3846
static void
 
3847
_glcpp_parser_expand_token_list (glcpp_parser_t *parser,
 
3848
                                 token_list_t *list)
 
3849
{
 
3850
        token_node_t *node_prev;
 
3851
        token_node_t *node, *last = NULL;
 
3852
        token_list_t *expansion;
 
3853
 
 
3854
        if (list == NULL)
 
3855
                return;
 
3856
 
 
3857
        _token_list_trim_trailing_space (list);
 
3858
 
 
3859
        node_prev = NULL;
 
3860
        node = list->head;
 
3861
 
 
3862
        while (node) {
 
3863
 
 
3864
                while (parser->active && parser->active->marker == node)
 
3865
                        parser->active = _active_list_pop (parser->active);
 
3866
 
 
3867
                /* Find the expansion for node, which will replace all
 
3868
                 * nodes from node to last, inclusive. */
 
3869
                expansion = _glcpp_parser_expand_node (parser, node, &last);
 
3870
                if (expansion) {
 
3871
                        token_node_t *n;
 
3872
 
 
3873
                        for (n = node; n != last->next; n = n->next)
 
3874
                                while (parser->active &&
 
3875
                                       parser->active->marker == n)
 
3876
                                {
 
3877
                                        parser->active = _active_list_pop (parser->active);
 
3878
                                }
 
3879
 
 
3880
                        parser->active = _active_list_push (parser->active,
 
3881
                                                            node->token->value.str,
 
3882
                                                            last->next);
 
3883
                        
 
3884
                        /* Splice expansion into list, supporting a
 
3885
                         * simple deletion if the expansion is
 
3886
                         * empty. */
 
3887
                        if (expansion->head) {
 
3888
                                if (node_prev)
 
3889
                                        node_prev->next = expansion->head;
 
3890
                                else
 
3891
                                        list->head = expansion->head;
 
3892
                                expansion->tail->next = last->next;
 
3893
                                if (last == list->tail)
 
3894
                                        list->tail = expansion->tail;
 
3895
                        } else {
 
3896
                                if (node_prev)
 
3897
                                        node_prev->next = last->next;
 
3898
                                else
 
3899
                                        list->head = last->next;
 
3900
                                if (last == list->tail)
 
3901
                                        list->tail = NULL;
 
3902
                        }
 
3903
                } else {
 
3904
                        node_prev = node;
 
3905
                }
 
3906
                node = node_prev ? node_prev->next : list->head;
 
3907
        }
 
3908
 
 
3909
        while (parser->active)
 
3910
                parser->active = _active_list_pop (parser->active);
 
3911
 
 
3912
        list->non_space_tail = list->tail;
 
3913
}
 
3914
 
 
3915
void
 
3916
_glcpp_parser_print_expanded_token_list (glcpp_parser_t *parser,
 
3917
                                         token_list_t *list)
 
3918
{
 
3919
        if (list == NULL)
 
3920
                return;
 
3921
 
 
3922
        _glcpp_parser_expand_token_list (parser, list);
 
3923
 
 
3924
        _token_list_trim_trailing_space (list);
 
3925
 
 
3926
        _token_list_print (parser, list);
 
3927
}
 
3928
 
 
3929
static void
 
3930
_check_for_reserved_macro_name (glcpp_parser_t *parser, YYLTYPE *loc,
 
3931
                                const char *identifier)
 
3932
{
 
3933
        /* According to the GLSL specification, macro names starting with "__"
 
3934
         * or "GL_" are reserved for future use.  So, don't allow them.
 
3935
         */
 
3936
        if (strncmp(identifier, "__", 2) == 0) {
 
3937
                glcpp_error (loc, parser, "Macro names starting with \"__\" are reserved.\n");
 
3938
        }
 
3939
        if (strncmp(identifier, "GL_", 3) == 0) {
 
3940
                glcpp_error (loc, parser, "Macro names starting with \"GL_\" are reserved.\n");
 
3941
        }
 
3942
}
 
3943
 
 
3944
static int
 
3945
_macro_equal (macro_t *a, macro_t *b)
 
3946
{
 
3947
        if (a->is_function != b->is_function)
 
3948
                return 0;
 
3949
 
 
3950
        if (a->is_function) {
 
3951
                if (! _string_list_equal (a->parameters, b->parameters))
 
3952
                        return 0;
 
3953
        }
 
3954
 
 
3955
        return _token_list_equal_ignoring_space (a->replacements,
 
3956
                                                 b->replacements);
 
3957
}
 
3958
 
 
3959
void
 
3960
_define_object_macro (glcpp_parser_t *parser,
 
3961
                      YYLTYPE *loc,
 
3962
                      const char *identifier,
 
3963
                      token_list_t *replacements)
 
3964
{
 
3965
        macro_t *macro, *previous;
 
3966
 
 
3967
        if (loc != NULL)
 
3968
                _check_for_reserved_macro_name(parser, loc, identifier);
 
3969
 
 
3970
        macro = talloc (parser, macro_t);
 
3971
 
 
3972
        macro->is_function = 0;
 
3973
        macro->parameters = NULL;
 
3974
        macro->identifier = talloc_strdup (macro, identifier);
 
3975
        macro->replacements = talloc_steal (macro, replacements);
 
3976
 
 
3977
        previous = hash_table_find (parser->defines, identifier);
 
3978
        if (previous) {
 
3979
                if (_macro_equal (macro, previous)) {
 
3980
                        talloc_free (macro);
 
3981
                        return;
 
3982
                }
 
3983
                glcpp_error (loc, parser, "Redefinition of macro %s\n",
 
3984
                             identifier);
 
3985
        }
 
3986
 
 
3987
        hash_table_insert (parser->defines, macro, identifier);
 
3988
}
 
3989
 
 
3990
void
 
3991
_define_function_macro (glcpp_parser_t *parser,
 
3992
                        YYLTYPE *loc,
 
3993
                        const char *identifier,
 
3994
                        string_list_t *parameters,
 
3995
                        token_list_t *replacements)
 
3996
{
 
3997
        macro_t *macro, *previous;
 
3998
 
 
3999
        _check_for_reserved_macro_name(parser, loc, identifier);
 
4000
 
 
4001
        macro = talloc (parser, macro_t);
 
4002
 
 
4003
        macro->is_function = 1;
 
4004
        macro->parameters = talloc_steal (macro, parameters);
 
4005
        macro->identifier = talloc_strdup (macro, identifier);
 
4006
        macro->replacements = talloc_steal (macro, replacements);
 
4007
 
 
4008
        previous = hash_table_find (parser->defines, identifier);
 
4009
        if (previous) {
 
4010
                if (_macro_equal (macro, previous)) {
 
4011
                        talloc_free (macro);
 
4012
                        return;
 
4013
                }
 
4014
                glcpp_error (loc, parser, "Redefinition of macro %s\n",
 
4015
                             identifier);
 
4016
        }
 
4017
 
 
4018
        hash_table_insert (parser->defines, macro, identifier);
 
4019
}
 
4020
 
 
4021
static int
 
4022
glcpp_parser_lex (YYSTYPE *yylval, YYLTYPE *yylloc, glcpp_parser_t *parser)
 
4023
{
 
4024
        token_node_t *node;
 
4025
        int ret;
 
4026
 
 
4027
        if (parser->lex_from_list == NULL) {
 
4028
                ret = glcpp_lex (yylval, yylloc, parser->scanner);
 
4029
 
 
4030
                /* XXX: This ugly block of code exists for the sole
 
4031
                 * purpose of converting a NEWLINE token into a SPACE
 
4032
                 * token, but only in the case where we have seen a
 
4033
                 * function-like macro name, but have not yet seen its
 
4034
                 * closing parenthesis.
 
4035
                 *
 
4036
                 * There's perhaps a more compact way to do this with
 
4037
                 * mid-rule actions in the grammar.
 
4038
                 *
 
4039
                 * I'm definitely not pleased with the complexity of
 
4040
                 * this code here.
 
4041
                 */
 
4042
                if (parser->newline_as_space)
 
4043
                {
 
4044
                        if (ret == '(') {
 
4045
                                parser->paren_count++;
 
4046
                        } else if (ret == ')') {
 
4047
                                parser->paren_count--;
 
4048
                                if (parser->paren_count == 0)
 
4049
                                        parser->newline_as_space = 0;
 
4050
                        } else if (ret == NEWLINE) {
 
4051
                                ret = SPACE;
 
4052
                        } else if (ret != SPACE) {
 
4053
                                if (parser->paren_count == 0)
 
4054
                                        parser->newline_as_space = 0;
 
4055
                        }
 
4056
                }
 
4057
                else if (parser->in_control_line)
 
4058
                {
 
4059
                        if (ret == NEWLINE)
 
4060
                                parser->in_control_line = 0;
 
4061
                }
 
4062
                else if (ret == HASH_DEFINE_OBJ || ret == HASH_DEFINE_FUNC ||
 
4063
                           ret == HASH_UNDEF || ret == HASH_IF ||
 
4064
                           ret == HASH_IFDEF || ret == HASH_IFNDEF ||
 
4065
                           ret == HASH_ELIF || ret == HASH_ELSE ||
 
4066
                           ret == HASH_ENDIF || ret == HASH)
 
4067
                {
 
4068
                        parser->in_control_line = 1;
 
4069
                }
 
4070
                else if (ret == IDENTIFIER)
 
4071
                {
 
4072
                        macro_t *macro;
 
4073
                        macro = hash_table_find (parser->defines,
 
4074
                                                 yylval->str);
 
4075
                        if (macro && macro->is_function) {
 
4076
                                parser->newline_as_space = 1;
 
4077
                                parser->paren_count = 0;
 
4078
                        }
 
4079
                }
 
4080
 
 
4081
                return ret;
 
4082
        }
 
4083
 
 
4084
        node = parser->lex_from_node;
 
4085
 
 
4086
        if (node == NULL) {
 
4087
                talloc_free (parser->lex_from_list);
 
4088
                parser->lex_from_list = NULL;
 
4089
                return NEWLINE;
 
4090
        }
 
4091
 
 
4092
        *yylval = node->token->value;
 
4093
        ret = node->token->type;
 
4094
 
 
4095
        parser->lex_from_node = node->next;
 
4096
 
 
4097
        return ret;
 
4098
}
 
4099
 
 
4100
static void
 
4101
glcpp_parser_lex_from (glcpp_parser_t *parser, token_list_t *list)
 
4102
{
 
4103
        token_node_t *node;
 
4104
 
 
4105
        assert (parser->lex_from_list == NULL);
 
4106
 
 
4107
        /* Copy list, eliminating any space tokens. */
 
4108
        parser->lex_from_list = _token_list_create (parser);
 
4109
 
 
4110
        for (node = list->head; node; node = node->next) {
 
4111
                if (node->token->type == SPACE)
 
4112
                        continue;
 
4113
                _token_list_append (parser->lex_from_list, node->token);
 
4114
        }
 
4115
 
 
4116
        talloc_free (list);
 
4117
 
 
4118
        parser->lex_from_node = parser->lex_from_list->head;
 
4119
 
 
4120
        /* It's possible the list consisted of nothing but whitespace. */
 
4121
        if (parser->lex_from_node == NULL) {
 
4122
                talloc_free (parser->lex_from_list);
 
4123
                parser->lex_from_list = NULL;
 
4124
        }
 
4125
}
 
4126
 
 
4127
static void
 
4128
_glcpp_parser_skip_stack_push_if (glcpp_parser_t *parser, YYLTYPE *loc,
 
4129
                                  int condition)
 
4130
{
 
4131
        skip_type_t current = SKIP_NO_SKIP;
 
4132
        skip_node_t *node;
 
4133
 
 
4134
        if (parser->skip_stack)
 
4135
                current = parser->skip_stack->type;
 
4136
 
 
4137
        node = talloc (parser, skip_node_t);
 
4138
        node->loc = *loc;
 
4139
 
 
4140
        if (current == SKIP_NO_SKIP) {
 
4141
                if (condition)
 
4142
                        node->type = SKIP_NO_SKIP;
 
4143
                else
 
4144
                        node->type = SKIP_TO_ELSE;
 
4145
        } else {
 
4146
                node->type = SKIP_TO_ENDIF;
 
4147
        }
 
4148
 
 
4149
        node->next = parser->skip_stack;
 
4150
        parser->skip_stack = node;
 
4151
}
 
4152
 
 
4153
static void
 
4154
_glcpp_parser_skip_stack_change_if (glcpp_parser_t *parser, YYLTYPE *loc,
 
4155
                                    const char *type, int condition)
 
4156
{
 
4157
        if (parser->skip_stack == NULL) {
 
4158
                glcpp_error (loc, parser, "%s without #if\n", type);
 
4159
                return;
 
4160
        }
 
4161
 
 
4162
        if (parser->skip_stack->type == SKIP_TO_ELSE) {
 
4163
                if (condition)
 
4164
                        parser->skip_stack->type = SKIP_NO_SKIP;
 
4165
        } else {
 
4166
                parser->skip_stack->type = SKIP_TO_ENDIF;
 
4167
        }
 
4168
}
 
4169
 
 
4170
static void
 
4171
_glcpp_parser_skip_stack_pop (glcpp_parser_t *parser, YYLTYPE *loc)
 
4172
{
 
4173
        skip_node_t *node;
 
4174
 
 
4175
        if (parser->skip_stack == NULL) {
 
4176
                glcpp_error (loc, parser, "#endif without #if\n");
 
4177
                return;
 
4178
        }
 
4179
 
 
4180
        node = parser->skip_stack;
 
4181
        parser->skip_stack = node->next;
 
4182
        talloc_free (node);
 
4183
}
 
4184