1 /* $NetBSD: parse.c,v 1.3 2023/06/19 21:41:42 christos Exp $ */
2
3 /* A Bison parser, made by GNU Bison 3.8.2. */
4
5 /* Bison implementation for Yacc-like parsers in C
6
7 Copyright (C) 1984, 1989-1990, 2000-2015, 2018-2021 Free Software Foundation,
8 Inc.
9
10 This program is free software: you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation, either version 3 of the License, or
13 (at your option) any later version.
14
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
19
20 You should have received a copy of the GNU General Public License
21 along with this program. If not, see <https://www.gnu.org/licenses/>. */
22
23 /* As a special exception, you may create a larger work that contains
24 part or all of the Bison parser skeleton and distribute that work
25 under terms of your choice, so long as that work isn't itself a
26 parser generator using the skeleton or a modified version thereof
27 as a parser skeleton. Alternatively, if you modify or redistribute
28 the parser skeleton itself, you may (at your option) remove this
29 special exception, which will cause the skeleton and the resulting
30 Bison output files to be licensed under the GNU General Public
31 License without this special exception.
32
33 This special exception was added by the Free Software Foundation in
34 version 2.2 of Bison. */
35
36 /* C LALR(1) parser skeleton written by Richard Stallman, by
37 simplifying the original so-called "semantic" parser. */
38
39 /* DO NOT RELY ON FEATURES THAT ARE NOT DOCUMENTED in the manual,
40 especially those whose name start with YY_ or yy_. They are
41 private implementation details that can be changed or removed. */
42
43 /* All symbols defined below should begin with yy or YY, to avoid
44 infringing on user name space. This should be done even for local
45 variables, as they might otherwise be expanded by user macros.
46 There are some unavoidable exceptions within include files to
47 define necessary library symbols; they are noted "INFRINGES ON
48 USER NAME SPACE" below. */
49
50 /* Identify Bison output, and Bison version. */
51 #define YYBISON 30802
52
53 /* Bison version string. */
54 #define YYBISON_VERSION "3.8.2"
55
56 /* Skeleton name. */
57 #define YYSKELETON_NAME "yacc.c"
58
59 /* Pure parsers. */
60 #define YYPURE 0
61
62 /* Push parsers. */
63 #define YYPUSH 0
64
65 /* Pull parsers. */
66 #define YYPULL 1
67
68
69
70
71 /* First part of user prologue. */
72 #line 1 "parse.y"
73
74 /*
75 * Copyright (c) 1998 - 2000 Kungliga Tekniska Högskolan
76 * (Royal Institute of Technology, Stockholm, Sweden).
77 * All rights reserved.
78 *
79 * Redistribution and use in source and binary forms, with or without
80 * modification, are permitted provided that the following conditions
81 * are met:
82 *
83 * 1. Redistributions of source code must retain the above copyright
84 * notice, this list of conditions and the following disclaimer.
85 *
86 * 2. Redistributions in binary form must reproduce the above copyright
87 * notice, this list of conditions and the following disclaimer in the
88 * documentation and/or other materials provided with the distribution.
89 *
90 * 3. Neither the name of the Institute nor the names of its contributors
91 * may be used to endorse or promote products derived from this software
92 * without specific prior written permission.
93 *
94 * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
95 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
96 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
97 * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
98 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
99 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
100 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
101 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
102 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
103 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
104 * SUCH DAMAGE.
105 */
106
107 #include "compile_et.h"
108 #include "lex.h"
109
110 void yyerror (char *s);
111 static long name2number(const char *str);
112
113 extern char *yytext;
114
115 /* This is for bison */
116
117 #if !defined(alloca) && !defined(HAVE_ALLOCA)
118 #define alloca(x) malloc(x)
119 #endif
120
121 #define YYMALLOC malloc
122 #define YYFREE free
123
124
125 #line 124 "parse.c"
126
127 # ifndef YY_CAST
128 # ifdef __cplusplus
129 # define YY_CAST(Type, Val) static_cast<Type> (Val)
130 # define YY_REINTERPRET_CAST(Type, Val) reinterpret_cast<Type> (Val)
131 # else
132 # define YY_CAST(Type, Val) ((Type) (Val))
133 # define YY_REINTERPRET_CAST(Type, Val) ((Type) (Val))
134 # endif
135 # endif
136 # ifndef YY_NULLPTR
137 # if defined __cplusplus
138 # if 201103L <= __cplusplus
139 # define YY_NULLPTR nullptr
140 # else
141 # define YY_NULLPTR 0
142 # endif
143 # else
144 # define YY_NULLPTR ((void*)0)
145 # endif
146 # endif
147
148 /* Use api.header.include to #include this header
149 instead of duplicating it here. */
150 #ifndef YY_YY_PARSE_H_INCLUDED
151 # define YY_YY_PARSE_H_INCLUDED
152 /* Debug traces. */
153 #ifndef YYDEBUG
154 # define YYDEBUG 0
155 #endif
156 #if YYDEBUG
157 extern int yydebug;
158 #endif
159
160 /* Token kinds. */
161 #ifndef YYTOKENTYPE
162 # define YYTOKENTYPE
163 enum yytokentype
164 {
165 YYEMPTY = -2,
166 YYEOF = 0, /* "end of file" */
167 YYerror = 256, /* error */
168 YYUNDEF = 257, /* "invalid token" */
169 ET = 258, /* ET */
170 INDEX = 259, /* INDEX */
171 PREFIX = 260, /* PREFIX */
172 EC = 261, /* EC */
173 ID = 262, /* ID */
174 END = 263, /* END */
175 STRING = 264, /* STRING */
176 NUMBER = 265 /* NUMBER */
177 };
178 typedef enum yytokentype yytoken_kind_t;
179 #endif
180 /* Token kinds. */
181 #define YYEMPTY -2
182 #define YYEOF 0
183 #define YYerror 256
184 #define YYUNDEF 257
185 #define ET 258
186 #define INDEX 259
187 #define PREFIX 260
188 #define EC 261
189 #define ID 262
190 #define END 263
191 #define STRING 264
192 #define NUMBER 265
193
194 /* Value type. */
195 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
196 union YYSTYPE
197 {
198 #line 54 "parse.y"
199
200 char *string;
201 int number;
202
203 #line 202 "parse.c"
204
205 };
206 typedef union YYSTYPE YYSTYPE;
207 # define YYSTYPE_IS_TRIVIAL 1
208 # define YYSTYPE_IS_DECLARED 1
209 #endif
210
211
212 extern YYSTYPE yylval;
213
214
215 int yyparse (void);
216
217
218 #endif /* !YY_YY_PARSE_H_INCLUDED */
219 /* Symbol kind. */
220 enum yysymbol_kind_t
221 {
222 YYSYMBOL_YYEMPTY = -2,
223 YYSYMBOL_YYEOF = 0, /* "end of file" */
224 YYSYMBOL_YYerror = 1, /* error */
225 YYSYMBOL_YYUNDEF = 2, /* "invalid token" */
226 YYSYMBOL_ET = 3, /* ET */
227 YYSYMBOL_INDEX = 4, /* INDEX */
228 YYSYMBOL_PREFIX = 5, /* PREFIX */
229 YYSYMBOL_EC = 6, /* EC */
230 YYSYMBOL_ID = 7, /* ID */
231 YYSYMBOL_END = 8, /* END */
232 YYSYMBOL_STRING = 9, /* STRING */
233 YYSYMBOL_NUMBER = 10, /* NUMBER */
234 YYSYMBOL_11_ = 11, /* ',' */
235 YYSYMBOL_YYACCEPT = 12, /* $accept */
236 YYSYMBOL_file = 13, /* file */
237 YYSYMBOL_header = 14, /* header */
238 YYSYMBOL_id = 15, /* id */
239 YYSYMBOL_et = 16, /* et */
240 YYSYMBOL_statements = 17, /* statements */
241 YYSYMBOL_statement = 18 /* statement */
242 };
243 typedef enum yysymbol_kind_t yysymbol_kind_t;
244
245
246
247
248 #ifdef short
249 # undef short
250 #endif
251
252 /* On compilers that do not define __PTRDIFF_MAX__ etc., make sure
253 <limits.h> and (if available) <stdint.h> are included
254 so that the code can choose integer types of a good width. */
255
256 #ifndef __PTRDIFF_MAX__
257 # include <limits.h> /* INFRINGES ON USER NAME SPACE */
258 # if defined __STDC_VERSION__ && 199901 <= __STDC_VERSION__
259 # include <stdint.h> /* INFRINGES ON USER NAME SPACE */
260 # define YY_STDINT_H
261 # endif
262 #endif
263
264 /* Narrow types that promote to a signed type and that can represent a
265 signed or unsigned integer of at least N bits. In tables they can
266 save space and decrease cache pressure. Promoting to a signed type
267 helps avoid bugs in integer arithmetic. */
268
269 #ifdef __INT_LEAST8_MAX__
270 typedef __INT_LEAST8_TYPE__ yytype_int8;
271 #elif defined YY_STDINT_H
272 typedef int_least8_t yytype_int8;
273 #else
274 typedef signed char yytype_int8;
275 #endif
276
277 #ifdef __INT_LEAST16_MAX__
278 typedef __INT_LEAST16_TYPE__ yytype_int16;
279 #elif defined YY_STDINT_H
280 typedef int_least16_t yytype_int16;
281 #else
282 typedef short yytype_int16;
283 #endif
284
285 /* Work around bug in HP-UX 11.23, which defines these macros
286 incorrectly for preprocessor constants. This workaround can likely
287 be removed in 2023, as HPE has promised support for HP-UX 11.23
288 (aka HP-UX 11i v2) only through the end of 2022; see Table 2 of
289 <https://h20195.www2.hpe.com/V2/getpdf.aspx/4AA4-7673ENW.pdf>. */
290 #ifdef __hpux
291 # undef UINT_LEAST8_MAX
292 # undef UINT_LEAST16_MAX
293 # define UINT_LEAST8_MAX 255
294 # define UINT_LEAST16_MAX 65535
295 #endif
296
297 #if defined __UINT_LEAST8_MAX__ && __UINT_LEAST8_MAX__ <= __INT_MAX__
298 typedef __UINT_LEAST8_TYPE__ yytype_uint8;
299 #elif (!defined __UINT_LEAST8_MAX__ && defined YY_STDINT_H \
300 && UINT_LEAST8_MAX <= INT_MAX)
301 typedef uint_least8_t yytype_uint8;
302 #elif !defined __UINT_LEAST8_MAX__ && UCHAR_MAX <= INT_MAX
303 typedef unsigned char yytype_uint8;
304 #else
305 typedef short yytype_uint8;
306 #endif
307
308 #if defined __UINT_LEAST16_MAX__ && __UINT_LEAST16_MAX__ <= __INT_MAX__
309 typedef __UINT_LEAST16_TYPE__ yytype_uint16;
310 #elif (!defined __UINT_LEAST16_MAX__ && defined YY_STDINT_H \
311 && UINT_LEAST16_MAX <= INT_MAX)
312 typedef uint_least16_t yytype_uint16;
313 #elif !defined __UINT_LEAST16_MAX__ && USHRT_MAX <= INT_MAX
314 typedef unsigned short yytype_uint16;
315 #else
316 typedef int yytype_uint16;
317 #endif
318
319 #ifndef YYPTRDIFF_T
320 # if defined __PTRDIFF_TYPE__ && defined __PTRDIFF_MAX__
321 # define YYPTRDIFF_T __PTRDIFF_TYPE__
322 # define YYPTRDIFF_MAXIMUM __PTRDIFF_MAX__
323 # elif defined PTRDIFF_MAX
324 # ifndef ptrdiff_t
325 # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
326 # endif
327 # define YYPTRDIFF_T ptrdiff_t
328 # define YYPTRDIFF_MAXIMUM PTRDIFF_MAX
329 # else
330 # define YYPTRDIFF_T long
331 # define YYPTRDIFF_MAXIMUM LONG_MAX
332 # endif
333 #endif
334
335 #ifndef YYSIZE_T
336 # ifdef __SIZE_TYPE__
337 # define YYSIZE_T __SIZE_TYPE__
338 # elif defined size_t
339 # define YYSIZE_T size_t
340 # elif defined __STDC_VERSION__ && 199901 <= __STDC_VERSION__
341 # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
342 # define YYSIZE_T size_t
343 # else
344 # define YYSIZE_T unsigned
345 # endif
346 #endif
347
348 #define YYSIZE_MAXIMUM \
349 YY_CAST (YYPTRDIFF_T, \
350 (YYPTRDIFF_MAXIMUM < YY_CAST (YYSIZE_T, -1) \
351 ? YYPTRDIFF_MAXIMUM \
352 : YY_CAST (YYSIZE_T, -1)))
353
354 #define YYSIZEOF(X) YY_CAST (YYPTRDIFF_T, sizeof (X))
355
356
357 /* Stored state numbers (used for stacks). */
358 typedef yytype_int8 yy_state_t;
359
360 /* State numbers in computations. */
361 typedef int yy_state_fast_t;
362
363 #ifndef YY_
364 # if defined YYENABLE_NLS && YYENABLE_NLS
365 # if ENABLE_NLS
366 # include <libintl.h> /* INFRINGES ON USER NAME SPACE */
367 # define YY_(Msgid) dgettext ("bison-runtime", Msgid)
368 # endif
369 # endif
370 # ifndef YY_
371 # define YY_(Msgid) Msgid
372 # endif
373 #endif
374
375
376 #ifndef YY_ATTRIBUTE_PURE
377 # if defined __GNUC__ && 2 < __GNUC__ + (96 <= __GNUC_MINOR__)
378 # define YY_ATTRIBUTE_PURE __attribute__ ((__pure__))
379 # else
380 # define YY_ATTRIBUTE_PURE
381 # endif
382 #endif
383
384 #ifndef YY_ATTRIBUTE_UNUSED
385 # if defined __GNUC__ && 2 < __GNUC__ + (7 <= __GNUC_MINOR__)
386 # define YY_ATTRIBUTE_UNUSED __attribute__ ((__unused__))
387 # else
388 # define YY_ATTRIBUTE_UNUSED
389 # endif
390 #endif
391
392 /* Suppress unused-variable warnings by "using" E. */
393 #if ! defined lint || defined __GNUC__
394 # define YY_USE(E) ((void) (E))
395 #else
396 # define YY_USE(E) /* empty */
397 #endif
398
399 /* Suppress an incorrect diagnostic about yylval being uninitialized. */
400 #if defined __GNUC__ && ! defined __ICC && 406 <= __GNUC__ * 100 + __GNUC_MINOR__
401 # if __GNUC__ * 100 + __GNUC_MINOR__ < 407
402 # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
403 _Pragma ("GCC diagnostic push") \
404 _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")
405 # else
406 # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
407 _Pragma ("GCC diagnostic push") \
408 _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"") \
409 _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
410 # endif
411 # define YY_IGNORE_MAYBE_UNINITIALIZED_END \
412 _Pragma ("GCC diagnostic pop")
413 #else
414 # define YY_INITIAL_VALUE(Value) Value
415 #endif
416 #ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
417 # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
418 # define YY_IGNORE_MAYBE_UNINITIALIZED_END
419 #endif
420 #ifndef YY_INITIAL_VALUE
421 # define YY_INITIAL_VALUE(Value) /* Nothing. */
422 #endif
423
424 #if defined __cplusplus && defined __GNUC__ && ! defined __ICC && 6 <= __GNUC__
425 # define YY_IGNORE_USELESS_CAST_BEGIN \
426 _Pragma ("GCC diagnostic push") \
427 _Pragma ("GCC diagnostic ignored \"-Wuseless-cast\"")
428 # define YY_IGNORE_USELESS_CAST_END \
429 _Pragma ("GCC diagnostic pop")
430 #endif
431 #ifndef YY_IGNORE_USELESS_CAST_BEGIN
432 # define YY_IGNORE_USELESS_CAST_BEGIN
433 # define YY_IGNORE_USELESS_CAST_END
434 #endif
435
436
437 #define YY_ASSERT(E) ((void) (0 && (E)))
438
439 #if !defined yyoverflow
440
441 /* The parser invokes alloca or malloc; define the necessary symbols. */
442
443 # ifdef YYSTACK_USE_ALLOCA
444 # if YYSTACK_USE_ALLOCA
445 # ifdef __GNUC__
446 # define YYSTACK_ALLOC __builtin_alloca
447 # elif defined __BUILTIN_VA_ARG_INCR
448 # include <alloca.h> /* INFRINGES ON USER NAME SPACE */
449 # elif defined _AIX
450 # define YYSTACK_ALLOC __alloca
451 # elif defined _MSC_VER
452 # include <malloc.h> /* INFRINGES ON USER NAME SPACE */
453 # define alloca _alloca
454 # else
455 # define YYSTACK_ALLOC alloca
456 # if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS
457 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
458 /* Use EXIT_SUCCESS as a witness for stdlib.h. */
459 # ifndef EXIT_SUCCESS
460 # define EXIT_SUCCESS 0
461 # endif
462 # endif
463 # endif
464 # endif
465 # endif
466
467 # ifdef YYSTACK_ALLOC
468 /* Pacify GCC's 'empty if-body' warning. */
469 # define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
470 # ifndef YYSTACK_ALLOC_MAXIMUM
471 /* The OS might guarantee only one guard page at the bottom of the stack,
472 and a page size can be as small as 4096 bytes. So we cannot safely
473 invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
474 to allow for a few compiler-allocated temporary stack slots. */
475 # define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
476 # endif
477 # else
478 # define YYSTACK_ALLOC YYMALLOC
479 # define YYSTACK_FREE YYFREE
480 # ifndef YYSTACK_ALLOC_MAXIMUM
481 # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
482 # endif
483 # if (defined __cplusplus && ! defined EXIT_SUCCESS \
484 && ! ((defined YYMALLOC || defined malloc) \
485 && (defined YYFREE || defined free)))
486 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
487 # ifndef EXIT_SUCCESS
488 # define EXIT_SUCCESS 0
489 # endif
490 # endif
491 # ifndef YYMALLOC
492 # define YYMALLOC malloc
493 # if ! defined malloc && ! defined EXIT_SUCCESS
494 void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
495 # endif
496 # endif
497 # ifndef YYFREE
498 # define YYFREE free
499 # if ! defined free && ! defined EXIT_SUCCESS
500 void free (void *); /* INFRINGES ON USER NAME SPACE */
501 # endif
502 # endif
503 # endif
504 #endif /* !defined yyoverflow */
505
506 #if (! defined yyoverflow \
507 && (! defined __cplusplus \
508 || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
509
510 /* A type that is properly aligned for any stack member. */
511 union yyalloc
512 {
513 yy_state_t yyss_alloc;
514 YYSTYPE yyvs_alloc;
515 };
516
517 /* The size of the maximum gap between one aligned stack and the next. */
518 # define YYSTACK_GAP_MAXIMUM (YYSIZEOF (union yyalloc) - 1)
519
520 /* The size of an array large to enough to hold all stacks, each with
521 N elements. */
522 # define YYSTACK_BYTES(N) \
523 ((N) * (YYSIZEOF (yy_state_t) + YYSIZEOF (YYSTYPE)) \
524 + YYSTACK_GAP_MAXIMUM)
525
526 # define YYCOPY_NEEDED 1
527
528 /* Relocate STACK from its old location to the new one. The
529 local variables YYSIZE and YYSTACKSIZE give the old and new number of
530 elements in the stack, and YYPTR gives the new location of the
531 stack. Advance YYPTR to a properly aligned location for the next
532 stack. */
533 # define YYSTACK_RELOCATE(Stack_alloc, Stack) \
534 do \
535 { \
536 YYPTRDIFF_T yynewbytes; \
537 YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \
538 Stack = &yyptr->Stack_alloc; \
539 yynewbytes = yystacksize * YYSIZEOF (*Stack) + YYSTACK_GAP_MAXIMUM; \
540 yyptr += yynewbytes / YYSIZEOF (*yyptr); \
541 } \
542 while (0)
543
544 #endif
545
546 #if defined YYCOPY_NEEDED && YYCOPY_NEEDED
547 /* Copy COUNT objects from SRC to DST. The source and destination do
548 not overlap. */
549 # ifndef YYCOPY
550 # if defined __GNUC__ && 1 < __GNUC__
551 # define YYCOPY(Dst, Src, Count) \
552 __builtin_memcpy (Dst, Src, YY_CAST (YYSIZE_T, (Count)) * sizeof (*(Src)))
553 # else
554 # define YYCOPY(Dst, Src, Count) \
555 do \
556 { \
557 YYPTRDIFF_T yyi; \
558 for (yyi = 0; yyi < (Count); yyi++) \
559 (Dst)[yyi] = (Src)[yyi]; \
560 } \
561 while (0)
562 # endif
563 # endif
564 #endif /* !YYCOPY_NEEDED */
565
566 /* YYFINAL -- State number of the termination state. */
567 #define YYFINAL 9
568 /* YYLAST -- Last index in YYTABLE. */
569 #define YYLAST 23
570
571 /* YYNTOKENS -- Number of terminals. */
572 #define YYNTOKENS 12
573 /* YYNNTS -- Number of nonterminals. */
574 #define YYNNTS 7
575 /* YYNRULES -- Number of rules. */
576 #define YYNRULES 15
577 /* YYNSTATES -- Number of states. */
578 #define YYNSTATES 24
579
580 /* YYMAXUTOK -- Last valid token kind. */
581 #define YYMAXUTOK 265
582
583
584 /* YYTRANSLATE(TOKEN-NUM) -- Symbol number corresponding to TOKEN-NUM
585 as returned by yylex, with out-of-bounds checking. */
586 #define YYTRANSLATE(YYX) \
587 (0 <= (YYX) && (YYX) <= YYMAXUTOK \
588 ? YY_CAST (yysymbol_kind_t, yytranslate[YYX]) \
589 : YYSYMBOL_YYUNDEF)
590
591 /* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM
592 as returned by yylex. */
593 static const yytype_int8 yytranslate[] =
594 {
595 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
596 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
597 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
598 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
599 2, 2, 2, 2, 11, 2, 2, 2, 2, 2,
600 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
601 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
602 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
603 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
604 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
605 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
606 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
607 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
608 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
609 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
610 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
611 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
612 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
613 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
614 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
615 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
616 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
617 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
618 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
619 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
620 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
621 5, 6, 7, 8, 9, 10
622 };
623
624 #if YYDEBUG
625 /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */
626 static const yytype_uint8 yyrline[] =
627 {
628 0, 65, 65, 66, 69, 70, 73, 79, 85, 94,
629 95, 98, 102, 110, 117, 137
630 };
631 #endif
632
633 /** Accessing symbol of state STATE. */
634 #define YY_ACCESSING_SYMBOL(State) YY_CAST (yysymbol_kind_t, yystos[State])
635
636 #if YYDEBUG || 0
637 /* The user-facing name of the symbol whose (internal) number is
638 YYSYMBOL. No bounds checking. */
639 static const char *yysymbol_name (yysymbol_kind_t yysymbol) YY_ATTRIBUTE_UNUSED;
640
641 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
642 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
643 static const char *const yytname[] =
644 {
645 "\"end of file\"", "error", "\"invalid token\"", "ET", "INDEX",
646 "PREFIX", "EC", "ID", "END", "STRING", "NUMBER", "','", "$accept",
647 "file", "header", "id", "et", "statements", "statement", YY_NULLPTR
648 };
649
650 static const char *
yysymbol_name(yysymbol_kind_t yysymbol)651 yysymbol_name (yysymbol_kind_t yysymbol)
652 {
653 return yytname[yysymbol];
654 }
655 #endif
656
657 #define YYPACT_NINF (-5)
658
659 #define yypact_value_is_default(Yyn) \
660 ((Yyn) == YYPACT_NINF)
661
662 #define YYTABLE_NINF (-1)
663
664 #define yytable_value_is_error(Yyn) \
665 0
666
667 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
668 STATE-NUM. */
669 static const yytype_int8 yypact[] =
670 {
671 0, -3, -1, 5, -4, 6, -5, 1, -5, -5,
672 2, 4, 7, -5, -4, -5, -5, -5, -5, -5,
673 3, -5, 8, -5
674 };
675
676 /* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM.
677 Performed when YYTABLE does not specify something else to do. Zero
678 means the default is an error. */
679 static const yytype_int8 yydefact[] =
680 {
681 2, 0, 0, 0, 0, 0, 5, 7, 6, 1,
682 0, 13, 0, 15, 3, 9, 4, 8, 11, 12,
683 0, 10, 0, 14
684 };
685
686 /* YYPGOTO[NTERM-NUM]. */
687 static const yytype_int8 yypgoto[] =
688 {
689 -5, -5, -5, -5, 10, -5, 9
690 };
691
692 /* YYDEFGOTO[NTERM-NUM]. */
693 static const yytype_int8 yydefgoto[] =
694 {
695 0, 3, 4, 5, 6, 14, 15
696 };
697
698 /* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If
699 positive, shift that token. If negative, reduce the rule whose
700 number is the opposite. If YYTABLE_NINF, syntax error. */
701 static const yytype_int8 yytable[] =
702 {
703 10, 11, 12, 1, 13, 9, 7, 2, 8, 1,
704 17, 0, 18, 19, 22, 16, 20, 23, 0, 0,
705 0, 0, 0, 21
706 };
707
708 static const yytype_int8 yycheck[] =
709 {
710 4, 5, 6, 3, 8, 0, 9, 7, 9, 3,
711 9, -1, 10, 9, 11, 5, 9, 9, -1, -1,
712 -1, -1, -1, 14
713 };
714
715 /* YYSTOS[STATE-NUM] -- The symbol kind of the accessing symbol of
716 state STATE-NUM. */
717 static const yytype_int8 yystos[] =
718 {
719 0, 3, 7, 13, 14, 15, 16, 9, 9, 0,
720 4, 5, 6, 8, 17, 18, 16, 9, 10, 9,
721 9, 18, 11, 9
722 };
723
724 /* YYR1[RULE-NUM] -- Symbol kind of the left-hand side of rule RULE-NUM. */
725 static const yytype_int8 yyr1[] =
726 {
727 0, 12, 13, 13, 14, 14, 15, 16, 16, 17,
728 17, 18, 18, 18, 18, 18
729 };
730
731 /* YYR2[RULE-NUM] -- Number of symbols on the right-hand side of rule RULE-NUM. */
732 static const yytype_int8 yyr2[] =
733 {
734 0, 2, 0, 2, 2, 1, 2, 2, 3, 1,
735 2, 2, 2, 1, 4, 1
736 };
737
738
739 enum { YYENOMEM = -2 };
740
741 #define yyerrok (yyerrstatus = 0)
742 #define yyclearin (yychar = YYEMPTY)
743
744 #define YYACCEPT goto yyacceptlab
745 #define YYABORT goto yyabortlab
746 #define YYERROR goto yyerrorlab
747 #define YYNOMEM goto yyexhaustedlab
748
749
750 #define YYRECOVERING() (!!yyerrstatus)
751
752 #define YYBACKUP(Token, Value) \
753 do \
754 if (yychar == YYEMPTY) \
755 { \
756 yychar = (Token); \
757 yylval = (Value); \
758 YYPOPSTACK (yylen); \
759 yystate = *yyssp; \
760 goto yybackup; \
761 } \
762 else \
763 { \
764 yyerror (YY_("syntax error: cannot back up")); \
765 YYERROR; \
766 } \
767 while (0)
768
769 /* Backward compatibility with an undocumented macro.
770 Use YYerror or YYUNDEF. */
771 #define YYERRCODE YYUNDEF
772
773
774 /* Enable debugging if requested. */
775 #if YYDEBUG
776
777 # ifndef YYFPRINTF
778 # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
779 # define YYFPRINTF fprintf
780 # endif
781
782 # define YYDPRINTF(Args) \
783 do { \
784 if (yydebug) \
785 YYFPRINTF Args; \
786 } while (0)
787
788
789
790
791 # define YY_SYMBOL_PRINT(Title, Kind, Value, Location) \
792 do { \
793 if (yydebug) \
794 { \
795 YYFPRINTF (stderr, "%s ", Title); \
796 yy_symbol_print (stderr, \
797 Kind, Value); \
798 YYFPRINTF (stderr, "\n"); \
799 } \
800 } while (0)
801
802
803 /*-----------------------------------.
804 | Print this symbol's value on YYO. |
805 `-----------------------------------*/
806
807 static void
yy_symbol_value_print(FILE * yyo,yysymbol_kind_t yykind,YYSTYPE const * const yyvaluep)808 yy_symbol_value_print (FILE *yyo,
809 yysymbol_kind_t yykind, YYSTYPE const * const yyvaluep)
810 {
811 FILE *yyoutput = yyo;
812 YY_USE (yyoutput);
813 if (!yyvaluep)
814 return;
815 YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
816 YY_USE (yykind);
817 YY_IGNORE_MAYBE_UNINITIALIZED_END
818 }
819
820
821 /*---------------------------.
822 | Print this symbol on YYO. |
823 `---------------------------*/
824
825 static void
yy_symbol_print(FILE * yyo,yysymbol_kind_t yykind,YYSTYPE const * const yyvaluep)826 yy_symbol_print (FILE *yyo,
827 yysymbol_kind_t yykind, YYSTYPE const * const yyvaluep)
828 {
829 YYFPRINTF (yyo, "%s %s (",
830 yykind < YYNTOKENS ? "token" : "nterm", yysymbol_name (yykind));
831
832 yy_symbol_value_print (yyo, yykind, yyvaluep);
833 YYFPRINTF (yyo, ")");
834 }
835
836 /*------------------------------------------------------------------.
837 | yy_stack_print -- Print the state stack from its BOTTOM up to its |
838 | TOP (included). |
839 `------------------------------------------------------------------*/
840
841 static void
yy_stack_print(yy_state_t * yybottom,yy_state_t * yytop)842 yy_stack_print (yy_state_t *yybottom, yy_state_t *yytop)
843 {
844 YYFPRINTF (stderr, "Stack now");
845 for (; yybottom <= yytop; yybottom++)
846 {
847 int yybot = *yybottom;
848 YYFPRINTF (stderr, " %d", yybot);
849 }
850 YYFPRINTF (stderr, "\n");
851 }
852
853 # define YY_STACK_PRINT(Bottom, Top) \
854 do { \
855 if (yydebug) \
856 yy_stack_print ((Bottom), (Top)); \
857 } while (0)
858
859
860 /*------------------------------------------------.
861 | Report that the YYRULE is going to be reduced. |
862 `------------------------------------------------*/
863
864 static void
yy_reduce_print(yy_state_t * yyssp,YYSTYPE * yyvsp,int yyrule)865 yy_reduce_print (yy_state_t *yyssp, YYSTYPE *yyvsp,
866 int yyrule)
867 {
868 int yylno = yyrline[yyrule];
869 int yynrhs = yyr2[yyrule];
870 int yyi;
871 YYFPRINTF (stderr, "Reducing stack by rule %d (line %d):\n",
872 yyrule - 1, yylno);
873 /* The symbols being reduced. */
874 for (yyi = 0; yyi < yynrhs; yyi++)
875 {
876 YYFPRINTF (stderr, " $%d = ", yyi + 1);
877 yy_symbol_print (stderr,
878 YY_ACCESSING_SYMBOL (+yyssp[yyi + 1 - yynrhs]),
879 &yyvsp[(yyi + 1) - (yynrhs)]);
880 YYFPRINTF (stderr, "\n");
881 }
882 }
883
884 # define YY_REDUCE_PRINT(Rule) \
885 do { \
886 if (yydebug) \
887 yy_reduce_print (yyssp, yyvsp, Rule); \
888 } while (0)
889
890 /* Nonzero means print parse trace. It is left uninitialized so that
891 multiple parsers can coexist. */
892 int yydebug;
893 #else /* !YYDEBUG */
894 # define YYDPRINTF(Args) ((void) 0)
895 # define YY_SYMBOL_PRINT(Title, Kind, Value, Location)
896 # define YY_STACK_PRINT(Bottom, Top)
897 # define YY_REDUCE_PRINT(Rule)
898 #endif /* !YYDEBUG */
899
900
901 /* YYINITDEPTH -- initial size of the parser's stacks. */
902 #ifndef YYINITDEPTH
903 # define YYINITDEPTH 200
904 #endif
905
906 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
907 if the built-in stack extension method is used).
908
909 Do not make this value too large; the results are undefined if
910 YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
911 evaluated with infinite-precision integer arithmetic. */
912
913 #ifndef YYMAXDEPTH
914 # define YYMAXDEPTH 10000
915 #endif
916
917
918
919
920
921
922 /*-----------------------------------------------.
923 | Release the memory associated to this symbol. |
924 `-----------------------------------------------*/
925
926 static void
yydestruct(const char * yymsg,yysymbol_kind_t yykind,YYSTYPE * yyvaluep)927 yydestruct (const char *yymsg,
928 yysymbol_kind_t yykind, YYSTYPE *yyvaluep)
929 {
930 YY_USE (yyvaluep);
931 if (!yymsg)
932 yymsg = "Deleting";
933 YY_SYMBOL_PRINT (yymsg, yykind, yyvaluep, yylocationp);
934
935 YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
936 YY_USE (yykind);
937 YY_IGNORE_MAYBE_UNINITIALIZED_END
938 }
939
940
941 /* Lookahead token kind. */
942 int yychar;
943
944 /* The semantic value of the lookahead symbol. */
945 YYSTYPE yylval;
946 /* Number of syntax errors so far. */
947 int yynerrs;
948
949
950
951
952 /*----------.
953 | yyparse. |
954 `----------*/
955
956 int
yyparse(void)957 yyparse (void)
958 {
959 yy_state_fast_t yystate = 0;
960 /* Number of tokens to shift before error messages enabled. */
961 int yyerrstatus = 0;
962
963 /* Refer to the stacks through separate pointers, to allow yyoverflow
964 to reallocate them elsewhere. */
965
966 /* Their size. */
967 YYPTRDIFF_T yystacksize = YYINITDEPTH;
968
969 /* The state stack: array, bottom, top. */
970 yy_state_t yyssa[YYINITDEPTH];
971 yy_state_t *yyss = yyssa;
972 yy_state_t *yyssp = yyss;
973
974 /* The semantic value stack: array, bottom, top. */
975 YYSTYPE yyvsa[YYINITDEPTH];
976 YYSTYPE *yyvs = yyvsa;
977 YYSTYPE *yyvsp = yyvs;
978
979 int yyn;
980 /* The return value of yyparse. */
981 int yyresult;
982 /* Lookahead symbol kind. */
983 yysymbol_kind_t yytoken = YYSYMBOL_YYEMPTY;
984 /* The variables used to return semantic value and location from the
985 action routines. */
986 YYSTYPE yyval;
987
988
989
990 #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
991
992 /* The number of symbols on the RHS of the reduced rule.
993 Keep to zero when no symbol should be popped. */
994 int yylen = 0;
995
996 YYDPRINTF ((stderr, "Starting parse\n"));
997
998 yychar = YYEMPTY; /* Cause a token to be read. */
999
1000 goto yysetstate;
1001
1002
1003 /*------------------------------------------------------------.
1004 | yynewstate -- push a new state, which is found in yystate. |
1005 `------------------------------------------------------------*/
1006 yynewstate:
1007 /* In all cases, when you get here, the value and location stacks
1008 have just been pushed. So pushing a state here evens the stacks. */
1009 yyssp++;
1010
1011
1012 /*--------------------------------------------------------------------.
1013 | yysetstate -- set current state (the top of the stack) to yystate. |
1014 `--------------------------------------------------------------------*/
1015 yysetstate:
1016 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
1017 YY_ASSERT (0 <= yystate && yystate < YYNSTATES);
1018 YY_IGNORE_USELESS_CAST_BEGIN
1019 *yyssp = YY_CAST (yy_state_t, yystate);
1020 YY_IGNORE_USELESS_CAST_END
1021 YY_STACK_PRINT (yyss, yyssp);
1022
1023 if (yyss + yystacksize - 1 <= yyssp)
1024 #if !defined yyoverflow && !defined YYSTACK_RELOCATE
1025 YYNOMEM;
1026 #else
1027 {
1028 /* Get the current used size of the three stacks, in elements. */
1029 YYPTRDIFF_T yysize = yyssp - yyss + 1;
1030
1031 # if defined yyoverflow
1032 {
1033 /* Give user a chance to reallocate the stack. Use copies of
1034 these so that the &'s don't force the real ones into
1035 memory. */
1036 yy_state_t *yyss1 = yyss;
1037 YYSTYPE *yyvs1 = yyvs;
1038
1039 /* Each stack pointer address is followed by the size of the
1040 data in use in that stack, in bytes. This used to be a
1041 conditional around just the two extra args, but that might
1042 be undefined if yyoverflow is a macro. */
1043 yyoverflow (YY_("memory exhausted"),
1044 &yyss1, yysize * YYSIZEOF (*yyssp),
1045 &yyvs1, yysize * YYSIZEOF (*yyvsp),
1046 &yystacksize);
1047 yyss = yyss1;
1048 yyvs = yyvs1;
1049 }
1050 # else /* defined YYSTACK_RELOCATE */
1051 /* Extend the stack our own way. */
1052 if (YYMAXDEPTH <= yystacksize)
1053 YYNOMEM;
1054 yystacksize *= 2;
1055 if (YYMAXDEPTH < yystacksize)
1056 yystacksize = YYMAXDEPTH;
1057
1058 {
1059 yy_state_t *yyss1 = yyss;
1060 union yyalloc *yyptr =
1061 YY_CAST (union yyalloc *,
1062 YYSTACK_ALLOC (YY_CAST (YYSIZE_T, YYSTACK_BYTES (yystacksize))));
1063 if (! yyptr)
1064 YYNOMEM;
1065 YYSTACK_RELOCATE (yyss_alloc, yyss);
1066 YYSTACK_RELOCATE (yyvs_alloc, yyvs);
1067 # undef YYSTACK_RELOCATE
1068 if (yyss1 != yyssa)
1069 YYSTACK_FREE (yyss1);
1070 }
1071 # endif
1072
1073 yyssp = yyss + yysize - 1;
1074 yyvsp = yyvs + yysize - 1;
1075
1076 YY_IGNORE_USELESS_CAST_BEGIN
1077 YYDPRINTF ((stderr, "Stack size increased to %ld\n",
1078 YY_CAST (long, yystacksize)));
1079 YY_IGNORE_USELESS_CAST_END
1080
1081 if (yyss + yystacksize - 1 <= yyssp)
1082 YYABORT;
1083 }
1084 #endif /* !defined yyoverflow && !defined YYSTACK_RELOCATE */
1085
1086
1087 if (yystate == YYFINAL)
1088 YYACCEPT;
1089
1090 goto yybackup;
1091
1092
1093 /*-----------.
1094 | yybackup. |
1095 `-----------*/
1096 yybackup:
1097 /* Do appropriate processing given the current state. Read a
1098 lookahead token if we need one and don't already have one. */
1099
1100 /* First try to decide what to do without reference to lookahead token. */
1101 yyn = yypact[yystate];
1102 if (yypact_value_is_default (yyn))
1103 goto yydefault;
1104
1105 /* Not known => get a lookahead token if don't already have one. */
1106
1107 /* YYCHAR is either empty, or end-of-input, or a valid lookahead. */
1108 if (yychar == YYEMPTY)
1109 {
1110 YYDPRINTF ((stderr, "Reading a token\n"));
1111 yychar = yylex ();
1112 }
1113
1114 if (yychar <= YYEOF)
1115 {
1116 yychar = YYEOF;
1117 yytoken = YYSYMBOL_YYEOF;
1118 YYDPRINTF ((stderr, "Now at end of input.\n"));
1119 }
1120 else if (yychar == YYerror)
1121 {
1122 /* The scanner already issued an error message, process directly
1123 to error recovery. But do not keep the error token as
1124 lookahead, it is too special and may lead us to an endless
1125 loop in error recovery. */
1126 yychar = YYUNDEF;
1127 yytoken = YYSYMBOL_YYerror;
1128 goto yyerrlab1;
1129 }
1130 else
1131 {
1132 yytoken = YYTRANSLATE (yychar);
1133 YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
1134 }
1135
1136 /* If the proper action on seeing token YYTOKEN is to reduce or to
1137 detect an error, take that action. */
1138 yyn += yytoken;
1139 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
1140 goto yydefault;
1141 yyn = yytable[yyn];
1142 if (yyn <= 0)
1143 {
1144 if (yytable_value_is_error (yyn))
1145 goto yyerrlab;
1146 yyn = -yyn;
1147 goto yyreduce;
1148 }
1149
1150 /* Count tokens shifted since error; after three, turn off error
1151 status. */
1152 if (yyerrstatus)
1153 yyerrstatus--;
1154
1155 /* Shift the lookahead token. */
1156 YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
1157 yystate = yyn;
1158 YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1159 *++yyvsp = yylval;
1160 YY_IGNORE_MAYBE_UNINITIALIZED_END
1161
1162 /* Discard the shifted token. */
1163 yychar = YYEMPTY;
1164 goto yynewstate;
1165
1166
1167 /*-----------------------------------------------------------.
1168 | yydefault -- do the default action for the current state. |
1169 `-----------------------------------------------------------*/
1170 yydefault:
1171 yyn = yydefact[yystate];
1172 if (yyn == 0)
1173 goto yyerrlab;
1174 goto yyreduce;
1175
1176
1177 /*-----------------------------.
1178 | yyreduce -- do a reduction. |
1179 `-----------------------------*/
1180 yyreduce:
1181 /* yyn is the number of a rule to reduce with. */
1182 yylen = yyr2[yyn];
1183
1184 /* If YYLEN is nonzero, implement the default value of the action:
1185 '$$ = $1'.
1186
1187 Otherwise, the following line sets YYVAL to garbage.
1188 This behavior is undocumented and Bison
1189 users should not rely upon it. Assigning to YYVAL
1190 unconditionally makes the parser a bit smaller, and it avoids a
1191 GCC warning that YYVAL may be used uninitialized. */
1192 yyval = yyvsp[1-yylen];
1193
1194
1195 YY_REDUCE_PRINT (yyn);
1196 switch (yyn)
1197 {
1198 case 6: /* id: ID STRING */
1199 #line 74 "parse.y"
1200 {
1201 id_str = (yyvsp[0].string);
1202 }
1203 #line 1202 "parse.c"
1204 break;
1205
1206 case 7: /* et: ET STRING */
1207 #line 80 "parse.y"
1208 {
1209 base_id = name2number((yyvsp[0].string));
1210 strlcpy(name, (yyvsp[0].string), sizeof(name));
1211 free((yyvsp[0].string));
1212 }
1213 #line 1212 "parse.c"
1214 break;
1215
1216 case 8: /* et: ET STRING STRING */
1217 #line 86 "parse.y"
1218 {
1219 base_id = name2number((yyvsp[-1].string));
1220 strlcpy(name, (yyvsp[0].string), sizeof(name));
1221 free((yyvsp[-1].string));
1222 free((yyvsp[0].string));
1223 }
1224 #line 1223 "parse.c"
1225 break;
1226
1227 case 11: /* statement: INDEX NUMBER */
1228 #line 99 "parse.y"
1229 {
1230 number = (yyvsp[0].number);
1231 }
1232 #line 1231 "parse.c"
1233 break;
1234
1235 case 12: /* statement: PREFIX STRING */
1236 #line 103 "parse.y"
1237 {
1238 free(prefix);
1239 asprintf (&prefix, "%s_", (yyvsp[0].string));
1240 if (prefix == NULL)
1241 errx(1, "malloc");
1242 free((yyvsp[0].string));
1243 }
1244 #line 1243 "parse.c"
1245 break;
1246
1247 case 13: /* statement: PREFIX */
1248 #line 111 "parse.y"
1249 {
1250 prefix = realloc(prefix, 1);
1251 if (prefix == NULL)
1252 errx(1, "malloc");
1253 *prefix = '\0';
1254 }
1255 #line 1254 "parse.c"
1256 break;
1257
1258 case 14: /* statement: EC STRING ',' STRING */
1259 #line 118 "parse.y"
1260 {
1261 struct error_code *ec = malloc(sizeof(*ec));
1262
1263 if (ec == NULL)
1264 errx(1, "malloc");
1265
1266 ec->next = NULL;
1267 ec->number = number;
1268 if(prefix && *prefix != '\0') {
1269 asprintf (&ec->name, "%s%s", prefix, (yyvsp[-2].string));
1270 if (ec->name == NULL)
1271 errx(1, "malloc");
1272 free((yyvsp[-2].string));
1273 } else
1274 ec->name = (yyvsp[-2].string);
1275 ec->string = (yyvsp[0].string);
1276 APPEND(codes, ec);
1277 number++;
1278 }
1279 #line 1278 "parse.c"
1280 break;
1281
1282 case 15: /* statement: END */
1283 #line 138 "parse.y"
1284 {
1285 YYACCEPT;
1286 }
1287 #line 1286 "parse.c"
1288 break;
1289
1290
1291 #line 1290 "parse.c"
1292
1293 default: break;
1294 }
1295 /* User semantic actions sometimes alter yychar, and that requires
1296 that yytoken be updated with the new translation. We take the
1297 approach of translating immediately before every use of yytoken.
1298 One alternative is translating here after every semantic action,
1299 but that translation would be missed if the semantic action invokes
1300 YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or
1301 if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an
1302 incorrect destructor might then be invoked immediately. In the
1303 case of YYERROR or YYBACKUP, subsequent parser actions might lead
1304 to an incorrect destructor call or verbose syntax error message
1305 before the lookahead is translated. */
1306 YY_SYMBOL_PRINT ("-> $$ =", YY_CAST (yysymbol_kind_t, yyr1[yyn]), &yyval, &yyloc);
1307
1308 YYPOPSTACK (yylen);
1309 yylen = 0;
1310
1311 *++yyvsp = yyval;
1312
1313 /* Now 'shift' the result of the reduction. Determine what state
1314 that goes to, based on the state we popped back to and the rule
1315 number reduced by. */
1316 {
1317 const int yylhs = yyr1[yyn] - YYNTOKENS;
1318 const int yyi = yypgoto[yylhs] + *yyssp;
1319 yystate = (0 <= yyi && yyi <= YYLAST && yycheck[yyi] == *yyssp
1320 ? yytable[yyi]
1321 : yydefgoto[yylhs]);
1322 }
1323
1324 goto yynewstate;
1325
1326
1327 /*--------------------------------------.
1328 | yyerrlab -- here on detecting error. |
1329 `--------------------------------------*/
1330 yyerrlab:
1331 /* Make sure we have latest lookahead translation. See comments at
1332 user semantic actions for why this is necessary. */
1333 yytoken = yychar == YYEMPTY ? YYSYMBOL_YYEMPTY : YYTRANSLATE (yychar);
1334 /* If not already recovering from an error, report this error. */
1335 if (!yyerrstatus)
1336 {
1337 ++yynerrs;
1338 yyerror (YY_("syntax error"));
1339 }
1340
1341 if (yyerrstatus == 3)
1342 {
1343 /* If just tried and failed to reuse lookahead token after an
1344 error, discard it. */
1345
1346 if (yychar <= YYEOF)
1347 {
1348 /* Return failure if at end of input. */
1349 if (yychar == YYEOF)
1350 YYABORT;
1351 }
1352 else
1353 {
1354 yydestruct ("Error: discarding",
1355 yytoken, &yylval);
1356 yychar = YYEMPTY;
1357 }
1358 }
1359
1360 /* Else will try to reuse lookahead token after shifting the error
1361 token. */
1362 goto yyerrlab1;
1363
1364
1365 /*---------------------------------------------------.
1366 | yyerrorlab -- error raised explicitly by YYERROR. |
1367 `---------------------------------------------------*/
1368 yyerrorlab:
1369 /* Pacify compilers when the user code never invokes YYERROR and the
1370 label yyerrorlab therefore never appears in user code. */
1371 if (0)
1372 YYERROR;
1373 ++yynerrs;
1374
1375 /* Do not reclaim the symbols of the rule whose action triggered
1376 this YYERROR. */
1377 YYPOPSTACK (yylen);
1378 yylen = 0;
1379 YY_STACK_PRINT (yyss, yyssp);
1380 yystate = *yyssp;
1381 goto yyerrlab1;
1382
1383
1384 /*-------------------------------------------------------------.
1385 | yyerrlab1 -- common code for both syntax error and YYERROR. |
1386 `-------------------------------------------------------------*/
1387 yyerrlab1:
1388 yyerrstatus = 3; /* Each real token shifted decrements this. */
1389
1390 /* Pop stack until we find a state that shifts the error token. */
1391 for (;;)
1392 {
1393 yyn = yypact[yystate];
1394 if (!yypact_value_is_default (yyn))
1395 {
1396 yyn += YYSYMBOL_YYerror;
1397 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYSYMBOL_YYerror)
1398 {
1399 yyn = yytable[yyn];
1400 if (0 < yyn)
1401 break;
1402 }
1403 }
1404
1405 /* Pop the current state because it cannot handle the error token. */
1406 if (yyssp == yyss)
1407 YYABORT;
1408
1409
1410 yydestruct ("Error: popping",
1411 YY_ACCESSING_SYMBOL (yystate), yyvsp);
1412 YYPOPSTACK (1);
1413 yystate = *yyssp;
1414 YY_STACK_PRINT (yyss, yyssp);
1415 }
1416
1417 YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1418 *++yyvsp = yylval;
1419 YY_IGNORE_MAYBE_UNINITIALIZED_END
1420
1421
1422 /* Shift the error token. */
1423 YY_SYMBOL_PRINT ("Shifting", YY_ACCESSING_SYMBOL (yyn), yyvsp, yylsp);
1424
1425 yystate = yyn;
1426 goto yynewstate;
1427
1428
1429 /*-------------------------------------.
1430 | yyacceptlab -- YYACCEPT comes here. |
1431 `-------------------------------------*/
1432 yyacceptlab:
1433 yyresult = 0;
1434 goto yyreturnlab;
1435
1436
1437 /*-----------------------------------.
1438 | yyabortlab -- YYABORT comes here. |
1439 `-----------------------------------*/
1440 yyabortlab:
1441 yyresult = 1;
1442 goto yyreturnlab;
1443
1444
1445 /*-----------------------------------------------------------.
1446 | yyexhaustedlab -- YYNOMEM (memory exhaustion) comes here. |
1447 `-----------------------------------------------------------*/
1448 yyexhaustedlab:
1449 yyerror (YY_("memory exhausted"));
1450 yyresult = 2;
1451 goto yyreturnlab;
1452
1453
1454 /*----------------------------------------------------------.
1455 | yyreturnlab -- parsing is finished, clean up and return. |
1456 `----------------------------------------------------------*/
1457 yyreturnlab:
1458 if (yychar != YYEMPTY)
1459 {
1460 /* Make sure we have latest lookahead translation. See comments at
1461 user semantic actions for why this is necessary. */
1462 yytoken = YYTRANSLATE (yychar);
1463 yydestruct ("Cleanup: discarding lookahead",
1464 yytoken, &yylval);
1465 }
1466 /* Do not reclaim the symbols of the rule whose action triggered
1467 this YYABORT or YYACCEPT. */
1468 YYPOPSTACK (yylen);
1469 YY_STACK_PRINT (yyss, yyssp);
1470 while (yyssp != yyss)
1471 {
1472 yydestruct ("Cleanup: popping",
1473 YY_ACCESSING_SYMBOL (+*yyssp), yyvsp);
1474 YYPOPSTACK (1);
1475 }
1476 #ifndef yyoverflow
1477 if (yyss != yyssa)
1478 YYSTACK_FREE (yyss);
1479 #endif
1480
1481 return yyresult;
1482 }
1483
1484 #line 143 "parse.y"
1485
1486
1487 static long
name2number(const char * str)1488 name2number(const char *str)
1489 {
1490 const char *p;
1491 long num = 0;
1492 const char *x = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
1493 "abcdefghijklmnopqrstuvwxyz0123456789_";
1494 if(strlen(str) > 4) {
1495 yyerror("table name too long");
1496 return 0;
1497 }
1498 for(p = str; *p; p++){
1499 char *q = strchr(x, *p);
1500 if(q == NULL) {
1501 yyerror("invalid character in table name");
1502 return 0;
1503 }
1504 num = (num << 6) + (q - x) + 1;
1505 }
1506 num <<= 8;
1507 if(num > 0x7fffffff)
1508 num = -(0xffffffff - num + 1);
1509 return num;
1510 }
1511
1512 void
yyerror(char * s)1513 yyerror (char *s)
1514 {
1515 _lex_error_message ("%s\n", s);
1516 }
1517