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