Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Blame | Last modification | View Log | RSS feed

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