Imported Upstream version 1.6.1
[platform/upstream/libksba.git] / src / asn1-parse.c
1 /* A Bison parser, made by GNU Bison 3.3.2.  */
2
3 /* Bison implementation for Yacc-like parsers in C
4
5    Copyright (C) 1984, 1989-1990, 2000-2015, 2018-2019 Free Software Foundation,
6    Inc.
7
8    This program is free software: you can redistribute it and/or modify
9    it under the terms of the GNU General Public License as published by
10    the Free Software Foundation, either version 3 of the License, or
11    (at your option) any later version.
12
13    This program is distributed in the hope that it will be useful,
14    but WITHOUT ANY WARRANTY; without even the implied warranty of
15    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16    GNU General Public License for more details.
17
18    You should have received a copy of the GNU General Public License
19    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
20
21 /* As a special exception, you may create a larger work that contains
22    part or all of the Bison parser skeleton and distribute that work
23    under terms of your choice, so long as that work isn't itself a
24    parser generator using the skeleton or a modified version thereof
25    as a parser skeleton.  Alternatively, if you modify or redistribute
26    the parser skeleton itself, you may (at your option) remove this
27    special exception, which will cause the skeleton and the resulting
28    Bison output files to be licensed under the GNU General Public
29    License without this special exception.
30
31    This special exception was added by the Free Software Foundation in
32    version 2.2 of Bison.  */
33
34 /* C LALR(1) parser skeleton written by Richard Stallman, by
35    simplifying the original so-called "semantic" parser.  */
36
37 /* All symbols defined below should begin with yy or YY, to avoid
38    infringing on user name space.  This should be done even for local
39    variables, as they might otherwise be expanded by user macros.
40    There are some unavoidable exceptions within include files to
41    define necessary library symbols; they are noted "INFRINGES ON
42    USER NAME SPACE" below.  */
43
44 /* Undocumented macros, especially those whose name start with YY_,
45    are private implementation details.  Do not rely on them.  */
46
47 /* Identify Bison output.  */
48 #define YYBISON 1
49
50 /* Bison version.  */
51 #define YYBISON_VERSION "3.3.2"
52
53 /* Skeleton name.  */
54 #define YYSKELETON_NAME "yacc.c"
55
56 /* Pure parsers.  */
57 #define YYPURE 2
58
59 /* Push parsers.  */
60 #define YYPUSH 0
61
62 /* Pull parsers.  */
63 #define YYPULL 1
64
65
66
67
68 /* First part of user prologue.  */
69 #line 42 "/home/wk/s/libksba/src/asn1-parse.y" /* yacc.c:337  */
70
71 #ifndef BUILD_GENTOOLS
72 # include <config.h>
73 #endif
74 #include <stdlib.h>
75 #include <stdio.h>
76 #include <string.h>
77 #include <assert.h>
78 #include <ctype.h>
79 #include <errno.h>
80
81 #ifdef BUILD_GENTOOLS
82 # include "gen-help.h"
83 #else
84 # include "util.h"
85 # include "ksba.h"
86 #endif
87
88 #include "asn1-func.h"
89
90 /* It would be better to make yyparse static but there is no way to do
91    this.  Let's hope that this macros works. */
92 #define yyparse _ksba_asn1_yyparse
93
94 /* #define YYDEBUG 1 */
95 #define MAX_STRING_LENGTH 129
96
97
98 /* constants used in the grammar */
99 enum {
100   CONST_EXPLICIT = 1,
101   CONST_IMPLICIT
102 };
103
104 struct parser_control_s {
105   FILE *fp;
106   int lineno;
107   int debug;
108   int result_parse;
109   AsnNode parse_tree;
110   AsnNode all_nodes;
111 };
112 #define PARSECTL ((struct parser_control_s *)parm)
113
114
115 #line 116 "asn1-parse.c" /* yacc.c:337  */
116 # ifndef YY_NULLPTR
117 #  if defined __cplusplus
118 #   if 201103L <= __cplusplus
119 #    define YY_NULLPTR nullptr
120 #   else
121 #    define YY_NULLPTR 0
122 #   endif
123 #  else
124 #   define YY_NULLPTR ((void*)0)
125 #  endif
126 # endif
127
128 /* Enabling verbose error messages.  */
129 #ifdef YYERROR_VERBOSE
130 # undef YYERROR_VERBOSE
131 # define YYERROR_VERBOSE 1
132 #else
133 # define YYERROR_VERBOSE 1
134 #endif
135
136
137 /* Debug traces.  */
138 #ifndef YYDEBUG
139 # define YYDEBUG 0
140 #endif
141 #if YYDEBUG
142 extern int yydebug;
143 #endif
144
145 /* Token type.  */
146 #ifndef YYTOKENTYPE
147 # define YYTOKENTYPE
148   enum yytokentype
149   {
150     ASSIG = 258,
151     NUM = 259,
152     IDENTIFIER = 260,
153     OPTIONAL = 261,
154     INTEGER = 262,
155     SIZE = 263,
156     OCTET = 264,
157     STRING = 265,
158     SEQUENCE = 266,
159     BIT = 267,
160     UNIVERSAL = 268,
161     PRIVATE = 269,
162     DEFAULT = 270,
163     CHOICE = 271,
164     OF = 272,
165     OBJECT = 273,
166     STR_IDENTIFIER = 274,
167     ksba_BOOLEAN = 275,
168     ksba_TRUE = 276,
169     ksba_FALSE = 277,
170     APPLICATION = 278,
171     ANY = 279,
172     DEFINED = 280,
173     SET = 281,
174     BY = 282,
175     EXPLICIT = 283,
176     IMPLICIT = 284,
177     DEFINITIONS = 285,
178     TAGS = 286,
179     ksba_BEGIN = 287,
180     ksba_END = 288,
181     UTCTime = 289,
182     GeneralizedTime = 290,
183     FROM = 291,
184     IMPORTS = 292,
185     TOKEN_NULL = 293,
186     ENUMERATED = 294,
187     UTF8STRING = 295,
188     NUMERICSTRING = 296,
189     PRINTABLESTRING = 297,
190     TELETEXSTRING = 298,
191     IA5STRING = 299,
192     UNIVERSALSTRING = 300,
193     BMPSTRING = 301
194   };
195 #endif
196
197 /* Value type.  */
198 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
199
200 union YYSTYPE
201 {
202 #line 94 "/home/wk/s/libksba/src/asn1-parse.y" /* yacc.c:352  */
203
204   unsigned int constant;
205   char str[MAX_STRING_LENGTH];
206   AsnNode node;
207
208 #line 209 "asn1-parse.c" /* yacc.c:352  */
209 };
210
211 typedef union YYSTYPE YYSTYPE;
212 # define YYSTYPE_IS_TRIVIAL 1
213 # define YYSTYPE_IS_DECLARED 1
214 #endif
215
216
217
218 int yyparse (void *parm);
219
220
221
222 /* Second part of user prologue.  */
223 #line 100 "/home/wk/s/libksba/src/asn1-parse.y" /* yacc.c:354  */
224
225 static AsnNode new_node (struct parser_control_s *parsectl, node_type_t type);
226 #define NEW_NODE(a)  (new_node (PARSECTL, (a)))
227 static void set_name (AsnNode node, const char *name);
228 static void set_str_value (AsnNode node, const char *text);
229 static void set_ulong_value (AsnNode node, const char *text);
230 static void set_right (AsnNode node, AsnNode right);
231 static void append_right (AsnNode node, AsnNode right);
232 static void set_down (AsnNode node, AsnNode down);
233
234
235 static int yylex (YYSTYPE *lvalp, void *parm);
236 static void yyerror (void *parm, const char *s);
237
238 #line 239 "asn1-parse.c" /* yacc.c:354  */
239
240 #ifdef short
241 # undef short
242 #endif
243
244 #ifdef YYTYPE_UINT8
245 typedef YYTYPE_UINT8 yytype_uint8;
246 #else
247 typedef unsigned char yytype_uint8;
248 #endif
249
250 #ifdef YYTYPE_INT8
251 typedef YYTYPE_INT8 yytype_int8;
252 #else
253 typedef signed char yytype_int8;
254 #endif
255
256 #ifdef YYTYPE_UINT16
257 typedef YYTYPE_UINT16 yytype_uint16;
258 #else
259 typedef unsigned short yytype_uint16;
260 #endif
261
262 #ifdef YYTYPE_INT16
263 typedef YYTYPE_INT16 yytype_int16;
264 #else
265 typedef short yytype_int16;
266 #endif
267
268 #ifndef YYSIZE_T
269 # ifdef __SIZE_TYPE__
270 #  define YYSIZE_T __SIZE_TYPE__
271 # elif defined size_t
272 #  define YYSIZE_T size_t
273 # elif ! defined YYSIZE_T
274 #  include <stddef.h> /* INFRINGES ON USER NAME SPACE */
275 #  define YYSIZE_T size_t
276 # else
277 #  define YYSIZE_T unsigned
278 # endif
279 #endif
280
281 #define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
282
283 #ifndef YY_
284 # if defined YYENABLE_NLS && YYENABLE_NLS
285 #  if ENABLE_NLS
286 #   include <libintl.h> /* INFRINGES ON USER NAME SPACE */
287 #   define YY_(Msgid) dgettext ("bison-runtime", Msgid)
288 #  endif
289 # endif
290 # ifndef YY_
291 #  define YY_(Msgid) Msgid
292 # endif
293 #endif
294
295 #ifndef YY_ATTRIBUTE
296 # if (defined __GNUC__                                               \
297       && (2 < __GNUC__ || (__GNUC__ == 2 && 96 <= __GNUC_MINOR__)))  \
298      || defined __SUNPRO_C && 0x5110 <= __SUNPRO_C
299 #  define YY_ATTRIBUTE(Spec) __attribute__(Spec)
300 # else
301 #  define YY_ATTRIBUTE(Spec) /* empty */
302 # endif
303 #endif
304
305 #ifndef YY_ATTRIBUTE_PURE
306 # define YY_ATTRIBUTE_PURE   YY_ATTRIBUTE ((__pure__))
307 #endif
308
309 #ifndef YY_ATTRIBUTE_UNUSED
310 # define YY_ATTRIBUTE_UNUSED YY_ATTRIBUTE ((__unused__))
311 #endif
312
313 /* Suppress unused-variable warnings by "using" E.  */
314 #if ! defined lint || defined __GNUC__
315 # define YYUSE(E) ((void) (E))
316 #else
317 # define YYUSE(E) /* empty */
318 #endif
319
320 #if defined __GNUC__ && ! defined __ICC && 407 <= __GNUC__ * 100 + __GNUC_MINOR__
321 /* Suppress an incorrect diagnostic about yylval being uninitialized.  */
322 # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
323     _Pragma ("GCC diagnostic push") \
324     _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")\
325     _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
326 # define YY_IGNORE_MAYBE_UNINITIALIZED_END \
327     _Pragma ("GCC diagnostic pop")
328 #else
329 # define YY_INITIAL_VALUE(Value) Value
330 #endif
331 #ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
332 # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
333 # define YY_IGNORE_MAYBE_UNINITIALIZED_END
334 #endif
335 #ifndef YY_INITIAL_VALUE
336 # define YY_INITIAL_VALUE(Value) /* Nothing. */
337 #endif
338
339
340 #if ! defined yyoverflow || YYERROR_VERBOSE
341
342 /* The parser invokes alloca or malloc; define the necessary symbols.  */
343
344 # ifdef YYSTACK_USE_ALLOCA
345 #  if YYSTACK_USE_ALLOCA
346 #   ifdef __GNUC__
347 #    define YYSTACK_ALLOC __builtin_alloca
348 #   elif defined __BUILTIN_VA_ARG_INCR
349 #    include <alloca.h> /* INFRINGES ON USER NAME SPACE */
350 #   elif defined _AIX
351 #    define YYSTACK_ALLOC __alloca
352 #   elif defined _MSC_VER
353 #    include <malloc.h> /* INFRINGES ON USER NAME SPACE */
354 #    define alloca _alloca
355 #   else
356 #    define YYSTACK_ALLOC alloca
357 #    if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS
358 #     include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
359       /* Use EXIT_SUCCESS as a witness for stdlib.h.  */
360 #     ifndef EXIT_SUCCESS
361 #      define EXIT_SUCCESS 0
362 #     endif
363 #    endif
364 #   endif
365 #  endif
366 # endif
367
368 # ifdef YYSTACK_ALLOC
369    /* Pacify GCC's 'empty if-body' warning.  */
370 #  define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
371 #  ifndef YYSTACK_ALLOC_MAXIMUM
372     /* The OS might guarantee only one guard page at the bottom of the stack,
373        and a page size can be as small as 4096 bytes.  So we cannot safely
374        invoke alloca (N) if N exceeds 4096.  Use a slightly smaller number
375        to allow for a few compiler-allocated temporary stack slots.  */
376 #   define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
377 #  endif
378 # else
379 #  define YYSTACK_ALLOC YYMALLOC
380 #  define YYSTACK_FREE YYFREE
381 #  ifndef YYSTACK_ALLOC_MAXIMUM
382 #   define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
383 #  endif
384 #  if (defined __cplusplus && ! defined EXIT_SUCCESS \
385        && ! ((defined YYMALLOC || defined malloc) \
386              && (defined YYFREE || defined free)))
387 #   include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
388 #   ifndef EXIT_SUCCESS
389 #    define EXIT_SUCCESS 0
390 #   endif
391 #  endif
392 #  ifndef YYMALLOC
393 #   define YYMALLOC malloc
394 #   if ! defined malloc && ! defined EXIT_SUCCESS
395 void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
396 #   endif
397 #  endif
398 #  ifndef YYFREE
399 #   define YYFREE free
400 #   if ! defined free && ! defined EXIT_SUCCESS
401 void free (void *); /* INFRINGES ON USER NAME SPACE */
402 #   endif
403 #  endif
404 # endif
405 #endif /* ! defined yyoverflow || YYERROR_VERBOSE */
406
407
408 #if (! defined yyoverflow \
409      && (! defined __cplusplus \
410          || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
411
412 /* A type that is properly aligned for any stack member.  */
413 union yyalloc
414 {
415   yytype_int16 yyss_alloc;
416   YYSTYPE yyvs_alloc;
417 };
418
419 /* The size of the maximum gap between one aligned stack and the next.  */
420 # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
421
422 /* The size of an array large to enough to hold all stacks, each with
423    N elements.  */
424 # define YYSTACK_BYTES(N) \
425      ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
426       + YYSTACK_GAP_MAXIMUM)
427
428 # define YYCOPY_NEEDED 1
429
430 /* Relocate STACK from its old location to the new one.  The
431    local variables YYSIZE and YYSTACKSIZE give the old and new number of
432    elements in the stack, and YYPTR gives the new location of the
433    stack.  Advance YYPTR to a properly aligned location for the next
434    stack.  */
435 # define YYSTACK_RELOCATE(Stack_alloc, Stack)                           \
436     do                                                                  \
437       {                                                                 \
438         YYSIZE_T yynewbytes;                                            \
439         YYCOPY (&yyptr->Stack_alloc, Stack, yysize);                    \
440         Stack = &yyptr->Stack_alloc;                                    \
441         yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
442         yyptr += yynewbytes / sizeof (*yyptr);                          \
443       }                                                                 \
444     while (0)
445
446 #endif
447
448 #if defined YYCOPY_NEEDED && YYCOPY_NEEDED
449 /* Copy COUNT objects from SRC to DST.  The source and destination do
450    not overlap.  */
451 # ifndef YYCOPY
452 #  if defined __GNUC__ && 1 < __GNUC__
453 #   define YYCOPY(Dst, Src, Count) \
454       __builtin_memcpy (Dst, Src, (Count) * sizeof (*(Src)))
455 #  else
456 #   define YYCOPY(Dst, Src, Count)              \
457       do                                        \
458         {                                       \
459           YYSIZE_T yyi;                         \
460           for (yyi = 0; yyi < (Count); yyi++)   \
461             (Dst)[yyi] = (Src)[yyi];            \
462         }                                       \
463       while (0)
464 #  endif
465 # endif
466 #endif /* !YYCOPY_NEEDED */
467
468 /* YYFINAL -- State number of the termination state.  */
469 #define YYFINAL  2
470 /* YYLAST -- Last index in YYTABLE.  */
471 #define YYLAST   195
472
473 /* YYNTOKENS -- Number of terminals.  */
474 #define YYNTOKENS  57
475 /* YYNNTS -- Number of nonterminals.  */
476 #define YYNNTS  51
477 /* YYNRULES -- Number of rules.  */
478 #define YYNRULES  116
479 /* YYNSTATES -- Number of states.  */
480 #define YYNSTATES  203
481
482 #define YYUNDEFTOK  2
483 #define YYMAXUTOK   301
484
485 /* YYTRANSLATE(TOKEN-NUM) -- Symbol number corresponding to TOKEN-NUM
486    as returned by yylex, with out-of-bounds checking.  */
487 #define YYTRANSLATE(YYX)                                                \
488   ((unsigned) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
489
490 /* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM
491    as returned by yylex.  */
492 static const yytype_uint8 yytranslate[] =
493 {
494        0,     2,     2,     2,     2,     2,     2,     2,     2,     2,
495        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
496        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
497        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
498       49,    50,     2,    47,    51,    48,    56,     2,     2,     2,
499        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
500        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
501        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
502        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
503        2,    52,     2,    53,     2,     2,     2,     2,     2,     2,
504        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
505        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
506        2,     2,     2,    54,     2,    55,     2,     2,     2,     2,
507        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
508        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
509        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
510        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
511        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
512        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
513        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
514        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
515        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
516        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
517        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
518        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
519        2,     2,     2,     2,     2,     2,     1,     2,     3,     4,
520        5,     6,     7,     8,     9,    10,    11,    12,    13,    14,
521       15,    16,    17,    18,    19,    20,    21,    22,    23,    24,
522       25,    26,    27,    28,    29,    30,    31,    32,    33,    34,
523       35,    36,    37,    38,    39,    40,    41,    42,    43,    44,
524       45,    46
525 };
526
527 #if YYDEBUG
528   /* YYRLINE[YYN] -- Source line where rule number YYN was defined.  */
529 static const yytype_uint16 yyrline[] =
530 {
531        0,   179,   179,   180,   183,   184,   187,   194,   195,   198,
532      199,   202,   203,   206,   211,   219,   220,   245,   250,   258,
533      260,   267,   268,   269,   272,   278,   286,   288,   293,   300,
534      305,   310,   317,   321,   327,   338,   344,   348,   354,   360,
535      369,   373,   379,   383,   391,   392,   399,   400,   407,   409,
536      416,   418,   425,   426,   433,   435,   442,   443,   452,   453,
537      454,   455,   456,   457,   458,   464,   472,   476,   483,   487,
538      495,   503,   509,   514,   521,   522,   523,   524,   525,   526,
539      527,   528,   529,   530,   531,   532,   533,   539,   543,   554,
540      558,   565,   572,   579,   581,   588,   593,   598,   607,   612,
541      617,   626,   633,   637,   649,   656,   663,   672,   681,   682,
542      685,   687,   694,   703,   719,   720,   723
543 };
544 #endif
545
546 #if YYDEBUG || YYERROR_VERBOSE || 1
547 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
548    First, the terminals, then, starting at YYNTOKENS, nonterminals.  */
549 static const char *const yytname[] =
550 {
551   "$end", "error", "$undefined", "\"::=\"", "NUM", "IDENTIFIER",
552   "\"OPTIONAL\"", "\"INTEGER\"", "\"SIZE\"", "\"OCTET\"", "\"STRING\"",
553   "\"SEQUENCE\"", "\"BIT\"", "\"UNIVERSAL\"", "\"PRIVATE\"", "\"DEFAULT\"",
554   "\"CHOICE\"", "\"OF\"", "\"OBJECT\"", "\"IDENTIFIER\"", "\"BOOLEAN\"",
555   "\"TRUE\"", "\"FALSE\"", "\"APPLICATION\"", "\"ANY\"", "\"DEFINED\"",
556   "\"SET\"", "\"BY\"", "\"EXPLICIT\"", "\"IMPLICIT\"", "\"DEFINITIONS\"",
557   "\"TAGS\"", "\"BEGIN\"", "\"END\"", "\"UTCTime\"", "\"GeneralizedTime\"",
558   "\"FROM\"", "\"IMPORTS\"", "\"NULL\"", "\"ENUMERATED\"",
559   "\"UTF8String\"", "\"NumericString\"", "\"PrintableString\"",
560   "\"TeletexString\"", "\"IA5String\"", "\"UniversalString\"",
561   "\"BMPString\"", "'+'", "'-'", "'('", "')'", "','", "'['", "']'", "'{'",
562   "'}'", "'.'", "$accept", "input", "pos_num", "neg_num", "pos_neg_num",
563   "num_identifier", "pos_neg_identifier", "constant", "constant_list",
564   "obj_constant", "obj_constant_list", "class", "tag_type", "tag",
565   "default", "integer_def", "boolean_def", "Time", "size_def2", "size_def",
566   "octet_string_def", "utf8_string_def", "numeric_string_def",
567   "printable_string_def", "teletex_string_def", "ia5_string_def",
568   "universal_string_def", "bmp_string_def", "string_def", "bit_element",
569   "bit_element_list", "bit_string_def", "enumerated_def", "object_def",
570   "type_assig_right", "type_assig_right_tag",
571   "type_assig_right_tag_default", "type_assig", "type_assig_list",
572   "sequence_def", "set_def", "choise_def", "any_def", "type_def",
573   "constant_def", "type_constant", "type_constant_list", "definitions_id",
574   "imports_def", "explicit_implicit", "definitions", YY_NULLPTR
575 };
576 #endif
577
578 # ifdef YYPRINT
579 /* YYTOKNUM[NUM] -- (External) token number corresponding to the
580    (internal) symbol number NUM (which must be that of a token).  */
581 static const yytype_uint16 yytoknum[] =
582 {
583        0,   256,   257,   258,   259,   260,   261,   262,   263,   264,
584      265,   266,   267,   268,   269,   270,   271,   272,   273,   274,
585      275,   276,   277,   278,   279,   280,   281,   282,   283,   284,
586      285,   286,   287,   288,   289,   290,   291,   292,   293,   294,
587      295,   296,   297,   298,   299,   300,   301,    43,    45,    40,
588       41,    44,    91,    93,   123,   125,    46
589 };
590 # endif
591
592 #define YYPACT_NINF -137
593
594 #define yypact_value_is_default(Yystate) \
595   (!!((Yystate) == (-137)))
596
597 #define YYTABLE_NINF -1
598
599 #define yytable_value_is_error(Yytable_value) \
600   0
601
602   /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
603      STATE-NUM.  */
604 static const yytype_int16 yypact[] =
605 {
606     -137,    33,  -137,   -39,     0,  -137,    76,   115,  -137,     4,
607     -137,  -137,    -1,  -137,  -137,    15,    63,  -137,  -137,    59,
608       77,    86,  -137,  -137,   105,    24,  -137,  -137,  -137,    18,
609       52,   126,   129,   128,  -137,  -137,    16,    94,   139,    17,
610      140,    97,   133,  -137,   130,    20,  -137,  -137,  -137,    99,
611       16,    16,    16,    16,    16,    16,    16,    22,   117,    96,
612      107,  -137,  -137,  -137,  -137,  -137,  -137,  -137,  -137,  -137,
613     -137,  -137,  -137,  -137,  -137,  -137,  -137,  -137,  -137,  -137,
614     -137,   100,   153,   155,   110,   152,  -137,  -137,     7,    16,
615       96,   156,   146,   111,   156,  -137,   137,    96,   156,   149,
616      162,  -137,  -137,  -137,  -137,  -137,  -137,  -137,   116,  -137,
617     -137,  -137,   164,  -137,  -137,  -137,    84,    76,  -137,   118,
618       84,   120,   122,    37,  -137,    -3,  -137,  -137,    52,  -137,
619       51,    96,   162,    58,   168,  -137,    60,    96,   125,  -137,
620       66,  -137,   123,  -137,   119,     3,    76,    -6,  -137,    37,
621     -137,   173,   174,  -137,  -137,   131,     7,  -137,    34,  -137,
622      156,  -137,  -137,    68,  -137,  -137,  -137,  -137,   175,   162,
623     -137,  -137,   124,  -137,     5,  -137,   127,   132,  -137,  -137,
624     -137,  -137,  -137,    78,  -137,  -137,  -137,   134,  -137,    84,
625     -137,    84,  -137,  -137,  -137,  -137,  -137,  -137,  -137,   135,
626      136,  -137,  -137
627 };
628
629   /* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM.
630      Performed when YYTABLE does not specify something else to do.  Zero
631      means the default is an error.  */
632 static const yytype_uint8 yydefact[] =
633 {
634        2,     0,     1,     0,     0,     3,     0,     0,     9,    10,
635       17,    19,     0,   114,   115,     0,     0,   112,    20,     0,
636        0,     0,    18,   113,     0,     0,   108,   109,   110,     0,
637        0,     0,     0,     0,   116,   111,    72,    32,     0,     0,
638        0,     0,     0,    35,   102,     0,    36,    37,    86,     0,
639       44,    46,    48,    50,    52,    54,    56,     0,    26,     0,
640       74,    76,    78,    79,    58,    59,    60,    61,    62,    63,
641       64,    77,    80,    75,    82,    87,   104,    81,    85,    83,
642       84,     0,     0,     0,     0,     0,    40,    73,     0,    42,
643        0,     0,     0,    68,     0,    71,     0,     0,     0,     0,
644        0,    45,    47,    49,    51,    53,    55,    57,     0,    21,
645       22,    23,     0,    27,    28,    88,     0,     0,   107,     0,
646        0,     0,     0,     0,    15,     0,    43,    96,     0,    93,
647        0,     0,     0,     0,     0,    99,     0,     0,     0,    66,
648        0,    24,     0,    10,     0,     0,     0,     0,    41,     0,
649        4,     0,     0,     7,     8,     0,     0,    33,    89,    92,
650        0,    95,    97,     0,   101,   103,    98,   100,     0,     0,
651       70,    25,     0,   106,     0,    38,     0,     0,     5,     6,
652       13,    16,    91,     0,    90,    94,    69,     0,    67,     0,
653      105,     0,    14,    12,    30,    31,    11,    29,    65,     0,
654        0,    34,    39
655 };
656
657   /* YYPGOTO[NTERM-NUM].  */
658 static const yytype_int16 yypgoto[] =
659 {
660     -137,  -137,  -137,  -137,  -136,  -114,  -137,    31,  -137,   -12,
661     -103,  -137,  -137,  -137,  -137,  -137,  -137,  -137,   103,   -34,
662     -137,  -137,  -137,  -137,  -137,  -137,  -137,  -137,  -137,    21,
663       57,  -137,  -137,  -137,   -58,    64,  -137,    35,    30,  -137,
664     -137,  -137,  -137,  -137,  -137,   165,  -137,  -137,  -137,  -137,
665     -137
666 };
667
668   /* YYDEFGOTO[NTERM-NUM].  */
669 static const yytype_int16 yydefgoto[] =
670 {
671       -1,     1,   153,   154,   155,    10,   197,   124,   125,    11,
672       12,   112,    58,    59,   184,    60,    61,    62,    86,    87,
673       63,    64,    65,    66,    67,    68,    69,    70,    71,   139,
674      140,    72,    73,    74,    75,    76,   159,   129,   130,    77,
675       78,    79,    80,    26,    27,    28,    29,     4,    24,    15,
676        5
677 };
678
679   /* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM.  If
680      positive, shift that token.  If negative, reduce the rule whose
681      number is the opposite.  If YYTABLE_NINF, syntax error.  */
682 static const yytype_uint8 yytable[] =
683 {
684       18,   115,   144,     8,     9,    92,   147,     8,     9,     8,
685        9,    99,   122,   177,   145,     6,   101,   102,   103,   104,
686      105,   106,   107,    25,    84,    84,   108,    30,    84,    31,
687        7,    32,   127,     2,    90,   109,   110,    97,     3,   135,
688      182,   150,    33,   174,   175,   111,    19,   196,   156,   183,
689      176,    34,   157,    16,    17,   126,   123,    36,   173,    37,
690      190,    38,    21,    39,    40,    85,    85,    20,    41,    85,
691       42,    91,    43,   162,    98,   199,    44,   200,    45,   167,
692        8,     9,   150,   193,   151,   152,    46,    47,     8,   143,
693       48,    49,    50,    51,    52,    53,    54,    55,    56,   194,
694      195,    36,   160,    37,    57,    38,   161,    39,    40,   160,
695       25,   160,    41,   164,    42,   166,    43,   169,    23,   169,
696       44,   170,    45,   186,   133,   151,   152,    22,   136,    81,
697       46,    47,    82,    18,    48,    49,    50,    51,    52,    53,
698       54,    55,    56,    13,    14,   113,   114,    83,    88,    89,
699       93,    94,    95,   100,   117,    96,   116,   118,   119,   120,
700       84,   128,    18,   131,   134,   132,   137,   138,   142,   141,
701      148,   149,   146,   165,   168,   172,   171,   178,   179,   187,
702      189,   180,   192,   191,   198,   201,   202,   181,   121,   163,
703      188,     0,   158,     0,    35,   185
704 };
705
706 static const yytype_int16 yycheck[] =
707 {
708       12,    59,   116,     4,     5,    39,   120,     4,     5,     4,
709        5,    45,     5,   149,   117,    54,    50,    51,    52,    53,
710       54,    55,    56,     5,     8,     8,     4,     3,     8,     5,
711       30,     7,    90,     0,    17,    13,    14,    17,     5,    97,
712        6,     4,    18,   146,    50,    23,    31,   183,    51,    15,
713       56,    33,    55,    49,    55,    89,    49,     5,    55,     7,
714       55,     9,     3,    11,    12,    49,    49,     4,    16,    49,
715       18,    54,    20,   131,    54,   189,    24,   191,    26,   137,
716        4,     5,     4,     5,    47,    48,    34,    35,     4,     5,
717       38,    39,    40,    41,    42,    43,    44,    45,    46,    21,
718       22,     5,    51,     7,    52,     9,    55,    11,    12,    51,
719        5,    51,    16,    55,    18,    55,    20,    51,    32,    51,
720       24,    55,    26,    55,    94,    47,    48,    50,    98,     3,
721       34,    35,     3,   145,    38,    39,    40,    41,    42,    43,
722       44,    45,    46,    28,    29,    28,    29,    19,    54,    10,
723       10,    54,    19,    54,    54,    25,    49,     4,     3,    49,
724        8,     5,   174,    17,    27,    54,    17,     5,     4,    53,
725       50,    49,    54,     5,    49,    56,    53,     4,     4,     4,
726       56,    50,    50,    56,    50,    50,    50,   156,    85,   132,
727      169,    -1,   128,    -1,    29,   160
728 };
729
730   /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
731      symbol of state STATE-NUM.  */
732 static const yytype_uint8 yystos[] =
733 {
734        0,    58,     0,     5,   104,   107,    54,    30,     4,     5,
735       62,    66,    67,    28,    29,   106,    49,    55,    66,    31,
736        4,     3,    50,    32,   105,     5,   100,   101,   102,   103,
737        3,     5,     7,    18,    33,   102,     5,     7,     9,    11,
738       12,    16,    18,    20,    24,    26,    34,    35,    38,    39,
739       40,    41,    42,    43,    44,    45,    46,    52,    69,    70,
740       72,    73,    74,    77,    78,    79,    80,    81,    82,    83,
741       84,    85,    88,    89,    90,    91,    92,    96,    97,    98,
742       99,     3,     3,    19,     8,    49,    75,    76,    54,    10,
743       17,    54,    76,    10,    54,    19,    25,    17,    54,    76,
744       54,    76,    76,    76,    76,    76,    76,    76,     4,    13,
745       14,    23,    68,    28,    29,    91,    49,    54,     4,     3,
746       49,    75,     5,    49,    64,    65,    76,    91,     5,    94,
747       95,    17,    54,    95,    27,    91,    95,    17,     5,    86,
748       87,    53,     4,     5,    62,    67,    54,    62,    50,    49,
749        4,    47,    48,    59,    60,    61,    51,    55,    92,    93,
750       51,    55,    91,    87,    55,     5,    55,    91,    49,    51,
751       55,    53,    56,    55,    67,    50,    56,    61,     4,     4,
752       50,    64,     6,    15,    71,    94,    55,     4,    86,    56,
753       55,    56,    50,     5,    21,    22,    61,    63,    50,    62,
754       62,    50,    50
755 };
756
757   /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives.  */
758 static const yytype_uint8 yyr1[] =
759 {
760        0,    57,    58,    58,    59,    59,    60,    61,    61,    62,
761       62,    63,    63,    64,    64,    65,    65,    66,    66,    67,
762       67,    68,    68,    68,    69,    69,    70,    70,    70,    71,
763       71,    71,    72,    72,    72,    73,    74,    74,    75,    75,
764       76,    76,    77,    77,    78,    78,    79,    79,    80,    80,
765       81,    81,    82,    82,    83,    83,    84,    84,    85,    85,
766       85,    85,    85,    85,    85,    86,    87,    87,    88,    88,
767       89,    90,    91,    91,    91,    91,    91,    91,    91,    91,
768       91,    91,    91,    91,    91,    91,    91,    92,    92,    93,
769       93,    93,    94,    95,    95,    96,    96,    96,    97,    97,
770       97,    98,    99,    99,   100,   101,   101,   101,   102,   102,
771      103,   103,   104,   105,   106,   106,   107
772 };
773
774   /* YYR2[YYN] -- Number of symbols on the right hand side of rule YYN.  */
775 static const yytype_uint8 yyr2[] =
776 {
777        0,     2,     0,     2,     1,     2,     2,     1,     1,     1,
778        1,     1,     1,     3,     4,     1,     3,     1,     4,     1,
779        2,     1,     1,     1,     3,     4,     1,     2,     2,     2,
780        2,     2,     1,     4,     7,     1,     1,     1,     4,     7,
781        1,     3,     2,     3,     1,     2,     1,     2,     1,     2,
782        1,     2,     1,     2,     1,     2,     1,     2,     1,     1,
783        1,     1,     1,     1,     1,     4,     1,     3,     2,     5,
784        4,     2,     1,     2,     1,     1,     1,     1,     1,     1,
785        1,     1,     1,     1,     1,     1,     1,     1,     2,     1,
786        2,     2,     2,     1,     3,     4,     3,     4,     4,     3,
787        4,     4,     1,     4,     3,     7,     6,     4,     1,     1,
788        1,     2,     4,     0,     1,     1,     9
789 };
790
791
792 #define yyerrok         (yyerrstatus = 0)
793 #define yyclearin       (yychar = YYEMPTY)
794 #define YYEMPTY         (-2)
795 #define YYEOF           0
796
797 #define YYACCEPT        goto yyacceptlab
798 #define YYABORT         goto yyabortlab
799 #define YYERROR         goto yyerrorlab
800
801
802 #define YYRECOVERING()  (!!yyerrstatus)
803
804 #define YYBACKUP(Token, Value)                                    \
805   do                                                              \
806     if (yychar == YYEMPTY)                                        \
807       {                                                           \
808         yychar = (Token);                                         \
809         yylval = (Value);                                         \
810         YYPOPSTACK (yylen);                                       \
811         yystate = *yyssp;                                         \
812         goto yybackup;                                            \
813       }                                                           \
814     else                                                          \
815       {                                                           \
816         yyerror (parm, YY_("syntax error: cannot back up")); \
817         YYERROR;                                                  \
818       }                                                           \
819   while (0)
820
821 /* Error token number */
822 #define YYTERROR        1
823 #define YYERRCODE       256
824
825
826
827 /* Enable debugging if requested.  */
828 #if YYDEBUG
829
830 # ifndef YYFPRINTF
831 #  include <stdio.h> /* INFRINGES ON USER NAME SPACE */
832 #  define YYFPRINTF fprintf
833 # endif
834
835 # define YYDPRINTF(Args)                        \
836 do {                                            \
837   if (yydebug)                                  \
838     YYFPRINTF Args;                             \
839 } while (0)
840
841 /* This macro is provided for backward compatibility. */
842 #ifndef YY_LOCATION_PRINT
843 # define YY_LOCATION_PRINT(File, Loc) ((void) 0)
844 #endif
845
846
847 # define YY_SYMBOL_PRINT(Title, Type, Value, Location)                    \
848 do {                                                                      \
849   if (yydebug)                                                            \
850     {                                                                     \
851       YYFPRINTF (stderr, "%s ", Title);                                   \
852       yy_symbol_print (stderr,                                            \
853                   Type, Value, parm); \
854       YYFPRINTF (stderr, "\n");                                           \
855     }                                                                     \
856 } while (0)
857
858
859 /*-----------------------------------.
860 | Print this symbol's value on YYO.  |
861 `-----------------------------------*/
862
863 static void
864 yy_symbol_value_print (FILE *yyo, int yytype, YYSTYPE const * const yyvaluep, void *parm)
865 {
866   FILE *yyoutput = yyo;
867   YYUSE (yyoutput);
868   YYUSE (parm);
869   if (!yyvaluep)
870     return;
871 # ifdef YYPRINT
872   if (yytype < YYNTOKENS)
873     YYPRINT (yyo, yytoknum[yytype], *yyvaluep);
874 # endif
875   YYUSE (yytype);
876 }
877
878
879 /*---------------------------.
880 | Print this symbol on YYO.  |
881 `---------------------------*/
882
883 static void
884 yy_symbol_print (FILE *yyo, int yytype, YYSTYPE const * const yyvaluep, void *parm)
885 {
886   YYFPRINTF (yyo, "%s %s (",
887              yytype < YYNTOKENS ? "token" : "nterm", yytname[yytype]);
888
889   yy_symbol_value_print (yyo, yytype, yyvaluep, parm);
890   YYFPRINTF (yyo, ")");
891 }
892
893 /*------------------------------------------------------------------.
894 | yy_stack_print -- Print the state stack from its BOTTOM up to its |
895 | TOP (included).                                                   |
896 `------------------------------------------------------------------*/
897
898 static void
899 yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop)
900 {
901   YYFPRINTF (stderr, "Stack now");
902   for (; yybottom <= yytop; yybottom++)
903     {
904       int yybot = *yybottom;
905       YYFPRINTF (stderr, " %d", yybot);
906     }
907   YYFPRINTF (stderr, "\n");
908 }
909
910 # define YY_STACK_PRINT(Bottom, Top)                            \
911 do {                                                            \
912   if (yydebug)                                                  \
913     yy_stack_print ((Bottom), (Top));                           \
914 } while (0)
915
916
917 /*------------------------------------------------.
918 | Report that the YYRULE is going to be reduced.  |
919 `------------------------------------------------*/
920
921 static void
922 yy_reduce_print (yytype_int16 *yyssp, YYSTYPE *yyvsp, int yyrule, void *parm)
923 {
924   unsigned long yylno = yyrline[yyrule];
925   int yynrhs = yyr2[yyrule];
926   int yyi;
927   YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
928              yyrule - 1, yylno);
929   /* The symbols being reduced.  */
930   for (yyi = 0; yyi < yynrhs; yyi++)
931     {
932       YYFPRINTF (stderr, "   $%d = ", yyi + 1);
933       yy_symbol_print (stderr,
934                        yystos[yyssp[yyi + 1 - yynrhs]],
935                        &yyvsp[(yyi + 1) - (yynrhs)]
936                                               , parm);
937       YYFPRINTF (stderr, "\n");
938     }
939 }
940
941 # define YY_REDUCE_PRINT(Rule)          \
942 do {                                    \
943   if (yydebug)                          \
944     yy_reduce_print (yyssp, yyvsp, Rule, parm); \
945 } while (0)
946
947 /* Nonzero means print parse trace.  It is left uninitialized so that
948    multiple parsers can coexist.  */
949 int yydebug;
950 #else /* !YYDEBUG */
951 # define YYDPRINTF(Args)
952 # define YY_SYMBOL_PRINT(Title, Type, Value, Location)
953 # define YY_STACK_PRINT(Bottom, Top)
954 # define YY_REDUCE_PRINT(Rule)
955 #endif /* !YYDEBUG */
956
957
958 /* YYINITDEPTH -- initial size of the parser's stacks.  */
959 #ifndef YYINITDEPTH
960 # define YYINITDEPTH 200
961 #endif
962
963 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
964    if the built-in stack extension method is used).
965
966    Do not make this value too large; the results are undefined if
967    YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
968    evaluated with infinite-precision integer arithmetic.  */
969
970 #ifndef YYMAXDEPTH
971 # define YYMAXDEPTH 10000
972 #endif
973
974
975 #if YYERROR_VERBOSE
976
977 # ifndef yystrlen
978 #  if defined __GLIBC__ && defined _STRING_H
979 #   define yystrlen strlen
980 #  else
981 /* Return the length of YYSTR.  */
982 static YYSIZE_T
983 yystrlen (const char *yystr)
984 {
985   YYSIZE_T yylen;
986   for (yylen = 0; yystr[yylen]; yylen++)
987     continue;
988   return yylen;
989 }
990 #  endif
991 # endif
992
993 # ifndef yystpcpy
994 #  if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
995 #   define yystpcpy stpcpy
996 #  else
997 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
998    YYDEST.  */
999 static char *
1000 yystpcpy (char *yydest, const char *yysrc)
1001 {
1002   char *yyd = yydest;
1003   const char *yys = yysrc;
1004
1005   while ((*yyd++ = *yys++) != '\0')
1006     continue;
1007
1008   return yyd - 1;
1009 }
1010 #  endif
1011 # endif
1012
1013 # ifndef yytnamerr
1014 /* Copy to YYRES the contents of YYSTR after stripping away unnecessary
1015    quotes and backslashes, so that it's suitable for yyerror.  The
1016    heuristic is that double-quoting is unnecessary unless the string
1017    contains an apostrophe, a comma, or backslash (other than
1018    backslash-backslash).  YYSTR is taken from yytname.  If YYRES is
1019    null, do not copy; instead, return the length of what the result
1020    would have been.  */
1021 static YYSIZE_T
1022 yytnamerr (char *yyres, const char *yystr)
1023 {
1024   if (*yystr == '"')
1025     {
1026       YYSIZE_T yyn = 0;
1027       char const *yyp = yystr;
1028
1029       for (;;)
1030         switch (*++yyp)
1031           {
1032           case '\'':
1033           case ',':
1034             goto do_not_strip_quotes;
1035
1036           case '\\':
1037             if (*++yyp != '\\')
1038               goto do_not_strip_quotes;
1039             else
1040               goto append;
1041
1042           append:
1043           default:
1044             if (yyres)
1045               yyres[yyn] = *yyp;
1046             yyn++;
1047             break;
1048
1049           case '"':
1050             if (yyres)
1051               yyres[yyn] = '\0';
1052             return yyn;
1053           }
1054     do_not_strip_quotes: ;
1055     }
1056
1057   if (! yyres)
1058     return yystrlen (yystr);
1059
1060   return (YYSIZE_T) (yystpcpy (yyres, yystr) - yyres);
1061 }
1062 # endif
1063
1064 /* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message
1065    about the unexpected token YYTOKEN for the state stack whose top is
1066    YYSSP.
1067
1068    Return 0 if *YYMSG was successfully written.  Return 1 if *YYMSG is
1069    not large enough to hold the message.  In that case, also set
1070    *YYMSG_ALLOC to the required number of bytes.  Return 2 if the
1071    required number of bytes is too large to store.  */
1072 static int
1073 yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg,
1074                 yytype_int16 *yyssp, int yytoken)
1075 {
1076   YYSIZE_T yysize0 = yytnamerr (YY_NULLPTR, yytname[yytoken]);
1077   YYSIZE_T yysize = yysize0;
1078   enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
1079   /* Internationalized format string. */
1080   const char *yyformat = YY_NULLPTR;
1081   /* Arguments of yyformat. */
1082   char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
1083   /* Number of reported tokens (one for the "unexpected", one per
1084      "expected"). */
1085   int yycount = 0;
1086
1087   /* There are many possibilities here to consider:
1088      - If this state is a consistent state with a default action, then
1089        the only way this function was invoked is if the default action
1090        is an error action.  In that case, don't check for expected
1091        tokens because there are none.
1092      - The only way there can be no lookahead present (in yychar) is if
1093        this state is a consistent state with a default action.  Thus,
1094        detecting the absence of a lookahead is sufficient to determine
1095        that there is no unexpected or expected token to report.  In that
1096        case, just report a simple "syntax error".
1097      - Don't assume there isn't a lookahead just because this state is a
1098        consistent state with a default action.  There might have been a
1099        previous inconsistent state, consistent state with a non-default
1100        action, or user semantic action that manipulated yychar.
1101      - Of course, the expected token list depends on states to have
1102        correct lookahead information, and it depends on the parser not
1103        to perform extra reductions after fetching a lookahead from the
1104        scanner and before detecting a syntax error.  Thus, state merging
1105        (from LALR or IELR) and default reductions corrupt the expected
1106        token list.  However, the list is correct for canonical LR with
1107        one exception: it will still contain any token that will not be
1108        accepted due to an error action in a later state.
1109   */
1110   if (yytoken != YYEMPTY)
1111     {
1112       int yyn = yypact[*yyssp];
1113       yyarg[yycount++] = yytname[yytoken];
1114       if (!yypact_value_is_default (yyn))
1115         {
1116           /* Start YYX at -YYN if negative to avoid negative indexes in
1117              YYCHECK.  In other words, skip the first -YYN actions for
1118              this state because they are default actions.  */
1119           int yyxbegin = yyn < 0 ? -yyn : 0;
1120           /* Stay within bounds of both yycheck and yytname.  */
1121           int yychecklim = YYLAST - yyn + 1;
1122           int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
1123           int yyx;
1124
1125           for (yyx = yyxbegin; yyx < yyxend; ++yyx)
1126             if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR
1127                 && !yytable_value_is_error (yytable[yyx + yyn]))
1128               {
1129                 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
1130                   {
1131                     yycount = 1;
1132                     yysize = yysize0;
1133                     break;
1134                   }
1135                 yyarg[yycount++] = yytname[yyx];
1136                 {
1137                   YYSIZE_T yysize1 = yysize + yytnamerr (YY_NULLPTR, yytname[yyx]);
1138                   if (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM)
1139                     yysize = yysize1;
1140                   else
1141                     return 2;
1142                 }
1143               }
1144         }
1145     }
1146
1147   switch (yycount)
1148     {
1149 # define YYCASE_(N, S)                      \
1150       case N:                               \
1151         yyformat = S;                       \
1152       break
1153     default: /* Avoid compiler warnings. */
1154       YYCASE_(0, YY_("syntax error"));
1155       YYCASE_(1, YY_("syntax error, unexpected %s"));
1156       YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s"));
1157       YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s"));
1158       YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s"));
1159       YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"));
1160 # undef YYCASE_
1161     }
1162
1163   {
1164     YYSIZE_T yysize1 = yysize + yystrlen (yyformat);
1165     if (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM)
1166       yysize = yysize1;
1167     else
1168       return 2;
1169   }
1170
1171   if (*yymsg_alloc < yysize)
1172     {
1173       *yymsg_alloc = 2 * yysize;
1174       if (! (yysize <= *yymsg_alloc
1175              && *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM))
1176         *yymsg_alloc = YYSTACK_ALLOC_MAXIMUM;
1177       return 1;
1178     }
1179
1180   /* Avoid sprintf, as that infringes on the user's name space.
1181      Don't have undefined behavior even if the translation
1182      produced a string with the wrong number of "%s"s.  */
1183   {
1184     char *yyp = *yymsg;
1185     int yyi = 0;
1186     while ((*yyp = *yyformat) != '\0')
1187       if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount)
1188         {
1189           yyp += yytnamerr (yyp, yyarg[yyi++]);
1190           yyformat += 2;
1191         }
1192       else
1193         {
1194           yyp++;
1195           yyformat++;
1196         }
1197   }
1198   return 0;
1199 }
1200 #endif /* YYERROR_VERBOSE */
1201
1202 /*-----------------------------------------------.
1203 | Release the memory associated to this symbol.  |
1204 `-----------------------------------------------*/
1205
1206 static void
1207 yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, void *parm)
1208 {
1209   YYUSE (yyvaluep);
1210   YYUSE (parm);
1211   if (!yymsg)
1212     yymsg = "Deleting";
1213   YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
1214
1215   YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1216   YYUSE (yytype);
1217   YY_IGNORE_MAYBE_UNINITIALIZED_END
1218 }
1219
1220
1221
1222
1223 /*----------.
1224 | yyparse.  |
1225 `----------*/
1226
1227 int
1228 yyparse (void *parm)
1229 {
1230 /* The lookahead symbol.  */
1231 int yychar;
1232
1233
1234 /* The semantic value of the lookahead symbol.  */
1235 /* Default value used for initialization, for pacifying older GCCs
1236    or non-GCC compilers.  */
1237 YY_INITIAL_VALUE (static YYSTYPE yyval_default;)
1238 YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default);
1239
1240     /* Number of syntax errors so far.  */
1241     int yynerrs;
1242
1243     int yystate;
1244     /* Number of tokens to shift before error messages enabled.  */
1245     int yyerrstatus;
1246
1247     /* The stacks and their tools:
1248        'yyss': related to states.
1249        'yyvs': related to semantic values.
1250
1251        Refer to the stacks through separate pointers, to allow yyoverflow
1252        to reallocate them elsewhere.  */
1253
1254     /* The state stack.  */
1255     yytype_int16 yyssa[YYINITDEPTH];
1256     yytype_int16 *yyss;
1257     yytype_int16 *yyssp;
1258
1259     /* The semantic value stack.  */
1260     YYSTYPE yyvsa[YYINITDEPTH];
1261     YYSTYPE *yyvs;
1262     YYSTYPE *yyvsp;
1263
1264     YYSIZE_T yystacksize;
1265
1266   int yyn;
1267   int yyresult;
1268   /* Lookahead token as an internal (translated) token number.  */
1269   int yytoken = 0;
1270   /* The variables used to return semantic value and location from the
1271      action routines.  */
1272   YYSTYPE yyval;
1273
1274 #if YYERROR_VERBOSE
1275   /* Buffer for error messages, and its allocated size.  */
1276   char yymsgbuf[128];
1277   char *yymsg = yymsgbuf;
1278   YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
1279 #endif
1280
1281 #define YYPOPSTACK(N)   (yyvsp -= (N), yyssp -= (N))
1282
1283   /* The number of symbols on the RHS of the reduced rule.
1284      Keep to zero when no symbol should be popped.  */
1285   int yylen = 0;
1286
1287   yyssp = yyss = yyssa;
1288   yyvsp = yyvs = yyvsa;
1289   yystacksize = YYINITDEPTH;
1290
1291   YYDPRINTF ((stderr, "Starting parse\n"));
1292
1293   yystate = 0;
1294   yyerrstatus = 0;
1295   yynerrs = 0;
1296   yychar = YYEMPTY; /* Cause a token to be read.  */
1297   goto yysetstate;
1298
1299
1300 /*------------------------------------------------------------.
1301 | yynewstate -- push a new state, which is found in yystate.  |
1302 `------------------------------------------------------------*/
1303 yynewstate:
1304   /* In all cases, when you get here, the value and location stacks
1305      have just been pushed.  So pushing a state here evens the stacks.  */
1306   yyssp++;
1307
1308
1309 /*--------------------------------------------------------------------.
1310 | yynewstate -- set current state (the top of the stack) to yystate.  |
1311 `--------------------------------------------------------------------*/
1312 yysetstate:
1313   *yyssp = (yytype_int16) yystate;
1314
1315   if (yyss + yystacksize - 1 <= yyssp)
1316 #if !defined yyoverflow && !defined YYSTACK_RELOCATE
1317     goto yyexhaustedlab;
1318 #else
1319     {
1320       /* Get the current used size of the three stacks, in elements.  */
1321       YYSIZE_T yysize = (YYSIZE_T) (yyssp - yyss + 1);
1322
1323 # if defined yyoverflow
1324       {
1325         /* Give user a chance to reallocate the stack.  Use copies of
1326            these so that the &'s don't force the real ones into
1327            memory.  */
1328         YYSTYPE *yyvs1 = yyvs;
1329         yytype_int16 *yyss1 = yyss;
1330
1331         /* Each stack pointer address is followed by the size of the
1332            data in use in that stack, in bytes.  This used to be a
1333            conditional around just the two extra args, but that might
1334            be undefined if yyoverflow is a macro.  */
1335         yyoverflow (YY_("memory exhausted"),
1336                     &yyss1, yysize * sizeof (*yyssp),
1337                     &yyvs1, yysize * sizeof (*yyvsp),
1338                     &yystacksize);
1339         yyss = yyss1;
1340         yyvs = yyvs1;
1341       }
1342 # else /* defined YYSTACK_RELOCATE */
1343       /* Extend the stack our own way.  */
1344       if (YYMAXDEPTH <= yystacksize)
1345         goto yyexhaustedlab;
1346       yystacksize *= 2;
1347       if (YYMAXDEPTH < yystacksize)
1348         yystacksize = YYMAXDEPTH;
1349
1350       {
1351         yytype_int16 *yyss1 = yyss;
1352         union yyalloc *yyptr =
1353           (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
1354         if (! yyptr)
1355           goto yyexhaustedlab;
1356         YYSTACK_RELOCATE (yyss_alloc, yyss);
1357         YYSTACK_RELOCATE (yyvs_alloc, yyvs);
1358 # undef YYSTACK_RELOCATE
1359         if (yyss1 != yyssa)
1360           YYSTACK_FREE (yyss1);
1361       }
1362 # endif
1363
1364       yyssp = yyss + yysize - 1;
1365       yyvsp = yyvs + yysize - 1;
1366
1367       YYDPRINTF ((stderr, "Stack size increased to %lu\n",
1368                   (unsigned long) yystacksize));
1369
1370       if (yyss + yystacksize - 1 <= yyssp)
1371         YYABORT;
1372     }
1373 #endif /* !defined yyoverflow && !defined YYSTACK_RELOCATE */
1374
1375   YYDPRINTF ((stderr, "Entering state %d\n", yystate));
1376
1377   if (yystate == YYFINAL)
1378     YYACCEPT;
1379
1380   goto yybackup;
1381
1382
1383 /*-----------.
1384 | yybackup.  |
1385 `-----------*/
1386 yybackup:
1387   /* Do appropriate processing given the current state.  Read a
1388      lookahead token if we need one and don't already have one.  */
1389
1390   /* First try to decide what to do without reference to lookahead token.  */
1391   yyn = yypact[yystate];
1392   if (yypact_value_is_default (yyn))
1393     goto yydefault;
1394
1395   /* Not known => get a lookahead token if don't already have one.  */
1396
1397   /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol.  */
1398   if (yychar == YYEMPTY)
1399     {
1400       YYDPRINTF ((stderr, "Reading a token: "));
1401       yychar = yylex (&yylval, parm);
1402     }
1403
1404   if (yychar <= YYEOF)
1405     {
1406       yychar = yytoken = YYEOF;
1407       YYDPRINTF ((stderr, "Now at end of input.\n"));
1408     }
1409   else
1410     {
1411       yytoken = YYTRANSLATE (yychar);
1412       YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
1413     }
1414
1415   /* If the proper action on seeing token YYTOKEN is to reduce or to
1416      detect an error, take that action.  */
1417   yyn += yytoken;
1418   if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
1419     goto yydefault;
1420   yyn = yytable[yyn];
1421   if (yyn <= 0)
1422     {
1423       if (yytable_value_is_error (yyn))
1424         goto yyerrlab;
1425       yyn = -yyn;
1426       goto yyreduce;
1427     }
1428
1429   /* Count tokens shifted since error; after three, turn off error
1430      status.  */
1431   if (yyerrstatus)
1432     yyerrstatus--;
1433
1434   /* Shift the lookahead token.  */
1435   YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
1436
1437   /* Discard the shifted token.  */
1438   yychar = YYEMPTY;
1439
1440   yystate = yyn;
1441   YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1442   *++yyvsp = yylval;
1443   YY_IGNORE_MAYBE_UNINITIALIZED_END
1444
1445   goto yynewstate;
1446
1447
1448 /*-----------------------------------------------------------.
1449 | yydefault -- do the default action for the current state.  |
1450 `-----------------------------------------------------------*/
1451 yydefault:
1452   yyn = yydefact[yystate];
1453   if (yyn == 0)
1454     goto yyerrlab;
1455   goto yyreduce;
1456
1457
1458 /*-----------------------------.
1459 | yyreduce -- do a reduction.  |
1460 `-----------------------------*/
1461 yyreduce:
1462   /* yyn is the number of a rule to reduce with.  */
1463   yylen = yyr2[yyn];
1464
1465   /* If YYLEN is nonzero, implement the default value of the action:
1466      '$$ = $1'.
1467
1468      Otherwise, the following line sets YYVAL to garbage.
1469      This behavior is undocumented and Bison
1470      users should not rely upon it.  Assigning to YYVAL
1471      unconditionally makes the parser a bit smaller, and it avoids a
1472      GCC warning that YYVAL may be used uninitialized.  */
1473   yyval = yyvsp[1-yylen];
1474
1475
1476   YY_REDUCE_PRINT (yyn);
1477   switch (yyn)
1478     {
1479         case 4:
1480 #line 183 "/home/wk/s/libksba/src/asn1-parse.y" /* yacc.c:1652  */
1481     { strcpy((yyval.str),(yyvsp[0].str)); }
1482 #line 1483 "asn1-parse.c" /* yacc.c:1652  */
1483     break;
1484
1485   case 5:
1486 #line 184 "/home/wk/s/libksba/src/asn1-parse.y" /* yacc.c:1652  */
1487     { strcpy((yyval.str),(yyvsp[0].str)); }
1488 #line 1489 "asn1-parse.c" /* yacc.c:1652  */
1489     break;
1490
1491   case 6:
1492 #line 188 "/home/wk/s/libksba/src/asn1-parse.y" /* yacc.c:1652  */
1493     {
1494                   strcpy((yyval.str),"-");
1495                   strcat((yyval.str),(yyvsp[0].str));
1496                 }
1497 #line 1498 "asn1-parse.c" /* yacc.c:1652  */
1498     break;
1499
1500   case 7:
1501 #line 194 "/home/wk/s/libksba/src/asn1-parse.y" /* yacc.c:1652  */
1502     { strcpy((yyval.str),(yyvsp[0].str)); }
1503 #line 1504 "asn1-parse.c" /* yacc.c:1652  */
1504     break;
1505
1506   case 8:
1507 #line 195 "/home/wk/s/libksba/src/asn1-parse.y" /* yacc.c:1652  */
1508     { strcpy((yyval.str),(yyvsp[0].str)); }
1509 #line 1510 "asn1-parse.c" /* yacc.c:1652  */
1510     break;
1511
1512   case 9:
1513 #line 198 "/home/wk/s/libksba/src/asn1-parse.y" /* yacc.c:1652  */
1514     {strcpy((yyval.str),(yyvsp[0].str));}
1515 #line 1516 "asn1-parse.c" /* yacc.c:1652  */
1516     break;
1517
1518   case 10:
1519 #line 199 "/home/wk/s/libksba/src/asn1-parse.y" /* yacc.c:1652  */
1520     {strcpy((yyval.str),(yyvsp[0].str));}
1521 #line 1522 "asn1-parse.c" /* yacc.c:1652  */
1522     break;
1523
1524   case 11:
1525 #line 202 "/home/wk/s/libksba/src/asn1-parse.y" /* yacc.c:1652  */
1526     {strcpy((yyval.str),(yyvsp[0].str));}
1527 #line 1528 "asn1-parse.c" /* yacc.c:1652  */
1528     break;
1529
1530   case 12:
1531 #line 203 "/home/wk/s/libksba/src/asn1-parse.y" /* yacc.c:1652  */
1532     {strcpy((yyval.str),(yyvsp[0].str));}
1533 #line 1534 "asn1-parse.c" /* yacc.c:1652  */
1534     break;
1535
1536   case 13:
1537 #line 207 "/home/wk/s/libksba/src/asn1-parse.y" /* yacc.c:1652  */
1538     {
1539                           (yyval.node) = NEW_NODE (TYPE_CONSTANT);
1540                           set_str_value ((yyval.node), (yyvsp[-1].str));
1541                         }
1542 #line 1543 "asn1-parse.c" /* yacc.c:1652  */
1543     break;
1544
1545   case 14:
1546 #line 212 "/home/wk/s/libksba/src/asn1-parse.y" /* yacc.c:1652  */
1547     {
1548                           (yyval.node) = NEW_NODE (TYPE_CONSTANT);
1549                           set_name ((yyval.node), (yyvsp[-3].str));
1550                           set_str_value ((yyval.node), (yyvsp[-1].str));
1551                         }
1552 #line 1553 "asn1-parse.c" /* yacc.c:1652  */
1553     break;
1554
1555   case 15:
1556 #line 219 "/home/wk/s/libksba/src/asn1-parse.y" /* yacc.c:1652  */
1557     { (yyval.node)=(yyvsp[0].node); }
1558 #line 1559 "asn1-parse.c" /* yacc.c:1652  */
1559     break;
1560
1561   case 16:
1562 #line 221 "/home/wk/s/libksba/src/asn1-parse.y" /* yacc.c:1652  */
1563     {
1564                     (yyval.node) = (yyvsp[-2].node);
1565                     append_right ((yyvsp[-2].node), (yyvsp[0].node));
1566                   }
1567 #line 1568 "asn1-parse.c" /* yacc.c:1652  */
1568     break;
1569
1570   case 17:
1571 #line 246 "/home/wk/s/libksba/src/asn1-parse.y" /* yacc.c:1652  */
1572     {
1573                    (yyval.node) = NEW_NODE (TYPE_CONSTANT);
1574                    set_str_value ((yyval.node), (yyvsp[0].str));
1575                  }
1576 #line 1577 "asn1-parse.c" /* yacc.c:1652  */
1577     break;
1578
1579   case 18:
1580 #line 251 "/home/wk/s/libksba/src/asn1-parse.y" /* yacc.c:1652  */
1581     {
1582                    (yyval.node) = NEW_NODE (TYPE_CONSTANT);
1583                    set_name ((yyval.node), (yyvsp[-3].str));
1584                    set_str_value ((yyval.node), (yyvsp[-1].str));
1585                  }
1586 #line 1587 "asn1-parse.c" /* yacc.c:1652  */
1587     break;
1588
1589   case 19:
1590 #line 259 "/home/wk/s/libksba/src/asn1-parse.y" /* yacc.c:1652  */
1591     { (yyval.node)=(yyvsp[0].node);}
1592 #line 1593 "asn1-parse.c" /* yacc.c:1652  */
1593     break;
1594
1595   case 20:
1596 #line 261 "/home/wk/s/libksba/src/asn1-parse.y" /* yacc.c:1652  */
1597     {
1598                           (yyval.node)=(yyvsp[-1].node);
1599                           append_right ((yyval.node), (yyvsp[0].node));
1600                         }
1601 #line 1602 "asn1-parse.c" /* yacc.c:1652  */
1602     break;
1603
1604   case 21:
1605 #line 267 "/home/wk/s/libksba/src/asn1-parse.y" /* yacc.c:1652  */
1606     { (yyval.constant) = CLASS_UNIVERSAL;   }
1607 #line 1608 "asn1-parse.c" /* yacc.c:1652  */
1608     break;
1609
1610   case 22:
1611 #line 268 "/home/wk/s/libksba/src/asn1-parse.y" /* yacc.c:1652  */
1612     { (yyval.constant) = CLASS_PRIVATE;     }
1613 #line 1614 "asn1-parse.c" /* yacc.c:1652  */
1614     break;
1615
1616   case 23:
1617 #line 269 "/home/wk/s/libksba/src/asn1-parse.y" /* yacc.c:1652  */
1618     { (yyval.constant) = CLASS_APPLICATION; }
1619 #line 1620 "asn1-parse.c" /* yacc.c:1652  */
1620     break;
1621
1622   case 24:
1623 #line 273 "/home/wk/s/libksba/src/asn1-parse.y" /* yacc.c:1652  */
1624     {
1625                   (yyval.node) = NEW_NODE (TYPE_TAG);
1626                   (yyval.node)->flags.class = CLASS_CONTEXT;
1627                   set_ulong_value ((yyval.node), (yyvsp[-1].str));
1628                 }
1629 #line 1630 "asn1-parse.c" /* yacc.c:1652  */
1630     break;
1631
1632   case 25:
1633 #line 279 "/home/wk/s/libksba/src/asn1-parse.y" /* yacc.c:1652  */
1634     {
1635                   (yyval.node) = NEW_NODE (TYPE_TAG);
1636                   (yyval.node)->flags.class = (yyvsp[-2].constant);
1637                   set_ulong_value ((yyval.node), (yyvsp[-1].str));
1638                 }
1639 #line 1640 "asn1-parse.c" /* yacc.c:1652  */
1640     break;
1641
1642   case 26:
1643 #line 287 "/home/wk/s/libksba/src/asn1-parse.y" /* yacc.c:1652  */
1644     { (yyval.node) = (yyvsp[0].node); }
1645 #line 1646 "asn1-parse.c" /* yacc.c:1652  */
1646     break;
1647
1648   case 27:
1649 #line 289 "/home/wk/s/libksba/src/asn1-parse.y" /* yacc.c:1652  */
1650     {
1651            (yyval.node) = (yyvsp[-1].node);
1652            (yyval.node)->flags.explicit = 1;
1653          }
1654 #line 1655 "asn1-parse.c" /* yacc.c:1652  */
1655     break;
1656
1657   case 28:
1658 #line 294 "/home/wk/s/libksba/src/asn1-parse.y" /* yacc.c:1652  */
1659     {
1660            (yyval.node) = (yyvsp[-1].node);
1661            (yyval.node)->flags.implicit = 1;
1662          }
1663 #line 1664 "asn1-parse.c" /* yacc.c:1652  */
1664     break;
1665
1666   case 29:
1667 #line 301 "/home/wk/s/libksba/src/asn1-parse.y" /* yacc.c:1652  */
1668     {
1669                  (yyval.node) = NEW_NODE (TYPE_DEFAULT);
1670                  set_str_value ((yyval.node), (yyvsp[0].str));
1671                }
1672 #line 1673 "asn1-parse.c" /* yacc.c:1652  */
1673     break;
1674
1675   case 30:
1676 #line 306 "/home/wk/s/libksba/src/asn1-parse.y" /* yacc.c:1652  */
1677     {
1678                  (yyval.node) = NEW_NODE (TYPE_DEFAULT);
1679                  (yyval.node)->flags.is_true = 1;
1680                }
1681 #line 1682 "asn1-parse.c" /* yacc.c:1652  */
1682     break;
1683
1684   case 31:
1685 #line 311 "/home/wk/s/libksba/src/asn1-parse.y" /* yacc.c:1652  */
1686     {
1687                  (yyval.node) = NEW_NODE (TYPE_DEFAULT);
1688                  (yyval.node)->flags.is_false = 1;
1689                }
1690 #line 1691 "asn1-parse.c" /* yacc.c:1652  */
1691     break;
1692
1693   case 32:
1694 #line 318 "/home/wk/s/libksba/src/asn1-parse.y" /* yacc.c:1652  */
1695     {
1696                  (yyval.node) = NEW_NODE (TYPE_INTEGER);
1697                }
1698 #line 1699 "asn1-parse.c" /* yacc.c:1652  */
1699     break;
1700
1701   case 33:
1702 #line 322 "/home/wk/s/libksba/src/asn1-parse.y" /* yacc.c:1652  */
1703     {
1704                  (yyval.node) = NEW_NODE (TYPE_INTEGER);
1705                  (yyval.node)->flags.has_list = 1;
1706                  set_down ((yyval.node), (yyvsp[-1].node));
1707                }
1708 #line 1709 "asn1-parse.c" /* yacc.c:1652  */
1709     break;
1710
1711   case 34:
1712 #line 328 "/home/wk/s/libksba/src/asn1-parse.y" /* yacc.c:1652  */
1713     {
1714                  (yyval.node) = NEW_NODE (TYPE_INTEGER);
1715                  (yyval.node)->flags.has_min_max = 1;
1716                  /* the following is wrong.  Better use a union for the value*/
1717                  set_down ((yyval.node), NEW_NODE (TYPE_SIZE) );
1718                  set_str_value ((yyval.node)->down, (yyvsp[-1].str));
1719                  set_name ((yyval.node)->down, (yyvsp[-4].str));
1720                }
1721 #line 1722 "asn1-parse.c" /* yacc.c:1652  */
1722     break;
1723
1724   case 35:
1725 #line 339 "/home/wk/s/libksba/src/asn1-parse.y" /* yacc.c:1652  */
1726     {
1727                 (yyval.node) = NEW_NODE (TYPE_BOOLEAN);
1728               }
1729 #line 1730 "asn1-parse.c" /* yacc.c:1652  */
1730     break;
1731
1732   case 36:
1733 #line 345 "/home/wk/s/libksba/src/asn1-parse.y" /* yacc.c:1652  */
1734     {
1735             (yyval.node) = NEW_NODE (TYPE_UTC_TIME);
1736           }
1737 #line 1738 "asn1-parse.c" /* yacc.c:1652  */
1738     break;
1739
1740   case 37:
1741 #line 349 "/home/wk/s/libksba/src/asn1-parse.y" /* yacc.c:1652  */
1742     {
1743             (yyval.node) = NEW_NODE (TYPE_GENERALIZED_TIME);
1744           }
1745 #line 1746 "asn1-parse.c" /* yacc.c:1652  */
1746     break;
1747
1748   case 38:
1749 #line 355 "/home/wk/s/libksba/src/asn1-parse.y" /* yacc.c:1652  */
1750     {
1751                (yyval.node) = NEW_NODE (TYPE_SIZE);
1752                (yyval.node)->flags.one_param = 1;
1753                set_str_value ((yyval.node), (yyvsp[-1].str));
1754              }
1755 #line 1756 "asn1-parse.c" /* yacc.c:1652  */
1756     break;
1757
1758   case 39:
1759 #line 361 "/home/wk/s/libksba/src/asn1-parse.y" /* yacc.c:1652  */
1760     {
1761                (yyval.node) = NEW_NODE (TYPE_SIZE);
1762                (yyval.node)->flags.has_min_max = 1;
1763                set_str_value ((yyval.node), (yyvsp[-4].str));
1764                set_name ((yyval.node), (yyvsp[-1].str));
1765              }
1766 #line 1767 "asn1-parse.c" /* yacc.c:1652  */
1767     break;
1768
1769   case 40:
1770 #line 370 "/home/wk/s/libksba/src/asn1-parse.y" /* yacc.c:1652  */
1771     {
1772                (yyval.node)=(yyvsp[0].node);
1773              }
1774 #line 1775 "asn1-parse.c" /* yacc.c:1652  */
1775     break;
1776
1777   case 41:
1778 #line 374 "/home/wk/s/libksba/src/asn1-parse.y" /* yacc.c:1652  */
1779     {
1780                (yyval.node)=(yyvsp[-1].node);
1781              }
1782 #line 1783 "asn1-parse.c" /* yacc.c:1652  */
1783     break;
1784
1785   case 42:
1786 #line 380 "/home/wk/s/libksba/src/asn1-parse.y" /* yacc.c:1652  */
1787     {
1788                        (yyval.node) = NEW_NODE (TYPE_OCTET_STRING);
1789                      }
1790 #line 1791 "asn1-parse.c" /* yacc.c:1652  */
1791     break;
1792
1793   case 43:
1794 #line 384 "/home/wk/s/libksba/src/asn1-parse.y" /* yacc.c:1652  */
1795     {
1796                        (yyval.node) = NEW_NODE (TYPE_OCTET_STRING);
1797                        (yyval.node)->flags.has_size = 1;
1798                        set_down ((yyval.node),(yyvsp[0].node));
1799                      }
1800 #line 1801 "asn1-parse.c" /* yacc.c:1652  */
1801     break;
1802
1803   case 44:
1804 #line 391 "/home/wk/s/libksba/src/asn1-parse.y" /* yacc.c:1652  */
1805     { (yyval.node) = NEW_NODE (TYPE_UTF8_STRING); }
1806 #line 1807 "asn1-parse.c" /* yacc.c:1652  */
1807     break;
1808
1809   case 45:
1810 #line 393 "/home/wk/s/libksba/src/asn1-parse.y" /* yacc.c:1652  */
1811     {
1812                        (yyval.node) = NEW_NODE (TYPE_UTF8_STRING);
1813                        (yyval.node)->flags.has_size = 1;
1814                        set_down ((yyval.node),(yyvsp[0].node));
1815                      }
1816 #line 1817 "asn1-parse.c" /* yacc.c:1652  */
1817     break;
1818
1819   case 46:
1820 #line 399 "/home/wk/s/libksba/src/asn1-parse.y" /* yacc.c:1652  */
1821     { (yyval.node) = NEW_NODE (TYPE_NUMERIC_STRING); }
1822 #line 1823 "asn1-parse.c" /* yacc.c:1652  */
1823     break;
1824
1825   case 47:
1826 #line 401 "/home/wk/s/libksba/src/asn1-parse.y" /* yacc.c:1652  */
1827     {
1828                        (yyval.node) = NEW_NODE (TYPE_NUMERIC_STRING);
1829                        (yyval.node)->flags.has_size = 1;
1830                        set_down ((yyval.node),(yyvsp[0].node));
1831                      }
1832 #line 1833 "asn1-parse.c" /* yacc.c:1652  */
1833     break;
1834
1835   case 48:
1836 #line 408 "/home/wk/s/libksba/src/asn1-parse.y" /* yacc.c:1652  */
1837     { (yyval.node) = NEW_NODE (TYPE_PRINTABLE_STRING); }
1838 #line 1839 "asn1-parse.c" /* yacc.c:1652  */
1839     break;
1840
1841   case 49:
1842 #line 410 "/home/wk/s/libksba/src/asn1-parse.y" /* yacc.c:1652  */
1843     {
1844                           (yyval.node) = NEW_NODE (TYPE_PRINTABLE_STRING);
1845                           (yyval.node)->flags.has_size = 1;
1846                           set_down ((yyval.node),(yyvsp[0].node));
1847                         }
1848 #line 1849 "asn1-parse.c" /* yacc.c:1652  */
1849     break;
1850
1851   case 50:
1852 #line 417 "/home/wk/s/libksba/src/asn1-parse.y" /* yacc.c:1652  */
1853     { (yyval.node) = NEW_NODE (TYPE_TELETEX_STRING); }
1854 #line 1855 "asn1-parse.c" /* yacc.c:1652  */
1855     break;
1856
1857   case 51:
1858 #line 419 "/home/wk/s/libksba/src/asn1-parse.y" /* yacc.c:1652  */
1859     {
1860                        (yyval.node) = NEW_NODE (TYPE_TELETEX_STRING);
1861                        (yyval.node)->flags.has_size = 1;
1862                        set_down ((yyval.node),(yyvsp[0].node));
1863                      }
1864 #line 1865 "asn1-parse.c" /* yacc.c:1652  */
1865     break;
1866
1867   case 52:
1868 #line 425 "/home/wk/s/libksba/src/asn1-parse.y" /* yacc.c:1652  */
1869     { (yyval.node) = NEW_NODE (TYPE_IA5_STRING); }
1870 #line 1871 "asn1-parse.c" /* yacc.c:1652  */
1871     break;
1872
1873   case 53:
1874 #line 427 "/home/wk/s/libksba/src/asn1-parse.y" /* yacc.c:1652  */
1875     {
1876                        (yyval.node) = NEW_NODE (TYPE_IA5_STRING);
1877                        (yyval.node)->flags.has_size = 1;
1878                        set_down ((yyval.node),(yyvsp[0].node));
1879                      }
1880 #line 1881 "asn1-parse.c" /* yacc.c:1652  */
1881     break;
1882
1883   case 54:
1884 #line 434 "/home/wk/s/libksba/src/asn1-parse.y" /* yacc.c:1652  */
1885     { (yyval.node) = NEW_NODE (TYPE_UNIVERSAL_STRING); }
1886 #line 1887 "asn1-parse.c" /* yacc.c:1652  */
1887     break;
1888
1889   case 55:
1890 #line 436 "/home/wk/s/libksba/src/asn1-parse.y" /* yacc.c:1652  */
1891     {
1892                            (yyval.node) = NEW_NODE (TYPE_UNIVERSAL_STRING);
1893                            (yyval.node)->flags.has_size = 1;
1894                            set_down ((yyval.node),(yyvsp[0].node));
1895                          }
1896 #line 1897 "asn1-parse.c" /* yacc.c:1652  */
1897     break;
1898
1899   case 56:
1900 #line 442 "/home/wk/s/libksba/src/asn1-parse.y" /* yacc.c:1652  */
1901     { (yyval.node) = NEW_NODE (TYPE_BMP_STRING); }
1902 #line 1903 "asn1-parse.c" /* yacc.c:1652  */
1903     break;
1904
1905   case 57:
1906 #line 444 "/home/wk/s/libksba/src/asn1-parse.y" /* yacc.c:1652  */
1907     {
1908                        (yyval.node) = NEW_NODE (TYPE_BMP_STRING);
1909                        (yyval.node)->flags.has_size = 1;
1910                        set_down ((yyval.node),(yyvsp[0].node));
1911                      }
1912 #line 1913 "asn1-parse.c" /* yacc.c:1652  */
1913     break;
1914
1915   case 65:
1916 #line 465 "/home/wk/s/libksba/src/asn1-parse.y" /* yacc.c:1652  */
1917     {
1918                    (yyval.node) = NEW_NODE (TYPE_CONSTANT);
1919                    set_name ((yyval.node), (yyvsp[-3].str));
1920                    set_str_value ((yyval.node), (yyvsp[-1].str));
1921                  }
1922 #line 1923 "asn1-parse.c" /* yacc.c:1652  */
1923     break;
1924
1925   case 66:
1926 #line 473 "/home/wk/s/libksba/src/asn1-parse.y" /* yacc.c:1652  */
1927     {
1928                         (yyval.node)=(yyvsp[0].node);
1929                       }
1930 #line 1931 "asn1-parse.c" /* yacc.c:1652  */
1931     break;
1932
1933   case 67:
1934 #line 477 "/home/wk/s/libksba/src/asn1-parse.y" /* yacc.c:1652  */
1935     {
1936                         (yyval.node)=(yyvsp[-2].node);
1937                         append_right ((yyval.node), (yyvsp[0].node));
1938                       }
1939 #line 1940 "asn1-parse.c" /* yacc.c:1652  */
1940     break;
1941
1942   case 68:
1943 #line 484 "/home/wk/s/libksba/src/asn1-parse.y" /* yacc.c:1652  */
1944     {
1945                      (yyval.node) = NEW_NODE (TYPE_BIT_STRING);
1946                    }
1947 #line 1948 "asn1-parse.c" /* yacc.c:1652  */
1948     break;
1949
1950   case 69:
1951 #line 488 "/home/wk/s/libksba/src/asn1-parse.y" /* yacc.c:1652  */
1952     {
1953                      (yyval.node) = NEW_NODE (TYPE_BIT_STRING);
1954                      (yyval.node)->flags.has_list = 1;
1955                      set_down ((yyval.node), (yyvsp[-1].node));
1956                    }
1957 #line 1958 "asn1-parse.c" /* yacc.c:1652  */
1958     break;
1959
1960   case 70:
1961 #line 496 "/home/wk/s/libksba/src/asn1-parse.y" /* yacc.c:1652  */
1962     {
1963                      (yyval.node) = NEW_NODE (TYPE_ENUMERATED);
1964                      (yyval.node)->flags.has_list = 1;
1965                      set_down ((yyval.node), (yyvsp[-1].node));
1966                    }
1967 #line 1968 "asn1-parse.c" /* yacc.c:1652  */
1968     break;
1969
1970   case 71:
1971 #line 504 "/home/wk/s/libksba/src/asn1-parse.y" /* yacc.c:1652  */
1972     {
1973                      (yyval.node) = NEW_NODE (TYPE_OBJECT_ID);
1974                    }
1975 #line 1976 "asn1-parse.c" /* yacc.c:1652  */
1976     break;
1977
1978   case 72:
1979 #line 510 "/home/wk/s/libksba/src/asn1-parse.y" /* yacc.c:1652  */
1980     {
1981                       (yyval.node) = NEW_NODE (TYPE_IDENTIFIER);
1982                       set_str_value ((yyval.node), (yyvsp[0].str));
1983                     }
1984 #line 1985 "asn1-parse.c" /* yacc.c:1652  */
1985     break;
1986
1987   case 73:
1988 #line 515 "/home/wk/s/libksba/src/asn1-parse.y" /* yacc.c:1652  */
1989     {
1990                       (yyval.node) = NEW_NODE (TYPE_IDENTIFIER);
1991                       (yyval.node)->flags.has_size = 1;
1992                       set_str_value ((yyval.node), (yyvsp[-1].str));
1993                       set_down ((yyval.node), (yyvsp[0].node));
1994                     }
1995 #line 1996 "asn1-parse.c" /* yacc.c:1652  */
1996     break;
1997
1998   case 74:
1999 #line 521 "/home/wk/s/libksba/src/asn1-parse.y" /* yacc.c:1652  */
2000     {(yyval.node)=(yyvsp[0].node);}
2001 #line 2002 "asn1-parse.c" /* yacc.c:1652  */
2002     break;
2003
2004   case 75:
2005 #line 522 "/home/wk/s/libksba/src/asn1-parse.y" /* yacc.c:1652  */
2006     {(yyval.node)=(yyvsp[0].node);}
2007 #line 2008 "asn1-parse.c" /* yacc.c:1652  */
2008     break;
2009
2010   case 76:
2011 #line 523 "/home/wk/s/libksba/src/asn1-parse.y" /* yacc.c:1652  */
2012     {(yyval.node)=(yyvsp[0].node);}
2013 #line 2014 "asn1-parse.c" /* yacc.c:1652  */
2014     break;
2015
2016   case 77:
2017 #line 524 "/home/wk/s/libksba/src/asn1-parse.y" /* yacc.c:1652  */
2018     {(yyval.node)=(yyvsp[0].node);}
2019 #line 2020 "asn1-parse.c" /* yacc.c:1652  */
2020     break;
2021
2022   case 79:
2023 #line 526 "/home/wk/s/libksba/src/asn1-parse.y" /* yacc.c:1652  */
2024     {(yyval.node)=(yyvsp[0].node);}
2025 #line 2026 "asn1-parse.c" /* yacc.c:1652  */
2026     break;
2027
2028   case 80:
2029 #line 527 "/home/wk/s/libksba/src/asn1-parse.y" /* yacc.c:1652  */
2030     {(yyval.node)=(yyvsp[0].node);}
2031 #line 2032 "asn1-parse.c" /* yacc.c:1652  */
2032     break;
2033
2034   case 81:
2035 #line 528 "/home/wk/s/libksba/src/asn1-parse.y" /* yacc.c:1652  */
2036     {(yyval.node)=(yyvsp[0].node);}
2037 #line 2038 "asn1-parse.c" /* yacc.c:1652  */
2038     break;
2039
2040   case 82:
2041 #line 529 "/home/wk/s/libksba/src/asn1-parse.y" /* yacc.c:1652  */
2042     {(yyval.node)=(yyvsp[0].node);}
2043 #line 2044 "asn1-parse.c" /* yacc.c:1652  */
2044     break;
2045
2046   case 83:
2047 #line 530 "/home/wk/s/libksba/src/asn1-parse.y" /* yacc.c:1652  */
2048     {(yyval.node)=(yyvsp[0].node);}
2049 #line 2050 "asn1-parse.c" /* yacc.c:1652  */
2050     break;
2051
2052   case 84:
2053 #line 531 "/home/wk/s/libksba/src/asn1-parse.y" /* yacc.c:1652  */
2054     {(yyval.node)=(yyvsp[0].node);}
2055 #line 2056 "asn1-parse.c" /* yacc.c:1652  */
2056     break;
2057
2058   case 85:
2059 #line 532 "/home/wk/s/libksba/src/asn1-parse.y" /* yacc.c:1652  */
2060     {(yyval.node)=(yyvsp[0].node);}
2061 #line 2062 "asn1-parse.c" /* yacc.c:1652  */
2062     break;
2063
2064   case 86:
2065 #line 534 "/home/wk/s/libksba/src/asn1-parse.y" /* yacc.c:1652  */
2066     {
2067                       (yyval.node) = NEW_NODE(TYPE_NULL);
2068                     }
2069 #line 2070 "asn1-parse.c" /* yacc.c:1652  */
2070     break;
2071
2072   case 87:
2073 #line 540 "/home/wk/s/libksba/src/asn1-parse.y" /* yacc.c:1652  */
2074     {
2075                              (yyval.node) = (yyvsp[0].node);
2076                            }
2077 #line 2078 "asn1-parse.c" /* yacc.c:1652  */
2078     break;
2079
2080   case 88:
2081 #line 544 "/home/wk/s/libksba/src/asn1-parse.y" /* yacc.c:1652  */
2082     {
2083 /*                               $2->flags.has_tag = 1; */
2084 /*                               $$ = $2; */
2085 /*                               set_right ($1, $$->down ); */
2086 /*                               set_down ($$, $1); */
2087                              (yyval.node) = (yyvsp[-1].node);
2088                              set_down ((yyval.node), (yyvsp[0].node));
2089                            }
2090 #line 2091 "asn1-parse.c" /* yacc.c:1652  */
2091     break;
2092
2093   case 89:
2094 #line 555 "/home/wk/s/libksba/src/asn1-parse.y" /* yacc.c:1652  */
2095     {
2096                                    (yyval.node) = (yyvsp[0].node);
2097                                  }
2098 #line 2099 "asn1-parse.c" /* yacc.c:1652  */
2099     break;
2100
2101   case 90:
2102 #line 559 "/home/wk/s/libksba/src/asn1-parse.y" /* yacc.c:1652  */
2103     {
2104                                    (yyvsp[-1].node)->flags.has_default = 1;
2105                                    (yyval.node) = (yyvsp[-1].node);
2106                                    set_right ((yyvsp[0].node), (yyval.node)->down);
2107                                    set_down ((yyval.node), (yyvsp[0].node));
2108                                  }
2109 #line 2110 "asn1-parse.c" /* yacc.c:1652  */
2110     break;
2111
2112   case 91:
2113 #line 566 "/home/wk/s/libksba/src/asn1-parse.y" /* yacc.c:1652  */
2114     {
2115                                    (yyvsp[-1].node)->flags.is_optional = 1;
2116                                    (yyval.node) = (yyvsp[-1].node);
2117                                  }
2118 #line 2119 "asn1-parse.c" /* yacc.c:1652  */
2119     break;
2120
2121   case 92:
2122 #line 573 "/home/wk/s/libksba/src/asn1-parse.y" /* yacc.c:1652  */
2123     {
2124                  set_name ((yyvsp[0].node), (yyvsp[-1].str));
2125                  (yyval.node) = (yyvsp[0].node);
2126                }
2127 #line 2128 "asn1-parse.c" /* yacc.c:1652  */
2128     break;
2129
2130   case 93:
2131 #line 580 "/home/wk/s/libksba/src/asn1-parse.y" /* yacc.c:1652  */
2132     { (yyval.node)=(yyvsp[0].node); }
2133 #line 2134 "asn1-parse.c" /* yacc.c:1652  */
2134     break;
2135
2136   case 94:
2137 #line 582 "/home/wk/s/libksba/src/asn1-parse.y" /* yacc.c:1652  */
2138     {
2139                       (yyval.node)=(yyvsp[-2].node);
2140                       append_right ((yyval.node), (yyvsp[0].node));
2141                     }
2142 #line 2143 "asn1-parse.c" /* yacc.c:1652  */
2143     break;
2144
2145   case 95:
2146 #line 589 "/home/wk/s/libksba/src/asn1-parse.y" /* yacc.c:1652  */
2147     {
2148                    (yyval.node) = NEW_NODE (TYPE_SEQUENCE);
2149                    set_down ((yyval.node), (yyvsp[-1].node));
2150                  }
2151 #line 2152 "asn1-parse.c" /* yacc.c:1652  */
2152     break;
2153
2154   case 96:
2155 #line 594 "/home/wk/s/libksba/src/asn1-parse.y" /* yacc.c:1652  */
2156     {
2157                    (yyval.node) = NEW_NODE (TYPE_SEQUENCE_OF);
2158                    set_down ((yyval.node), (yyvsp[0].node));
2159                  }
2160 #line 2161 "asn1-parse.c" /* yacc.c:1652  */
2161     break;
2162
2163   case 97:
2164 #line 599 "/home/wk/s/libksba/src/asn1-parse.y" /* yacc.c:1652  */
2165     {
2166                    (yyval.node) = NEW_NODE (TYPE_SEQUENCE_OF);
2167                    (yyval.node)->flags.has_size = 1;
2168                    set_right ((yyvsp[-2].node),(yyvsp[0].node));
2169                    set_down ((yyval.node),(yyvsp[-2].node));
2170                  }
2171 #line 2172 "asn1-parse.c" /* yacc.c:1652  */
2172     break;
2173
2174   case 98:
2175 #line 608 "/home/wk/s/libksba/src/asn1-parse.y" /* yacc.c:1652  */
2176     {
2177                (yyval.node) = NEW_NODE (TYPE_SET);
2178                set_down ((yyval.node), (yyvsp[-1].node));
2179              }
2180 #line 2181 "asn1-parse.c" /* yacc.c:1652  */
2181     break;
2182
2183   case 99:
2184 #line 613 "/home/wk/s/libksba/src/asn1-parse.y" /* yacc.c:1652  */
2185     {
2186                (yyval.node) = NEW_NODE (TYPE_SET_OF);
2187                set_down ((yyval.node), (yyvsp[0].node));
2188              }
2189 #line 2190 "asn1-parse.c" /* yacc.c:1652  */
2190     break;
2191
2192   case 100:
2193 #line 618 "/home/wk/s/libksba/src/asn1-parse.y" /* yacc.c:1652  */
2194     {
2195                (yyval.node) = NEW_NODE (TYPE_SET_OF);
2196                (yyval.node)->flags.has_size = 1;
2197                set_right ((yyvsp[-2].node), (yyvsp[0].node));
2198                set_down ((yyval.node), (yyvsp[-2].node));
2199              }
2200 #line 2201 "asn1-parse.c" /* yacc.c:1652  */
2201     break;
2202
2203   case 101:
2204 #line 627 "/home/wk/s/libksba/src/asn1-parse.y" /* yacc.c:1652  */
2205     {
2206                   (yyval.node) = NEW_NODE (TYPE_CHOICE);
2207                   set_down ((yyval.node), (yyvsp[-1].node));
2208                 }
2209 #line 2210 "asn1-parse.c" /* yacc.c:1652  */
2210     break;
2211
2212   case 102:
2213 #line 634 "/home/wk/s/libksba/src/asn1-parse.y" /* yacc.c:1652  */
2214     {
2215                (yyval.node) = NEW_NODE (TYPE_ANY);
2216              }
2217 #line 2218 "asn1-parse.c" /* yacc.c:1652  */
2218     break;
2219
2220   case 103:
2221 #line 638 "/home/wk/s/libksba/src/asn1-parse.y" /* yacc.c:1652  */
2222     {
2223                AsnNode node;
2224
2225                (yyval.node) = NEW_NODE (TYPE_ANY);
2226                (yyval.node)->flags.has_defined_by = 1;
2227                node = NEW_NODE (TYPE_CONSTANT);
2228                set_name (node, (yyvsp[0].str));
2229                set_down((yyval.node), node);
2230              }
2231 #line 2232 "asn1-parse.c" /* yacc.c:1652  */
2232     break;
2233
2234   case 104:
2235 #line 650 "/home/wk/s/libksba/src/asn1-parse.y" /* yacc.c:1652  */
2236     {
2237                set_name ((yyvsp[0].node), (yyvsp[-2].str));
2238                (yyval.node) = (yyvsp[0].node);
2239              }
2240 #line 2241 "asn1-parse.c" /* yacc.c:1652  */
2241     break;
2242
2243   case 105:
2244 #line 657 "/home/wk/s/libksba/src/asn1-parse.y" /* yacc.c:1652  */
2245     {
2246                    (yyval.node) = NEW_NODE (TYPE_OBJECT_ID);
2247                    (yyval.node)->flags.assignment = 1;
2248                    set_name ((yyval.node), (yyvsp[-6].str));
2249                    set_down ((yyval.node), (yyvsp[-1].node));
2250                  }
2251 #line 2252 "asn1-parse.c" /* yacc.c:1652  */
2252     break;
2253
2254   case 106:
2255 #line 664 "/home/wk/s/libksba/src/asn1-parse.y" /* yacc.c:1652  */
2256     {
2257                    (yyval.node) = NEW_NODE (TYPE_OBJECT_ID);
2258                    (yyval.node)->flags.assignment = 1;
2259                    (yyval.node)->flags.one_param = 1;
2260                    set_name ((yyval.node), (yyvsp[-5].str));
2261                    set_str_value ((yyval.node), (yyvsp[-4].str));
2262                    set_down ((yyval.node), (yyvsp[-1].node));
2263                  }
2264 #line 2265 "asn1-parse.c" /* yacc.c:1652  */
2265     break;
2266
2267   case 107:
2268 #line 673 "/home/wk/s/libksba/src/asn1-parse.y" /* yacc.c:1652  */
2269     {
2270                    (yyval.node) = NEW_NODE (TYPE_INTEGER);
2271                    (yyval.node)->flags.assignment = 1;
2272                    set_name ((yyval.node), (yyvsp[-3].str));
2273                    set_str_value ((yyval.node), (yyvsp[0].str));
2274                  }
2275 #line 2276 "asn1-parse.c" /* yacc.c:1652  */
2276     break;
2277
2278   case 108:
2279 #line 681 "/home/wk/s/libksba/src/asn1-parse.y" /* yacc.c:1652  */
2280     { (yyval.node) = (yyvsp[0].node); }
2281 #line 2282 "asn1-parse.c" /* yacc.c:1652  */
2282     break;
2283
2284   case 109:
2285 #line 682 "/home/wk/s/libksba/src/asn1-parse.y" /* yacc.c:1652  */
2286     { (yyval.node) = (yyvsp[0].node); }
2287 #line 2288 "asn1-parse.c" /* yacc.c:1652  */
2288     break;
2289
2290   case 110:
2291 #line 686 "/home/wk/s/libksba/src/asn1-parse.y" /* yacc.c:1652  */
2292     { (yyval.node) = (yyvsp[0].node); }
2293 #line 2294 "asn1-parse.c" /* yacc.c:1652  */
2294     break;
2295
2296   case 111:
2297 #line 688 "/home/wk/s/libksba/src/asn1-parse.y" /* yacc.c:1652  */
2298     {
2299                          (yyval.node) = (yyvsp[-1].node);
2300                          append_right ((yyval.node), (yyvsp[0].node));
2301                        }
2302 #line 2303 "asn1-parse.c" /* yacc.c:1652  */
2303     break;
2304
2305   case 112:
2306 #line 695 "/home/wk/s/libksba/src/asn1-parse.y" /* yacc.c:1652  */
2307     {
2308                      (yyval.node) = NEW_NODE (TYPE_OBJECT_ID);
2309                      set_down ((yyval.node), (yyvsp[-1].node));
2310                      set_name ((yyval.node), (yyvsp[-3].str));
2311                    }
2312 #line 2313 "asn1-parse.c" /* yacc.c:1652  */
2313     break;
2314
2315   case 113:
2316 #line 703 "/home/wk/s/libksba/src/asn1-parse.y" /* yacc.c:1652  */
2317     { (yyval.node)=NULL;}
2318 #line 2319 "asn1-parse.c" /* yacc.c:1652  */
2319     break;
2320
2321   case 114:
2322 #line 719 "/home/wk/s/libksba/src/asn1-parse.y" /* yacc.c:1652  */
2323     { (yyval.constant) = CONST_EXPLICIT; }
2324 #line 2325 "asn1-parse.c" /* yacc.c:1652  */
2325     break;
2326
2327   case 115:
2328 #line 720 "/home/wk/s/libksba/src/asn1-parse.y" /* yacc.c:1652  */
2329     { (yyval.constant) = CONST_IMPLICIT; }
2330 #line 2331 "asn1-parse.c" /* yacc.c:1652  */
2331     break;
2332
2333   case 116:
2334 #line 726 "/home/wk/s/libksba/src/asn1-parse.y" /* yacc.c:1652  */
2335     {
2336                  AsnNode node;
2337
2338                  (yyval.node) = node = NEW_NODE (TYPE_DEFINITIONS);
2339
2340                  if ((yyvsp[-6].constant) == CONST_EXPLICIT)
2341                    node->flags.explicit = 1;
2342                  else if ((yyvsp[-6].constant) == CONST_IMPLICIT)
2343                    node->flags.implicit = 1;
2344
2345                  if ((yyvsp[-2].node))
2346                    node->flags.has_imports = 1;
2347
2348                  set_name ((yyval.node), (yyvsp[-8].node)->name);
2349                  set_name ((yyvsp[-8].node), "");
2350
2351                  if (!node->flags.has_imports)
2352                    set_right ((yyvsp[-8].node),(yyvsp[-1].node));
2353                  else
2354                    {
2355                      set_right ((yyvsp[-2].node),(yyvsp[-1].node));
2356                      set_right ((yyvsp[-8].node),(yyvsp[-2].node));
2357                    }
2358
2359                  set_down ((yyval.node), (yyvsp[-8].node));
2360
2361                  _ksba_asn_set_default_tag ((yyval.node));
2362                  _ksba_asn_type_set_config ((yyval.node));
2363                  PARSECTL->result_parse = _ksba_asn_check_identifier((yyval.node));
2364                  PARSECTL->parse_tree=(yyval.node);
2365                }
2366 #line 2367 "asn1-parse.c" /* yacc.c:1652  */
2367     break;
2368
2369
2370 #line 2371 "asn1-parse.c" /* yacc.c:1652  */
2371       default: break;
2372     }
2373   /* User semantic actions sometimes alter yychar, and that requires
2374      that yytoken be updated with the new translation.  We take the
2375      approach of translating immediately before every use of yytoken.
2376      One alternative is translating here after every semantic action,
2377      but that translation would be missed if the semantic action invokes
2378      YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or
2379      if it invokes YYBACKUP.  In the case of YYABORT or YYACCEPT, an
2380      incorrect destructor might then be invoked immediately.  In the
2381      case of YYERROR or YYBACKUP, subsequent parser actions might lead
2382      to an incorrect destructor call or verbose syntax error message
2383      before the lookahead is translated.  */
2384   YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
2385
2386   YYPOPSTACK (yylen);
2387   yylen = 0;
2388   YY_STACK_PRINT (yyss, yyssp);
2389
2390   *++yyvsp = yyval;
2391
2392   /* Now 'shift' the result of the reduction.  Determine what state
2393      that goes to, based on the state we popped back to and the rule
2394      number reduced by.  */
2395   {
2396     const int yylhs = yyr1[yyn] - YYNTOKENS;
2397     const int yyi = yypgoto[yylhs] + *yyssp;
2398     yystate = (0 <= yyi && yyi <= YYLAST && yycheck[yyi] == *yyssp
2399                ? yytable[yyi]
2400                : yydefgoto[yylhs]);
2401   }
2402
2403   goto yynewstate;
2404
2405
2406 /*--------------------------------------.
2407 | yyerrlab -- here on detecting error.  |
2408 `--------------------------------------*/
2409 yyerrlab:
2410   /* Make sure we have latest lookahead translation.  See comments at
2411      user semantic actions for why this is necessary.  */
2412   yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE (yychar);
2413
2414   /* If not already recovering from an error, report this error.  */
2415   if (!yyerrstatus)
2416     {
2417       ++yynerrs;
2418 #if ! YYERROR_VERBOSE
2419       yyerror (parm, YY_("syntax error"));
2420 #else
2421 # define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \
2422                                         yyssp, yytoken)
2423       {
2424         char const *yymsgp = YY_("syntax error");
2425         int yysyntax_error_status;
2426         yysyntax_error_status = YYSYNTAX_ERROR;
2427         if (yysyntax_error_status == 0)
2428           yymsgp = yymsg;
2429         else if (yysyntax_error_status == 1)
2430           {
2431             if (yymsg != yymsgbuf)
2432               YYSTACK_FREE (yymsg);
2433             yymsg = (char *) YYSTACK_ALLOC (yymsg_alloc);
2434             if (!yymsg)
2435               {
2436                 yymsg = yymsgbuf;
2437                 yymsg_alloc = sizeof yymsgbuf;
2438                 yysyntax_error_status = 2;
2439               }
2440             else
2441               {
2442                 yysyntax_error_status = YYSYNTAX_ERROR;
2443                 yymsgp = yymsg;
2444               }
2445           }
2446         yyerror (parm, yymsgp);
2447         if (yysyntax_error_status == 2)
2448           goto yyexhaustedlab;
2449       }
2450 # undef YYSYNTAX_ERROR
2451 #endif
2452     }
2453
2454
2455
2456   if (yyerrstatus == 3)
2457     {
2458       /* If just tried and failed to reuse lookahead token after an
2459          error, discard it.  */
2460
2461       if (yychar <= YYEOF)
2462         {
2463           /* Return failure if at end of input.  */
2464           if (yychar == YYEOF)
2465             YYABORT;
2466         }
2467       else
2468         {
2469           yydestruct ("Error: discarding",
2470                       yytoken, &yylval, parm);
2471           yychar = YYEMPTY;
2472         }
2473     }
2474
2475   /* Else will try to reuse lookahead token after shifting the error
2476      token.  */
2477   goto yyerrlab1;
2478
2479
2480 /*---------------------------------------------------.
2481 | yyerrorlab -- error raised explicitly by YYERROR.  |
2482 `---------------------------------------------------*/
2483 yyerrorlab:
2484   /* Pacify compilers when the user code never invokes YYERROR and the
2485      label yyerrorlab therefore never appears in user code.  */
2486   if (0)
2487     YYERROR;
2488
2489   /* Do not reclaim the symbols of the rule whose action triggered
2490      this YYERROR.  */
2491   YYPOPSTACK (yylen);
2492   yylen = 0;
2493   YY_STACK_PRINT (yyss, yyssp);
2494   yystate = *yyssp;
2495   goto yyerrlab1;
2496
2497
2498 /*-------------------------------------------------------------.
2499 | yyerrlab1 -- common code for both syntax error and YYERROR.  |
2500 `-------------------------------------------------------------*/
2501 yyerrlab1:
2502   yyerrstatus = 3;      /* Each real token shifted decrements this.  */
2503
2504   for (;;)
2505     {
2506       yyn = yypact[yystate];
2507       if (!yypact_value_is_default (yyn))
2508         {
2509           yyn += YYTERROR;
2510           if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
2511             {
2512               yyn = yytable[yyn];
2513               if (0 < yyn)
2514                 break;
2515             }
2516         }
2517
2518       /* Pop the current state because it cannot handle the error token.  */
2519       if (yyssp == yyss)
2520         YYABORT;
2521
2522
2523       yydestruct ("Error: popping",
2524                   yystos[yystate], yyvsp, parm);
2525       YYPOPSTACK (1);
2526       yystate = *yyssp;
2527       YY_STACK_PRINT (yyss, yyssp);
2528     }
2529
2530   YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
2531   *++yyvsp = yylval;
2532   YY_IGNORE_MAYBE_UNINITIALIZED_END
2533
2534
2535   /* Shift the error token.  */
2536   YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
2537
2538   yystate = yyn;
2539   goto yynewstate;
2540
2541
2542 /*-------------------------------------.
2543 | yyacceptlab -- YYACCEPT comes here.  |
2544 `-------------------------------------*/
2545 yyacceptlab:
2546   yyresult = 0;
2547   goto yyreturn;
2548
2549
2550 /*-----------------------------------.
2551 | yyabortlab -- YYABORT comes here.  |
2552 `-----------------------------------*/
2553 yyabortlab:
2554   yyresult = 1;
2555   goto yyreturn;
2556
2557
2558 #if !defined yyoverflow || YYERROR_VERBOSE
2559 /*-------------------------------------------------.
2560 | yyexhaustedlab -- memory exhaustion comes here.  |
2561 `-------------------------------------------------*/
2562 yyexhaustedlab:
2563   yyerror (parm, YY_("memory exhausted"));
2564   yyresult = 2;
2565   /* Fall through.  */
2566 #endif
2567
2568
2569 /*-----------------------------------------------------.
2570 | yyreturn -- parsing is finished, return the result.  |
2571 `-----------------------------------------------------*/
2572 yyreturn:
2573   if (yychar != YYEMPTY)
2574     {
2575       /* Make sure we have latest lookahead translation.  See comments at
2576          user semantic actions for why this is necessary.  */
2577       yytoken = YYTRANSLATE (yychar);
2578       yydestruct ("Cleanup: discarding lookahead",
2579                   yytoken, &yylval, parm);
2580     }
2581   /* Do not reclaim the symbols of the rule whose action triggered
2582      this YYABORT or YYACCEPT.  */
2583   YYPOPSTACK (yylen);
2584   YY_STACK_PRINT (yyss, yyssp);
2585   while (yyssp != yyss)
2586     {
2587       yydestruct ("Cleanup: popping",
2588                   yystos[*yyssp], yyvsp, parm);
2589       YYPOPSTACK (1);
2590     }
2591 #ifndef yyoverflow
2592   if (yyss != yyssa)
2593     YYSTACK_FREE (yyss);
2594 #endif
2595 #if YYERROR_VERBOSE
2596   if (yymsg != yymsgbuf)
2597     YYSTACK_FREE (yymsg);
2598 #endif
2599   return yyresult;
2600 }
2601 #line 759 "/home/wk/s/libksba/src/asn1-parse.y" /* yacc.c:1918  */
2602
2603
2604 \f
2605 struct token_table_s {
2606   const char *word;
2607   int token;
2608 };
2609
2610 static struct token_table_s token_table[] = {
2611   { "::=",             ASSIG           },
2612   { "ANY",             ANY             },
2613   { "APPLICATION",     APPLICATION     },
2614   { "BEGIN",           ksba_BEGIN      },
2615   { "BIT",             BIT             },
2616   { "BMPString",       BMPSTRING       },
2617   { "BOOLEAN",         ksba_BOOLEAN    },
2618   { "BY",              BY              },
2619   { "CHOICE",          CHOICE          },
2620   { "DEFAULT",         DEFAULT         },
2621   { "DEFINED",         DEFINED         },
2622   { "DEFINITIONS",     DEFINITIONS     },
2623   { "END",             ksba_END        },
2624   { "ENUMERATED",      ENUMERATED      },
2625   { "EXPLICIT",        EXPLICIT        },
2626   { "FALSE",           ksba_FALSE      },
2627   { "FROM",            FROM            },
2628   { "GeneralizedTime", GeneralizedTime },
2629   { "IA5String",       IA5STRING       },
2630   { "IDENTIFIER",      STR_IDENTIFIER  },
2631   { "IMPLICIT",        IMPLICIT        },
2632   { "IMPORTS",         IMPORTS         },
2633   { "INTEGER",         INTEGER         },
2634   { "NULL",            TOKEN_NULL      },
2635   { "NumericString",   NUMERICSTRING   },
2636   { "OBJECT",          OBJECT          },
2637   { "OCTET",           OCTET           },
2638   { "OF",              OF              },
2639   { "OPTIONAL",        OPTIONAL        },
2640   { "PRIVATE",         PRIVATE         },
2641   { "PrintableString", PRINTABLESTRING },
2642   { "SEQUENCE",        SEQUENCE        },
2643   { "SET",             SET             },
2644   { "SIZE",            SIZE            },
2645   { "STRING",          STRING          },
2646   { "TAGS",            TAGS            },
2647   { "TRUE",            ksba_TRUE       },
2648   { "TeletexString",   TELETEXSTRING   },
2649   { "UNIVERSAL",       UNIVERSAL       },
2650   { "UTCTime",         UTCTime         },
2651   { "UTF8String",      UTF8STRING      },
2652   { "UniversalString", UNIVERSALSTRING },
2653 };
2654
2655 /*************************************************************/
2656 /*  Function: yylex                                          */
2657 /*  Description: looks for tokens in file_asn1 pointer file. */
2658 /*  Return: int                                              */
2659 /*    Token identifier or ASCII code or 0(zero: End Of File) */
2660 /*************************************************************/
2661 static int
2662 yylex (YYSTYPE *lvalp, void *parm)
2663 {
2664   int c,counter=0,k;
2665   char string[MAX_STRING_LENGTH];
2666   FILE *fp = PARSECTL->fp;
2667
2668   if (!PARSECTL->lineno)
2669     PARSECTL->lineno++; /* start with line one */
2670
2671   while (1)
2672     {
2673       while ( (c=fgetc (fp))==' ' || c=='\t')
2674         ;
2675       if (c =='\n')
2676         {
2677           PARSECTL->lineno++;
2678           continue;
2679         }
2680       if(c==EOF)
2681         return 0;
2682
2683       if ( c=='(' || c==')' || c=='[' || c==']'
2684            || c=='{' || c=='}' || c==',' || c=='.' || c=='+')
2685         return c;
2686
2687       if (c=='-')
2688         {
2689           if ( (c=fgetc(fp))!='-')
2690             {
2691               ungetc(c,fp);
2692               return '-';
2693             }
2694           else
2695             {
2696               /* A comment finishes at the end of line */
2697               counter=0;
2698               while ( (c=fgetc(fp))!=EOF && c != '\n' )
2699                 ;
2700               if (c==EOF)
2701                 return 0;
2702               else
2703                 continue; /* repeat the search */
2704             }
2705         }
2706
2707       do
2708         {
2709           if (counter >= DIM (string)-1 )
2710             {
2711               fprintf (stderr,"%s:%d: token too long\n", "myfile:",
2712                        PARSECTL->lineno);
2713               return 0; /* EOF */
2714             }
2715           string[counter++]=c;
2716         }
2717       while ( !((c=fgetc(fp))==EOF
2718                 || c==' '|| c=='\t' || c=='\n'
2719                 || c=='(' || c==')' || c=='[' || c==']'
2720                 || c=='{' || c=='}' || c==',' || c=='.'));
2721
2722       ungetc (c,fp);
2723       string[counter]=0;
2724       /*fprintf (stderr, "yylex token `%s'\n", string);*/
2725
2726       /* Is STRING a number? */
2727       for (k=0; k<counter; k++)
2728         {
2729           if(!isdigit(string[k]))
2730             break;
2731         }
2732       if (k>=counter)
2733         {
2734           strcpy (lvalp->str,string);
2735           if (PARSECTL->debug)
2736             fprintf (stderr,"%d: yylex found number `%s'\n",
2737                      PARSECTL->lineno, string);
2738           return NUM;
2739         }
2740
2741       /* Is STRING a keyword? */
2742       for (k = 0; k < DIM (token_table); k++)
2743         {
2744           if (!strcmp (token_table[k].word, string))
2745             return token_table[k].token;
2746         }
2747
2748       /* STRING is an IDENTIFIER */
2749       strcpy(lvalp->str,string);
2750       if (PARSECTL->debug)
2751         fprintf (stderr,"%d: yylex found identifier `%s'\n",
2752                  PARSECTL->lineno, string);
2753       return IDENTIFIER;
2754     }
2755 }
2756
2757 static void
2758 yyerror (void *parm, const char *s)
2759 {
2760   (void)parm;
2761   /* Sends the error description to stderr */
2762   fprintf (stderr, "%s\n", s);
2763   /* Why doesn't bison provide a way to pass the parm to yyerror?
2764      Update: Newer bison versions allow for this.  We need to see how
2765      we can make use of it.  */
2766 }
2767
2768
2769 \f
2770 static AsnNode
2771 new_node (struct parser_control_s *parsectl, node_type_t type)
2772 {
2773   AsnNode node;
2774
2775   node = xcalloc (1, sizeof *node);
2776   node->type = type;
2777   node->off = -1;
2778   node->link_next = parsectl->all_nodes;
2779   parsectl->all_nodes = node;
2780
2781   return node;
2782 }
2783
2784 static void
2785 release_all_nodes (AsnNode node)
2786 {
2787   AsnNode node2;
2788
2789   for (; node; node = node2)
2790     {
2791       node2 = node->link_next;
2792       xfree (node->name);
2793
2794       if (node->valuetype == VALTYPE_CSTR)
2795         xfree (node->value.v_cstr);
2796       else if (node->valuetype == VALTYPE_MEM)
2797         xfree (node->value.v_mem.buf);
2798
2799       xfree (node);
2800     }
2801 }
2802
2803 static void
2804 set_name (AsnNode node, const char *name)
2805 {
2806   _ksba_asn_set_name (node, name);
2807 }
2808
2809 static void
2810 set_str_value (AsnNode node, const char *text)
2811 {
2812   if (text && *text)
2813     _ksba_asn_set_value (node, VALTYPE_CSTR, text, 0);
2814   else
2815     _ksba_asn_set_value (node, VALTYPE_NULL, NULL, 0);
2816 }
2817
2818 static void
2819 set_ulong_value (AsnNode node, const char *text)
2820 {
2821   unsigned long val;
2822
2823   if (text && *text)
2824     val = strtoul (text, NULL, 10);
2825   else
2826     val = 0;
2827   _ksba_asn_set_value (node, VALTYPE_ULONG, &val, sizeof(val));
2828 }
2829
2830 static void
2831 set_right (AsnNode node, AsnNode right)
2832 {
2833   return_if_fail (node);
2834
2835   node->right = right;
2836   if (right)
2837     right->left = node;
2838 }
2839
2840 static void
2841 append_right (AsnNode node, AsnNode right)
2842 {
2843   return_if_fail (node);
2844
2845   while (node->right)
2846     node = node->right;
2847
2848   node->right = right;
2849   if (right)
2850     right->left = node;
2851 }
2852
2853
2854 static void
2855 set_down (AsnNode node, AsnNode down)
2856 {
2857   return_if_fail (node);
2858
2859   node->down = down;
2860   if (down)
2861     down->left = node;
2862 }
2863
2864 \f
2865 /**
2866  * ksba_asn_parse_file:
2867  * @file_name: Filename with the ASN module
2868  * @pointer: Returns the syntax tree
2869  * @debug: Enable debug output
2870  *
2871  * Parse an ASN.1 file and return an syntax tree.
2872  *
2873  * Return value: 0 for okay or an ASN_xx error code
2874  **/
2875 int
2876 ksba_asn_parse_file (const char *file_name, ksba_asn_tree_t *result, int debug)
2877 {
2878   struct parser_control_s parsectl;
2879
2880   *result = NULL;
2881
2882   parsectl.fp = file_name? fopen (file_name, "r") : NULL;
2883   if ( !parsectl.fp )
2884     return gpg_error_from_syserror ();
2885
2886   parsectl.lineno = 0;
2887   parsectl.debug = debug;
2888   parsectl.result_parse = gpg_error (GPG_ERR_SYNTAX);
2889   parsectl.parse_tree = NULL;
2890   parsectl.all_nodes = NULL;
2891   /* yydebug = 1; */
2892   if ( yyparse ((void*)&parsectl) || parsectl.result_parse )
2893     { /* error */
2894       fprintf (stderr, "%s:%d: parse error\n",
2895                file_name?file_name:"-", parsectl.lineno );
2896       release_all_nodes (parsectl.all_nodes);
2897       parsectl.all_nodes = NULL;
2898     }
2899   else
2900     { /* okay */
2901       ksba_asn_tree_t tree;
2902
2903       _ksba_asn_change_integer_value (parsectl.parse_tree);
2904       _ksba_asn_expand_object_id (parsectl.parse_tree);
2905       tree = xmalloc ( sizeof *tree + (file_name? strlen (file_name):1) );
2906       tree->parse_tree = parsectl.parse_tree;
2907       tree->node_list = parsectl.all_nodes;
2908       strcpy (tree->filename, file_name? file_name:"-");
2909       *result = tree;
2910     }
2911
2912   if (file_name)
2913     fclose (parsectl.fp);
2914   return parsectl.result_parse;
2915 }
2916
2917 void
2918 ksba_asn_tree_release (ksba_asn_tree_t tree)
2919 {
2920   if (!tree)
2921     return;
2922   release_all_nodes (tree->node_list);
2923   tree->node_list = NULL;
2924   xfree (tree);
2925 }
2926
2927
2928 void
2929 _ksba_asn_release_nodes (AsnNode node)
2930 {
2931   /* FIXME: it does not work yet because the allocation function in
2932      asn1-func.c does not link all nodes together */
2933   release_all_nodes (node);
2934 }