Subversion Repositories Kolibri OS

Rev

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

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