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