1 /* A Bison parser, made by GNU Bison 3.7.1.  */
2 
3 /* Bison implementation for Yacc-like parsers in C
4 
5    Copyright (C) 1984, 1989-1990, 2000-2015, 2018-2020 Free Software Foundation,
6    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 /* DO NOT RELY ON FEATURES THAT ARE NOT DOCUMENTED in the manual,
38    especially those whose name start with YY_ or yy_.  They are
39    private implementation details that can be changed or removed.  */
40 
41 /* All symbols defined below should begin with yy or YY, to avoid
42    infringing on user name space.  This should be done even for local
43    variables, as they might otherwise be expanded by user macros.
44    There are some unavoidable exceptions within include files to
45    define necessary library symbols; they are noted "INFRINGES ON
46    USER NAME SPACE" below.  */
47 
48 /* Identify Bison output.  */
49 #define YYBISON 1
50 
51 /* Bison version.  */
52 #define YYBISON_VERSION "3.7.1"
53 
54 /* Skeleton name.  */
55 #define YYSKELETON_NAME "yacc.c"
56 
57 /* Pure parsers.  */
58 #define YYPURE 1
59 
60 /* Push parsers.  */
61 #define YYPUSH 0
62 
63 /* Pull parsers.  */
64 #define YYPULL 1
65 
66 
67 /* Substitute the variable and function names.  */
68 #define yyparse         pragma_parse
69 #define yylex           pragma_lex
70 #define yyerror         pragma_error
71 #define yydebug         pragma_debug
72 #define yynerrs         pragma_nerrs
73 
74 /* First part of user prologue.  */
75 #line 1 "ctlib/pragma.y"
76 
77 /*******************************************************************************
78 *
79 * MODULE: pragma.y
80 *
81 ********************************************************************************
82 *
83 * DESCRIPTION: Pragma parser
84 *
85 ********************************************************************************
86 *
87 * Copyright (c) 2002-2020 Marcus Holland-Moritz. All rights reserved.
88 * This program is free software; you can redistribute it and/or modify
89 * it under the same terms as Perl itself.
90 *
91 *******************************************************************************/
92 
93 /*===== GLOBAL INCLUDES ======================================================*/
94 
95 #include <stdio.h>
96 #include <stdlib.h>
97 #include <string.h>
98 
99 
100 /*===== LOCAL INCLUDES =======================================================*/
101 
102 #include "ctdebug.h"
103 #include "cterror.h"
104 #include "pragma.h"
105 
106 #include "util/ccattr.h"
107 #include "util/memalloc.h"
108 #include "util/list.h"
109 
110 #include "ucpp/cpp.h"
111 
112 
113 /*===== DEFINES ==============================================================*/
114 
115 /* ADDITIONAL BISON CONFIGURATION */
116 
117 /*
118  * Bison version >= 1.31 is needed for YYFPRINTF
119  */
120 #if YYDEBUG && defined CTLIB_DEBUGGING
121 #define YYFPRINTF BisonDebugFunc
122 #endif
123 
124 #define pragma_error( state, msg )     \
125         CT_DEBUG( PRAGMA, ("pragma_error(): %s", msg) )
126 
127 #define pragma_parse            CTlib_pragma_parse
128 
129 /* MACROS */
130 
131 #define PSTATE                  ((PragmaState *) pState)
132 
133 #define VALID_PACK( value )     \
134          (   (value) ==  0      \
135           || (value) ==  1      \
136           || (value) ==  2      \
137           || (value) ==  4      \
138           || (value) ==  8      \
139          )
140 
141 
142 /*===== TYPEDEFS =============================================================*/
143 
144 struct _pragmaState {
145 
146   CParseInfo  *pCPI;
147   const char  *file;
148   long int     line;
149   const char  *code;
150 
151   struct {
152     LinkedList stack;
153     unsigned   current;
154   }            pack;
155 
156 };
157 
158 typedef struct {
159   unsigned size;
160 } PackElement;
161 
162 
163 /*===== EXTERNAL VARIABLES ===================================================*/
164 
165 /*===== GLOBAL VARIABLES =====================================================*/
166 
167 /*===== STATIC VARIABLES =====================================================*/
168 
169 /* TOKEN MAPPING TABLE */
170 
171 static const int tokentab[] = {
172 	0,		/* NONE, */		/* whitespace */
173 	0,		/* NEWLINE, */		/* newline */
174 	0,		/* COMMENT, */		/* comment */
175 	0,		/* NUMBER, */		/* number constant */
176 	0,		/* NAME, */		/* identifier */
177 	0,		/* BUNCH, */		/* non-C characters */
178 	0,		/* PRAGMA, */		/* a #pragma directive */
179 	0,		/* CONTEXT, */		/* new file or #line */
180 	0,		/* STRING, */		/* constant "xxx" */
181 	0,		/* CHAR, */		/* constant 'xxx' */
182 	'/',		/* SLASH, */		/*	/	*/
183 	0,		/* ASSLASH, */		/*	/=	*/
184 	'-',		/* MINUS, */		/*	-	*/
185 	0,		/* MMINUS, */		/*	--	*/
186 	0,		/* ASMINUS, */		/*	-=	*/
187 	0,		/* ARROW, */		/*	->	*/
188 	'+',		/* PLUS, */		/*	+	*/
189 	0,		/* PPLUS, */		/*	++	*/
190 	0,		/* ASPLUS, */		/*	+=	*/
191 	'<',		/* LT, */		/*	<	*/
192 	0,		/* LEQ, */		/*	<=	*/
193 	0,		/* LSH, */		/*	<<	*/
194 	0,		/* ASLSH, */		/*	<<=	*/
195 	'>',		/* GT, */		/*	>	*/
196 	0,		/* GEQ, */		/*	>=	*/
197 	0,		/* RSH, */		/*	>>	*/
198 	0,		/* ASRSH, */		/*	>>=	*/
199 	'=',		/* ASGN, */		/*	=	*/
200 	0,		/* SAME, */		/*	==	*/
201 #ifdef CAST_OP
202 	0,		/* CAST, */		/*	=>	*/
203 #endif
204 	'~',		/* NOT, */		/*	~	*/
205 	0,		/* NEQ, */		/*	!=	*/
206 	'&',		/* AND, */		/*	&	*/
207 	0,		/* LAND, */		/*	&&	*/
208 	0,		/* ASAND, */		/*	&=	*/
209 	'|',		/* OR, */		/*	|	*/
210 	0,		/* LOR, */		/*	||	*/
211 	0,		/* ASOR, */		/*	|=	*/
212 	'%',		/* PCT, */		/*	%	*/
213 	0,		/* ASPCT, */		/*	%=	*/
214 	'*',		/* STAR, */		/*	*	*/
215 	0,		/* ASSTAR, */		/*	*=	*/
216 	'^',		/* CIRC, */		/*	^	*/
217 	0,		/* ASCIRC, */		/*	^=	*/
218 	'!',		/* LNOT, */		/*	!	*/
219 	'{',		/* LBRA, */		/*	{	*/
220 	'}',		/* RBRA, */		/*	}	*/
221 	'[',		/* LBRK, */		/*	[	*/
222 	']',		/* RBRK, */		/*	]	*/
223 	'(',		/* LPAR, */		/*	(	*/
224 	')',		/* RPAR, */		/*	)	*/
225 	',',		/* COMMA, */		/*	,	*/
226 	'?',		/* QUEST, */		/*	?	*/
227 	';',		/* SEMIC, */		/*	;	*/
228 	':',		/* COLON, */		/*	:	*/
229 	'.',		/* DOT, */		/*	.	*/
230 	0,		/* MDOTS, */		/*	...	*/
231 	0,		/* SHARP, */		/*	#	*/
232 	0,		/* DSHARP, */		/*	##	*/
233 
234 	0,		/* OPT_NONE, */		/* optional space to separate tokens in text output */
235 
236 	0,		/* DIGRAPH_TOKENS, */		/* there begin digraph tokens */
237 
238 	/* for DIG_*, do not change order, unless checking undig() in cpp.c */
239 	'[',		/* DIG_LBRK, */		/*	<:	*/
240 	']',		/* DIG_RBRK, */		/*	:>	*/
241 	'{',		/* DIG_LBRA, */		/*	<%	*/
242 	'}',		/* DIG_RBRA, */		/*	%>	*/
243 	0,		/* DIG_SHARP, */	/*	%:	*/
244 	0,		/* DIG_DSHARP, */	/*	%:%:	*/
245 
246 	0,		/* DIGRAPH_TOKENS_END, */	/* digraph tokens end here */
247 
248 	0,		/* LAST_MEANINGFUL_TOKEN, */	/* reserved words will go there */
249 
250 	0,		/* MACROARG, */		/* special token for representing macro arguments */
251 
252 	0,		/* UPLUS = CPPERR, */	/* unary + */
253 	0,		/* UMINUS */		/* unary - */
254 };
255 
256 
257 #line 258 "ctlib/y_pragma.c"
258 
259 # ifndef YY_CAST
260 #  ifdef __cplusplus
261 #   define YY_CAST(Type, Val) static_cast<Type> (Val)
262 #   define YY_REINTERPRET_CAST(Type, Val) reinterpret_cast<Type> (Val)
263 #  else
264 #   define YY_CAST(Type, Val) ((Type) (Val))
265 #   define YY_REINTERPRET_CAST(Type, Val) ((Type) (Val))
266 #  endif
267 # endif
268 # ifndef YY_NULLPTR
269 #  if defined __cplusplus
270 #   if 201103L <= __cplusplus
271 #    define YY_NULLPTR nullptr
272 #   else
273 #    define YY_NULLPTR 0
274 #   endif
275 #  else
276 #   define YY_NULLPTR ((void*)0)
277 #  endif
278 # endif
279 
280 
281 /* Debug traces.  */
282 #ifndef YYDEBUG
283 # define YYDEBUG 0
284 #endif
285 #if YYDEBUG
286 extern int pragma_debug;
287 #endif
288 
289 /* Token kinds.  */
290 #ifndef YYTOKENTYPE
291 # define YYTOKENTYPE
292   enum yytokentype
293   {
294     YYEMPTY = -2,
295     YYEOF = 0,                     /* "end of file"  */
296     YYerror = 256,                 /* error  */
297     YYUNDEF = 257,                 /* "invalid token"  */
298     CONSTANT = 258,                /* CONSTANT  */
299     PACK_TOK = 259,                /* PACK_TOK  */
300     PUSH_TOK = 260,                /* PUSH_TOK  */
301     POP_TOK = 261                  /* POP_TOK  */
302   };
303   typedef enum yytokentype yytoken_kind_t;
304 #endif
305 
306 /* Value type.  */
307 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
308 union YYSTYPE
309 {
310 #line 185 "ctlib/pragma.y"
311 
312   int ival;
313 
314 #line 315 "ctlib/y_pragma.c"
315 
316 };
317 typedef union YYSTYPE YYSTYPE;
318 # define YYSTYPE_IS_TRIVIAL 1
319 # define YYSTYPE_IS_DECLARED 1
320 #endif
321 
322 
323 
324 int pragma_parse (PragmaState *pState);
325 
326 
327 /* Symbol kind.  */
328 enum yysymbol_kind_t
329 {
330   YYSYMBOL_YYEMPTY = -2,
331   YYSYMBOL_YYEOF = 0,                      /* "end of file"  */
332   YYSYMBOL_YYerror = 1,                    /* error  */
333   YYSYMBOL_YYUNDEF = 2,                    /* "invalid token"  */
334   YYSYMBOL_CONSTANT = 3,                   /* CONSTANT  */
335   YYSYMBOL_PACK_TOK = 4,                   /* PACK_TOK  */
336   YYSYMBOL_PUSH_TOK = 5,                   /* PUSH_TOK  */
337   YYSYMBOL_POP_TOK = 6,                    /* POP_TOK  */
338   YYSYMBOL_7_ = 7,                         /* '('  */
339   YYSYMBOL_8_ = 8,                         /* ')'  */
340   YYSYMBOL_9_ = 9,                         /* ','  */
341   YYSYMBOL_YYACCEPT = 10,                  /* $accept  */
342   YYSYMBOL_pragma = 11,                    /* pragma  */
343   YYSYMBOL_pragma_pack = 12,               /* pragma_pack  */
344   YYSYMBOL_pragma_pack_args = 13           /* pragma_pack_args  */
345 };
346 typedef enum yysymbol_kind_t yysymbol_kind_t;
347 
348 
349 /* Second part of user prologue.  */
350 #line 189 "ctlib/pragma.y"
351 
352 
353 /*===== STATIC FUNCTION PROTOTYPES ===========================================*/
354 
355 static        int          is_valid_pack_arg(PragmaState *pState, int arg);
356 
357 static inline int          pragma_lex(YYSTYPE *plval, PragmaState *pState);
358 
359 static        PackElement *packelem_new(unsigned size);
360 static        void         packelem_delete(PackElement *pPack);
361 
362 
363 #line 364 "ctlib/y_pragma.c"
364 
365 
366 #ifdef short
367 # undef short
368 #endif
369 
370 /* On compilers that do not define __PTRDIFF_MAX__ etc., make sure
371    <limits.h> and (if available) <stdint.h> are included
372    so that the code can choose integer types of a good width.  */
373 
374 #ifndef __PTRDIFF_MAX__
375 # include <limits.h> /* INFRINGES ON USER NAME SPACE */
376 # if defined __STDC_VERSION__ && 199901 <= __STDC_VERSION__
377 #  include <stdint.h> /* INFRINGES ON USER NAME SPACE */
378 #  define YY_STDINT_H
379 # endif
380 #endif
381 
382 /* Narrow types that promote to a signed type and that can represent a
383    signed or unsigned integer of at least N bits.  In tables they can
384    save space and decrease cache pressure.  Promoting to a signed type
385    helps avoid bugs in integer arithmetic.  */
386 
387 #ifdef __INT_LEAST8_MAX__
388 typedef __INT_LEAST8_TYPE__ yytype_int8;
389 #elif defined YY_STDINT_H
390 typedef int_least8_t yytype_int8;
391 #else
392 typedef signed char yytype_int8;
393 #endif
394 
395 #ifdef __INT_LEAST16_MAX__
396 typedef __INT_LEAST16_TYPE__ yytype_int16;
397 #elif defined YY_STDINT_H
398 typedef int_least16_t yytype_int16;
399 #else
400 typedef short yytype_int16;
401 #endif
402 
403 #if defined __UINT_LEAST8_MAX__ && __UINT_LEAST8_MAX__ <= __INT_MAX__
404 typedef __UINT_LEAST8_TYPE__ yytype_uint8;
405 #elif (!defined __UINT_LEAST8_MAX__ && defined YY_STDINT_H \
406        && UINT_LEAST8_MAX <= INT_MAX)
407 typedef uint_least8_t yytype_uint8;
408 #elif !defined __UINT_LEAST8_MAX__ && UCHAR_MAX <= INT_MAX
409 typedef unsigned char yytype_uint8;
410 #else
411 typedef short yytype_uint8;
412 #endif
413 
414 #if defined __UINT_LEAST16_MAX__ && __UINT_LEAST16_MAX__ <= __INT_MAX__
415 typedef __UINT_LEAST16_TYPE__ yytype_uint16;
416 #elif (!defined __UINT_LEAST16_MAX__ && defined YY_STDINT_H \
417        && UINT_LEAST16_MAX <= INT_MAX)
418 typedef uint_least16_t yytype_uint16;
419 #elif !defined __UINT_LEAST16_MAX__ && USHRT_MAX <= INT_MAX
420 typedef unsigned short yytype_uint16;
421 #else
422 typedef int yytype_uint16;
423 #endif
424 
425 #ifndef YYPTRDIFF_T
426 # if defined __PTRDIFF_TYPE__ && defined __PTRDIFF_MAX__
427 #  define YYPTRDIFF_T __PTRDIFF_TYPE__
428 #  define YYPTRDIFF_MAXIMUM __PTRDIFF_MAX__
429 # elif defined PTRDIFF_MAX
430 #  ifndef ptrdiff_t
431 #   include <stddef.h> /* INFRINGES ON USER NAME SPACE */
432 #  endif
433 #  define YYPTRDIFF_T ptrdiff_t
434 #  define YYPTRDIFF_MAXIMUM PTRDIFF_MAX
435 # else
436 #  define YYPTRDIFF_T long
437 #  define YYPTRDIFF_MAXIMUM LONG_MAX
438 # endif
439 #endif
440 
441 #ifndef YYSIZE_T
442 # ifdef __SIZE_TYPE__
443 #  define YYSIZE_T __SIZE_TYPE__
444 # elif defined size_t
445 #  define YYSIZE_T size_t
446 # elif defined __STDC_VERSION__ && 199901 <= __STDC_VERSION__
447 #  include <stddef.h> /* INFRINGES ON USER NAME SPACE */
448 #  define YYSIZE_T size_t
449 # else
450 #  define YYSIZE_T unsigned
451 # endif
452 #endif
453 
454 #define YYSIZE_MAXIMUM                                  \
455   YY_CAST (YYPTRDIFF_T,                                 \
456            (YYPTRDIFF_MAXIMUM < YY_CAST (YYSIZE_T, -1)  \
457             ? YYPTRDIFF_MAXIMUM                         \
458             : YY_CAST (YYSIZE_T, -1)))
459 
460 #define YYSIZEOF(X) YY_CAST (YYPTRDIFF_T, sizeof (X))
461 
462 
463 /* Stored state numbers (used for stacks). */
464 typedef yytype_int8 yy_state_t;
465 
466 /* State numbers in computations.  */
467 typedef int yy_state_fast_t;
468 
469 #ifndef YY_
470 # if defined YYENABLE_NLS && YYENABLE_NLS
471 #  if ENABLE_NLS
472 #   include <libintl.h> /* INFRINGES ON USER NAME SPACE */
473 #   define YY_(Msgid) dgettext ("bison-runtime", Msgid)
474 #  endif
475 # endif
476 # ifndef YY_
477 #  define YY_(Msgid) Msgid
478 # endif
479 #endif
480 
481 
482 #ifndef YY_ATTRIBUTE_PURE
483 # if defined __GNUC__ && 2 < __GNUC__ + (96 <= __GNUC_MINOR__)
484 #  define YY_ATTRIBUTE_PURE __attribute__ ((__pure__))
485 # else
486 #  define YY_ATTRIBUTE_PURE
487 # endif
488 #endif
489 
490 #ifndef YY_ATTRIBUTE_UNUSED
491 # if defined __GNUC__ && 2 < __GNUC__ + (7 <= __GNUC_MINOR__)
492 #  define YY_ATTRIBUTE_UNUSED __attribute__ ((__unused__))
493 # else
494 #  define YY_ATTRIBUTE_UNUSED
495 # endif
496 #endif
497 
498 /* Suppress unused-variable warnings by "using" E.  */
499 #if ! defined lint || defined __GNUC__
500 # define YYUSE(E) ((void) (E))
501 #else
502 # define YYUSE(E) /* empty */
503 #endif
504 
505 #if defined __GNUC__ && ! defined __ICC && 407 <= __GNUC__ * 100 + __GNUC_MINOR__
506 /* Suppress an incorrect diagnostic about yylval being uninitialized.  */
507 # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN                            \
508     _Pragma ("GCC diagnostic push")                                     \
509     _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")              \
510     _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
511 # define YY_IGNORE_MAYBE_UNINITIALIZED_END      \
512     _Pragma ("GCC diagnostic pop")
513 #else
514 # define YY_INITIAL_VALUE(Value) Value
515 #endif
516 #ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
517 # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
518 # define YY_IGNORE_MAYBE_UNINITIALIZED_END
519 #endif
520 #ifndef YY_INITIAL_VALUE
521 # define YY_INITIAL_VALUE(Value) /* Nothing. */
522 #endif
523 
524 #if defined __cplusplus && defined __GNUC__ && ! defined __ICC && 6 <= __GNUC__
525 # define YY_IGNORE_USELESS_CAST_BEGIN                          \
526     _Pragma ("GCC diagnostic push")                            \
527     _Pragma ("GCC diagnostic ignored \"-Wuseless-cast\"")
528 # define YY_IGNORE_USELESS_CAST_END            \
529     _Pragma ("GCC diagnostic pop")
530 #endif
531 #ifndef YY_IGNORE_USELESS_CAST_BEGIN
532 # define YY_IGNORE_USELESS_CAST_BEGIN
533 # define YY_IGNORE_USELESS_CAST_END
534 #endif
535 
536 
537 #define YY_ASSERT(E) ((void) (0 && (E)))
538 
539 #if 1
540 
541 /* The parser invokes alloca or malloc; define the necessary symbols.  */
542 
543 # ifdef YYSTACK_USE_ALLOCA
544 #  if YYSTACK_USE_ALLOCA
545 #   ifdef __GNUC__
546 #    define YYSTACK_ALLOC __builtin_alloca
547 #   elif defined __BUILTIN_VA_ARG_INCR
548 #    include <alloca.h> /* INFRINGES ON USER NAME SPACE */
549 #   elif defined _AIX
550 #    define YYSTACK_ALLOC __alloca
551 #   elif defined _MSC_VER
552 #    include <malloc.h> /* INFRINGES ON USER NAME SPACE */
553 #    define alloca _alloca
554 #   else
555 #    define YYSTACK_ALLOC alloca
556 #    if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS
557 #     include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
558       /* Use EXIT_SUCCESS as a witness for stdlib.h.  */
559 #     ifndef EXIT_SUCCESS
560 #      define EXIT_SUCCESS 0
561 #     endif
562 #    endif
563 #   endif
564 #  endif
565 # endif
566 
567 # ifdef YYSTACK_ALLOC
568    /* Pacify GCC's 'empty if-body' warning.  */
569 #  define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
570 #  ifndef YYSTACK_ALLOC_MAXIMUM
571     /* The OS might guarantee only one guard page at the bottom of the stack,
572        and a page size can be as small as 4096 bytes.  So we cannot safely
573        invoke alloca (N) if N exceeds 4096.  Use a slightly smaller number
574        to allow for a few compiler-allocated temporary stack slots.  */
575 #   define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
576 #  endif
577 # else
578 #  define YYSTACK_ALLOC YYMALLOC
579 #  define YYSTACK_FREE YYFREE
580 #  ifndef YYSTACK_ALLOC_MAXIMUM
581 #   define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
582 #  endif
583 #  if (defined __cplusplus && ! defined EXIT_SUCCESS \
584        && ! ((defined YYMALLOC || defined malloc) \
585              && (defined YYFREE || defined free)))
586 #   include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
587 #   ifndef EXIT_SUCCESS
588 #    define EXIT_SUCCESS 0
589 #   endif
590 #  endif
591 #  ifndef YYMALLOC
592 #   define YYMALLOC malloc
593 #   if ! defined malloc && ! defined EXIT_SUCCESS
594 void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
595 #   endif
596 #  endif
597 #  ifndef YYFREE
598 #   define YYFREE free
599 #   if ! defined free && ! defined EXIT_SUCCESS
600 void free (void *); /* INFRINGES ON USER NAME SPACE */
601 #   endif
602 #  endif
603 # endif
604 #endif /* 1 */
605 
606 #if (! defined yyoverflow \
607      && (! defined __cplusplus \
608          || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
609 
610 /* A type that is properly aligned for any stack member.  */
611 union yyalloc
612 {
613   yy_state_t yyss_alloc;
614   YYSTYPE yyvs_alloc;
615 };
616 
617 /* The size of the maximum gap between one aligned stack and the next.  */
618 # define YYSTACK_GAP_MAXIMUM (YYSIZEOF (union yyalloc) - 1)
619 
620 /* The size of an array large to enough to hold all stacks, each with
621    N elements.  */
622 # define YYSTACK_BYTES(N) \
623      ((N) * (YYSIZEOF (yy_state_t) + YYSIZEOF (YYSTYPE)) \
624       + YYSTACK_GAP_MAXIMUM)
625 
626 # define YYCOPY_NEEDED 1
627 
628 /* Relocate STACK from its old location to the new one.  The
629    local variables YYSIZE and YYSTACKSIZE give the old and new number of
630    elements in the stack, and YYPTR gives the new location of the
631    stack.  Advance YYPTR to a properly aligned location for the next
632    stack.  */
633 # define YYSTACK_RELOCATE(Stack_alloc, Stack)                           \
634     do                                                                  \
635       {                                                                 \
636         YYPTRDIFF_T yynewbytes;                                         \
637         YYCOPY (&yyptr->Stack_alloc, Stack, yysize);                    \
638         Stack = &yyptr->Stack_alloc;                                    \
639         yynewbytes = yystacksize * YYSIZEOF (*Stack) + YYSTACK_GAP_MAXIMUM; \
640         yyptr += yynewbytes / YYSIZEOF (*yyptr);                        \
641       }                                                                 \
642     while (0)
643 
644 #endif
645 
646 #if defined YYCOPY_NEEDED && YYCOPY_NEEDED
647 /* Copy COUNT objects from SRC to DST.  The source and destination do
648    not overlap.  */
649 # ifndef YYCOPY
650 #  if defined __GNUC__ && 1 < __GNUC__
651 #   define YYCOPY(Dst, Src, Count) \
652       __builtin_memcpy (Dst, Src, YY_CAST (YYSIZE_T, (Count)) * sizeof (*(Src)))
653 #  else
654 #   define YYCOPY(Dst, Src, Count)              \
655       do                                        \
656         {                                       \
657           YYPTRDIFF_T yyi;                      \
658           for (yyi = 0; yyi < (Count); yyi++)   \
659             (Dst)[yyi] = (Src)[yyi];            \
660         }                                       \
661       while (0)
662 #  endif
663 # endif
664 #endif /* !YYCOPY_NEEDED */
665 
666 /* YYFINAL -- State number of the termination state.  */
667 #define YYFINAL  5
668 /* YYLAST -- Last index in YYTABLE.  */
669 #define YYLAST   9
670 
671 /* YYNTOKENS -- Number of terminals.  */
672 #define YYNTOKENS  10
673 /* YYNNTS -- Number of nonterminals.  */
674 #define YYNNTS  4
675 /* YYNRULES -- Number of rules.  */
676 #define YYNRULES  8
677 /* YYNSTATES -- Number of states.  */
678 #define YYNSTATES  14
679 
680 /* YYMAXUTOK -- Last valid token kind.  */
681 #define YYMAXUTOK   261
682 
683 
684 /* YYTRANSLATE(TOKEN-NUM) -- Symbol number corresponding to TOKEN-NUM
685    as returned by yylex, with out-of-bounds checking.  */
686 #define YYTRANSLATE(YYX)                                \
687   (0 <= (YYX) && (YYX) <= YYMAXUTOK                     \
688    ? YY_CAST (yysymbol_kind_t, yytranslate[YYX])        \
689    : YYSYMBOL_YYUNDEF)
690 
691 /* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM
692    as returned by yylex.  */
693 static const yytype_int8 yytranslate[] =
694 {
695        0,     2,     2,     2,     2,     2,     2,     2,     2,     2,
696        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
697        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
698        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
699        7,     8,     2,     2,     9,     2,     2,     2,     2,     2,
700        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
701        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
702        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
703        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
704        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
705        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
706        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
707        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
708        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
709        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
710        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
711        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
712        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
713        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
714        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
715        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
716        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
717        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
718        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
719        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
720        2,     2,     2,     2,     2,     2,     1,     2,     3,     4,
721        5,     6
722 };
723 
724 #if YYDEBUG
725   /* YYRLINE[YYN] -- Source line where rule number YYN was defined.  */
726 static const yytype_uint8 yyrline[] =
727 {
728        0,   218,   218,   222,   224,   226,   230,   237,   245
729 };
730 #endif
731 
732 /** Accessing symbol of state STATE.  */
733 #define YY_ACCESSING_SYMBOL(State) YY_CAST (yysymbol_kind_t, yystos[State])
734 
735 #if 1
736 /* The user-facing name of the symbol whose (internal) number is
737    YYSYMBOL.  No bounds checking.  */
738 static const char *yysymbol_name (yysymbol_kind_t yysymbol) YY_ATTRIBUTE_UNUSED;
739 
740 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
741    First, the terminals, then, starting at YYNTOKENS, nonterminals.  */
742 static const char *const yytname[] =
743 {
744   "\"end of file\"", "error", "\"invalid token\"", "CONSTANT", "PACK_TOK",
745   "PUSH_TOK", "POP_TOK", "'('", "')'", "','", "$accept", "pragma",
746   "pragma_pack", "pragma_pack_args", YY_NULLPTR
747 };
748 
749 static const char *
yysymbol_name(yysymbol_kind_t yysymbol)750 yysymbol_name (yysymbol_kind_t yysymbol)
751 {
752   return yytname[yysymbol];
753 }
754 #endif
755 
756 #ifdef YYPRINT
757 /* YYTOKNUM[NUM] -- (External) token number corresponding to the
758    (internal) symbol number NUM (which must be that of a token).  */
759 static const yytype_int16 yytoknum[] =
760 {
761        0,   256,   257,   258,   259,   260,   261,    40,    41,    44
762 };
763 #endif
764 
765 #define YYPACT_NINF (-7)
766 
767 #define yypact_value_is_default(Yyn) \
768   ((Yyn) == YYPACT_NINF)
769 
770 #define YYTABLE_NINF (-1)
771 
772 #define yytable_value_is_error(Yyn) \
773   0
774 
775   /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
776      STATE-NUM.  */
777 static const yytype_int8 yypact[] =
778 {
779        0,    -6,     6,    -7,    -3,    -7,    -7,    -2,    -7,    -7,
780        1,     5,    -7,    -7
781 };
782 
783   /* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM.
784      Performed when YYTABLE does not specify something else to do.  Zero
785      means the default is an error.  */
786 static const yytype_int8 yydefact[] =
787 {
788        0,     3,     0,     2,     0,     1,     6,     0,     8,     4,
789        0,     0,     5,     7
790 };
791 
792   /* YYPGOTO[NTERM-NUM].  */
793 static const yytype_int8 yypgoto[] =
794 {
795       -7,    -7,    -7,    -7
796 };
797 
798   /* YYDEFGOTO[NTERM-NUM].  */
799 static const yytype_int8 yydefgoto[] =
800 {
801       -1,     2,     3,    10
802 };
803 
804   /* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM.  If
805      positive, shift that token.  If negative, reduce the rule whose
806      number is the opposite.  If YYTABLE_NINF, syntax error.  */
807 static const yytype_int8 yytable[] =
808 {
809        6,     4,     7,     8,     1,     9,     5,    11,    13,    12
810 };
811 
812 static const yytype_int8 yycheck[] =
813 {
814        3,     7,     5,     6,     4,     8,     0,     9,     3,     8
815 };
816 
817   /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
818      symbol of state STATE-NUM.  */
819 static const yytype_int8 yystos[] =
820 {
821        0,     4,    11,    12,     7,     0,     3,     5,     6,     8,
822       13,     9,     8,     3
823 };
824 
825   /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives.  */
826 static const yytype_int8 yyr1[] =
827 {
828        0,    10,    11,    12,    12,    12,    13,    13,    13
829 };
830 
831   /* YYR2[YYN] -- Number of symbols on the right hand side of rule YYN.  */
832 static const yytype_int8 yyr2[] =
833 {
834        0,     2,     1,     1,     3,     4,     1,     3,     1
835 };
836 
837 
838 enum { YYENOMEM = -2 };
839 
840 #define yyerrok         (yyerrstatus = 0)
841 #define yyclearin       (yychar = YYEMPTY)
842 
843 #define YYACCEPT        goto yyacceptlab
844 #define YYABORT         goto yyabortlab
845 #define YYERROR         goto yyerrorlab
846 
847 
848 #define YYRECOVERING()  (!!yyerrstatus)
849 
850 #define YYBACKUP(Token, Value)                                    \
851   do                                                              \
852     if (yychar == YYEMPTY)                                        \
853       {                                                           \
854         yychar = (Token);                                         \
855         yylval = (Value);                                         \
856         YYPOPSTACK (yylen);                                       \
857         yystate = *yyssp;                                         \
858         goto yybackup;                                            \
859       }                                                           \
860     else                                                          \
861       {                                                           \
862         yyerror (pState, YY_("syntax error: cannot back up")); \
863         YYERROR;                                                  \
864       }                                                           \
865   while (0)
866 
867 /* Backward compatibility with an undocumented macro.
868    Use YYerror or YYUNDEF. */
869 #define YYERRCODE YYUNDEF
870 
871 
872 /* Enable debugging if requested.  */
873 #if YYDEBUG
874 
875 # ifndef YYFPRINTF
876 #  include <stdio.h> /* INFRINGES ON USER NAME SPACE */
877 #  define YYFPRINTF fprintf
878 # endif
879 
880 # define YYDPRINTF(Args)                        \
881 do {                                            \
882   if (yydebug)                                  \
883     YYFPRINTF Args;                             \
884 } while (0)
885 
886 /* This macro is provided for backward compatibility. */
887 # ifndef YY_LOCATION_PRINT
888 #  define YY_LOCATION_PRINT(File, Loc) ((void) 0)
889 # endif
890 
891 
892 # define YY_SYMBOL_PRINT(Title, Kind, Value, Location)                    \
893 do {                                                                      \
894   if (yydebug)                                                            \
895     {                                                                     \
896       YYFPRINTF (stderr, "%s ", Title);                                   \
897       yy_symbol_print (stderr,                                            \
898                   Kind, Value, pState); \
899       YYFPRINTF (stderr, "\n");                                           \
900     }                                                                     \
901 } while (0)
902 
903 
904 /*-----------------------------------.
905 | Print this symbol's value on YYO.  |
906 `-----------------------------------*/
907 
908 static void
yy_symbol_value_print(FILE * yyo,yysymbol_kind_t yykind,YYSTYPE const * const yyvaluep,PragmaState * pState)909 yy_symbol_value_print (FILE *yyo,
910                        yysymbol_kind_t yykind, YYSTYPE const * const yyvaluep, PragmaState *pState)
911 {
912   FILE *yyoutput = yyo;
913   YYUSE (yyoutput);
914   YYUSE (pState);
915   if (!yyvaluep)
916     return;
917 # ifdef YYPRINT
918   if (yykind < YYNTOKENS)
919     YYPRINT (yyo, yytoknum[yykind], *yyvaluep);
920 # endif
921   YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
922   YYUSE (yykind);
923   YY_IGNORE_MAYBE_UNINITIALIZED_END
924 }
925 
926 
927 /*---------------------------.
928 | Print this symbol on YYO.  |
929 `---------------------------*/
930 
931 static void
yy_symbol_print(FILE * yyo,yysymbol_kind_t yykind,YYSTYPE const * const yyvaluep,PragmaState * pState)932 yy_symbol_print (FILE *yyo,
933                  yysymbol_kind_t yykind, YYSTYPE const * const yyvaluep, PragmaState *pState)
934 {
935   YYFPRINTF (yyo, "%s %s (",
936              yykind < YYNTOKENS ? "token" : "nterm", yysymbol_name (yykind));
937 
938   yy_symbol_value_print (yyo, yykind, yyvaluep, pState);
939   YYFPRINTF (yyo, ")");
940 }
941 
942 /*------------------------------------------------------------------.
943 | yy_stack_print -- Print the state stack from its BOTTOM up to its |
944 | TOP (included).                                                   |
945 `------------------------------------------------------------------*/
946 
947 static void
yy_stack_print(yy_state_t * yybottom,yy_state_t * yytop)948 yy_stack_print (yy_state_t *yybottom, yy_state_t *yytop)
949 {
950   YYFPRINTF (stderr, "Stack now");
951   for (; yybottom <= yytop; yybottom++)
952     {
953       int yybot = *yybottom;
954       YYFPRINTF (stderr, " %d", yybot);
955     }
956   YYFPRINTF (stderr, "\n");
957 }
958 
959 # define YY_STACK_PRINT(Bottom, Top)                            \
960 do {                                                            \
961   if (yydebug)                                                  \
962     yy_stack_print ((Bottom), (Top));                           \
963 } while (0)
964 
965 
966 /*------------------------------------------------.
967 | Report that the YYRULE is going to be reduced.  |
968 `------------------------------------------------*/
969 
970 static void
yy_reduce_print(yy_state_t * yyssp,YYSTYPE * yyvsp,int yyrule,PragmaState * pState)971 yy_reduce_print (yy_state_t *yyssp, YYSTYPE *yyvsp,
972                  int yyrule, PragmaState *pState)
973 {
974   int yylno = yyrline[yyrule];
975   int yynrhs = yyr2[yyrule];
976   int yyi;
977   YYFPRINTF (stderr, "Reducing stack by rule %d (line %d):\n",
978              yyrule - 1, yylno);
979   /* The symbols being reduced.  */
980   for (yyi = 0; yyi < yynrhs; yyi++)
981     {
982       YYFPRINTF (stderr, "   $%d = ", yyi + 1);
983       yy_symbol_print (stderr,
984                        YY_ACCESSING_SYMBOL (+yyssp[yyi + 1 - yynrhs]),
985                        &yyvsp[(yyi + 1) - (yynrhs)], pState);
986       YYFPRINTF (stderr, "\n");
987     }
988 }
989 
990 # define YY_REDUCE_PRINT(Rule)          \
991 do {                                    \
992   if (yydebug)                          \
993     yy_reduce_print (yyssp, yyvsp, Rule, pState); \
994 } while (0)
995 
996 /* Nonzero means print parse trace.  It is left uninitialized so that
997    multiple parsers can coexist.  */
998 int yydebug;
999 #else /* !YYDEBUG */
1000 # define YYDPRINTF(Args) ((void) 0)
1001 # define YY_SYMBOL_PRINT(Title, Kind, Value, Location)
1002 # define YY_STACK_PRINT(Bottom, Top)
1003 # define YY_REDUCE_PRINT(Rule)
1004 #endif /* !YYDEBUG */
1005 
1006 
1007 /* YYINITDEPTH -- initial size of the parser's stacks.  */
1008 #ifndef YYINITDEPTH
1009 # define YYINITDEPTH 200
1010 #endif
1011 
1012 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
1013    if the built-in stack extension method is used).
1014 
1015    Do not make this value too large; the results are undefined if
1016    YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
1017    evaluated with infinite-precision integer arithmetic.  */
1018 
1019 #ifndef YYMAXDEPTH
1020 # define YYMAXDEPTH 10000
1021 #endif
1022 
1023 
1024 /* Context of a parse error.  */
1025 typedef struct
1026 {
1027   yy_state_t *yyssp;
1028   yysymbol_kind_t yytoken;
1029 } yypcontext_t;
1030 
1031 /* Put in YYARG at most YYARGN of the expected tokens given the
1032    current YYCTX, and return the number of tokens stored in YYARG.  If
1033    YYARG is null, return the number of expected tokens (guaranteed to
1034    be less than YYNTOKENS).  Return YYENOMEM on memory exhaustion.
1035    Return 0 if there are more than YYARGN expected tokens, yet fill
1036    YYARG up to YYARGN. */
1037 static int
yypcontext_expected_tokens(const yypcontext_t * yyctx,yysymbol_kind_t yyarg[],int yyargn)1038 yypcontext_expected_tokens (const yypcontext_t *yyctx,
1039                             yysymbol_kind_t yyarg[], int yyargn)
1040 {
1041   /* Actual size of YYARG. */
1042   int yycount = 0;
1043   int yyn = yypact[+*yyctx->yyssp];
1044   if (!yypact_value_is_default (yyn))
1045     {
1046       /* Start YYX at -YYN if negative to avoid negative indexes in
1047          YYCHECK.  In other words, skip the first -YYN actions for
1048          this state because they are default actions.  */
1049       int yyxbegin = yyn < 0 ? -yyn : 0;
1050       /* Stay within bounds of both yycheck and yytname.  */
1051       int yychecklim = YYLAST - yyn + 1;
1052       int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
1053       int yyx;
1054       for (yyx = yyxbegin; yyx < yyxend; ++yyx)
1055         if (yycheck[yyx + yyn] == yyx && yyx != YYSYMBOL_YYerror
1056             && !yytable_value_is_error (yytable[yyx + yyn]))
1057           {
1058             if (!yyarg)
1059               ++yycount;
1060             else if (yycount == yyargn)
1061               return 0;
1062             else
1063               yyarg[yycount++] = YY_CAST (yysymbol_kind_t, yyx);
1064           }
1065     }
1066   if (yyarg && yycount == 0 && 0 < yyargn)
1067     yyarg[0] = YYSYMBOL_YYEMPTY;
1068   return yycount;
1069 }
1070 
1071 
1072 
1073 
1074 #ifndef yystrlen
1075 # if defined __GLIBC__ && defined _STRING_H
1076 #  define yystrlen(S) (YY_CAST (YYPTRDIFF_T, strlen (S)))
1077 # else
1078 /* Return the length of YYSTR.  */
1079 static YYPTRDIFF_T
yystrlen(const char * yystr)1080 yystrlen (const char *yystr)
1081 {
1082   YYPTRDIFF_T yylen;
1083   for (yylen = 0; yystr[yylen]; yylen++)
1084     continue;
1085   return yylen;
1086 }
1087 # endif
1088 #endif
1089 
1090 #ifndef yystpcpy
1091 # if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
1092 #  define yystpcpy stpcpy
1093 # else
1094 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
1095    YYDEST.  */
1096 static char *
yystpcpy(char * yydest,const char * yysrc)1097 yystpcpy (char *yydest, const char *yysrc)
1098 {
1099   char *yyd = yydest;
1100   const char *yys = yysrc;
1101 
1102   while ((*yyd++ = *yys++) != '\0')
1103     continue;
1104 
1105   return yyd - 1;
1106 }
1107 # endif
1108 #endif
1109 
1110 #ifndef yytnamerr
1111 /* Copy to YYRES the contents of YYSTR after stripping away unnecessary
1112    quotes and backslashes, so that it's suitable for yyerror.  The
1113    heuristic is that double-quoting is unnecessary unless the string
1114    contains an apostrophe, a comma, or backslash (other than
1115    backslash-backslash).  YYSTR is taken from yytname.  If YYRES is
1116    null, do not copy; instead, return the length of what the result
1117    would have been.  */
1118 static YYPTRDIFF_T
yytnamerr(char * yyres,const char * yystr)1119 yytnamerr (char *yyres, const char *yystr)
1120 {
1121   if (*yystr == '"')
1122     {
1123       YYPTRDIFF_T yyn = 0;
1124       char const *yyp = yystr;
1125       for (;;)
1126         switch (*++yyp)
1127           {
1128           case '\'':
1129           case ',':
1130             goto do_not_strip_quotes;
1131 
1132           case '\\':
1133             if (*++yyp != '\\')
1134               goto do_not_strip_quotes;
1135             else
1136               goto append;
1137 
1138           append:
1139           default:
1140             if (yyres)
1141               yyres[yyn] = *yyp;
1142             yyn++;
1143             break;
1144 
1145           case '"':
1146             if (yyres)
1147               yyres[yyn] = '\0';
1148             return yyn;
1149           }
1150     do_not_strip_quotes: ;
1151     }
1152 
1153   if (yyres)
1154     return yystpcpy (yyres, yystr) - yyres;
1155   else
1156     return yystrlen (yystr);
1157 }
1158 #endif
1159 
1160 
1161 static int
yy_syntax_error_arguments(const yypcontext_t * yyctx,yysymbol_kind_t yyarg[],int yyargn)1162 yy_syntax_error_arguments (const yypcontext_t *yyctx,
1163                            yysymbol_kind_t yyarg[], int yyargn)
1164 {
1165   /* Actual size of YYARG. */
1166   int yycount = 0;
1167   /* There are many possibilities here to consider:
1168      - If this state is a consistent state with a default action, then
1169        the only way this function was invoked is if the default action
1170        is an error action.  In that case, don't check for expected
1171        tokens because there are none.
1172      - The only way there can be no lookahead present (in yychar) is if
1173        this state is a consistent state with a default action.  Thus,
1174        detecting the absence of a lookahead is sufficient to determine
1175        that there is no unexpected or expected token to report.  In that
1176        case, just report a simple "syntax error".
1177      - Don't assume there isn't a lookahead just because this state is a
1178        consistent state with a default action.  There might have been a
1179        previous inconsistent state, consistent state with a non-default
1180        action, or user semantic action that manipulated yychar.
1181      - Of course, the expected token list depends on states to have
1182        correct lookahead information, and it depends on the parser not
1183        to perform extra reductions after fetching a lookahead from the
1184        scanner and before detecting a syntax error.  Thus, state merging
1185        (from LALR or IELR) and default reductions corrupt the expected
1186        token list.  However, the list is correct for canonical LR with
1187        one exception: it will still contain any token that will not be
1188        accepted due to an error action in a later state.
1189   */
1190   if (yyctx->yytoken != YYSYMBOL_YYEMPTY)
1191     {
1192       int yyn;
1193       if (yyarg)
1194         yyarg[yycount] = yyctx->yytoken;
1195       ++yycount;
1196       yyn = yypcontext_expected_tokens (yyctx,
1197                                         yyarg ? yyarg + 1 : yyarg, yyargn - 1);
1198       if (yyn == YYENOMEM)
1199         return YYENOMEM;
1200       else
1201         yycount += yyn;
1202     }
1203   return yycount;
1204 }
1205 
1206 /* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message
1207    about the unexpected token YYTOKEN for the state stack whose top is
1208    YYSSP.
1209 
1210    Return 0 if *YYMSG was successfully written.  Return -1 if *YYMSG is
1211    not large enough to hold the message.  In that case, also set
1212    *YYMSG_ALLOC to the required number of bytes.  Return YYENOMEM if the
1213    required number of bytes is too large to store.  */
1214 static int
yysyntax_error(YYPTRDIFF_T * yymsg_alloc,char ** yymsg,const yypcontext_t * yyctx)1215 yysyntax_error (YYPTRDIFF_T *yymsg_alloc, char **yymsg,
1216                 const yypcontext_t *yyctx)
1217 {
1218   enum { YYARGS_MAX = 5 };
1219   /* Internationalized format string. */
1220   const char *yyformat = YY_NULLPTR;
1221   /* Arguments of yyformat: reported tokens (one for the "unexpected",
1222      one per "expected"). */
1223   yysymbol_kind_t yyarg[YYARGS_MAX];
1224   /* Cumulated lengths of YYARG.  */
1225   YYPTRDIFF_T yysize = 0;
1226 
1227   /* Actual size of YYARG. */
1228   int yycount = yy_syntax_error_arguments (yyctx, yyarg, YYARGS_MAX);
1229   if (yycount == YYENOMEM)
1230     return YYENOMEM;
1231 
1232   switch (yycount)
1233     {
1234 #define YYCASE_(N, S)                       \
1235       case N:                               \
1236         yyformat = S;                       \
1237         break
1238     default: /* Avoid compiler warnings. */
1239       YYCASE_(0, YY_("syntax error"));
1240       YYCASE_(1, YY_("syntax error, unexpected %s"));
1241       YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s"));
1242       YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s"));
1243       YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s"));
1244       YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"));
1245 #undef YYCASE_
1246     }
1247 
1248   /* Compute error message size.  Don't count the "%s"s, but reserve
1249      room for the terminator.  */
1250   yysize = yystrlen (yyformat) - 2 * yycount + 1;
1251   {
1252     int yyi;
1253     for (yyi = 0; yyi < yycount; ++yyi)
1254       {
1255         YYPTRDIFF_T yysize1
1256           = yysize + yytnamerr (YY_NULLPTR, yytname[yyarg[yyi]]);
1257         if (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM)
1258           yysize = yysize1;
1259         else
1260           return YYENOMEM;
1261       }
1262   }
1263 
1264   if (*yymsg_alloc < yysize)
1265     {
1266       *yymsg_alloc = 2 * yysize;
1267       if (! (yysize <= *yymsg_alloc
1268              && *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM))
1269         *yymsg_alloc = YYSTACK_ALLOC_MAXIMUM;
1270       return -1;
1271     }
1272 
1273   /* Avoid sprintf, as that infringes on the user's name space.
1274      Don't have undefined behavior even if the translation
1275      produced a string with the wrong number of "%s"s.  */
1276   {
1277     char *yyp = *yymsg;
1278     int yyi = 0;
1279     while ((*yyp = *yyformat) != '\0')
1280       if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount)
1281         {
1282           yyp += yytnamerr (yyp, yytname[yyarg[yyi++]]);
1283           yyformat += 2;
1284         }
1285       else
1286         {
1287           ++yyp;
1288           ++yyformat;
1289         }
1290   }
1291   return 0;
1292 }
1293 
1294 
1295 /*-----------------------------------------------.
1296 | Release the memory associated to this symbol.  |
1297 `-----------------------------------------------*/
1298 
1299 static void
yydestruct(const char * yymsg,yysymbol_kind_t yykind,YYSTYPE * yyvaluep,PragmaState * pState)1300 yydestruct (const char *yymsg,
1301             yysymbol_kind_t yykind, YYSTYPE *yyvaluep, PragmaState *pState)
1302 {
1303   YYUSE (yyvaluep);
1304   YYUSE (pState);
1305   if (!yymsg)
1306     yymsg = "Deleting";
1307   YY_SYMBOL_PRINT (yymsg, yykind, yyvaluep, yylocationp);
1308 
1309   YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1310   YYUSE (yykind);
1311   YY_IGNORE_MAYBE_UNINITIALIZED_END
1312 }
1313 
1314 
1315 
1316 
1317 
1318 
1319 /*----------.
1320 | yyparse.  |
1321 `----------*/
1322 
1323 int
yyparse(PragmaState * pState)1324 yyparse (PragmaState *pState)
1325 {
1326 /* Lookahead token kind.  */
1327 int yychar;
1328 
1329 
1330 /* The semantic value of the lookahead symbol.  */
1331 /* Default value used for initialization, for pacifying older GCCs
1332    or non-GCC compilers.  */
1333 YY_INITIAL_VALUE (static YYSTYPE yyval_default;)
1334 YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default);
1335 
1336     /* Number of syntax errors so far.  */
1337     int yynerrs = 0;
1338 
1339     yy_state_fast_t yystate = 0;
1340     /* Number of tokens to shift before error messages enabled.  */
1341     int yyerrstatus = 0;
1342 
1343     /* Refer to the stacks through separate pointers, to allow yyoverflow
1344        to reallocate them elsewhere.  */
1345 
1346     /* Their size.  */
1347     YYPTRDIFF_T yystacksize = YYINITDEPTH;
1348 
1349     /* The state stack: array, bottom, top.  */
1350     yy_state_t yyssa[YYINITDEPTH];
1351     yy_state_t *yyss = yyssa;
1352     yy_state_t *yyssp = yyss;
1353 
1354     /* The semantic value stack: array, bottom, top.  */
1355     YYSTYPE yyvsa[YYINITDEPTH];
1356     YYSTYPE *yyvs = yyvsa;
1357     YYSTYPE *yyvsp = yyvs;
1358 
1359   int yyn;
1360   /* The return value of yyparse.  */
1361   int yyresult;
1362   /* Lookahead symbol kind.  */
1363   yysymbol_kind_t yytoken = YYSYMBOL_YYEMPTY;
1364   /* The variables used to return semantic value and location from the
1365      action routines.  */
1366   YYSTYPE yyval;
1367 
1368   /* Buffer for error messages, and its allocated size.  */
1369   char yymsgbuf[128];
1370   char *yymsg = yymsgbuf;
1371   YYPTRDIFF_T yymsg_alloc = sizeof yymsgbuf;
1372 
1373 #define YYPOPSTACK(N)   (yyvsp -= (N), yyssp -= (N))
1374 
1375   /* The number of symbols on the RHS of the reduced rule.
1376      Keep to zero when no symbol should be popped.  */
1377   int yylen = 0;
1378 
1379   YYDPRINTF ((stderr, "Starting parse\n"));
1380 
1381   yychar = YYEMPTY; /* Cause a token to be read.  */
1382   goto yysetstate;
1383 
1384 
1385 /*------------------------------------------------------------.
1386 | yynewstate -- push a new state, which is found in yystate.  |
1387 `------------------------------------------------------------*/
1388 yynewstate:
1389   /* In all cases, when you get here, the value and location stacks
1390      have just been pushed.  So pushing a state here evens the stacks.  */
1391   yyssp++;
1392 
1393 
1394 /*--------------------------------------------------------------------.
1395 | yysetstate -- set current state (the top of the stack) to yystate.  |
1396 `--------------------------------------------------------------------*/
1397 yysetstate:
1398   YYDPRINTF ((stderr, "Entering state %d\n", yystate));
1399   YY_ASSERT (0 <= yystate && yystate < YYNSTATES);
1400   YY_IGNORE_USELESS_CAST_BEGIN
1401   *yyssp = YY_CAST (yy_state_t, yystate);
1402   YY_IGNORE_USELESS_CAST_END
1403   YY_STACK_PRINT (yyss, yyssp);
1404 
1405   if (yyss + yystacksize - 1 <= yyssp)
1406 #if !defined yyoverflow && !defined YYSTACK_RELOCATE
1407     goto yyexhaustedlab;
1408 #else
1409     {
1410       /* Get the current used size of the three stacks, in elements.  */
1411       YYPTRDIFF_T yysize = yyssp - yyss + 1;
1412 
1413 # if defined yyoverflow
1414       {
1415         /* Give user a chance to reallocate the stack.  Use copies of
1416            these so that the &'s don't force the real ones into
1417            memory.  */
1418         yy_state_t *yyss1 = yyss;
1419         YYSTYPE *yyvs1 = yyvs;
1420 
1421         /* Each stack pointer address is followed by the size of the
1422            data in use in that stack, in bytes.  This used to be a
1423            conditional around just the two extra args, but that might
1424            be undefined if yyoverflow is a macro.  */
1425         yyoverflow (YY_("memory exhausted"),
1426                     &yyss1, yysize * YYSIZEOF (*yyssp),
1427                     &yyvs1, yysize * YYSIZEOF (*yyvsp),
1428                     &yystacksize);
1429         yyss = yyss1;
1430         yyvs = yyvs1;
1431       }
1432 # else /* defined YYSTACK_RELOCATE */
1433       /* Extend the stack our own way.  */
1434       if (YYMAXDEPTH <= yystacksize)
1435         goto yyexhaustedlab;
1436       yystacksize *= 2;
1437       if (YYMAXDEPTH < yystacksize)
1438         yystacksize = YYMAXDEPTH;
1439 
1440       {
1441         yy_state_t *yyss1 = yyss;
1442         union yyalloc *yyptr =
1443           YY_CAST (union yyalloc *,
1444                    YYSTACK_ALLOC (YY_CAST (YYSIZE_T, YYSTACK_BYTES (yystacksize))));
1445         if (! yyptr)
1446           goto yyexhaustedlab;
1447         YYSTACK_RELOCATE (yyss_alloc, yyss);
1448         YYSTACK_RELOCATE (yyvs_alloc, yyvs);
1449 #  undef YYSTACK_RELOCATE
1450         if (yyss1 != yyssa)
1451           YYSTACK_FREE (yyss1);
1452       }
1453 # endif
1454 
1455       yyssp = yyss + yysize - 1;
1456       yyvsp = yyvs + yysize - 1;
1457 
1458       YY_IGNORE_USELESS_CAST_BEGIN
1459       YYDPRINTF ((stderr, "Stack size increased to %ld\n",
1460                   YY_CAST (long, yystacksize)));
1461       YY_IGNORE_USELESS_CAST_END
1462 
1463       if (yyss + yystacksize - 1 <= yyssp)
1464         YYABORT;
1465     }
1466 #endif /* !defined yyoverflow && !defined YYSTACK_RELOCATE */
1467 
1468   if (yystate == YYFINAL)
1469     YYACCEPT;
1470 
1471   goto yybackup;
1472 
1473 
1474 /*-----------.
1475 | yybackup.  |
1476 `-----------*/
1477 yybackup:
1478   /* Do appropriate processing given the current state.  Read a
1479      lookahead token if we need one and don't already have one.  */
1480 
1481   /* First try to decide what to do without reference to lookahead token.  */
1482   yyn = yypact[yystate];
1483   if (yypact_value_is_default (yyn))
1484     goto yydefault;
1485 
1486   /* Not known => get a lookahead token if don't already have one.  */
1487 
1488   /* YYCHAR is either empty, or end-of-input, or a valid lookahead.  */
1489   if (yychar == YYEMPTY)
1490     {
1491       YYDPRINTF ((stderr, "Reading a token\n"));
1492       yychar = yylex (&yylval, pState);
1493     }
1494 
1495   if (yychar <= YYEOF)
1496     {
1497       yychar = YYEOF;
1498       yytoken = YYSYMBOL_YYEOF;
1499       YYDPRINTF ((stderr, "Now at end of input.\n"));
1500     }
1501   else if (yychar == YYerror)
1502     {
1503       /* The scanner already issued an error message, process directly
1504          to error recovery.  But do not keep the error token as
1505          lookahead, it is too special and may lead us to an endless
1506          loop in error recovery. */
1507       yychar = YYUNDEF;
1508       yytoken = YYSYMBOL_YYerror;
1509       goto yyerrlab1;
1510     }
1511   else
1512     {
1513       yytoken = YYTRANSLATE (yychar);
1514       YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
1515     }
1516 
1517   /* If the proper action on seeing token YYTOKEN is to reduce or to
1518      detect an error, take that action.  */
1519   yyn += yytoken;
1520   if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
1521     goto yydefault;
1522   yyn = yytable[yyn];
1523   if (yyn <= 0)
1524     {
1525       if (yytable_value_is_error (yyn))
1526         goto yyerrlab;
1527       yyn = -yyn;
1528       goto yyreduce;
1529     }
1530 
1531   /* Count tokens shifted since error; after three, turn off error
1532      status.  */
1533   if (yyerrstatus)
1534     yyerrstatus--;
1535 
1536   /* Shift the lookahead token.  */
1537   YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
1538   yystate = yyn;
1539   YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1540   *++yyvsp = yylval;
1541   YY_IGNORE_MAYBE_UNINITIALIZED_END
1542 
1543   /* Discard the shifted token.  */
1544   yychar = YYEMPTY;
1545   goto yynewstate;
1546 
1547 
1548 /*-----------------------------------------------------------.
1549 | yydefault -- do the default action for the current state.  |
1550 `-----------------------------------------------------------*/
1551 yydefault:
1552   yyn = yydefact[yystate];
1553   if (yyn == 0)
1554     goto yyerrlab;
1555   goto yyreduce;
1556 
1557 
1558 /*-----------------------------.
1559 | yyreduce -- do a reduction.  |
1560 `-----------------------------*/
1561 yyreduce:
1562   /* yyn is the number of a rule to reduce with.  */
1563   yylen = yyr2[yyn];
1564 
1565   /* If YYLEN is nonzero, implement the default value of the action:
1566      '$$ = $1'.
1567 
1568      Otherwise, the following line sets YYVAL to garbage.
1569      This behavior is undocumented and Bison
1570      users should not rely upon it.  Assigning to YYVAL
1571      unconditionally makes the parser a bit smaller, and it avoids a
1572      GCC warning that YYVAL may be used uninitialized.  */
1573   yyval = yyvsp[1-yylen];
1574 
1575 
1576   YY_REDUCE_PRINT (yyn);
1577   switch (yyn)
1578     {
1579   case 3: /* pragma_pack: PACK_TOK  */
1580 #line 223 "ctlib/pragma.y"
1581           { PSTATE->pack.current = 0; }
1582 #line 1583 "ctlib/y_pragma.c"
1583     break;
1584 
1585   case 4: /* pragma_pack: PACK_TOK '(' ')'  */
1586 #line 225 "ctlib/pragma.y"
1587           { PSTATE->pack.current = 0; }
1588 #line 1589 "ctlib/y_pragma.c"
1589     break;
1590 
1591   case 6: /* pragma_pack_args: CONSTANT  */
1592 #line 231 "ctlib/pragma.y"
1593           {
1594 	    if (is_valid_pack_arg(PSTATE, (yyvsp[0].ival)))
1595 	    {
1596 	      PSTATE->pack.current = (yyvsp[0].ival);
1597 	    }
1598 	  }
1599 #line 1600 "ctlib/y_pragma.c"
1600     break;
1601 
1602   case 7: /* pragma_pack_args: PUSH_TOK ',' CONSTANT  */
1603 #line 238 "ctlib/pragma.y"
1604           {
1605 	    if (is_valid_pack_arg(PSTATE, (yyvsp[0].ival)))
1606 	    {
1607 	      LL_push(PSTATE->pack.stack, packelem_new(PSTATE->pack.current));
1608 	      PSTATE->pack.current = (yyvsp[0].ival);
1609 	    }
1610 	  }
1611 #line 1612 "ctlib/y_pragma.c"
1612     break;
1613 
1614   case 8: /* pragma_pack_args: POP_TOK  */
1615 #line 246 "ctlib/pragma.y"
1616           {
1617 	    PackElement *pPack = LL_pop(PSTATE->pack.stack);
1618 
1619 	    if (pPack)
1620 	    {
1621 	      PSTATE->pack.current = pPack->size;
1622 	      packelem_delete(pPack);
1623 	    }
1624 	    else
1625 	      PSTATE->pack.current = 0;
1626 	  }
1627 #line 1628 "ctlib/y_pragma.c"
1628     break;
1629 
1630 
1631 #line 1632 "ctlib/y_pragma.c"
1632 
1633       default: break;
1634     }
1635   /* User semantic actions sometimes alter yychar, and that requires
1636      that yytoken be updated with the new translation.  We take the
1637      approach of translating immediately before every use of yytoken.
1638      One alternative is translating here after every semantic action,
1639      but that translation would be missed if the semantic action invokes
1640      YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or
1641      if it invokes YYBACKUP.  In the case of YYABORT or YYACCEPT, an
1642      incorrect destructor might then be invoked immediately.  In the
1643      case of YYERROR or YYBACKUP, subsequent parser actions might lead
1644      to an incorrect destructor call or verbose syntax error message
1645      before the lookahead is translated.  */
1646   YY_SYMBOL_PRINT ("-> $$ =", YY_CAST (yysymbol_kind_t, yyr1[yyn]), &yyval, &yyloc);
1647 
1648   YYPOPSTACK (yylen);
1649   yylen = 0;
1650 
1651   *++yyvsp = yyval;
1652 
1653   /* Now 'shift' the result of the reduction.  Determine what state
1654      that goes to, based on the state we popped back to and the rule
1655      number reduced by.  */
1656   {
1657     const int yylhs = yyr1[yyn] - YYNTOKENS;
1658     const int yyi = yypgoto[yylhs] + *yyssp;
1659     yystate = (0 <= yyi && yyi <= YYLAST && yycheck[yyi] == *yyssp
1660                ? yytable[yyi]
1661                : yydefgoto[yylhs]);
1662   }
1663 
1664   goto yynewstate;
1665 
1666 
1667 /*--------------------------------------.
1668 | yyerrlab -- here on detecting error.  |
1669 `--------------------------------------*/
1670 yyerrlab:
1671   /* Make sure we have latest lookahead translation.  See comments at
1672      user semantic actions for why this is necessary.  */
1673   yytoken = yychar == YYEMPTY ? YYSYMBOL_YYEMPTY : YYTRANSLATE (yychar);
1674   /* If not already recovering from an error, report this error.  */
1675   if (!yyerrstatus)
1676     {
1677       ++yynerrs;
1678       {
1679         yypcontext_t yyctx
1680           = {yyssp, yytoken};
1681         char const *yymsgp = YY_("syntax error");
1682         int yysyntax_error_status;
1683         yysyntax_error_status = yysyntax_error (&yymsg_alloc, &yymsg, &yyctx);
1684         if (yysyntax_error_status == 0)
1685           yymsgp = yymsg;
1686         else if (yysyntax_error_status == -1)
1687           {
1688             if (yymsg != yymsgbuf)
1689               YYSTACK_FREE (yymsg);
1690             yymsg = YY_CAST (char *,
1691                              YYSTACK_ALLOC (YY_CAST (YYSIZE_T, yymsg_alloc)));
1692             if (yymsg)
1693               {
1694                 yysyntax_error_status
1695                   = yysyntax_error (&yymsg_alloc, &yymsg, &yyctx);
1696                 yymsgp = yymsg;
1697               }
1698             else
1699               {
1700                 yymsg = yymsgbuf;
1701                 yymsg_alloc = sizeof yymsgbuf;
1702                 yysyntax_error_status = YYENOMEM;
1703               }
1704           }
1705         yyerror (pState, yymsgp);
1706         if (yysyntax_error_status == YYENOMEM)
1707           goto yyexhaustedlab;
1708       }
1709     }
1710 
1711   if (yyerrstatus == 3)
1712     {
1713       /* If just tried and failed to reuse lookahead token after an
1714          error, discard it.  */
1715 
1716       if (yychar <= YYEOF)
1717         {
1718           /* Return failure if at end of input.  */
1719           if (yychar == YYEOF)
1720             YYABORT;
1721         }
1722       else
1723         {
1724           yydestruct ("Error: discarding",
1725                       yytoken, &yylval, pState);
1726           yychar = YYEMPTY;
1727         }
1728     }
1729 
1730   /* Else will try to reuse lookahead token after shifting the error
1731      token.  */
1732   goto yyerrlab1;
1733 
1734 
1735 /*---------------------------------------------------.
1736 | yyerrorlab -- error raised explicitly by YYERROR.  |
1737 `---------------------------------------------------*/
1738 yyerrorlab:
1739   /* Pacify compilers when the user code never invokes YYERROR and the
1740      label yyerrorlab therefore never appears in user code.  */
1741   if (0)
1742     YYERROR;
1743 
1744   /* Do not reclaim the symbols of the rule whose action triggered
1745      this YYERROR.  */
1746   YYPOPSTACK (yylen);
1747   yylen = 0;
1748   YY_STACK_PRINT (yyss, yyssp);
1749   yystate = *yyssp;
1750   goto yyerrlab1;
1751 
1752 
1753 /*-------------------------------------------------------------.
1754 | yyerrlab1 -- common code for both syntax error and YYERROR.  |
1755 `-------------------------------------------------------------*/
1756 yyerrlab1:
1757   yyerrstatus = 3;      /* Each real token shifted decrements this.  */
1758 
1759   /* Pop stack until we find a state that shifts the error token.  */
1760   for (;;)
1761     {
1762       yyn = yypact[yystate];
1763       if (!yypact_value_is_default (yyn))
1764         {
1765           yyn += YYSYMBOL_YYerror;
1766           if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYSYMBOL_YYerror)
1767             {
1768               yyn = yytable[yyn];
1769               if (0 < yyn)
1770                 break;
1771             }
1772         }
1773 
1774       /* Pop the current state because it cannot handle the error token.  */
1775       if (yyssp == yyss)
1776         YYABORT;
1777 
1778 
1779       yydestruct ("Error: popping",
1780                   YY_ACCESSING_SYMBOL (yystate), yyvsp, pState);
1781       YYPOPSTACK (1);
1782       yystate = *yyssp;
1783       YY_STACK_PRINT (yyss, yyssp);
1784     }
1785 
1786   YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1787   *++yyvsp = yylval;
1788   YY_IGNORE_MAYBE_UNINITIALIZED_END
1789 
1790 
1791   /* Shift the error token.  */
1792   YY_SYMBOL_PRINT ("Shifting", YY_ACCESSING_SYMBOL (yyn), yyvsp, yylsp);
1793 
1794   yystate = yyn;
1795   goto yynewstate;
1796 
1797 
1798 /*-------------------------------------.
1799 | yyacceptlab -- YYACCEPT comes here.  |
1800 `-------------------------------------*/
1801 yyacceptlab:
1802   yyresult = 0;
1803   goto yyreturn;
1804 
1805 
1806 /*-----------------------------------.
1807 | yyabortlab -- YYABORT comes here.  |
1808 `-----------------------------------*/
1809 yyabortlab:
1810   yyresult = 1;
1811   goto yyreturn;
1812 
1813 
1814 #if 1
1815 /*-------------------------------------------------.
1816 | yyexhaustedlab -- memory exhaustion comes here.  |
1817 `-------------------------------------------------*/
1818 yyexhaustedlab:
1819   yyerror (pState, YY_("memory exhausted"));
1820   yyresult = 2;
1821   goto yyreturn;
1822 #endif
1823 
1824 
1825 /*-------------------------------------------------------.
1826 | yyreturn -- parsing is finished, clean up and return.  |
1827 `-------------------------------------------------------*/
1828 yyreturn:
1829   if (yychar != YYEMPTY)
1830     {
1831       /* Make sure we have latest lookahead translation.  See comments at
1832          user semantic actions for why this is necessary.  */
1833       yytoken = YYTRANSLATE (yychar);
1834       yydestruct ("Cleanup: discarding lookahead",
1835                   yytoken, &yylval, pState);
1836     }
1837   /* Do not reclaim the symbols of the rule whose action triggered
1838      this YYABORT or YYACCEPT.  */
1839   YYPOPSTACK (yylen);
1840   YY_STACK_PRINT (yyss, yyssp);
1841   while (yyssp != yyss)
1842     {
1843       yydestruct ("Cleanup: popping",
1844                   YY_ACCESSING_SYMBOL (+*yyssp), yyvsp, pState);
1845       YYPOPSTACK (1);
1846     }
1847 #ifndef yyoverflow
1848   if (yyss != yyssa)
1849     YYSTACK_FREE (yyss);
1850 #endif
1851   if (yymsg != yymsgbuf)
1852     YYSTACK_FREE (yymsg);
1853   return yyresult;
1854 }
1855 
1856 #line 259 "ctlib/pragma.y"
1857 
1858 
1859 /*===== STATIC FUNCTIONS =====================================================*/
1860 
1861 /*******************************************************************************
1862 *
1863 *   ROUTINE: is_valid_pack_arg
1864 *
1865 *   WRITTEN BY: Marcus Holland-Moritz             ON: Jun 2007
1866 *   CHANGED BY:                                   ON:
1867 *
1868 ********************************************************************************
1869 *
1870 * DESCRIPTION: Pack element constructor.
1871 *
1872 *   ARGUMENTS:
1873 *
1874 *     RETURNS:
1875 *
1876 *******************************************************************************/
1877 
is_valid_pack_arg(PragmaState * pState,int arg)1878 static int is_valid_pack_arg(PragmaState *pState, int arg)
1879 {
1880   if (VALID_PACK(arg))
1881     return 1;
1882 
1883   push_error(pState->pCPI, "%s, line %ld: invalid argument %d to #pragma pack",
1884              pState->file, pState->line, arg);
1885 
1886   return 0;
1887 }
1888 
1889 /*******************************************************************************
1890 *
1891 *   ROUTINE: packelem_new
1892 *
1893 *   WRITTEN BY: Marcus Holland-Moritz             ON: Jan 2002
1894 *   CHANGED BY:                                   ON:
1895 *
1896 ********************************************************************************
1897 *
1898 * DESCRIPTION: Pack element constructor.
1899 *
1900 *   ARGUMENTS:
1901 *
1902 *     RETURNS:
1903 *
1904 *******************************************************************************/
1905 
packelem_new(unsigned size)1906 static PackElement *packelem_new(unsigned size)
1907 {
1908   PackElement *pPack;
1909 
1910   AllocF(PackElement *, pPack, sizeof(PackElement));
1911 
1912   pPack->size = size;
1913 
1914   return pPack;
1915 }
1916 
1917 /*******************************************************************************
1918 *
1919 *   ROUTINE: packelem_delete
1920 *
1921 *   WRITTEN BY: Marcus Holland-Moritz             ON: Jan 2002
1922 *   CHANGED BY:                                   ON:
1923 *
1924 ********************************************************************************
1925 *
1926 * DESCRIPTION: Pack element destructor.
1927 *
1928 *   ARGUMENTS:
1929 *
1930 *     RETURNS:
1931 *
1932 *******************************************************************************/
1933 
packelem_delete(PackElement * pPack)1934 static void packelem_delete(PackElement *pPack)
1935 {
1936   if (pPack)
1937     Free(pPack);
1938 }
1939 
1940 /*******************************************************************************
1941 *
1942 *   ROUTINE: pragma_lex
1943 *
1944 *   WRITTEN BY: Marcus Holland-Moritz             ON: Jan 2002
1945 *   CHANGED BY:                                   ON:
1946 *
1947 ********************************************************************************
1948 *
1949 * DESCRIPTION: Pragma lexer.
1950 *
1951 *   ARGUMENTS:
1952 *
1953 *     RETURNS:
1954 *
1955 *******************************************************************************/
1956 
pragma_lex(YYSTYPE * plval,PragmaState * pState)1957 static inline int pragma_lex(YYSTYPE *plval, PragmaState *pState)
1958 {
1959   int token, rval;
1960 
1961   CT_DEBUG( PRAGMA, ("pragma_lex()"));
1962 
1963   while ((token = (int) *pState->code++) != 0)
1964   {
1965     switch (token)
1966     {
1967       case NUMBER:
1968         {
1969           const char *num = pState->code;
1970 
1971           pState->code = strchr(num, PRAGMA_TOKEN_END) + 1;
1972           plval->ival = strtol(num, NULL, 0);
1973 
1974           CT_DEBUG(PRAGMA, ("pragma - constant: %d", plval->ival));
1975 
1976           return CONSTANT;
1977         }
1978 
1979       case NAME:
1980         {
1981           const char *tokstr = pState->code;
1982           int toklen, tokval;
1983 
1984 #include "token/t_pragma.c"
1985 
1986         success:
1987           pState->code += toklen + 1;
1988           return tokval;
1989 
1990         unknown:
1991           break;
1992         }
1993 
1994       default:
1995         if ((rval = tokentab[token]) != 0)
1996           return rval;
1997 
1998         break;
1999     }
2000   }
2001 
2002   return 0;
2003 }
2004 
2005 
2006 /*===== FUNCTIONS ============================================================*/
2007 
2008 /*******************************************************************************
2009 *
2010 *   ROUTINE: pragma_parser_parse
2011 *
2012 *   WRITTEN BY: Marcus Holland-Moritz             ON: Jun 2007
2013 *   CHANGED BY:                                   ON:
2014 *
2015 ********************************************************************************
2016 *
2017 * DESCRIPTION:
2018 *
2019 *   ARGUMENTS:
2020 *
2021 *     RETURNS:
2022 *
2023 *******************************************************************************/
2024 
pragma_parser_parse(PragmaState * pPragma)2025 int pragma_parser_parse(PragmaState *pPragma)
2026 {
2027   return pragma_parse(pPragma);
2028 }
2029 
2030 /*******************************************************************************
2031 *
2032 *   ROUTINE: pragma_parser_new
2033 *
2034 *   WRITTEN BY: Marcus Holland-Moritz             ON: Jan 2002
2035 *   CHANGED BY:                                   ON:
2036 *
2037 ********************************************************************************
2038 *
2039 * DESCRIPTION:
2040 *
2041 *   ARGUMENTS:
2042 *
2043 *     RETURNS:
2044 *
2045 *******************************************************************************/
2046 
pragma_parser_new(CParseInfo * pCPI)2047 PragmaState *pragma_parser_new(CParseInfo *pCPI)
2048 {
2049   PragmaState *pState;
2050 
2051   CT_DEBUG(PRAGMA, ("pragma_parser_new"));
2052 
2053   AllocF(PragmaState *, pState, sizeof(PragmaState));
2054 
2055   pState->pCPI = pCPI;
2056   pState->file = 0;
2057   pState->line = 0;
2058   pState->code = 0;
2059   pState->pack.stack = LL_new();
2060   pState->pack.current = 0;
2061 
2062   return pState;
2063 }
2064 
2065 /*******************************************************************************
2066 *
2067 *   ROUTINE: pragma_parser_delete
2068 *
2069 *   WRITTEN BY: Marcus Holland-Moritz             ON: Jan 2002
2070 *   CHANGED BY:                                   ON:
2071 *
2072 ********************************************************************************
2073 *
2074 * DESCRIPTION:
2075 *
2076 *   ARGUMENTS:
2077 *
2078 *     RETURNS:
2079 *
2080 *******************************************************************************/
2081 
pragma_parser_delete(PragmaState * pPragma)2082 void pragma_parser_delete(PragmaState *pPragma)
2083 {
2084   if (pPragma)
2085   {
2086     CT_DEBUG(PRAGMA, ("pragma_parser_delete"));
2087     LL_destroy(pPragma->pack.stack, (LLDestroyFunc) packelem_delete);
2088     Free(pPragma);
2089   }
2090 }
2091 
2092 /*******************************************************************************
2093 *
2094 *   ROUTINE: pragma_parser_set_context
2095 *
2096 *   WRITTEN BY: Marcus Holland-Moritz             ON: Jun 2007
2097 *   CHANGED BY:                                   ON:
2098 *
2099 ********************************************************************************
2100 *
2101 * DESCRIPTION:
2102 *
2103 *   ARGUMENTS:
2104 *
2105 *     RETURNS:
2106 *
2107 *******************************************************************************/
2108 
pragma_parser_set_context(PragmaState * pPragma,const char * file,long int line,const char * code)2109 void pragma_parser_set_context(PragmaState *pPragma, const char *file, long int line, const char *code)
2110 {
2111   pPragma->file = file;
2112   pPragma->line = line;
2113   pPragma->code = code;
2114 }
2115 
2116 /*******************************************************************************
2117 *
2118 *   ROUTINE: pragma_parser_get_pack
2119 *
2120 *   WRITTEN BY: Marcus Holland-Moritz             ON: Jun 2007
2121 *   CHANGED BY:                                   ON:
2122 *
2123 ********************************************************************************
2124 *
2125 * DESCRIPTION:
2126 *
2127 *   ARGUMENTS:
2128 *
2129 *     RETURNS:
2130 *
2131 *******************************************************************************/
2132 
pragma_parser_get_pack(PragmaState * pPragma)2133 unsigned pragma_parser_get_pack(PragmaState *pPragma)
2134 {
2135   return pPragma->pack.current;
2136 }
2137 
2138