1 /* A Bison parser, made by GNU Bison 3.0.2.  */
2 
3 /* Bison implementation for Yacc-like parsers in C
4 
5    Copyright (C) 1984, 1989-1990, 2000-2013 Free Software Foundation, Inc.
6 
7    This program is free software: you can redistribute it and/or modify
8    it under the terms of the GNU General Public License as published by
9    the Free Software Foundation, either version 3 of the License, or
10    (at your option) any later version.
11 
12    This program is distributed in the hope that it will be useful,
13    but WITHOUT ANY WARRANTY; without even the implied warranty of
14    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15    GNU General Public License for more details.
16 
17    You should have received a copy of the GNU General Public License
18    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
19 
20 /* As a special exception, you may create a larger work that contains
21    part or all of the Bison parser skeleton and distribute that work
22    under terms of your choice, so long as that work isn't itself a
23    parser generator using the skeleton or a modified version thereof
24    as a parser skeleton.  Alternatively, if you modify or redistribute
25    the parser skeleton itself, you may (at your option) remove this
26    special exception, which will cause the skeleton and the resulting
27    Bison output files to be licensed under the GNU General Public
28    License without this special exception.
29 
30    This special exception was added by the Free Software Foundation in
31    version 2.2 of Bison.  */
32 
33 /* C LALR(1) parser skeleton written by Richard Stallman, by
34    simplifying the original so-called "semantic" parser.  */
35 
36 /* All symbols defined below should begin with yy or YY, to avoid
37    infringing on user name space.  This should be done even for local
38    variables, as they might otherwise be expanded by user macros.
39    There are some unavoidable exceptions within include files to
40    define necessary library symbols; they are noted "INFRINGES ON
41    USER NAME SPACE" below.  */
42 
43 /* Identify Bison output.  */
44 #define YYBISON 1
45 
46 /* Bison version.  */
47 #define YYBISON_VERSION "3.0.2"
48 
49 /* Skeleton name.  */
50 #define YYSKELETON_NAME "yacc.c"
51 
52 /* Pure parsers.  */
53 #define YYPURE 0
54 
55 /* Push parsers.  */
56 #define YYPUSH 0
57 
58 /* Pull parsers.  */
59 #define YYPULL 1
60 
61 
62 
63 
64 /* Copy the first part of user declarations.  */
65 #line 1 "code/tools/lcc/lburg/gram.y" /* yacc.c:339  */
66 
67 #include <stdio.h>
68 #include "lburg.h"
69 //static char rcsid[] = "$Id: gram.y 145 2001-10-17 21:53:10Z timo $";
70 /*lint -e616 -e527 -e652 -esym(552,yynerrs) -esym(563,yynewstate,yyerrlab) */
71 static int yylineno = 0;
72 
73 #line 74 "y.tab.c" /* yacc.c:339  */
74 
75 # ifndef YY_NULLPTR
76 #  if defined __cplusplus && 201103L <= __cplusplus
77 #   define YY_NULLPTR nullptr
78 #  else
79 #   define YY_NULLPTR 0
80 #  endif
81 # endif
82 
83 /* Enabling verbose error messages.  */
84 #ifdef YYERROR_VERBOSE
85 # undef YYERROR_VERBOSE
86 # define YYERROR_VERBOSE 1
87 #else
88 # define YYERROR_VERBOSE 0
89 #endif
90 
91 
92 /* Debug traces.  */
93 #ifndef YYDEBUG
94 # define YYDEBUG 0
95 #endif
96 #if YYDEBUG
97 extern int yydebug;
98 #endif
99 
100 /* Token type.  */
101 #ifndef YYTOKENTYPE
102 # define YYTOKENTYPE
103   enum yytokentype
104   {
105     TERMINAL = 258,
106     START = 259,
107     PPERCENT = 260,
108     ID = 261,
109     TEMPLATE = 262,
110     CODE = 263,
111     INT = 264
112   };
113 #endif
114 /* Tokens.  */
115 #define TERMINAL 258
116 #define START 259
117 #define PPERCENT 260
118 #define ID 261
119 #define TEMPLATE 262
120 #define CODE 263
121 #define INT 264
122 
123 /* Value type.  */
124 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
125 typedef union YYSTYPE YYSTYPE;
126 union YYSTYPE
127 {
128 #line 8 "code/tools/lcc/lburg/gram.y" /* yacc.c:355  */
129 
130 	int n;
131 	char *string;
132 	Tree tree;
133 
134 #line 135 "y.tab.c" /* yacc.c:355  */
135 };
136 # define YYSTYPE_IS_TRIVIAL 1
137 # define YYSTYPE_IS_DECLARED 1
138 #endif
139 
140 
141 extern YYSTYPE yylval;
142 
143 int yyparse (void);
144 int yylex(void);
145 
146 
147 
148 /* Copy the second part of user declarations.  */
149 
150 #line 150 "y.tab.c" /* yacc.c:358  */
151 
152 #ifdef short
153 # undef short
154 #endif
155 
156 #ifdef YYTYPE_UINT8
157 typedef YYTYPE_UINT8 yytype_uint8;
158 #else
159 typedef unsigned char yytype_uint8;
160 #endif
161 
162 #ifdef YYTYPE_INT8
163 typedef YYTYPE_INT8 yytype_int8;
164 #else
165 typedef signed char yytype_int8;
166 #endif
167 
168 #ifdef YYTYPE_UINT16
169 typedef YYTYPE_UINT16 yytype_uint16;
170 #else
171 typedef unsigned short int yytype_uint16;
172 #endif
173 
174 #ifdef YYTYPE_INT16
175 typedef YYTYPE_INT16 yytype_int16;
176 #else
177 typedef short int yytype_int16;
178 #endif
179 
180 #ifndef YYSIZE_T
181 # ifdef __SIZE_TYPE__
182 #  define YYSIZE_T __SIZE_TYPE__
183 # elif defined size_t
184 #  define YYSIZE_T size_t
185 # elif ! defined YYSIZE_T
186 #  include <stddef.h> /* INFRINGES ON USER NAME SPACE */
187 #  define YYSIZE_T size_t
188 # else
189 #  define YYSIZE_T unsigned int
190 # endif
191 #endif
192 
193 #define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
194 
195 #ifndef YY_
196 # if defined YYENABLE_NLS && YYENABLE_NLS
197 #  if ENABLE_NLS
198 #   include <libintl.h> /* INFRINGES ON USER NAME SPACE */
199 #   define YY_(Msgid) dgettext ("bison-runtime", Msgid)
200 #  endif
201 # endif
202 # ifndef YY_
203 #  define YY_(Msgid) Msgid
204 # endif
205 #endif
206 
207 #ifndef YY_ATTRIBUTE
208 # if (defined __GNUC__                                               \
209       && (2 < __GNUC__ || (__GNUC__ == 2 && 96 <= __GNUC_MINOR__)))  \
210      || defined __SUNPRO_C && 0x5110 <= __SUNPRO_C
211 #  define YY_ATTRIBUTE(Spec) __attribute__(Spec)
212 # else
213 #  define YY_ATTRIBUTE(Spec) /* empty */
214 # endif
215 #endif
216 
217 #ifndef YY_ATTRIBUTE_PURE
218 # define YY_ATTRIBUTE_PURE   YY_ATTRIBUTE ((__pure__))
219 #endif
220 
221 #ifndef YY_ATTRIBUTE_UNUSED
222 # define YY_ATTRIBUTE_UNUSED YY_ATTRIBUTE ((__unused__))
223 #endif
224 
225 #if !defined _Noreturn \
226      && (!defined __STDC_VERSION__ || __STDC_VERSION__ < 201112)
227 # if defined _MSC_VER && 1200 <= _MSC_VER
228 #  define _Noreturn __declspec (noreturn)
229 # else
230 #  define _Noreturn YY_ATTRIBUTE ((__noreturn__))
231 # endif
232 #endif
233 
234 /* Suppress unused-variable warnings by "using" E.  */
235 #if ! defined lint || defined __GNUC__
236 # define YYUSE(E) ((void) (E))
237 #else
238 # define YYUSE(E) /* empty */
239 #endif
240 
241 #if defined __GNUC__ && 407 <= __GNUC__ * 100 + __GNUC_MINOR__
242 /* Suppress an incorrect diagnostic about yylval being uninitialized.  */
243 # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
244     _Pragma ("GCC diagnostic push") \
245     _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")\
246     _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
247 # define YY_IGNORE_MAYBE_UNINITIALIZED_END \
248     _Pragma ("GCC diagnostic pop")
249 #else
250 # define YY_INITIAL_VALUE(Value) Value
251 #endif
252 #ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
253 # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
254 # define YY_IGNORE_MAYBE_UNINITIALIZED_END
255 #endif
256 #ifndef YY_INITIAL_VALUE
257 # define YY_INITIAL_VALUE(Value) /* Nothing. */
258 #endif
259 
260 
261 #if ! defined yyoverflow || YYERROR_VERBOSE
262 
263 /* The parser invokes alloca or malloc; define the necessary symbols.  */
264 
265 # ifdef YYSTACK_USE_ALLOCA
266 #  if YYSTACK_USE_ALLOCA
267 #   ifdef __GNUC__
268 #    define YYSTACK_ALLOC __builtin_alloca
269 #   elif defined __BUILTIN_VA_ARG_INCR
270 #    include <alloca.h> /* INFRINGES ON USER NAME SPACE */
271 #   elif defined _AIX
272 #    define YYSTACK_ALLOC __alloca
273 #   elif defined _MSC_VER
274 #    include <malloc.h> /* INFRINGES ON USER NAME SPACE */
275 #    define alloca _alloca
276 #   else
277 #    define YYSTACK_ALLOC alloca
278 #    if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS
279 #     include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
280       /* Use EXIT_SUCCESS as a witness for stdlib.h.  */
281 #     ifndef EXIT_SUCCESS
282 #      define EXIT_SUCCESS 0
283 #     endif
284 #    endif
285 #   endif
286 #  endif
287 # endif
288 
289 # ifdef YYSTACK_ALLOC
290    /* Pacify GCC's 'empty if-body' warning.  */
291 #  define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
292 #  ifndef YYSTACK_ALLOC_MAXIMUM
293     /* The OS might guarantee only one guard page at the bottom of the stack,
294        and a page size can be as small as 4096 bytes.  So we cannot safely
295        invoke alloca (N) if N exceeds 4096.  Use a slightly smaller number
296        to allow for a few compiler-allocated temporary stack slots.  */
297 #   define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
298 #  endif
299 # else
300 #  define YYSTACK_ALLOC YYMALLOC
301 #  define YYSTACK_FREE YYFREE
302 #  ifndef YYSTACK_ALLOC_MAXIMUM
303 #   define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
304 #  endif
305 #  if (defined __cplusplus && ! defined EXIT_SUCCESS \
306        && ! ((defined YYMALLOC || defined malloc) \
307              && (defined YYFREE || defined free)))
308 #   include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
309 #   ifndef EXIT_SUCCESS
310 #    define EXIT_SUCCESS 0
311 #   endif
312 #  endif
313 #  ifndef YYMALLOC
314 #   define YYMALLOC malloc
315 #   if ! defined malloc && ! defined EXIT_SUCCESS
316 void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
317 #   endif
318 #  endif
319 #  ifndef YYFREE
320 #   define YYFREE free
321 #   if ! defined free && ! defined EXIT_SUCCESS
322 void free (void *); /* INFRINGES ON USER NAME SPACE */
323 #   endif
324 #  endif
325 # endif
326 #endif /* ! defined yyoverflow || YYERROR_VERBOSE */
327 
328 
329 #if (! defined yyoverflow \
330      && (! defined __cplusplus \
331          || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
332 
333 /* A type that is properly aligned for any stack member.  */
334 union yyalloc
335 {
336   yytype_int16 yyss_alloc;
337   YYSTYPE yyvs_alloc;
338 };
339 
340 /* The size of the maximum gap between one aligned stack and the next.  */
341 # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
342 
343 /* The size of an array large to enough to hold all stacks, each with
344    N elements.  */
345 # define YYSTACK_BYTES(N) \
346      ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
347       + YYSTACK_GAP_MAXIMUM)
348 
349 # define YYCOPY_NEEDED 1
350 
351 /* Relocate STACK from its old location to the new one.  The
352    local variables YYSIZE and YYSTACKSIZE give the old and new number of
353    elements in the stack, and YYPTR gives the new location of the
354    stack.  Advance YYPTR to a properly aligned location for the next
355    stack.  */
356 # define YYSTACK_RELOCATE(Stack_alloc, Stack)                           \
357     do                                                                  \
358       {                                                                 \
359         YYSIZE_T yynewbytes;                                            \
360         YYCOPY (&yyptr->Stack_alloc, Stack, yysize);                    \
361         Stack = &yyptr->Stack_alloc;                                    \
362         yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
363         yyptr += yynewbytes / sizeof (*yyptr);                          \
364       }                                                                 \
365     while (0)
366 
367 #endif
368 
369 #if defined YYCOPY_NEEDED && YYCOPY_NEEDED
370 /* Copy COUNT objects from SRC to DST.  The source and destination do
371    not overlap.  */
372 # ifndef YYCOPY
373 #  if defined __GNUC__ && 1 < __GNUC__
374 #   define YYCOPY(Dst, Src, Count) \
375       __builtin_memcpy (Dst, Src, (Count) * sizeof (*(Src)))
376 #  else
377 #   define YYCOPY(Dst, Src, Count)              \
378       do                                        \
379         {                                       \
380           YYSIZE_T yyi;                         \
381           for (yyi = 0; yyi < (Count); yyi++)   \
382             (Dst)[yyi] = (Src)[yyi];            \
383         }                                       \
384       while (0)
385 #  endif
386 # endif
387 #endif /* !YYCOPY_NEEDED */
388 
389 /* YYFINAL -- State number of the termination state.  */
390 #define YYFINAL  3
391 /* YYLAST -- Last index in YYTABLE.  */
392 #define YYLAST   35
393 
394 /* YYNTOKENS -- Number of terminals.  */
395 #define YYNTOKENS  16
396 /* YYNNTS -- Number of nonterminals.  */
397 #define YYNNTS  9
398 /* YYNRULES -- Number of rules.  */
399 #define YYNRULES  20
400 /* YYNSTATES -- Number of states.  */
401 #define YYNSTATES  37
402 
403 /* YYTRANSLATE[YYX] -- Symbol number corresponding to YYX as returned
404    by yylex, with out-of-bounds checking.  */
405 #define YYUNDEFTOK  2
406 #define YYMAXUTOK   264
407 
408 #define YYTRANSLATE(YYX)                                                \
409   ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
410 
411 /* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM
412    as returned by yylex, without out-of-bounds checking.  */
413 static const yytype_uint8 yytranslate[] =
414 {
415        0,     2,     2,     2,     2,     2,     2,     2,     2,     2,
416       10,     2,     2,     2,     2,     2,     2,     2,     2,     2,
417        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
418        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
419       13,    14,     2,     2,    15,     2,     2,     2,     2,     2,
420        2,     2,     2,     2,     2,     2,     2,     2,    12,     2,
421        2,    11,     2,     2,     2,     2,     2,     2,     2,     2,
422        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
423        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
424        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
425        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
426        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
427        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
428        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
429        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
430        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
431        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
432        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
433        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
434        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
435        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
436        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
437        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
438        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
439        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
440        2,     2,     2,     2,     2,     2,     1,     2,     3,     4,
441        5,     6,     7,     8,     9
442 };
443 
444 #if YYDEBUG
445   /* YYRLINE[YYN] -- Source line where rule number YYN was defined.  */
446 static const yytype_uint8 yyrline[] =
447 {
448        0,    22,    22,    23,    26,    27,    30,    31,    35,    36,
449       39,    40,    43,    44,    45,    46,    49,    52,    53,    54,
450       57
451 };
452 #endif
453 
454 #if YYDEBUG || YYERROR_VERBOSE || 0
455 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
456    First, the terminals, then, starting at YYNTOKENS, nonterminals.  */
457 static const char *const yytname[] =
458 {
459   "$end", "error", "$undefined", "TERMINAL", "START", "PPERCENT", "ID",
460   "TEMPLATE", "CODE", "INT", "'\\n'", "'='", "':'", "'('", "')'", "','",
461   "$accept", "spec", "decls", "decl", "blist", "rules", "nonterm", "tree",
462   "cost", YY_NULLPTR
463 };
464 #endif
465 
466 # ifdef YYPRINT
467 /* YYTOKNUM[NUM] -- (External) token number corresponding to the
468    (internal) symbol number NUM (which must be that of a token).  */
469 static const yytype_uint16 yytoknum[] =
470 {
471        0,   256,   257,   258,   259,   260,   261,   262,   263,   264,
472       10,    61,    58,    40,    41,    44
473 };
474 # endif
475 
476 #define YYPACT_NINF -26
477 
478 #define yypact_value_is_default(Yystate) \
479   (!!((Yystate) == (-26)))
480 
481 #define YYTABLE_NINF -4
482 
483 #define yytable_value_is_error(Yytable_value) \
484   0
485 
486   /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
487      STATE-NUM.  */
488 static const yytype_int8 yypact[] =
489 {
490      -26,    11,     0,   -26,     5,   -26,     8,   -26,   -26,   -26,
491      -26,     3,   -26,     7,     6,     9,   -26,   -26,    12,   -26,
492       13,    14,   -26,    15,   -26,    16,    17,    15,    18,     4,
493      -26,    20,   -26,    15,   -26,    19,   -26
494 };
495 
496   /* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM.
497      Performed when YYTABLE does not specify something else to do.  Zero
498      means the default is an error.  */
499 static const yytype_uint8 yydefact[] =
500 {
501        4,     0,     0,     1,     0,    10,     0,    12,     8,     5,
502        9,     0,    16,     0,     0,     0,     6,     7,     0,    14,
503        0,     0,    15,     0,    11,    17,     0,     0,     0,     0,
504       20,     0,    18,     0,    13,     0,    19
505 };
506 
507   /* YYPGOTO[NTERM-NUM].  */
508 static const yytype_int8 yypgoto[] =
509 {
510      -26,   -26,   -26,   -26,   -26,   -26,    21,   -25,   -26
511 };
512 
513   /* YYDEFGOTO[NTERM-NUM].  */
514 static const yytype_int8 yydefgoto[] =
515 {
516       -1,     1,     2,     9,    11,    14,    13,    26,    31
517 };
518 
519   /* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM.  If
520      positive, shift that token.  If negative, reduce the rule whose
521      number is the opposite.  If YYTABLE_NINF, syntax error.  */
522 static const yytype_int8 yytable[] =
523 {
524       -3,     4,    29,     5,     6,     7,    -2,    18,    35,    15,
525        8,     3,    12,    16,    12,    10,    19,    17,    32,    33,
526       21,    25,    22,    24,    28,    23,    30,     0,     0,    27,
527       34,     0,     0,    36,     0,    20
528 };
529 
530 static const yytype_int8 yycheck[] =
531 {
532        0,     1,    27,     3,     4,     5,     0,     1,    33,     6,
533       10,     0,     6,    10,     6,    10,    10,    10,    14,    15,
534       11,     6,    10,     9,     7,    12,     8,    -1,    -1,    13,
535       10,    -1,    -1,    14,    -1,    14
536 };
537 
538   /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
539      symbol of state STATE-NUM.  */
540 static const yytype_uint8 yystos[] =
541 {
542        0,    17,    18,     0,     1,     3,     4,     5,    10,    19,
543       10,    20,     6,    22,    21,     6,    10,    10,     1,    10,
544       22,    11,    10,    12,     9,     6,    23,    13,     7,    23,
545        8,    24,    14,    15,    10,    23,    14
546 };
547 
548   /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives.  */
549 static const yytype_uint8 yyr1[] =
550 {
551        0,    16,    17,    17,    18,    18,    19,    19,    19,    19,
552       20,    20,    21,    21,    21,    21,    22,    23,    23,    23,
553       24
554 };
555 
556   /* YYR2[YYN] -- Number of symbols on the right hand side of rule YYN.  */
557 static const yytype_uint8 yyr2[] =
558 {
559        0,     2,     3,     1,     0,     2,     3,     3,     1,     2,
560        0,     4,     0,     7,     2,     3,     1,     1,     4,     6,
561        1
562 };
563 
564 
565 #define yyerrok         (yyerrstatus = 0)
566 #define yyclearin       (yychar = YYEMPTY)
567 #define YYEMPTY         (-2)
568 #define YYEOF           0
569 
570 #define YYACCEPT        goto yyacceptlab
571 #define YYABORT         goto yyabortlab
572 #define YYERROR         goto yyerrorlab
573 
574 
575 #define YYRECOVERING()  (!!yyerrstatus)
576 
577 #define YYBACKUP(Token, Value)                                  \
578 do                                                              \
579   if (yychar == YYEMPTY)                                        \
580     {                                                           \
581       yychar = (Token);                                         \
582       yylval = (Value);                                         \
583       YYPOPSTACK (yylen);                                       \
584       yystate = *yyssp;                                         \
585       goto yybackup;                                            \
586     }                                                           \
587   else                                                          \
588     {                                                           \
589       yyerror (YY_("syntax error: cannot back up")); \
590       YYERROR;                                                  \
591     }                                                           \
592 while (0)
593 
594 /* Error token number */
595 #define YYTERROR        1
596 #define YYERRCODE       256
597 
598 
599 
600 /* Enable debugging if requested.  */
601 #if YYDEBUG
602 
603 # ifndef YYFPRINTF
604 #  include <stdio.h> /* INFRINGES ON USER NAME SPACE */
605 #  define YYFPRINTF fprintf
606 # endif
607 
608 # define YYDPRINTF(Args)                        \
609 do {                                            \
610   if (yydebug)                                  \
611     YYFPRINTF Args;                             \
612 } while (0)
613 
614 /* This macro is provided for backward compatibility. */
615 #ifndef YY_LOCATION_PRINT
616 # define YY_LOCATION_PRINT(File, Loc) ((void) 0)
617 #endif
618 
619 
620 # define YY_SYMBOL_PRINT(Title, Type, Value, Location)                    \
621 do {                                                                      \
622   if (yydebug)                                                            \
623     {                                                                     \
624       YYFPRINTF (stderr, "%s ", Title);                                   \
625       yy_symbol_print (stderr,                                            \
626                   Type, Value); \
627       YYFPRINTF (stderr, "\n");                                           \
628     }                                                                     \
629 } while (0)
630 
631 
632 /*----------------------------------------.
633 | Print this symbol's value on YYOUTPUT.  |
634 `----------------------------------------*/
635 
636 static void
yy_symbol_value_print(FILE * yyoutput,int yytype,YYSTYPE const * const yyvaluep)637 yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
638 {
639   FILE *yyo = yyoutput;
640   YYUSE (yyo);
641   if (!yyvaluep)
642     return;
643 # ifdef YYPRINT
644   if (yytype < YYNTOKENS)
645     YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
646 # endif
647   YYUSE (yytype);
648 }
649 
650 
651 /*--------------------------------.
652 | Print this symbol on YYOUTPUT.  |
653 `--------------------------------*/
654 
655 static void
yy_symbol_print(FILE * yyoutput,int yytype,YYSTYPE const * const yyvaluep)656 yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
657 {
658   YYFPRINTF (yyoutput, "%s %s (",
659              yytype < YYNTOKENS ? "token" : "nterm", yytname[yytype]);
660 
661   yy_symbol_value_print (yyoutput, yytype, yyvaluep);
662   YYFPRINTF (yyoutput, ")");
663 }
664 
665 /*------------------------------------------------------------------.
666 | yy_stack_print -- Print the state stack from its BOTTOM up to its |
667 | TOP (included).                                                   |
668 `------------------------------------------------------------------*/
669 
670 static void
yy_stack_print(yytype_int16 * yybottom,yytype_int16 * yytop)671 yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop)
672 {
673   YYFPRINTF (stderr, "Stack now");
674   for (; yybottom <= yytop; yybottom++)
675     {
676       int yybot = *yybottom;
677       YYFPRINTF (stderr, " %d", yybot);
678     }
679   YYFPRINTF (stderr, "\n");
680 }
681 
682 # define YY_STACK_PRINT(Bottom, Top)                            \
683 do {                                                            \
684   if (yydebug)                                                  \
685     yy_stack_print ((Bottom), (Top));                           \
686 } while (0)
687 
688 
689 /*------------------------------------------------.
690 | Report that the YYRULE is going to be reduced.  |
691 `------------------------------------------------*/
692 
693 static void
yy_reduce_print(yytype_int16 * yyssp,YYSTYPE * yyvsp,int yyrule)694 yy_reduce_print (yytype_int16 *yyssp, YYSTYPE *yyvsp, int yyrule)
695 {
696   unsigned long int yylno = yyrline[yyrule];
697   int yynrhs = yyr2[yyrule];
698   int yyi;
699   YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
700              yyrule - 1, yylno);
701   /* The symbols being reduced.  */
702   for (yyi = 0; yyi < yynrhs; yyi++)
703     {
704       YYFPRINTF (stderr, "   $%d = ", yyi + 1);
705       yy_symbol_print (stderr,
706                        yystos[yyssp[yyi + 1 - yynrhs]],
707                        &(yyvsp[(yyi + 1) - (yynrhs)])
708                                               );
709       YYFPRINTF (stderr, "\n");
710     }
711 }
712 
713 # define YY_REDUCE_PRINT(Rule)          \
714 do {                                    \
715   if (yydebug)                          \
716     yy_reduce_print (yyssp, yyvsp, Rule); \
717 } while (0)
718 
719 /* Nonzero means print parse trace.  It is left uninitialized so that
720    multiple parsers can coexist.  */
721 int yydebug;
722 #else /* !YYDEBUG */
723 # define YYDPRINTF(Args)
724 # define YY_SYMBOL_PRINT(Title, Type, Value, Location)
725 # define YY_STACK_PRINT(Bottom, Top)
726 # define YY_REDUCE_PRINT(Rule)
727 #endif /* !YYDEBUG */
728 
729 
730 /* YYINITDEPTH -- initial size of the parser's stacks.  */
731 #ifndef YYINITDEPTH
732 # define YYINITDEPTH 200
733 #endif
734 
735 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
736    if the built-in stack extension method is used).
737 
738    Do not make this value too large; the results are undefined if
739    YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
740    evaluated with infinite-precision integer arithmetic.  */
741 
742 #ifndef YYMAXDEPTH
743 # define YYMAXDEPTH 10000
744 #endif
745 
746 
747 #if YYERROR_VERBOSE
748 
749 # ifndef yystrlen
750 #  if defined __GLIBC__ && defined _STRING_H
751 #   define yystrlen strlen
752 #  else
753 /* Return the length of YYSTR.  */
754 static YYSIZE_T
yystrlen(const char * yystr)755 yystrlen (const char *yystr)
756 {
757   YYSIZE_T yylen;
758   for (yylen = 0; yystr[yylen]; yylen++)
759     continue;
760   return yylen;
761 }
762 #  endif
763 # endif
764 
765 # ifndef yystpcpy
766 #  if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
767 #   define yystpcpy stpcpy
768 #  else
769 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
770    YYDEST.  */
771 static char *
yystpcpy(char * yydest,const char * yysrc)772 yystpcpy (char *yydest, const char *yysrc)
773 {
774   char *yyd = yydest;
775   const char *yys = yysrc;
776 
777   while ((*yyd++ = *yys++) != '\0')
778     continue;
779 
780   return yyd - 1;
781 }
782 #  endif
783 # endif
784 
785 # ifndef yytnamerr
786 /* Copy to YYRES the contents of YYSTR after stripping away unnecessary
787    quotes and backslashes, so that it's suitable for yyerror.  The
788    heuristic is that double-quoting is unnecessary unless the string
789    contains an apostrophe, a comma, or backslash (other than
790    backslash-backslash).  YYSTR is taken from yytname.  If YYRES is
791    null, do not copy; instead, return the length of what the result
792    would have been.  */
793 static YYSIZE_T
yytnamerr(char * yyres,const char * yystr)794 yytnamerr (char *yyres, const char *yystr)
795 {
796   if (*yystr == '"')
797     {
798       YYSIZE_T yyn = 0;
799       char const *yyp = yystr;
800 
801       for (;;)
802         switch (*++yyp)
803           {
804           case '\'':
805           case ',':
806             goto do_not_strip_quotes;
807 
808           case '\\':
809             if (*++yyp != '\\')
810               goto do_not_strip_quotes;
811             /* Fall through.  */
812           default:
813             if (yyres)
814               yyres[yyn] = *yyp;
815             yyn++;
816             break;
817 
818           case '"':
819             if (yyres)
820               yyres[yyn] = '\0';
821             return yyn;
822           }
823     do_not_strip_quotes: ;
824     }
825 
826   if (! yyres)
827     return yystrlen (yystr);
828 
829   return yystpcpy (yyres, yystr) - yyres;
830 }
831 # endif
832 
833 /* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message
834    about the unexpected token YYTOKEN for the state stack whose top is
835    YYSSP.
836 
837    Return 0 if *YYMSG was successfully written.  Return 1 if *YYMSG is
838    not large enough to hold the message.  In that case, also set
839    *YYMSG_ALLOC to the required number of bytes.  Return 2 if the
840    required number of bytes is too large to store.  */
841 static int
yysyntax_error(YYSIZE_T * yymsg_alloc,char ** yymsg,yytype_int16 * yyssp,int yytoken)842 yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg,
843                 yytype_int16 *yyssp, int yytoken)
844 {
845   YYSIZE_T yysize0 = yytnamerr (YY_NULLPTR, yytname[yytoken]);
846   YYSIZE_T yysize = yysize0;
847   enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
848   /* Internationalized format string. */
849   const char *yyformat = YY_NULLPTR;
850   /* Arguments of yyformat. */
851   char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
852   /* Number of reported tokens (one for the "unexpected", one per
853      "expected"). */
854   int yycount = 0;
855 
856   /* There are many possibilities here to consider:
857      - If this state is a consistent state with a default action, then
858        the only way this function was invoked is if the default action
859        is an error action.  In that case, don't check for expected
860        tokens because there are none.
861      - The only way there can be no lookahead present (in yychar) is if
862        this state is a consistent state with a default action.  Thus,
863        detecting the absence of a lookahead is sufficient to determine
864        that there is no unexpected or expected token to report.  In that
865        case, just report a simple "syntax error".
866      - Don't assume there isn't a lookahead just because this state is a
867        consistent state with a default action.  There might have been a
868        previous inconsistent state, consistent state with a non-default
869        action, or user semantic action that manipulated yychar.
870      - Of course, the expected token list depends on states to have
871        correct lookahead information, and it depends on the parser not
872        to perform extra reductions after fetching a lookahead from the
873        scanner and before detecting a syntax error.  Thus, state merging
874        (from LALR or IELR) and default reductions corrupt the expected
875        token list.  However, the list is correct for canonical LR with
876        one exception: it will still contain any token that will not be
877        accepted due to an error action in a later state.
878   */
879   if (yytoken != YYEMPTY)
880     {
881       int yyn = yypact[*yyssp];
882       yyarg[yycount++] = yytname[yytoken];
883       if (!yypact_value_is_default (yyn))
884         {
885           /* Start YYX at -YYN if negative to avoid negative indexes in
886              YYCHECK.  In other words, skip the first -YYN actions for
887              this state because they are default actions.  */
888           int yyxbegin = yyn < 0 ? -yyn : 0;
889           /* Stay within bounds of both yycheck and yytname.  */
890           int yychecklim = YYLAST - yyn + 1;
891           int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
892           int yyx;
893 
894           for (yyx = yyxbegin; yyx < yyxend; ++yyx)
895             if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR
896                 && !yytable_value_is_error (yytable[yyx + yyn]))
897               {
898                 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
899                   {
900                     yycount = 1;
901                     yysize = yysize0;
902                     break;
903                   }
904                 yyarg[yycount++] = yytname[yyx];
905                 {
906                   YYSIZE_T yysize1 = yysize + yytnamerr (YY_NULLPTR, yytname[yyx]);
907                   if (! (yysize <= yysize1
908                          && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
909                     return 2;
910                   yysize = yysize1;
911                 }
912               }
913         }
914     }
915 
916   switch (yycount)
917     {
918 # define YYCASE_(N, S)                      \
919       case N:                               \
920         yyformat = S;                       \
921       break
922       YYCASE_(0, YY_("syntax error"));
923       YYCASE_(1, YY_("syntax error, unexpected %s"));
924       YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s"));
925       YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s"));
926       YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s"));
927       YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"));
928 # undef YYCASE_
929     }
930 
931   {
932     YYSIZE_T yysize1 = yysize + yystrlen (yyformat);
933     if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
934       return 2;
935     yysize = yysize1;
936   }
937 
938   if (*yymsg_alloc < yysize)
939     {
940       *yymsg_alloc = 2 * yysize;
941       if (! (yysize <= *yymsg_alloc
942              && *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM))
943         *yymsg_alloc = YYSTACK_ALLOC_MAXIMUM;
944       return 1;
945     }
946 
947   /* Avoid sprintf, as that infringes on the user's name space.
948      Don't have undefined behavior even if the translation
949      produced a string with the wrong number of "%s"s.  */
950   {
951     char *yyp = *yymsg;
952     int yyi = 0;
953     while ((*yyp = *yyformat) != '\0')
954       if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount)
955         {
956           yyp += yytnamerr (yyp, yyarg[yyi++]);
957           yyformat += 2;
958         }
959       else
960         {
961           yyp++;
962           yyformat++;
963         }
964   }
965   return 0;
966 }
967 #endif /* YYERROR_VERBOSE */
968 
969 /*-----------------------------------------------.
970 | Release the memory associated to this symbol.  |
971 `-----------------------------------------------*/
972 
973 static void
yydestruct(const char * yymsg,int yytype,YYSTYPE * yyvaluep)974 yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
975 {
976   YYUSE (yyvaluep);
977   if (!yymsg)
978     yymsg = "Deleting";
979   YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
980 
981   YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
982   YYUSE (yytype);
983   YY_IGNORE_MAYBE_UNINITIALIZED_END
984 }
985 
986 
987 
988 
989 /* The lookahead symbol.  */
990 int yychar;
991 
992 /* The semantic value of the lookahead symbol.  */
993 YYSTYPE yylval;
994 /* Number of syntax errors so far.  */
995 int yynerrs;
996 
997 
998 /*----------.
999 | yyparse.  |
1000 `----------*/
1001 
1002 int
yyparse(void)1003 yyparse (void)
1004 {
1005     int yystate;
1006     /* Number of tokens to shift before error messages enabled.  */
1007     int yyerrstatus;
1008 
1009     /* The stacks and their tools:
1010        'yyss': related to states.
1011        'yyvs': related to semantic values.
1012 
1013        Refer to the stacks through separate pointers, to allow yyoverflow
1014        to reallocate them elsewhere.  */
1015 
1016     /* The state stack.  */
1017     yytype_int16 yyssa[YYINITDEPTH];
1018     yytype_int16 *yyss;
1019     yytype_int16 *yyssp;
1020 
1021     /* The semantic value stack.  */
1022     YYSTYPE yyvsa[YYINITDEPTH];
1023     YYSTYPE *yyvs;
1024     YYSTYPE *yyvsp;
1025 
1026     YYSIZE_T yystacksize;
1027 
1028   int yyn;
1029   int yyresult;
1030   /* Lookahead token as an internal (translated) token number.  */
1031   int yytoken = 0;
1032   /* The variables used to return semantic value and location from the
1033      action routines.  */
1034   YYSTYPE yyval;
1035 
1036 #if YYERROR_VERBOSE
1037   /* Buffer for error messages, and its allocated size.  */
1038   char yymsgbuf[128];
1039   char *yymsg = yymsgbuf;
1040   YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
1041 #endif
1042 
1043 #define YYPOPSTACK(N)   (yyvsp -= (N), yyssp -= (N))
1044 
1045   /* The number of symbols on the RHS of the reduced rule.
1046      Keep to zero when no symbol should be popped.  */
1047   int yylen = 0;
1048 
1049   yyssp = yyss = yyssa;
1050   yyvsp = yyvs = yyvsa;
1051   yystacksize = YYINITDEPTH;
1052 
1053   YYDPRINTF ((stderr, "Starting parse\n"));
1054 
1055   yystate = 0;
1056   yyerrstatus = 0;
1057   yynerrs = 0;
1058   yychar = YYEMPTY; /* Cause a token to be read.  */
1059   goto yysetstate;
1060 
1061 /*------------------------------------------------------------.
1062 | yynewstate -- Push a new state, which is found in yystate.  |
1063 `------------------------------------------------------------*/
1064  yynewstate:
1065   /* In all cases, when you get here, the value and location stacks
1066      have just been pushed.  So pushing a state here evens the stacks.  */
1067   yyssp++;
1068 
1069  yysetstate:
1070   *yyssp = yystate;
1071 
1072   if (yyss + yystacksize - 1 <= yyssp)
1073     {
1074       /* Get the current used size of the three stacks, in elements.  */
1075       YYSIZE_T yysize = yyssp - yyss + 1;
1076 
1077 #ifdef yyoverflow
1078       {
1079         /* Give user a chance to reallocate the stack.  Use copies of
1080            these so that the &'s don't force the real ones into
1081            memory.  */
1082         YYSTYPE *yyvs1 = yyvs;
1083         yytype_int16 *yyss1 = yyss;
1084 
1085         /* Each stack pointer address is followed by the size of the
1086            data in use in that stack, in bytes.  This used to be a
1087            conditional around just the two extra args, but that might
1088            be undefined if yyoverflow is a macro.  */
1089         yyoverflow (YY_("memory exhausted"),
1090                     &yyss1, yysize * sizeof (*yyssp),
1091                     &yyvs1, yysize * sizeof (*yyvsp),
1092                     &yystacksize);
1093 
1094         yyss = yyss1;
1095         yyvs = yyvs1;
1096       }
1097 #else /* no yyoverflow */
1098 # ifndef YYSTACK_RELOCATE
1099       goto yyexhaustedlab;
1100 # else
1101       /* Extend the stack our own way.  */
1102       if (YYMAXDEPTH <= yystacksize)
1103         goto yyexhaustedlab;
1104       yystacksize *= 2;
1105       if (YYMAXDEPTH < yystacksize)
1106         yystacksize = YYMAXDEPTH;
1107 
1108       {
1109         yytype_int16 *yyss1 = yyss;
1110         union yyalloc *yyptr =
1111           (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
1112         if (! yyptr)
1113           goto yyexhaustedlab;
1114         YYSTACK_RELOCATE (yyss_alloc, yyss);
1115         YYSTACK_RELOCATE (yyvs_alloc, yyvs);
1116 #  undef YYSTACK_RELOCATE
1117         if (yyss1 != yyssa)
1118           YYSTACK_FREE (yyss1);
1119       }
1120 # endif
1121 #endif /* no yyoverflow */
1122 
1123       yyssp = yyss + yysize - 1;
1124       yyvsp = yyvs + yysize - 1;
1125 
1126       YYDPRINTF ((stderr, "Stack size increased to %lu\n",
1127                   (unsigned long int) yystacksize));
1128 
1129       if (yyss + yystacksize - 1 <= yyssp)
1130         YYABORT;
1131     }
1132 
1133   YYDPRINTF ((stderr, "Entering state %d\n", yystate));
1134 
1135   if (yystate == YYFINAL)
1136     YYACCEPT;
1137 
1138   goto yybackup;
1139 
1140 /*-----------.
1141 | yybackup.  |
1142 `-----------*/
1143 yybackup:
1144 
1145   /* Do appropriate processing given the current state.  Read a
1146      lookahead token if we need one and don't already have one.  */
1147 
1148   /* First try to decide what to do without reference to lookahead token.  */
1149   yyn = yypact[yystate];
1150   if (yypact_value_is_default (yyn))
1151     goto yydefault;
1152 
1153   /* Not known => get a lookahead token if don't already have one.  */
1154 
1155   /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol.  */
1156   if (yychar == YYEMPTY)
1157     {
1158       YYDPRINTF ((stderr, "Reading a token: "));
1159       yychar = yylex ();
1160     }
1161 
1162   if (yychar <= YYEOF)
1163     {
1164       yychar = yytoken = YYEOF;
1165       YYDPRINTF ((stderr, "Now at end of input.\n"));
1166     }
1167   else
1168     {
1169       yytoken = YYTRANSLATE (yychar);
1170       YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
1171     }
1172 
1173   /* If the proper action on seeing token YYTOKEN is to reduce or to
1174      detect an error, take that action.  */
1175   yyn += yytoken;
1176   if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
1177     goto yydefault;
1178   yyn = yytable[yyn];
1179   if (yyn <= 0)
1180     {
1181       if (yytable_value_is_error (yyn))
1182         goto yyerrlab;
1183       yyn = -yyn;
1184       goto yyreduce;
1185     }
1186 
1187   /* Count tokens shifted since error; after three, turn off error
1188      status.  */
1189   if (yyerrstatus)
1190     yyerrstatus--;
1191 
1192   /* Shift the lookahead token.  */
1193   YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
1194 
1195   /* Discard the shifted token.  */
1196   yychar = YYEMPTY;
1197 
1198   yystate = yyn;
1199   YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1200   *++yyvsp = yylval;
1201   YY_IGNORE_MAYBE_UNINITIALIZED_END
1202 
1203   goto yynewstate;
1204 
1205 
1206 /*-----------------------------------------------------------.
1207 | yydefault -- do the default action for the current state.  |
1208 `-----------------------------------------------------------*/
1209 yydefault:
1210   yyn = yydefact[yystate];
1211   if (yyn == 0)
1212     goto yyerrlab;
1213   goto yyreduce;
1214 
1215 
1216 /*-----------------------------.
1217 | yyreduce -- Do a reduction.  |
1218 `-----------------------------*/
1219 yyreduce:
1220   /* yyn is the number of a rule to reduce with.  */
1221   yylen = yyr2[yyn];
1222 
1223   /* If YYLEN is nonzero, implement the default value of the action:
1224      '$$ = $1'.
1225 
1226      Otherwise, the following line sets YYVAL to garbage.
1227      This behavior is undocumented and Bison
1228      users should not rely upon it.  Assigning to YYVAL
1229      unconditionally makes the parser a bit smaller, and it avoids a
1230      GCC warning that YYVAL may be used uninitialized.  */
1231   yyval = yyvsp[1-yylen];
1232 
1233 
1234   YY_REDUCE_PRINT (yyn);
1235   switch (yyn)
1236     {
1237         case 2:
1238 #line 22 "code/tools/lcc/lburg/gram.y" /* yacc.c:1646  */
1239     { yylineno = 0; }
1240 #line 1240 "y.tab.c" /* yacc.c:1646  */
1241     break;
1242 
1243   case 3:
1244 #line 23 "code/tools/lcc/lburg/gram.y" /* yacc.c:1646  */
1245     { yylineno = 0; }
1246 #line 1246 "y.tab.c" /* yacc.c:1646  */
1247     break;
1248 
1249   case 7:
1250 #line 31 "code/tools/lcc/lburg/gram.y" /* yacc.c:1646  */
1251     {
1252 		if (nonterm((yyvsp[-1].string))->number != 1)
1253 			yyerror("redeclaration of the start symbol\n");
1254 		}
1255 #line 1255 "y.tab.c" /* yacc.c:1646  */
1256     break;
1257 
1258   case 9:
1259 #line 36 "code/tools/lcc/lburg/gram.y" /* yacc.c:1646  */
1260     { yyerrok; }
1261 #line 1261 "y.tab.c" /* yacc.c:1646  */
1262     break;
1263 
1264   case 11:
1265 #line 40 "code/tools/lcc/lburg/gram.y" /* yacc.c:1646  */
1266     { term((yyvsp[-2].string), (yyvsp[0].n)); }
1267 #line 1267 "y.tab.c" /* yacc.c:1646  */
1268     break;
1269 
1270   case 13:
1271 #line 44 "code/tools/lcc/lburg/gram.y" /* yacc.c:1646  */
1272     { rule((yyvsp[-5].string), (yyvsp[-3].tree), (yyvsp[-2].string), (yyvsp[-1].string)); }
1273 #line 1273 "y.tab.c" /* yacc.c:1646  */
1274     break;
1275 
1276   case 15:
1277 #line 46 "code/tools/lcc/lburg/gram.y" /* yacc.c:1646  */
1278     { yyerrok; }
1279 #line 1279 "y.tab.c" /* yacc.c:1646  */
1280     break;
1281 
1282   case 16:
1283 #line 49 "code/tools/lcc/lburg/gram.y" /* yacc.c:1646  */
1284     { nonterm((yyval.string) = (yyvsp[0].string)); }
1285 #line 1285 "y.tab.c" /* yacc.c:1646  */
1286     break;
1287 
1288   case 17:
1289 #line 52 "code/tools/lcc/lburg/gram.y" /* yacc.c:1646  */
1290     { (yyval.tree) = tree((yyvsp[0].string),  0,  0); }
1291 #line 1291 "y.tab.c" /* yacc.c:1646  */
1292     break;
1293 
1294   case 18:
1295 #line 53 "code/tools/lcc/lburg/gram.y" /* yacc.c:1646  */
1296     { (yyval.tree) = tree((yyvsp[-3].string), (yyvsp[-1].tree),  0); }
1297 #line 1297 "y.tab.c" /* yacc.c:1646  */
1298     break;
1299 
1300   case 19:
1301 #line 54 "code/tools/lcc/lburg/gram.y" /* yacc.c:1646  */
1302     { (yyval.tree) = tree((yyvsp[-5].string), (yyvsp[-3].tree), (yyvsp[-1].tree)); }
1303 #line 1303 "y.tab.c" /* yacc.c:1646  */
1304     break;
1305 
1306   case 20:
1307 #line 57 "code/tools/lcc/lburg/gram.y" /* yacc.c:1646  */
1308     { if (*(yyvsp[0].string) == 0) (yyval.string) = "0"; }
1309 #line 1309 "y.tab.c" /* yacc.c:1646  */
1310     break;
1311 
1312 
1313 #line 1313 "y.tab.c" /* yacc.c:1646  */
1314       default: break;
1315     }
1316   /* User semantic actions sometimes alter yychar, and that requires
1317      that yytoken be updated with the new translation.  We take the
1318      approach of translating immediately before every use of yytoken.
1319      One alternative is translating here after every semantic action,
1320      but that translation would be missed if the semantic action invokes
1321      YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or
1322      if it invokes YYBACKUP.  In the case of YYABORT or YYACCEPT, an
1323      incorrect destructor might then be invoked immediately.  In the
1324      case of YYERROR or YYBACKUP, subsequent parser actions might lead
1325      to an incorrect destructor call or verbose syntax error message
1326      before the lookahead is translated.  */
1327   YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
1328 
1329   YYPOPSTACK (yylen);
1330   yylen = 0;
1331   YY_STACK_PRINT (yyss, yyssp);
1332 
1333   *++yyvsp = yyval;
1334 
1335   /* Now 'shift' the result of the reduction.  Determine what state
1336      that goes to, based on the state we popped back to and the rule
1337      number reduced by.  */
1338 
1339   yyn = yyr1[yyn];
1340 
1341   yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
1342   if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
1343     yystate = yytable[yystate];
1344   else
1345     yystate = yydefgoto[yyn - YYNTOKENS];
1346 
1347   goto yynewstate;
1348 
1349 
1350 /*--------------------------------------.
1351 | yyerrlab -- here on detecting error.  |
1352 `--------------------------------------*/
1353 yyerrlab:
1354   /* Make sure we have latest lookahead translation.  See comments at
1355      user semantic actions for why this is necessary.  */
1356   yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE (yychar);
1357 
1358   /* If not already recovering from an error, report this error.  */
1359   if (!yyerrstatus)
1360     {
1361       ++yynerrs;
1362 #if ! YYERROR_VERBOSE
1363       yyerror (YY_("syntax error"));
1364 #else
1365 # define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \
1366                                         yyssp, yytoken)
1367       {
1368         char const *yymsgp = YY_("syntax error");
1369         int yysyntax_error_status;
1370         yysyntax_error_status = YYSYNTAX_ERROR;
1371         if (yysyntax_error_status == 0)
1372           yymsgp = yymsg;
1373         else if (yysyntax_error_status == 1)
1374           {
1375             if (yymsg != yymsgbuf)
1376               YYSTACK_FREE (yymsg);
1377             yymsg = (char *) YYSTACK_ALLOC (yymsg_alloc);
1378             if (!yymsg)
1379               {
1380                 yymsg = yymsgbuf;
1381                 yymsg_alloc = sizeof yymsgbuf;
1382                 yysyntax_error_status = 2;
1383               }
1384             else
1385               {
1386                 yysyntax_error_status = YYSYNTAX_ERROR;
1387                 yymsgp = yymsg;
1388               }
1389           }
1390         yyerror (yymsgp);
1391         if (yysyntax_error_status == 2)
1392           goto yyexhaustedlab;
1393       }
1394 # undef YYSYNTAX_ERROR
1395 #endif
1396     }
1397 
1398 
1399 
1400   if (yyerrstatus == 3)
1401     {
1402       /* If just tried and failed to reuse lookahead token after an
1403          error, discard it.  */
1404 
1405       if (yychar <= YYEOF)
1406         {
1407           /* Return failure if at end of input.  */
1408           if (yychar == YYEOF)
1409             YYABORT;
1410         }
1411       else
1412         {
1413           yydestruct ("Error: discarding",
1414                       yytoken, &yylval);
1415           yychar = YYEMPTY;
1416         }
1417     }
1418 
1419   /* Else will try to reuse lookahead token after shifting the error
1420      token.  */
1421   goto yyerrlab1;
1422 
1423 
1424 /*---------------------------------------------------.
1425 | yyerrorlab -- error raised explicitly by YYERROR.  |
1426 `---------------------------------------------------*/
1427 yyerrorlab:
1428 
1429   /* Pacify compilers like GCC when the user code never invokes
1430      YYERROR and the label yyerrorlab therefore never appears in user
1431      code.  */
1432   if (/*CONSTCOND*/ 0)
1433      goto yyerrorlab;
1434 
1435   /* Do not reclaim the symbols of the rule whose action triggered
1436      this YYERROR.  */
1437   YYPOPSTACK (yylen);
1438   yylen = 0;
1439   YY_STACK_PRINT (yyss, yyssp);
1440   yystate = *yyssp;
1441   goto yyerrlab1;
1442 
1443 
1444 /*-------------------------------------------------------------.
1445 | yyerrlab1 -- common code for both syntax error and YYERROR.  |
1446 `-------------------------------------------------------------*/
1447 yyerrlab1:
1448   yyerrstatus = 3;      /* Each real token shifted decrements this.  */
1449 
1450   for (;;)
1451     {
1452       yyn = yypact[yystate];
1453       if (!yypact_value_is_default (yyn))
1454         {
1455           yyn += YYTERROR;
1456           if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
1457             {
1458               yyn = yytable[yyn];
1459               if (0 < yyn)
1460                 break;
1461             }
1462         }
1463 
1464       /* Pop the current state because it cannot handle the error token.  */
1465       if (yyssp == yyss)
1466         YYABORT;
1467 
1468 
1469       yydestruct ("Error: popping",
1470                   yystos[yystate], yyvsp);
1471       YYPOPSTACK (1);
1472       yystate = *yyssp;
1473       YY_STACK_PRINT (yyss, yyssp);
1474     }
1475 
1476   YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1477   *++yyvsp = yylval;
1478   YY_IGNORE_MAYBE_UNINITIALIZED_END
1479 
1480 
1481   /* Shift the error token.  */
1482   YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
1483 
1484   yystate = yyn;
1485   goto yynewstate;
1486 
1487 
1488 /*-------------------------------------.
1489 | yyacceptlab -- YYACCEPT comes here.  |
1490 `-------------------------------------*/
1491 yyacceptlab:
1492   yyresult = 0;
1493   goto yyreturn;
1494 
1495 /*-----------------------------------.
1496 | yyabortlab -- YYABORT comes here.  |
1497 `-----------------------------------*/
1498 yyabortlab:
1499   yyresult = 1;
1500   goto yyreturn;
1501 
1502 #if !defined yyoverflow || YYERROR_VERBOSE
1503 /*-------------------------------------------------.
1504 | yyexhaustedlab -- memory exhaustion comes here.  |
1505 `-------------------------------------------------*/
1506 yyexhaustedlab:
1507   yyerror (YY_("memory exhausted"));
1508   yyresult = 2;
1509   /* Fall through.  */
1510 #endif
1511 
1512 yyreturn:
1513   if (yychar != YYEMPTY)
1514     {
1515       /* Make sure we have latest lookahead translation.  See comments at
1516          user semantic actions for why this is necessary.  */
1517       yytoken = YYTRANSLATE (yychar);
1518       yydestruct ("Cleanup: discarding lookahead",
1519                   yytoken, &yylval);
1520     }
1521   /* Do not reclaim the symbols of the rule whose action triggered
1522      this YYABORT or YYACCEPT.  */
1523   YYPOPSTACK (yylen);
1524   YY_STACK_PRINT (yyss, yyssp);
1525   while (yyssp != yyss)
1526     {
1527       yydestruct ("Cleanup: popping",
1528                   yystos[*yyssp], yyvsp);
1529       YYPOPSTACK (1);
1530     }
1531 #ifndef yyoverflow
1532   if (yyss != yyssa)
1533     YYSTACK_FREE (yyss);
1534 #endif
1535 #if YYERROR_VERBOSE
1536   if (yymsg != yymsgbuf)
1537     YYSTACK_FREE (yymsg);
1538 #endif
1539   return yyresult;
1540 }
1541 #line 59 "code/tools/lcc/lburg/gram.y" /* yacc.c:1906  */
1542 
1543 #include <assert.h>
1544 #include <stdarg.h>
1545 #include <ctype.h>
1546 #include <string.h>
1547 #include <limits.h>
1548 
1549 int errcnt = 0;
1550 FILE *infp = NULL;
1551 FILE *outfp = NULL;
1552 static char buf[BUFSIZ], *bp = buf;
1553 static int ppercent = 0;
1554 static int code = 0;
1555 
get(void)1556 static int get(void) {
1557 	if (*bp == 0) {
1558 		bp = buf;
1559 		*bp = 0;
1560 		if (fgets(buf, sizeof buf, infp) == NULL)
1561 			return EOF;
1562 		yylineno++;
1563 		while (buf[0] == '%' && buf[1] == '{' && buf[2] == '\n') {
1564 			for (;;) {
1565 				if (fgets(buf, sizeof buf, infp) == NULL) {
1566 					yywarn("unterminated %{...%}\n");
1567 					return EOF;
1568 				}
1569 				yylineno++;
1570 				if (strcmp(buf, "%}\n") == 0)
1571 					break;
1572 				fputs(buf, outfp);
1573 			}
1574 			if (fgets(buf, sizeof buf, infp) == NULL)
1575 				return EOF;
1576 			yylineno++;
1577 		}
1578 	}
1579 	return *bp++;
1580 }
1581 
yyerror(char * fmt,...)1582 void yyerror(char *fmt, ...) {
1583 	va_list ap;
1584 
1585 	va_start(ap, fmt);
1586 	if (yylineno > 0)
1587 		fprintf(stderr, "line %d: ", yylineno);
1588 	vfprintf(stderr, fmt, ap);
1589 	if (fmt[strlen(fmt)-1] != '\n')
1590 		 fprintf(stderr, "\n");
1591 	errcnt++;
1592 	va_end(ap);
1593 }
1594 
yylex(void)1595 int yylex(void) {
1596 	int c;
1597 
1598 	if (code) {
1599 		char *p;
1600 		bp += strspn(bp, " \t\f");
1601 		p = strchr(bp, '\n');
1602 		if (p == NULL)
1603 			p = strchr(bp, '\n');
1604 		while (p > bp && isspace(p[-1]))
1605 			p--;
1606 		yylval.string = alloc(p - bp + 1);
1607 		strncpy(yylval.string, bp, p - bp);
1608 		yylval.string[p - bp] = 0;
1609 		bp = p;
1610 		code--;
1611 		return CODE;
1612 	}
1613 	while ((c = get()) != EOF) {
1614 		switch (c) {
1615 		case ' ': case '\f': case '\t':
1616 			continue;
1617 		case '\n':
1618 		case '(': case ')': case ',':
1619 		case ':': case '=':
1620 			return c;
1621 		}
1622 		if (c == '%' && *bp == '%') {
1623 			bp++;
1624 			return ppercent++ ? 0 : PPERCENT;
1625 		} else if (c == '%' && strncmp(bp, "term", 4) == 0
1626 		&& isspace(bp[4])) {
1627 			bp += 4;
1628 			return TERMINAL;
1629 		} else if (c == '%' && strncmp(bp, "start", 5) == 0
1630 		&& isspace(bp[5])) {
1631 			bp += 5;
1632 			return START;
1633 		} else if (c == '"') {
1634 			char *p = strchr(bp, '"');
1635 			if (p == NULL) {
1636 				yyerror("missing \" in assembler template\n");
1637 				p = strchr(bp, '\n');
1638 				if (p == NULL)
1639 					p = strchr(bp, '\0');
1640 			}
1641 			assert(p);
1642 			yylval.string = alloc(p - bp + 1);
1643 			strncpy(yylval.string, bp, p - bp);
1644 			yylval.string[p - bp] = 0;
1645 			bp = *p == '"' ? p + 1 : p;
1646 			code++;
1647 			return TEMPLATE;
1648 		} else if (isdigit(c)) {
1649 			int n = 0;
1650 			do {
1651 				int d = c - '0';
1652 				if (n > (INT_MAX - d)/10)
1653 					yyerror("integer greater than %d\n", INT_MAX);
1654 				else
1655 					n = 10*n + d;
1656 				c = get();
1657 			} while (c != EOF && isdigit(c));
1658 			bp--;
1659 			yylval.n = n;
1660 			return INT;
1661 		} else if (isalpha(c)) {
1662 			char *p = bp - 1;
1663 			while (isalpha(*bp) || isdigit(*bp) || *bp == '_')
1664 				bp++;
1665 			yylval.string = alloc(bp - p + 1);
1666 			strncpy(yylval.string, p, bp - p);
1667 			yylval.string[bp - p] = 0;
1668 			return ID;
1669 		} else if (isprint(c))
1670 			yyerror("invalid character `%c'\n", c);
1671 		else
1672 			yyerror("invalid character `\\%03o'\n", (unsigned char)c);
1673 	}
1674 	return 0;
1675 }
1676 
yywarn(char * fmt,...)1677 void yywarn(char *fmt, ...) {
1678 	va_list ap;
1679 
1680 	va_start(ap, fmt);
1681 	if (yylineno > 0)
1682 		fprintf(stderr, "line %d: ", yylineno);
1683 	fprintf(stderr, "warning: ");
1684 	vfprintf(stderr, fmt, ap);
1685 	va_end(ap);
1686 }
1687