Bump version.
[libtasn1.git] / lib / ASN1.c
blob200c21aa5fc7b36f97465c2d5aeb790921ee08c2
1 /* A Bison parser, made by GNU Bison 2.3. */
3 /* Skeleton implementation for Bison's Yacc-like parsers in C
5 Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
6 Free Software Foundation, Inc.
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2, or (at your option)
11 any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 Boston, MA 02110-1301, USA. */
23 /* As a special exception, you may create a larger work that contains
24 part or all of the Bison parser skeleton and distribute that work
25 under terms of your choice, so long as that work isn't itself a
26 parser generator using the skeleton or a modified version thereof
27 as a parser skeleton. Alternatively, if you modify or redistribute
28 the parser skeleton itself, you may (at your option) remove this
29 special exception, which will cause the skeleton and the resulting
30 Bison output files to be licensed under the GNU General Public
31 License without this special exception.
33 This special exception was added by the Free Software Foundation in
34 version 2.2 of Bison. */
36 /* C LALR(1) parser skeleton written by Richard Stallman, by
37 simplifying the original so-called "semantic" parser. */
39 /* All symbols defined below should begin with yy or YY, to avoid
40 infringing on user name space. This should be done even for local
41 variables, as they might otherwise be expanded by user macros.
42 There are some unavoidable exceptions within include files to
43 define necessary library symbols; they are noted "INFRINGES ON
44 USER NAME SPACE" below. */
46 /* Identify Bison output. */
47 #define YYBISON 1
49 /* Bison version. */
50 #define YYBISON_VERSION "2.3"
52 /* Skeleton name. */
53 #define YYSKELETON_NAME "yacc.c"
55 /* Pure parsers. */
56 #define YYPURE 0
58 /* Using locations. */
59 #define YYLSP_NEEDED 0
61 /* Substitute the variable and function names. */
62 #define yyparse _asn1_yyparse
63 #define yylex _asn1_yylex
64 #define yyerror _asn1_yyerror
65 #define yylval _asn1_yylval
66 #define yychar _asn1_yychar
67 #define yydebug _asn1_yydebug
68 #define yynerrs _asn1_yynerrs
71 /* Tokens. */
72 #ifndef YYTOKENTYPE
73 # define YYTOKENTYPE
74 /* Put the tokens into the symbol table, so that GDB and other debuggers
75 know about them. */
76 enum yytokentype {
77 ASSIG = 258,
78 NUM = 259,
79 IDENTIFIER = 260,
80 OPTIONAL = 261,
81 INTEGER = 262,
82 SIZE = 263,
83 OCTET = 264,
84 STRING = 265,
85 SEQUENCE = 266,
86 BIT = 267,
87 UNIVERSAL = 268,
88 PRIVATE = 269,
89 APPLICATION = 270,
90 DEFAULT = 271,
91 CHOICE = 272,
92 OF = 273,
93 OBJECT = 274,
94 STR_IDENTIFIER = 275,
95 BOOLEAN = 276,
96 TRUE = 277,
97 FALSE = 278,
98 TOKEN_NULL = 279,
99 ANY = 280,
100 DEFINED = 281,
101 BY = 282,
102 SET = 283,
103 EXPLICIT = 284,
104 IMPLICIT = 285,
105 DEFINITIONS = 286,
106 TAGS = 287,
107 BEGIN = 288,
108 END = 289,
109 UTCTime = 290,
110 GeneralizedTime = 291,
111 GeneralString = 292,
112 FROM = 293,
113 IMPORTS = 294,
114 ENUMERATED = 295
116 #endif
117 /* Tokens. */
118 #define ASSIG 258
119 #define NUM 259
120 #define IDENTIFIER 260
121 #define OPTIONAL 261
122 #define INTEGER 262
123 #define SIZE 263
124 #define OCTET 264
125 #define STRING 265
126 #define SEQUENCE 266
127 #define BIT 267
128 #define UNIVERSAL 268
129 #define PRIVATE 269
130 #define APPLICATION 270
131 #define DEFAULT 271
132 #define CHOICE 272
133 #define OF 273
134 #define OBJECT 274
135 #define STR_IDENTIFIER 275
136 #define BOOLEAN 276
137 #define TRUE 277
138 #define FALSE 278
139 #define TOKEN_NULL 279
140 #define ANY 280
141 #define DEFINED 281
142 #define BY 282
143 #define SET 283
144 #define EXPLICIT 284
145 #define IMPLICIT 285
146 #define DEFINITIONS 286
147 #define TAGS 287
148 #define BEGIN 288
149 #define END 289
150 #define UTCTime 290
151 #define GeneralizedTime 291
152 #define GeneralString 292
153 #define FROM 293
154 #define IMPORTS 294
155 #define ENUMERATED 295
160 /* Copy the first part of user declarations. */
161 #line 32 "ASN1.y"
163 #include <int.h>
164 #include <errors.h>
165 #include <parser_aux.h>
166 #include <structure.h>
169 static FILE *file_asn1; /* Pointer to file to parse */
170 static asn1_retCode result_parse; /* result of the parser
171 algorithm */
172 static node_asn *p_tree; /* pointer to the root of the
173 structure created by the
174 parser*/
175 static unsigned long lineNumber; /* line number describing the
176 parser position inside the
177 file */
178 static char lastToken[MAX_NAME_SIZE+1]; /* last token find in the file
179 to parse before the 'parse
180 error' */
181 extern char _asn1_identifierMissing[];
182 static const char *fileName; /* file to parse */
184 int _asn1_yyerror (char *);
185 int _asn1_yylex(void);
189 /* Enabling traces. */
190 #ifndef YYDEBUG
191 # define YYDEBUG 0
192 #endif
194 /* Enabling verbose error messages. */
195 #ifdef YYERROR_VERBOSE
196 # undef YYERROR_VERBOSE
197 # define YYERROR_VERBOSE 1
198 #else
199 # define YYERROR_VERBOSE 0
200 #endif
202 /* Enabling the token table. */
203 #ifndef YYTOKEN_TABLE
204 # define YYTOKEN_TABLE 0
205 #endif
207 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
208 typedef union YYSTYPE
209 #line 62 "ASN1.y"
211 unsigned int constant;
212 char str[MAX_NAME_SIZE+1];
213 node_asn* node;
215 /* Line 187 of yacc.c. */
216 #line 217 "ASN1.c"
217 YYSTYPE;
218 # define yystype YYSTYPE /* obsolescent; will be withdrawn */
219 # define YYSTYPE_IS_DECLARED 1
220 # define YYSTYPE_IS_TRIVIAL 1
221 #endif
225 /* Copy the second part of user declarations. */
228 /* Line 216 of yacc.c. */
229 #line 230 "ASN1.c"
231 #ifdef short
232 # undef short
233 #endif
235 #ifdef YYTYPE_UINT8
236 typedef YYTYPE_UINT8 yytype_uint8;
237 #else
238 typedef unsigned char yytype_uint8;
239 #endif
241 #ifdef YYTYPE_INT8
242 typedef YYTYPE_INT8 yytype_int8;
243 #elif (defined __STDC__ || defined __C99__FUNC__ \
244 || defined __cplusplus || defined _MSC_VER)
245 typedef signed char yytype_int8;
246 #else
247 typedef short int yytype_int8;
248 #endif
250 #ifdef YYTYPE_UINT16
251 typedef YYTYPE_UINT16 yytype_uint16;
252 #else
253 typedef unsigned short int yytype_uint16;
254 #endif
256 #ifdef YYTYPE_INT16
257 typedef YYTYPE_INT16 yytype_int16;
258 #else
259 typedef short int yytype_int16;
260 #endif
262 #ifndef YYSIZE_T
263 # ifdef __SIZE_TYPE__
264 # define YYSIZE_T __SIZE_TYPE__
265 # elif defined size_t
266 # define YYSIZE_T size_t
267 # elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \
268 || defined __cplusplus || defined _MSC_VER)
269 # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
270 # define YYSIZE_T size_t
271 # else
272 # define YYSIZE_T unsigned int
273 # endif
274 #endif
276 #define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
278 #ifndef YY_
279 # if YYENABLE_NLS
280 # if ENABLE_NLS
281 # include <libintl.h> /* INFRINGES ON USER NAME SPACE */
282 # define YY_(msgid) dgettext ("bison-runtime", msgid)
283 # endif
284 # endif
285 # ifndef YY_
286 # define YY_(msgid) msgid
287 # endif
288 #endif
290 /* Suppress unused-variable warnings by "using" E. */
291 #if ! defined lint || defined __GNUC__
292 # define YYUSE(e) ((void) (e))
293 #else
294 # define YYUSE(e) /* empty */
295 #endif
297 /* Identity function, used to suppress warnings about constant conditions. */
298 #ifndef lint
299 # define YYID(n) (n)
300 #else
301 #if (defined __STDC__ || defined __C99__FUNC__ \
302 || defined __cplusplus || defined _MSC_VER)
303 static int
304 YYID (int i)
305 #else
306 static int
307 YYID (i)
308 int i;
309 #endif
311 return i;
313 #endif
315 #if ! defined yyoverflow || YYERROR_VERBOSE
317 /* The parser invokes alloca or malloc; define the necessary symbols. */
319 # ifdef YYSTACK_USE_ALLOCA
320 # if YYSTACK_USE_ALLOCA
321 # ifdef __GNUC__
322 # define YYSTACK_ALLOC __builtin_alloca
323 # elif defined __BUILTIN_VA_ARG_INCR
324 # include <alloca.h> /* INFRINGES ON USER NAME SPACE */
325 # elif defined _AIX
326 # define YYSTACK_ALLOC __alloca
327 # elif defined _MSC_VER
328 # include <malloc.h> /* INFRINGES ON USER NAME SPACE */
329 # define alloca _alloca
330 # else
331 # define YYSTACK_ALLOC alloca
332 # if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
333 || defined __cplusplus || defined _MSC_VER)
334 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
335 # ifndef _STDLIB_H
336 # define _STDLIB_H 1
337 # endif
338 # endif
339 # endif
340 # endif
341 # endif
343 # ifdef YYSTACK_ALLOC
344 /* Pacify GCC's `empty if-body' warning. */
345 # define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0))
346 # ifndef YYSTACK_ALLOC_MAXIMUM
347 /* The OS might guarantee only one guard page at the bottom of the stack,
348 and a page size can be as small as 4096 bytes. So we cannot safely
349 invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
350 to allow for a few compiler-allocated temporary stack slots. */
351 # define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
352 # endif
353 # else
354 # define YYSTACK_ALLOC YYMALLOC
355 # define YYSTACK_FREE YYFREE
356 # ifndef YYSTACK_ALLOC_MAXIMUM
357 # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
358 # endif
359 # if (defined __cplusplus && ! defined _STDLIB_H \
360 && ! ((defined YYMALLOC || defined malloc) \
361 && (defined YYFREE || defined free)))
362 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
363 # ifndef _STDLIB_H
364 # define _STDLIB_H 1
365 # endif
366 # endif
367 # ifndef YYMALLOC
368 # define YYMALLOC malloc
369 # if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
370 || defined __cplusplus || defined _MSC_VER)
371 void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
372 # endif
373 # endif
374 # ifndef YYFREE
375 # define YYFREE free
376 # if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
377 || defined __cplusplus || defined _MSC_VER)
378 void free (void *); /* INFRINGES ON USER NAME SPACE */
379 # endif
380 # endif
381 # endif
382 #endif /* ! defined yyoverflow || YYERROR_VERBOSE */
385 #if (! defined yyoverflow \
386 && (! defined __cplusplus \
387 || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
389 /* A type that is properly aligned for any stack member. */
390 union yyalloc
392 yytype_int16 yyss;
393 YYSTYPE yyvs;
396 /* The size of the maximum gap between one aligned stack and the next. */
397 # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
399 /* The size of an array large to enough to hold all stacks, each with
400 N elements. */
401 # define YYSTACK_BYTES(N) \
402 ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
403 + YYSTACK_GAP_MAXIMUM)
405 /* Copy COUNT objects from FROM to TO. The source and destination do
406 not overlap. */
407 # ifndef YYCOPY
408 # if defined __GNUC__ && 1 < __GNUC__
409 # define YYCOPY(To, From, Count) \
410 __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
411 # else
412 # define YYCOPY(To, From, Count) \
413 do \
415 YYSIZE_T yyi; \
416 for (yyi = 0; yyi < (Count); yyi++) \
417 (To)[yyi] = (From)[yyi]; \
419 while (YYID (0))
420 # endif
421 # endif
423 /* Relocate STACK from its old location to the new one. The
424 local variables YYSIZE and YYSTACKSIZE give the old and new number of
425 elements in the stack, and YYPTR gives the new location of the
426 stack. Advance YYPTR to a properly aligned location for the next
427 stack. */
428 # define YYSTACK_RELOCATE(Stack) \
429 do \
431 YYSIZE_T yynewbytes; \
432 YYCOPY (&yyptr->Stack, Stack, yysize); \
433 Stack = &yyptr->Stack; \
434 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
435 yyptr += yynewbytes / sizeof (*yyptr); \
437 while (YYID (0))
439 #endif
441 /* YYFINAL -- State number of the termination state. */
442 #define YYFINAL 5
443 /* YYLAST -- Last index in YYTABLE. */
444 #define YYLAST 192
446 /* YYNTOKENS -- Number of terminals. */
447 #define YYNTOKENS 52
448 /* YYNNTS -- Number of nonterminals. */
449 #define YYNNTS 43
450 /* YYNRULES -- Number of rules. */
451 #define YYNRULES 99
452 /* YYNRULES -- Number of states. */
453 #define YYNSTATES 190
455 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
456 #define YYUNDEFTOK 2
457 #define YYMAXUTOK 295
459 #define YYTRANSLATE(YYX) \
460 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
462 /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
463 static const yytype_uint8 yytranslate[] =
465 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
466 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
467 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
468 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
469 43, 44, 2, 41, 45, 42, 51, 2, 2, 2,
470 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
471 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
472 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
473 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
474 2, 46, 2, 47, 2, 2, 2, 2, 2, 2,
475 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
476 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
477 2, 2, 2, 49, 48, 50, 2, 2, 2, 2,
478 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
479 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
480 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
481 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
482 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
483 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
484 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
485 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
486 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
487 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
488 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
489 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
490 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
491 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
492 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
493 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
494 35, 36, 37, 38, 39, 40
497 #if YYDEBUG
498 /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
499 YYRHS. */
500 static const yytype_uint16 yyprhs[] =
502 0, 0, 3, 12, 14, 17, 20, 22, 24, 26,
503 28, 30, 32, 36, 41, 43, 47, 49, 54, 56,
504 59, 61, 63, 65, 69, 74, 76, 79, 82, 85,
505 88, 91, 93, 97, 99, 104, 109, 117, 119, 121,
506 123, 128, 136, 138, 142, 144, 147, 150, 154, 159,
507 161, 165, 168, 172, 178, 183, 186, 188, 191, 193,
508 195, 197, 199, 201, 203, 205, 207, 209, 211, 213,
509 215, 217, 219, 222, 224, 227, 230, 233, 235, 239,
510 244, 248, 253, 258, 262, 267, 272, 274, 279, 283,
511 291, 298, 303, 305, 307, 309, 312, 317, 321, 323
514 /* YYRHS -- A `-1'-separated list of the rules' RHS. */
515 static const yytype_int8 yyrhs[] =
517 53, 0, -1, 93, 31, 94, 32, 3, 33, 92,
518 34, -1, 4, -1, 41, 4, -1, 42, 4, -1,
519 54, -1, 55, -1, 4, -1, 5, -1, 56, -1,
520 5, -1, 43, 56, 44, -1, 5, 43, 56, 44,
521 -1, 59, -1, 60, 45, 59, -1, 57, -1, 5,
522 43, 4, 44, -1, 61, -1, 62, 61, -1, 13,
523 -1, 14, -1, 15, -1, 46, 4, 47, -1, 46,
524 63, 4, 47, -1, 64, -1, 64, 29, -1, 64,
525 30, -1, 16, 58, -1, 16, 22, -1, 16, 23,
526 -1, 56, -1, 67, 48, 56, -1, 7, -1, 7,
527 49, 60, 50, -1, 68, 43, 67, 44, -1, 68,
528 43, 57, 51, 51, 57, 44, -1, 21, -1, 35,
529 -1, 36, -1, 8, 43, 57, 44, -1, 8, 43,
530 57, 51, 51, 57, 44, -1, 71, -1, 43, 71,
531 44, -1, 37, -1, 37, 72, -1, 9, 10, -1,
532 9, 10, 72, -1, 5, 43, 4, 44, -1, 75,
533 -1, 76, 45, 75, -1, 12, 10, -1, 12, 10,
534 72, -1, 12, 10, 49, 76, 50, -1, 40, 49,
535 76, 50, -1, 19, 20, -1, 5, -1, 5, 72,
536 -1, 68, -1, 78, -1, 69, -1, 70, -1, 74,
537 -1, 77, -1, 73, -1, 85, -1, 79, -1, 87,
538 -1, 88, -1, 86, -1, 24, -1, 80, -1, 65,
539 80, -1, 81, -1, 81, 66, -1, 81, 6, -1,
540 5, 82, -1, 83, -1, 84, 45, 83, -1, 11,
541 49, 84, 50, -1, 11, 18, 80, -1, 11, 72,
542 18, 80, -1, 28, 49, 84, 50, -1, 28, 18,
543 80, -1, 28, 72, 18, 80, -1, 17, 49, 84,
544 50, -1, 25, -1, 25, 26, 27, 5, -1, 5,
545 3, 81, -1, 5, 19, 20, 3, 49, 62, 50,
546 -1, 5, 5, 3, 49, 62, 50, -1, 5, 7,
547 3, 56, -1, 89, -1, 90, -1, 91, -1, 92,
548 91, -1, 5, 49, 62, 50, -1, 5, 49, 50,
549 -1, 29, -1, 30, -1
552 /* YYRLINE[YYN] -- source line where rule number YYN was defined. */
553 static const yytype_uint16 yyrline[] =
555 0, 124, 124, 137, 138, 141, 145, 146, 149, 150,
556 153, 154, 157, 159, 164, 165, 169, 171, 176, 177,
557 181, 182, 183, 186, 188, 192, 193, 194, 197, 199,
558 200, 204, 205, 209, 210, 212, 213, 220, 223, 224,
559 227, 229, 235, 236, 239, 240, 244, 245, 249, 254,
560 255, 259, 260, 261, 266, 272, 275, 277, 280, 281,
561 282, 283, 284, 285, 286, 287, 288, 289, 290, 291,
562 292, 295, 296, 301, 302, 305, 308, 311, 312, 316,
563 318, 320, 325, 327, 329, 334, 338, 339, 344, 347,
564 351, 356, 362, 363, 366, 367, 371, 374, 398, 399
566 #endif
568 #if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
569 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
570 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
571 static const char *const yytname[] =
573 "$end", "error", "$undefined", "\"::=\"", "NUM", "IDENTIFIER",
574 "OPTIONAL", "INTEGER", "SIZE", "OCTET", "STRING", "SEQUENCE", "BIT",
575 "UNIVERSAL", "PRIVATE", "APPLICATION", "DEFAULT", "CHOICE", "OF",
576 "OBJECT", "STR_IDENTIFIER", "BOOLEAN", "TRUE", "FALSE", "TOKEN_NULL",
577 "ANY", "DEFINED", "BY", "SET", "EXPLICIT", "IMPLICIT", "DEFINITIONS",
578 "TAGS", "BEGIN", "END", "UTCTime", "GeneralizedTime", "GeneralString",
579 "FROM", "IMPORTS", "ENUMERATED", "'+'", "'-'", "'('", "')'", "','",
580 "'['", "']'", "'|'", "'{'", "'}'", "'.'", "$accept", "definitions",
581 "pos_num", "neg_num", "pos_neg_num", "num_identifier",
582 "pos_neg_identifier", "constant", "constant_list", "obj_constant",
583 "obj_constant_list", "class", "tag_type", "tag", "default",
584 "pos_neg_list", "integer_def", "boolean_def", "Time", "size_def2",
585 "size_def", "generalstring_def", "octet_string_def", "bit_element",
586 "bit_element_list", "bit_string_def", "enumerated_def", "object_def",
587 "type_assig_right", "type_assig_right_tag",
588 "type_assig_right_tag_default", "type_assig", "type_assig_list",
589 "sequence_def", "set_def", "choise_def", "any_def", "type_def",
590 "constant_def", "type_constant", "type_constant_list", "definitions_id",
591 "explicit_implicit", 0
593 #endif
595 # ifdef YYPRINT
596 /* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
597 token YYLEX-NUM. */
598 static const yytype_uint16 yytoknum[] =
600 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
601 265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
602 275, 276, 277, 278, 279, 280, 281, 282, 283, 284,
603 285, 286, 287, 288, 289, 290, 291, 292, 293, 294,
604 295, 43, 45, 40, 41, 44, 91, 93, 124, 123,
605 125, 46
607 # endif
609 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
610 static const yytype_uint8 yyr1[] =
612 0, 52, 53, 54, 54, 55, 56, 56, 57, 57,
613 58, 58, 59, 59, 60, 60, 61, 61, 62, 62,
614 63, 63, 63, 64, 64, 65, 65, 65, 66, 66,
615 66, 67, 67, 68, 68, 68, 68, 69, 70, 70,
616 71, 71, 72, 72, 73, 73, 74, 74, 75, 76,
617 76, 77, 77, 77, 78, 79, 80, 80, 80, 80,
618 80, 80, 80, 80, 80, 80, 80, 80, 80, 80,
619 80, 81, 81, 82, 82, 82, 83, 84, 84, 85,
620 85, 85, 86, 86, 86, 87, 88, 88, 89, 90,
621 90, 90, 91, 91, 92, 92, 93, 93, 94, 94
624 /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
625 static const yytype_uint8 yyr2[] =
627 0, 2, 8, 1, 2, 2, 1, 1, 1, 1,
628 1, 1, 3, 4, 1, 3, 1, 4, 1, 2,
629 1, 1, 1, 3, 4, 1, 2, 2, 2, 2,
630 2, 1, 3, 1, 4, 4, 7, 1, 1, 1,
631 4, 7, 1, 3, 1, 2, 2, 3, 4, 1,
632 3, 2, 3, 5, 4, 2, 1, 2, 1, 1,
633 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
634 1, 1, 2, 1, 2, 2, 2, 1, 3, 4,
635 3, 4, 4, 3, 4, 4, 1, 4, 3, 7,
636 6, 4, 1, 1, 1, 2, 4, 3, 1, 1
639 /* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
640 STATE-NUM when YYTABLE doesn't specify something else to do. Zero
641 means the default is an error. */
642 static const yytype_uint8 yydefact[] =
644 0, 0, 0, 0, 0, 1, 0, 8, 9, 97,
645 16, 18, 0, 98, 99, 0, 0, 96, 19, 0,
646 0, 0, 17, 0, 0, 92, 93, 94, 0, 0,
647 0, 0, 0, 2, 95, 56, 33, 0, 0, 0,
648 0, 0, 37, 70, 86, 0, 38, 39, 44, 0,
649 0, 25, 0, 58, 60, 61, 64, 62, 63, 59,
650 66, 71, 88, 65, 69, 67, 68, 0, 0, 0,
651 0, 0, 42, 57, 0, 46, 0, 0, 0, 51,
652 0, 55, 0, 0, 0, 0, 45, 0, 0, 20,
653 21, 22, 0, 26, 27, 72, 0, 0, 3, 0,
654 0, 6, 7, 91, 0, 0, 0, 0, 0, 14,
655 0, 47, 80, 0, 77, 0, 0, 0, 52, 0,
656 0, 83, 0, 0, 0, 49, 0, 23, 0, 3,
657 9, 31, 0, 0, 0, 4, 5, 0, 0, 43,
658 0, 0, 0, 34, 73, 76, 0, 79, 81, 0,
659 85, 87, 82, 84, 0, 0, 54, 24, 0, 35,
660 0, 90, 0, 40, 0, 0, 12, 15, 75, 0,
661 74, 78, 53, 0, 50, 0, 32, 89, 0, 13,
662 11, 29, 30, 10, 28, 48, 0, 0, 36, 41
665 /* YYDEFGOTO[NTERM-NUM]. */
666 static const yytype_int16 yydefgoto[] =
668 -1, 2, 101, 102, 103, 10, 184, 109, 110, 11,
669 12, 92, 51, 52, 170, 133, 53, 54, 55, 72,
670 73, 56, 57, 125, 126, 58, 59, 60, 61, 62,
671 145, 114, 115, 63, 64, 65, 66, 25, 26, 27,
672 28, 3, 15
675 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
676 STATE-NUM. */
677 #define YYPACT_NINF -96
678 static const yytype_int16 yypact[] =
680 24, -14, 48, 56, 0, -96, -10, -96, -2, -96,
681 -96, -96, 2, -96, -96, 71, 111, -96, -96, 117,
682 83, 96, -96, 127, 42, -96, -96, -96, 10, 77,
683 130, 131, 115, -96, -96, 8, 90, 132, 13, 135,
684 92, 126, -96, -96, 122, 15, -96, -96, 8, 100,
685 93, 49, 119, 94, -96, -96, -96, -96, -96, -96,
686 -96, -96, -96, -96, -96, -96, -96, 102, 28, 149,
687 110, 150, -96, -96, 17, 8, 119, 152, 142, 22,
688 152, -96, 134, 119, 152, 144, -96, 158, 118, -96,
689 -96, -96, 160, -96, -96, -96, 35, 88, -96, 162,
690 163, -96, -96, -96, 120, 114, 124, 128, 28, -96,
691 -8, -96, -96, 77, -96, -7, 119, 158, -96, 18,
692 165, -96, 50, 119, 129, -96, 54, -96, 133, 123,
693 -96, -96, 125, 37, 4, -96, -96, 88, -27, -96,
694 28, 137, 17, -96, 20, -96, 152, -96, -96, 66,
695 -96, -96, -96, -96, 169, 158, -96, -96, 136, -96,
696 28, -96, 7, -96, 138, 139, -96, -96, -96, 68,
697 -96, -96, -96, 140, -96, 114, -96, -96, 114, -96,
698 -96, -96, -96, -96, -96, -96, 141, 146, -96, -96
701 /* YYPGOTO[NTERM-NUM]. */
702 static const yytype_int16 yypgoto[] =
704 -96, -96, -96, -96, -94, -95, -96, 33, -96, -12,
705 -84, -96, -96, -96, -96, -96, -96, -96, -96, 106,
706 -20, -96, -96, 23, 62, -96, -96, -96, -49, 69,
707 -96, 40, 41, -96, -96, -96, -96, -96, -96, 164,
708 -96, -96, -96
711 /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
712 positive, shift that token. If negative, reduce the rule which
713 number is the opposite. If zero, do what YYDEFACT says.
714 If YYTABLE_NINF, syntax error. */
715 #define YYTABLE_NINF -9
716 static const yytype_int16 yytable[] =
718 18, 132, 131, 95, 7, 8, 7, 8, 7, 8,
719 138, 7, 8, 134, 141, 24, 70, 163, 78, 13,
720 14, 70, 107, 70, 164, 85, 168, 112, 86, 1,
721 70, 76, 98, 83, 121, 4, 169, 142, 146, 129,
722 130, 16, 143, 147, 33, 29, 165, 30, 5, 31,
723 9, 71, 17, 162, 161, 111, 71, 177, 71, 118,
724 108, 32, 77, 146, 84, 71, 176, 148, 150, 99,
725 100, 117, 98, 180, 153, 183, 99, 100, 93, 94,
726 186, 159, 35, 187, 36, 160, 37, 6, 38, 39,
727 181, 182, 7, 8, 40, 146, 41, 88, 42, 155,
728 152, 43, 44, 19, 156, 45, 89, 90, 91, 99,
729 100, 155, 46, 47, 48, 20, 172, 49, 7, 130,
730 21, 119, 18, 50, 35, 122, 36, 22, 37, 23,
731 38, 39, 24, 67, 68, 69, 40, 96, 41, 74,
732 42, 80, 75, 43, 44, 79, 81, 45, 82, 87,
733 18, 97, 104, 105, 46, 47, 48, 113, 70, 49,
734 116, 120, 123, 124, 128, 127, 135, 136, 139, 137,
735 151, 140, 154, 173, -8, 167, 158, 106, 174, 149,
736 157, 166, 144, 179, 185, 188, 171, 175, 0, 178,
737 189, 0, 34
740 static const yytype_int16 yycheck[] =
742 12, 96, 96, 52, 4, 5, 4, 5, 4, 5,
743 105, 4, 5, 97, 108, 5, 8, 44, 38, 29,
744 30, 8, 5, 8, 51, 45, 6, 76, 48, 5,
745 8, 18, 4, 18, 83, 49, 16, 45, 45, 4,
746 5, 43, 50, 50, 34, 3, 140, 5, 0, 7,
747 50, 43, 50, 137, 50, 75, 43, 50, 43, 79,
748 43, 19, 49, 45, 49, 43, 160, 116, 50, 41,
749 42, 49, 4, 5, 123, 169, 41, 42, 29, 30,
750 175, 44, 5, 178, 7, 48, 9, 31, 11, 12,
751 22, 23, 4, 5, 17, 45, 19, 4, 21, 45,
752 50, 24, 25, 32, 50, 28, 13, 14, 15, 41,
753 42, 45, 35, 36, 37, 4, 50, 40, 4, 5,
754 3, 80, 134, 46, 5, 84, 7, 44, 9, 33,
755 11, 12, 5, 3, 3, 20, 17, 43, 19, 49,
756 21, 49, 10, 24, 25, 10, 20, 28, 26, 49,
757 162, 49, 3, 43, 35, 36, 37, 5, 8, 40,
758 18, 27, 18, 5, 4, 47, 4, 4, 44, 49,
759 5, 43, 43, 4, 51, 142, 51, 71, 155, 117,
760 47, 44, 113, 44, 44, 44, 146, 51, -1, 51,
761 44, -1, 28
764 /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
765 symbol of state STATE-NUM. */
766 static const yytype_uint8 yystos[] =
768 0, 5, 53, 93, 49, 0, 31, 4, 5, 50,
769 57, 61, 62, 29, 30, 94, 43, 50, 61, 32,
770 4, 3, 44, 33, 5, 89, 90, 91, 92, 3,
771 5, 7, 19, 34, 91, 5, 7, 9, 11, 12,
772 17, 19, 21, 24, 25, 28, 35, 36, 37, 40,
773 46, 64, 65, 68, 69, 70, 73, 74, 77, 78,
774 79, 80, 81, 85, 86, 87, 88, 3, 3, 20,
775 8, 43, 71, 72, 49, 10, 18, 49, 72, 10,
776 49, 20, 26, 18, 49, 72, 72, 49, 4, 13,
777 14, 15, 63, 29, 30, 80, 43, 49, 4, 41,
778 42, 54, 55, 56, 3, 43, 71, 5, 43, 59,
779 60, 72, 80, 5, 83, 84, 18, 49, 72, 84,
780 27, 80, 84, 18, 5, 75, 76, 47, 4, 4,
781 5, 56, 57, 67, 62, 4, 4, 49, 57, 44,
782 43, 56, 45, 50, 81, 82, 45, 50, 80, 76,
783 50, 5, 50, 80, 43, 45, 50, 47, 51, 44,
784 48, 50, 62, 44, 51, 56, 44, 59, 6, 16,
785 66, 83, 50, 4, 75, 51, 56, 50, 51, 44,
786 5, 22, 23, 56, 58, 44, 57, 57, 44, 44
789 #define yyerrok (yyerrstatus = 0)
790 #define yyclearin (yychar = YYEMPTY)
791 #define YYEMPTY (-2)
792 #define YYEOF 0
794 #define YYACCEPT goto yyacceptlab
795 #define YYABORT goto yyabortlab
796 #define YYERROR goto yyerrorlab
799 /* Like YYERROR except do call yyerror. This remains here temporarily
800 to ease the transition to the new meaning of YYERROR, for GCC.
801 Once GCC version 2 has supplanted version 1, this can go. */
803 #define YYFAIL goto yyerrlab
805 #define YYRECOVERING() (!!yyerrstatus)
807 #define YYBACKUP(Token, Value) \
808 do \
809 if (yychar == YYEMPTY && yylen == 1) \
811 yychar = (Token); \
812 yylval = (Value); \
813 yytoken = YYTRANSLATE (yychar); \
814 YYPOPSTACK (1); \
815 goto yybackup; \
817 else \
819 yyerror (YY_("syntax error: cannot back up")); \
820 YYERROR; \
822 while (YYID (0))
825 #define YYTERROR 1
826 #define YYERRCODE 256
829 /* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
830 If N is 0, then set CURRENT to the empty location which ends
831 the previous symbol: RHS[0] (always defined). */
833 #define YYRHSLOC(Rhs, K) ((Rhs)[K])
834 #ifndef YYLLOC_DEFAULT
835 # define YYLLOC_DEFAULT(Current, Rhs, N) \
836 do \
837 if (YYID (N)) \
839 (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
840 (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
841 (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
842 (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
844 else \
846 (Current).first_line = (Current).last_line = \
847 YYRHSLOC (Rhs, 0).last_line; \
848 (Current).first_column = (Current).last_column = \
849 YYRHSLOC (Rhs, 0).last_column; \
851 while (YYID (0))
852 #endif
855 /* YY_LOCATION_PRINT -- Print the location on the stream.
856 This macro was not mandated originally: define only if we know
857 we won't break user code: when these are the locations we know. */
859 #ifndef YY_LOCATION_PRINT
860 # if YYLTYPE_IS_TRIVIAL
861 # define YY_LOCATION_PRINT(File, Loc) \
862 fprintf (File, "%d.%d-%d.%d", \
863 (Loc).first_line, (Loc).first_column, \
864 (Loc).last_line, (Loc).last_column)
865 # else
866 # define YY_LOCATION_PRINT(File, Loc) ((void) 0)
867 # endif
868 #endif
871 /* YYLEX -- calling `yylex' with the right arguments. */
873 #ifdef YYLEX_PARAM
874 # define YYLEX yylex (YYLEX_PARAM)
875 #else
876 # define YYLEX yylex ()
877 #endif
879 /* Enable debugging if requested. */
880 #if YYDEBUG
882 # ifndef YYFPRINTF
883 # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
884 # define YYFPRINTF fprintf
885 # endif
887 # define YYDPRINTF(Args) \
888 do { \
889 if (yydebug) \
890 YYFPRINTF Args; \
891 } while (YYID (0))
893 # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
894 do { \
895 if (yydebug) \
897 YYFPRINTF (stderr, "%s ", Title); \
898 yy_symbol_print (stderr, \
899 Type, Value); \
900 YYFPRINTF (stderr, "\n"); \
902 } while (YYID (0))
905 /*--------------------------------.
906 | Print this symbol on YYOUTPUT. |
907 `--------------------------------*/
909 /*ARGSUSED*/
910 #if (defined __STDC__ || defined __C99__FUNC__ \
911 || defined __cplusplus || defined _MSC_VER)
912 static void
913 yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
914 #else
915 static void
916 yy_symbol_value_print (yyoutput, yytype, yyvaluep)
917 FILE *yyoutput;
918 int yytype;
919 YYSTYPE const * const yyvaluep;
920 #endif
922 if (!yyvaluep)
923 return;
924 # ifdef YYPRINT
925 if (yytype < YYNTOKENS)
926 YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
927 # else
928 YYUSE (yyoutput);
929 # endif
930 switch (yytype)
932 default:
933 break;
938 /*--------------------------------.
939 | Print this symbol on YYOUTPUT. |
940 `--------------------------------*/
942 #if (defined __STDC__ || defined __C99__FUNC__ \
943 || defined __cplusplus || defined _MSC_VER)
944 static void
945 yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
946 #else
947 static void
948 yy_symbol_print (yyoutput, yytype, yyvaluep)
949 FILE *yyoutput;
950 int yytype;
951 YYSTYPE const * const yyvaluep;
952 #endif
954 if (yytype < YYNTOKENS)
955 YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
956 else
957 YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
959 yy_symbol_value_print (yyoutput, yytype, yyvaluep);
960 YYFPRINTF (yyoutput, ")");
963 /*------------------------------------------------------------------.
964 | yy_stack_print -- Print the state stack from its BOTTOM up to its |
965 | TOP (included). |
966 `------------------------------------------------------------------*/
968 #if (defined __STDC__ || defined __C99__FUNC__ \
969 || defined __cplusplus || defined _MSC_VER)
970 static void
971 yy_stack_print (yytype_int16 *bottom, yytype_int16 *top)
972 #else
973 static void
974 yy_stack_print (bottom, top)
975 yytype_int16 *bottom;
976 yytype_int16 *top;
977 #endif
979 YYFPRINTF (stderr, "Stack now");
980 for (; bottom <= top; ++bottom)
981 YYFPRINTF (stderr, " %d", *bottom);
982 YYFPRINTF (stderr, "\n");
985 # define YY_STACK_PRINT(Bottom, Top) \
986 do { \
987 if (yydebug) \
988 yy_stack_print ((Bottom), (Top)); \
989 } while (YYID (0))
992 /*------------------------------------------------.
993 | Report that the YYRULE is going to be reduced. |
994 `------------------------------------------------*/
996 #if (defined __STDC__ || defined __C99__FUNC__ \
997 || defined __cplusplus || defined _MSC_VER)
998 static void
999 yy_reduce_print (YYSTYPE *yyvsp, int yyrule)
1000 #else
1001 static void
1002 yy_reduce_print (yyvsp, yyrule)
1003 YYSTYPE *yyvsp;
1004 int yyrule;
1005 #endif
1007 int yynrhs = yyr2[yyrule];
1008 int yyi;
1009 unsigned long int yylno = yyrline[yyrule];
1010 YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
1011 yyrule - 1, yylno);
1012 /* The symbols being reduced. */
1013 for (yyi = 0; yyi < yynrhs; yyi++)
1015 fprintf (stderr, " $%d = ", yyi + 1);
1016 yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
1017 &(yyvsp[(yyi + 1) - (yynrhs)])
1019 fprintf (stderr, "\n");
1023 # define YY_REDUCE_PRINT(Rule) \
1024 do { \
1025 if (yydebug) \
1026 yy_reduce_print (yyvsp, Rule); \
1027 } while (YYID (0))
1029 /* Nonzero means print parse trace. It is left uninitialized so that
1030 multiple parsers can coexist. */
1031 int yydebug;
1032 #else /* !YYDEBUG */
1033 # define YYDPRINTF(Args)
1034 # define YY_SYMBOL_PRINT(Title, Type, Value, Location)
1035 # define YY_STACK_PRINT(Bottom, Top)
1036 # define YY_REDUCE_PRINT(Rule)
1037 #endif /* !YYDEBUG */
1040 /* YYINITDEPTH -- initial size of the parser's stacks. */
1041 #ifndef YYINITDEPTH
1042 # define YYINITDEPTH 200
1043 #endif
1045 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
1046 if the built-in stack extension method is used).
1048 Do not make this value too large; the results are undefined if
1049 YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
1050 evaluated with infinite-precision integer arithmetic. */
1052 #ifndef YYMAXDEPTH
1053 # define YYMAXDEPTH 10000
1054 #endif
1058 #if YYERROR_VERBOSE
1060 # ifndef yystrlen
1061 # if defined __GLIBC__ && defined _STRING_H
1062 # define yystrlen strlen
1063 # else
1064 /* Return the length of YYSTR. */
1065 #if (defined __STDC__ || defined __C99__FUNC__ \
1066 || defined __cplusplus || defined _MSC_VER)
1067 static YYSIZE_T
1068 yystrlen (const char *yystr)
1069 #else
1070 static YYSIZE_T
1071 yystrlen (yystr)
1072 const char *yystr;
1073 #endif
1075 YYSIZE_T yylen;
1076 for (yylen = 0; yystr[yylen]; yylen++)
1077 continue;
1078 return yylen;
1080 # endif
1081 # endif
1083 # ifndef yystpcpy
1084 # if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
1085 # define yystpcpy stpcpy
1086 # else
1087 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
1088 YYDEST. */
1089 #if (defined __STDC__ || defined __C99__FUNC__ \
1090 || defined __cplusplus || defined _MSC_VER)
1091 static char *
1092 yystpcpy (char *yydest, const char *yysrc)
1093 #else
1094 static char *
1095 yystpcpy (yydest, yysrc)
1096 char *yydest;
1097 const char *yysrc;
1098 #endif
1100 char *yyd = yydest;
1101 const char *yys = yysrc;
1103 while ((*yyd++ = *yys++) != '\0')
1104 continue;
1106 return yyd - 1;
1108 # endif
1109 # endif
1111 # ifndef yytnamerr
1112 /* Copy to YYRES the contents of YYSTR after stripping away unnecessary
1113 quotes and backslashes, so that it's suitable for yyerror. The
1114 heuristic is that double-quoting is unnecessary unless the string
1115 contains an apostrophe, a comma, or backslash (other than
1116 backslash-backslash). YYSTR is taken from yytname. If YYRES is
1117 null, do not copy; instead, return the length of what the result
1118 would have been. */
1119 static YYSIZE_T
1120 yytnamerr (char *yyres, const char *yystr)
1122 if (*yystr == '"')
1124 YYSIZE_T yyn = 0;
1125 char const *yyp = yystr;
1127 for (;;)
1128 switch (*++yyp)
1130 case '\'':
1131 case ',':
1132 goto do_not_strip_quotes;
1134 case '\\':
1135 if (*++yyp != '\\')
1136 goto do_not_strip_quotes;
1137 /* Fall through. */
1138 default:
1139 if (yyres)
1140 yyres[yyn] = *yyp;
1141 yyn++;
1142 break;
1144 case '"':
1145 if (yyres)
1146 yyres[yyn] = '\0';
1147 return yyn;
1149 do_not_strip_quotes: ;
1152 if (! yyres)
1153 return yystrlen (yystr);
1155 return yystpcpy (yyres, yystr) - yyres;
1157 # endif
1159 /* Copy into YYRESULT an error message about the unexpected token
1160 YYCHAR while in state YYSTATE. Return the number of bytes copied,
1161 including the terminating null byte. If YYRESULT is null, do not
1162 copy anything; just return the number of bytes that would be
1163 copied. As a special case, return 0 if an ordinary "syntax error"
1164 message will do. Return YYSIZE_MAXIMUM if overflow occurs during
1165 size calculation. */
1166 static YYSIZE_T
1167 yysyntax_error (char *yyresult, int yystate, int yychar)
1169 int yyn = yypact[yystate];
1171 if (! (YYPACT_NINF < yyn && yyn <= YYLAST))
1172 return 0;
1173 else
1175 int yytype = YYTRANSLATE (yychar);
1176 YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]);
1177 YYSIZE_T yysize = yysize0;
1178 YYSIZE_T yysize1;
1179 int yysize_overflow = 0;
1180 enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
1181 char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
1182 int yyx;
1184 # if 0
1185 /* This is so xgettext sees the translatable formats that are
1186 constructed on the fly. */
1187 YY_("syntax error, unexpected %s");
1188 YY_("syntax error, unexpected %s, expecting %s");
1189 YY_("syntax error, unexpected %s, expecting %s or %s");
1190 YY_("syntax error, unexpected %s, expecting %s or %s or %s");
1191 YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s");
1192 # endif
1193 char *yyfmt;
1194 char const *yyf;
1195 static char const yyunexpected[] = "syntax error, unexpected %s";
1196 static char const yyexpecting[] = ", expecting %s";
1197 static char const yyor[] = " or %s";
1198 char yyformat[sizeof yyunexpected
1199 + sizeof yyexpecting - 1
1200 + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2)
1201 * (sizeof yyor - 1))];
1202 char const *yyprefix = yyexpecting;
1204 /* Start YYX at -YYN if negative to avoid negative indexes in
1205 YYCHECK. */
1206 int yyxbegin = yyn < 0 ? -yyn : 0;
1208 /* Stay within bounds of both yycheck and yytname. */
1209 int yychecklim = YYLAST - yyn + 1;
1210 int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
1211 int yycount = 1;
1213 yyarg[0] = yytname[yytype];
1214 yyfmt = yystpcpy (yyformat, yyunexpected);
1216 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
1217 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
1219 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
1221 yycount = 1;
1222 yysize = yysize0;
1223 yyformat[sizeof yyunexpected - 1] = '\0';
1224 break;
1226 yyarg[yycount++] = yytname[yyx];
1227 yysize1 = yysize + yytnamerr (0, yytname[yyx]);
1228 yysize_overflow |= (yysize1 < yysize);
1229 yysize = yysize1;
1230 yyfmt = yystpcpy (yyfmt, yyprefix);
1231 yyprefix = yyor;
1234 yyf = YY_(yyformat);
1235 yysize1 = yysize + yystrlen (yyf);
1236 yysize_overflow |= (yysize1 < yysize);
1237 yysize = yysize1;
1239 if (yysize_overflow)
1240 return YYSIZE_MAXIMUM;
1242 if (yyresult)
1244 /* Avoid sprintf, as that infringes on the user's name space.
1245 Don't have undefined behavior even if the translation
1246 produced a string with the wrong number of "%s"s. */
1247 char *yyp = yyresult;
1248 int yyi = 0;
1249 while ((*yyp = *yyf) != '\0')
1251 if (*yyp == '%' && yyf[1] == 's' && yyi < yycount)
1253 yyp += yytnamerr (yyp, yyarg[yyi++]);
1254 yyf += 2;
1256 else
1258 yyp++;
1259 yyf++;
1263 return yysize;
1266 #endif /* YYERROR_VERBOSE */
1269 /*-----------------------------------------------.
1270 | Release the memory associated to this symbol. |
1271 `-----------------------------------------------*/
1273 /*ARGSUSED*/
1274 #if (defined __STDC__ || defined __C99__FUNC__ \
1275 || defined __cplusplus || defined _MSC_VER)
1276 static void
1277 yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
1278 #else
1279 static void
1280 yydestruct (yymsg, yytype, yyvaluep)
1281 const char *yymsg;
1282 int yytype;
1283 YYSTYPE *yyvaluep;
1284 #endif
1286 YYUSE (yyvaluep);
1288 if (!yymsg)
1289 yymsg = "Deleting";
1290 YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
1292 switch (yytype)
1295 default:
1296 break;
1301 /* Prevent warnings from -Wmissing-prototypes. */
1303 #ifdef YYPARSE_PARAM
1304 #if defined __STDC__ || defined __cplusplus
1305 int yyparse (void *YYPARSE_PARAM);
1306 #else
1307 int yyparse ();
1308 #endif
1309 #else /* ! YYPARSE_PARAM */
1310 #if defined __STDC__ || defined __cplusplus
1311 int yyparse (void);
1312 #else
1313 int yyparse ();
1314 #endif
1315 #endif /* ! YYPARSE_PARAM */
1319 /* The look-ahead symbol. */
1320 int yychar;
1322 /* The semantic value of the look-ahead symbol. */
1323 YYSTYPE yylval;
1325 /* Number of syntax errors so far. */
1326 int yynerrs;
1330 /*----------.
1331 | yyparse. |
1332 `----------*/
1334 #ifdef YYPARSE_PARAM
1335 #if (defined __STDC__ || defined __C99__FUNC__ \
1336 || defined __cplusplus || defined _MSC_VER)
1338 yyparse (void *YYPARSE_PARAM)
1339 #else
1341 yyparse (YYPARSE_PARAM)
1342 void *YYPARSE_PARAM;
1343 #endif
1344 #else /* ! YYPARSE_PARAM */
1345 #if (defined __STDC__ || defined __C99__FUNC__ \
1346 || defined __cplusplus || defined _MSC_VER)
1348 yyparse (void)
1349 #else
1351 yyparse ()
1353 #endif
1354 #endif
1357 int yystate;
1358 int yyn;
1359 int yyresult;
1360 /* Number of tokens to shift before error messages enabled. */
1361 int yyerrstatus;
1362 /* Look-ahead token as an internal (translated) token number. */
1363 int yytoken = 0;
1364 #if YYERROR_VERBOSE
1365 /* Buffer for error messages, and its allocated size. */
1366 char yymsgbuf[128];
1367 char *yymsg = yymsgbuf;
1368 YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
1369 #endif
1371 /* Three stacks and their tools:
1372 `yyss': related to states,
1373 `yyvs': related to semantic values,
1374 `yyls': related to locations.
1376 Refer to the stacks thru separate pointers, to allow yyoverflow
1377 to reallocate them elsewhere. */
1379 /* The state stack. */
1380 yytype_int16 yyssa[YYINITDEPTH];
1381 yytype_int16 *yyss = yyssa;
1382 yytype_int16 *yyssp;
1384 /* The semantic value stack. */
1385 YYSTYPE yyvsa[YYINITDEPTH];
1386 YYSTYPE *yyvs = yyvsa;
1387 YYSTYPE *yyvsp;
1391 #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
1393 YYSIZE_T yystacksize = YYINITDEPTH;
1395 /* The variables used to return semantic value and location from the
1396 action routines. */
1397 YYSTYPE yyval;
1400 /* The number of symbols on the RHS of the reduced rule.
1401 Keep to zero when no symbol should be popped. */
1402 int yylen = 0;
1404 YYDPRINTF ((stderr, "Starting parse\n"));
1406 yystate = 0;
1407 yyerrstatus = 0;
1408 yynerrs = 0;
1409 yychar = YYEMPTY; /* Cause a token to be read. */
1411 /* Initialize stack pointers.
1412 Waste one element of value and location stack
1413 so that they stay on the same level as the state stack.
1414 The wasted elements are never initialized. */
1416 yyssp = yyss;
1417 yyvsp = yyvs;
1419 goto yysetstate;
1421 /*------------------------------------------------------------.
1422 | yynewstate -- Push a new state, which is found in yystate. |
1423 `------------------------------------------------------------*/
1424 yynewstate:
1425 /* In all cases, when you get here, the value and location stacks
1426 have just been pushed. So pushing a state here evens the stacks. */
1427 yyssp++;
1429 yysetstate:
1430 *yyssp = yystate;
1432 if (yyss + yystacksize - 1 <= yyssp)
1434 /* Get the current used size of the three stacks, in elements. */
1435 YYSIZE_T yysize = yyssp - yyss + 1;
1437 #ifdef yyoverflow
1439 /* Give user a chance to reallocate the stack. Use copies of
1440 these so that the &'s don't force the real ones into
1441 memory. */
1442 YYSTYPE *yyvs1 = yyvs;
1443 yytype_int16 *yyss1 = yyss;
1446 /* Each stack pointer address is followed by the size of the
1447 data in use in that stack, in bytes. This used to be a
1448 conditional around just the two extra args, but that might
1449 be undefined if yyoverflow is a macro. */
1450 yyoverflow (YY_("memory exhausted"),
1451 &yyss1, yysize * sizeof (*yyssp),
1452 &yyvs1, yysize * sizeof (*yyvsp),
1454 &yystacksize);
1456 yyss = yyss1;
1457 yyvs = yyvs1;
1459 #else /* no yyoverflow */
1460 # ifndef YYSTACK_RELOCATE
1461 goto yyexhaustedlab;
1462 # else
1463 /* Extend the stack our own way. */
1464 if (YYMAXDEPTH <= yystacksize)
1465 goto yyexhaustedlab;
1466 yystacksize *= 2;
1467 if (YYMAXDEPTH < yystacksize)
1468 yystacksize = YYMAXDEPTH;
1471 yytype_int16 *yyss1 = yyss;
1472 union yyalloc *yyptr =
1473 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
1474 if (! yyptr)
1475 goto yyexhaustedlab;
1476 YYSTACK_RELOCATE (yyss);
1477 YYSTACK_RELOCATE (yyvs);
1479 # undef YYSTACK_RELOCATE
1480 if (yyss1 != yyssa)
1481 YYSTACK_FREE (yyss1);
1483 # endif
1484 #endif /* no yyoverflow */
1486 yyssp = yyss + yysize - 1;
1487 yyvsp = yyvs + yysize - 1;
1490 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
1491 (unsigned long int) yystacksize));
1493 if (yyss + yystacksize - 1 <= yyssp)
1494 YYABORT;
1497 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
1499 goto yybackup;
1501 /*-----------.
1502 | yybackup. |
1503 `-----------*/
1504 yybackup:
1506 /* Do appropriate processing given the current state. Read a
1507 look-ahead token if we need one and don't already have one. */
1509 /* First try to decide what to do without reference to look-ahead token. */
1510 yyn = yypact[yystate];
1511 if (yyn == YYPACT_NINF)
1512 goto yydefault;
1514 /* Not known => get a look-ahead token if don't already have one. */
1516 /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */
1517 if (yychar == YYEMPTY)
1519 YYDPRINTF ((stderr, "Reading a token: "));
1520 yychar = YYLEX;
1523 if (yychar <= YYEOF)
1525 yychar = yytoken = YYEOF;
1526 YYDPRINTF ((stderr, "Now at end of input.\n"));
1528 else
1530 yytoken = YYTRANSLATE (yychar);
1531 YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
1534 /* If the proper action on seeing token YYTOKEN is to reduce or to
1535 detect an error, take that action. */
1536 yyn += yytoken;
1537 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
1538 goto yydefault;
1539 yyn = yytable[yyn];
1540 if (yyn <= 0)
1542 if (yyn == 0 || yyn == YYTABLE_NINF)
1543 goto yyerrlab;
1544 yyn = -yyn;
1545 goto yyreduce;
1548 if (yyn == YYFINAL)
1549 YYACCEPT;
1551 /* Count tokens shifted since error; after three, turn off error
1552 status. */
1553 if (yyerrstatus)
1554 yyerrstatus--;
1556 /* Shift the look-ahead token. */
1557 YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
1559 /* Discard the shifted token unless it is eof. */
1560 if (yychar != YYEOF)
1561 yychar = YYEMPTY;
1563 yystate = yyn;
1564 *++yyvsp = yylval;
1566 goto yynewstate;
1569 /*-----------------------------------------------------------.
1570 | yydefault -- do the default action for the current state. |
1571 `-----------------------------------------------------------*/
1572 yydefault:
1573 yyn = yydefact[yystate];
1574 if (yyn == 0)
1575 goto yyerrlab;
1576 goto yyreduce;
1579 /*-----------------------------.
1580 | yyreduce -- Do a reduction. |
1581 `-----------------------------*/
1582 yyreduce:
1583 /* yyn is the number of a rule to reduce with. */
1584 yylen = yyr2[yyn];
1586 /* If YYLEN is nonzero, implement the default value of the action:
1587 `$$ = $1'.
1589 Otherwise, the following line sets YYVAL to garbage.
1590 This behavior is undocumented and Bison
1591 users should not rely upon it. Assigning to YYVAL
1592 unconditionally makes the parser a bit smaller, and it avoids a
1593 GCC warning that YYVAL may be used uninitialized. */
1594 yyval = yyvsp[1-yylen];
1597 YY_REDUCE_PRINT (yyn);
1598 switch (yyn)
1600 case 2:
1601 #line 127 "ASN1.y"
1602 {(yyval.node)=_asn1_add_node(TYPE_DEFINITIONS|(yyvsp[(3) - (8)].constant));
1603 _asn1_set_name((yyval.node),_asn1_get_name((yyvsp[(1) - (8)].node)));
1604 _asn1_set_name((yyvsp[(1) - (8)].node),"");
1605 _asn1_set_right((yyvsp[(1) - (8)].node),(yyvsp[(7) - (8)].node));
1606 _asn1_set_down((yyval.node),(yyvsp[(1) - (8)].node));
1608 p_tree=(yyval.node);
1610 break;
1612 case 3:
1613 #line 137 "ASN1.y"
1614 {strcpy((yyval.str),(yyvsp[(1) - (1)].str));}
1615 break;
1617 case 4:
1618 #line 138 "ASN1.y"
1619 {strcpy((yyval.str),(yyvsp[(2) - (2)].str));}
1620 break;
1622 case 5:
1623 #line 141 "ASN1.y"
1624 {strcpy((yyval.str),"-");
1625 strcat((yyval.str),(yyvsp[(2) - (2)].str));}
1626 break;
1628 case 6:
1629 #line 145 "ASN1.y"
1630 {strcpy((yyval.str),(yyvsp[(1) - (1)].str));}
1631 break;
1633 case 7:
1634 #line 146 "ASN1.y"
1635 {strcpy((yyval.str),(yyvsp[(1) - (1)].str));}
1636 break;
1638 case 8:
1639 #line 149 "ASN1.y"
1640 {strcpy((yyval.str),(yyvsp[(1) - (1)].str));}
1641 break;
1643 case 9:
1644 #line 150 "ASN1.y"
1645 {strcpy((yyval.str),(yyvsp[(1) - (1)].str));}
1646 break;
1648 case 10:
1649 #line 153 "ASN1.y"
1650 {strcpy((yyval.str),(yyvsp[(1) - (1)].str));}
1651 break;
1653 case 11:
1654 #line 154 "ASN1.y"
1655 {strcpy((yyval.str),(yyvsp[(1) - (1)].str));}
1656 break;
1658 case 12:
1659 #line 157 "ASN1.y"
1660 {(yyval.node)=_asn1_add_node(TYPE_CONSTANT);
1661 _asn1_set_value((yyval.node),(yyvsp[(2) - (3)].str),strlen((yyvsp[(2) - (3)].str))+1);}
1662 break;
1664 case 13:
1665 #line 159 "ASN1.y"
1666 {(yyval.node)=_asn1_add_node(TYPE_CONSTANT);
1667 _asn1_set_name((yyval.node),(yyvsp[(1) - (4)].str));
1668 _asn1_set_value((yyval.node),(yyvsp[(3) - (4)].str),strlen((yyvsp[(3) - (4)].str))+1);}
1669 break;
1671 case 14:
1672 #line 164 "ASN1.y"
1673 {(yyval.node)=(yyvsp[(1) - (1)].node);}
1674 break;
1676 case 15:
1677 #line 165 "ASN1.y"
1678 {(yyval.node)=(yyvsp[(1) - (3)].node);
1679 _asn1_set_right(_asn1_get_last_right((yyvsp[(1) - (3)].node)),(yyvsp[(3) - (3)].node));}
1680 break;
1682 case 16:
1683 #line 169 "ASN1.y"
1684 {(yyval.node)=_asn1_add_node(TYPE_CONSTANT);
1685 _asn1_set_value((yyval.node),(yyvsp[(1) - (1)].str),strlen((yyvsp[(1) - (1)].str))+1);}
1686 break;
1688 case 17:
1689 #line 171 "ASN1.y"
1690 {(yyval.node)=_asn1_add_node(TYPE_CONSTANT);
1691 _asn1_set_name((yyval.node),(yyvsp[(1) - (4)].str));
1692 _asn1_set_value((yyval.node),(yyvsp[(3) - (4)].str),strlen((yyvsp[(3) - (4)].str))+1);}
1693 break;
1695 case 18:
1696 #line 176 "ASN1.y"
1697 {(yyval.node)=(yyvsp[(1) - (1)].node);}
1698 break;
1700 case 19:
1701 #line 177 "ASN1.y"
1702 {(yyval.node)=(yyvsp[(1) - (2)].node);
1703 _asn1_set_right(_asn1_get_last_right((yyvsp[(1) - (2)].node)),(yyvsp[(2) - (2)].node));}
1704 break;
1706 case 20:
1707 #line 181 "ASN1.y"
1708 {(yyval.constant)=CONST_UNIVERSAL;}
1709 break;
1711 case 21:
1712 #line 182 "ASN1.y"
1713 {(yyval.constant)=CONST_PRIVATE;}
1714 break;
1716 case 22:
1717 #line 183 "ASN1.y"
1718 {(yyval.constant)=CONST_APPLICATION;}
1719 break;
1721 case 23:
1722 #line 186 "ASN1.y"
1723 {(yyval.node)=_asn1_add_node(TYPE_TAG);
1724 _asn1_set_value((yyval.node),(yyvsp[(2) - (3)].str),strlen((yyvsp[(2) - (3)].str))+1);}
1725 break;
1727 case 24:
1728 #line 188 "ASN1.y"
1729 {(yyval.node)=_asn1_add_node(TYPE_TAG | (yyvsp[(2) - (4)].constant));
1730 _asn1_set_value((yyval.node),(yyvsp[(3) - (4)].str),strlen((yyvsp[(3) - (4)].str))+1);}
1731 break;
1733 case 25:
1734 #line 192 "ASN1.y"
1735 {(yyval.node)=(yyvsp[(1) - (1)].node);}
1736 break;
1738 case 26:
1739 #line 193 "ASN1.y"
1740 {(yyval.node)=_asn1_mod_type((yyvsp[(1) - (2)].node),CONST_EXPLICIT);}
1741 break;
1743 case 27:
1744 #line 194 "ASN1.y"
1745 {(yyval.node)=_asn1_mod_type((yyvsp[(1) - (2)].node),CONST_IMPLICIT);}
1746 break;
1748 case 28:
1749 #line 197 "ASN1.y"
1750 {(yyval.node)=_asn1_add_node(TYPE_DEFAULT);
1751 _asn1_set_value((yyval.node),(yyvsp[(2) - (2)].str),strlen((yyvsp[(2) - (2)].str))+1);}
1752 break;
1754 case 29:
1755 #line 199 "ASN1.y"
1756 {(yyval.node)=_asn1_add_node(TYPE_DEFAULT|CONST_TRUE);}
1757 break;
1759 case 30:
1760 #line 200 "ASN1.y"
1761 {(yyval.node)=_asn1_add_node(TYPE_DEFAULT|CONST_FALSE);}
1762 break;
1764 case 33:
1765 #line 209 "ASN1.y"
1766 {(yyval.node)=_asn1_add_node(TYPE_INTEGER);}
1767 break;
1769 case 34:
1770 #line 210 "ASN1.y"
1771 {(yyval.node)=_asn1_add_node(TYPE_INTEGER|CONST_LIST);
1772 _asn1_set_down((yyval.node),(yyvsp[(3) - (4)].node));}
1773 break;
1775 case 35:
1776 #line 212 "ASN1.y"
1777 {(yyval.node)=_asn1_add_node(TYPE_INTEGER);}
1778 break;
1780 case 36:
1781 #line 214 "ASN1.y"
1782 {(yyval.node)=_asn1_add_node(TYPE_INTEGER|CONST_MIN_MAX);
1783 _asn1_set_down((yyval.node),_asn1_add_node(TYPE_SIZE));
1784 _asn1_set_value(_asn1_get_down((yyval.node)),(yyvsp[(6) - (7)].str),strlen((yyvsp[(6) - (7)].str))+1);
1785 _asn1_set_name(_asn1_get_down((yyval.node)),(yyvsp[(3) - (7)].str));}
1786 break;
1788 case 37:
1789 #line 220 "ASN1.y"
1790 {(yyval.node)=_asn1_add_node(TYPE_BOOLEAN);}
1791 break;
1793 case 38:
1794 #line 223 "ASN1.y"
1795 {(yyval.node)=_asn1_add_node(TYPE_TIME|CONST_UTC);}
1796 break;
1798 case 39:
1799 #line 224 "ASN1.y"
1800 {(yyval.node)=_asn1_add_node(TYPE_TIME|CONST_GENERALIZED);}
1801 break;
1803 case 40:
1804 #line 227 "ASN1.y"
1805 {(yyval.node)=_asn1_add_node(TYPE_SIZE|CONST_1_PARAM);
1806 _asn1_set_value((yyval.node),(yyvsp[(3) - (4)].str),strlen((yyvsp[(3) - (4)].str))+1);}
1807 break;
1809 case 41:
1810 #line 230 "ASN1.y"
1811 {(yyval.node)=_asn1_add_node(TYPE_SIZE|CONST_MIN_MAX);
1812 _asn1_set_value((yyval.node),(yyvsp[(3) - (7)].str),strlen((yyvsp[(3) - (7)].str))+1);
1813 _asn1_set_name((yyval.node),(yyvsp[(6) - (7)].str));}
1814 break;
1816 case 42:
1817 #line 235 "ASN1.y"
1818 {(yyval.node)=(yyvsp[(1) - (1)].node);}
1819 break;
1821 case 43:
1822 #line 236 "ASN1.y"
1823 {(yyval.node)=(yyvsp[(2) - (3)].node);}
1824 break;
1826 case 44:
1827 #line 239 "ASN1.y"
1828 {(yyval.node)=_asn1_add_node(TYPE_GENERALSTRING);}
1829 break;
1831 case 45:
1832 #line 240 "ASN1.y"
1833 {(yyval.node)=_asn1_add_node(TYPE_GENERALSTRING|CONST_SIZE);
1834 _asn1_set_down((yyval.node),(yyvsp[(2) - (2)].node));}
1835 break;
1837 case 46:
1838 #line 244 "ASN1.y"
1839 {(yyval.node)=_asn1_add_node(TYPE_OCTET_STRING);}
1840 break;
1842 case 47:
1843 #line 245 "ASN1.y"
1844 {(yyval.node)=_asn1_add_node(TYPE_OCTET_STRING|CONST_SIZE);
1845 _asn1_set_down((yyval.node),(yyvsp[(3) - (3)].node));}
1846 break;
1848 case 48:
1849 #line 249 "ASN1.y"
1850 {(yyval.node)=_asn1_add_node(TYPE_CONSTANT);
1851 _asn1_set_name((yyval.node),(yyvsp[(1) - (4)].str));
1852 _asn1_set_value((yyval.node),(yyvsp[(3) - (4)].str),strlen((yyvsp[(3) - (4)].str))+1);}
1853 break;
1855 case 49:
1856 #line 254 "ASN1.y"
1857 {(yyval.node)=(yyvsp[(1) - (1)].node);}
1858 break;
1860 case 50:
1861 #line 255 "ASN1.y"
1862 {(yyval.node)=(yyvsp[(1) - (3)].node);
1863 _asn1_set_right(_asn1_get_last_right((yyvsp[(1) - (3)].node)),(yyvsp[(3) - (3)].node));}
1864 break;
1866 case 51:
1867 #line 259 "ASN1.y"
1868 {(yyval.node)=_asn1_add_node(TYPE_BIT_STRING);}
1869 break;
1871 case 52:
1872 #line 260 "ASN1.y"
1873 {(yyval.node)=_asn1_add_node(TYPE_BIT_STRING|CONST_SIZE);}
1874 break;
1876 case 53:
1877 #line 262 "ASN1.y"
1878 {(yyval.node)=_asn1_add_node(TYPE_BIT_STRING|CONST_LIST);
1879 _asn1_set_down((yyval.node),(yyvsp[(4) - (5)].node));}
1880 break;
1882 case 54:
1883 #line 267 "ASN1.y"
1884 {(yyval.node)=_asn1_add_node(TYPE_ENUMERATED|CONST_LIST);
1885 _asn1_set_down((yyval.node),(yyvsp[(3) - (4)].node));}
1886 break;
1888 case 55:
1889 #line 272 "ASN1.y"
1890 {(yyval.node)=_asn1_add_node(TYPE_OBJECT_ID);}
1891 break;
1893 case 56:
1894 #line 275 "ASN1.y"
1895 {(yyval.node)=_asn1_add_node(TYPE_IDENTIFIER);
1896 _asn1_set_value((yyval.node),(yyvsp[(1) - (1)].str),strlen((yyvsp[(1) - (1)].str))+1);}
1897 break;
1899 case 57:
1900 #line 277 "ASN1.y"
1901 {(yyval.node)=_asn1_add_node(TYPE_IDENTIFIER|CONST_SIZE);
1902 _asn1_set_value((yyval.node),(yyvsp[(1) - (2)].str),strlen((yyvsp[(1) - (2)].str))+1);
1903 _asn1_set_down((yyval.node),(yyvsp[(2) - (2)].node));}
1904 break;
1906 case 58:
1907 #line 280 "ASN1.y"
1908 {(yyval.node)=(yyvsp[(1) - (1)].node);}
1909 break;
1911 case 59:
1912 #line 281 "ASN1.y"
1913 {(yyval.node)=(yyvsp[(1) - (1)].node);}
1914 break;
1916 case 60:
1917 #line 282 "ASN1.y"
1918 {(yyval.node)=(yyvsp[(1) - (1)].node);}
1919 break;
1921 case 62:
1922 #line 284 "ASN1.y"
1923 {(yyval.node)=(yyvsp[(1) - (1)].node);}
1924 break;
1926 case 63:
1927 #line 285 "ASN1.y"
1928 {(yyval.node)=(yyvsp[(1) - (1)].node);}
1929 break;
1931 case 64:
1932 #line 286 "ASN1.y"
1933 {(yyval.node)=(yyvsp[(1) - (1)].node);}
1934 break;
1936 case 65:
1937 #line 287 "ASN1.y"
1938 {(yyval.node)=(yyvsp[(1) - (1)].node);}
1939 break;
1941 case 66:
1942 #line 288 "ASN1.y"
1943 {(yyval.node)=(yyvsp[(1) - (1)].node);}
1944 break;
1946 case 67:
1947 #line 289 "ASN1.y"
1948 {(yyval.node)=(yyvsp[(1) - (1)].node);}
1949 break;
1951 case 68:
1952 #line 290 "ASN1.y"
1953 {(yyval.node)=(yyvsp[(1) - (1)].node);}
1954 break;
1956 case 69:
1957 #line 291 "ASN1.y"
1958 {(yyval.node)=(yyvsp[(1) - (1)].node);}
1959 break;
1961 case 70:
1962 #line 292 "ASN1.y"
1963 {(yyval.node)=_asn1_add_node(TYPE_NULL);}
1964 break;
1966 case 71:
1967 #line 295 "ASN1.y"
1968 {(yyval.node)=(yyvsp[(1) - (1)].node);}
1969 break;
1971 case 72:
1972 #line 296 "ASN1.y"
1973 {(yyval.node)=_asn1_mod_type((yyvsp[(2) - (2)].node),CONST_TAG);
1974 _asn1_set_right((yyvsp[(1) - (2)].node),_asn1_get_down((yyval.node)));
1975 _asn1_set_down((yyval.node),(yyvsp[(1) - (2)].node));}
1976 break;
1978 case 73:
1979 #line 301 "ASN1.y"
1980 {(yyval.node)=(yyvsp[(1) - (1)].node);}
1981 break;
1983 case 74:
1984 #line 302 "ASN1.y"
1985 {(yyval.node)=_asn1_mod_type((yyvsp[(1) - (2)].node),CONST_DEFAULT);
1986 _asn1_set_right((yyvsp[(2) - (2)].node),_asn1_get_down((yyval.node)));
1987 _asn1_set_down((yyval.node),(yyvsp[(2) - (2)].node));}
1988 break;
1990 case 75:
1991 #line 305 "ASN1.y"
1992 {(yyval.node)=_asn1_mod_type((yyvsp[(1) - (2)].node),CONST_OPTION);}
1993 break;
1995 case 76:
1996 #line 308 "ASN1.y"
1997 {(yyval.node)=_asn1_set_name((yyvsp[(2) - (2)].node),(yyvsp[(1) - (2)].str));}
1998 break;
2000 case 77:
2001 #line 311 "ASN1.y"
2002 {(yyval.node)=(yyvsp[(1) - (1)].node);}
2003 break;
2005 case 78:
2006 #line 312 "ASN1.y"
2007 {(yyval.node)=(yyvsp[(1) - (3)].node);
2008 _asn1_set_right(_asn1_get_last_right((yyvsp[(1) - (3)].node)),(yyvsp[(3) - (3)].node));}
2009 break;
2011 case 79:
2012 #line 316 "ASN1.y"
2013 {(yyval.node)=_asn1_add_node(TYPE_SEQUENCE);
2014 _asn1_set_down((yyval.node),(yyvsp[(3) - (4)].node));}
2015 break;
2017 case 80:
2018 #line 318 "ASN1.y"
2019 {(yyval.node)=_asn1_add_node(TYPE_SEQUENCE_OF);
2020 _asn1_set_down((yyval.node),(yyvsp[(3) - (3)].node));}
2021 break;
2023 case 81:
2024 #line 320 "ASN1.y"
2025 {(yyval.node)=_asn1_add_node(TYPE_SEQUENCE_OF|CONST_SIZE);
2026 _asn1_set_right((yyvsp[(2) - (4)].node),(yyvsp[(4) - (4)].node));
2027 _asn1_set_down((yyval.node),(yyvsp[(2) - (4)].node));}
2028 break;
2030 case 82:
2031 #line 325 "ASN1.y"
2032 {(yyval.node)=_asn1_add_node(TYPE_SET);
2033 _asn1_set_down((yyval.node),(yyvsp[(3) - (4)].node));}
2034 break;
2036 case 83:
2037 #line 327 "ASN1.y"
2038 {(yyval.node)=_asn1_add_node(TYPE_SET_OF);
2039 _asn1_set_down((yyval.node),(yyvsp[(3) - (3)].node));}
2040 break;
2042 case 84:
2043 #line 329 "ASN1.y"
2044 {(yyval.node)=_asn1_add_node(TYPE_SET_OF|CONST_SIZE);
2045 _asn1_set_right((yyvsp[(2) - (4)].node),(yyvsp[(4) - (4)].node));
2046 _asn1_set_down((yyval.node),(yyvsp[(2) - (4)].node));}
2047 break;
2049 case 85:
2050 #line 334 "ASN1.y"
2051 {(yyval.node)=_asn1_add_node(TYPE_CHOICE);
2052 _asn1_set_down((yyval.node),(yyvsp[(3) - (4)].node));}
2053 break;
2055 case 86:
2056 #line 338 "ASN1.y"
2057 {(yyval.node)=_asn1_add_node(TYPE_ANY);}
2058 break;
2060 case 87:
2061 #line 339 "ASN1.y"
2062 {(yyval.node)=_asn1_add_node(TYPE_ANY|CONST_DEFINED_BY);
2063 _asn1_set_down((yyval.node),_asn1_add_node(TYPE_CONSTANT));
2064 _asn1_set_name(_asn1_get_down((yyval.node)),(yyvsp[(4) - (4)].str));}
2065 break;
2067 case 88:
2068 #line 344 "ASN1.y"
2069 {(yyval.node)=_asn1_set_name((yyvsp[(3) - (3)].node),(yyvsp[(1) - (3)].str));}
2070 break;
2072 case 89:
2073 #line 348 "ASN1.y"
2074 {(yyval.node)=_asn1_add_node(TYPE_OBJECT_ID|CONST_ASSIGN);
2075 _asn1_set_name((yyval.node),(yyvsp[(1) - (7)].str));
2076 _asn1_set_down((yyval.node),(yyvsp[(6) - (7)].node));}
2077 break;
2079 case 90:
2080 #line 352 "ASN1.y"
2081 {(yyval.node)=_asn1_add_node(TYPE_OBJECT_ID|CONST_ASSIGN|CONST_1_PARAM);
2082 _asn1_set_name((yyval.node),(yyvsp[(1) - (6)].str));
2083 _asn1_set_value((yyval.node),(yyvsp[(2) - (6)].str),strlen((yyvsp[(2) - (6)].str))+1);
2084 _asn1_set_down((yyval.node),(yyvsp[(5) - (6)].node));}
2085 break;
2087 case 91:
2088 #line 357 "ASN1.y"
2089 {(yyval.node)=_asn1_add_node(TYPE_INTEGER|CONST_ASSIGN);
2090 _asn1_set_name((yyval.node),(yyvsp[(1) - (4)].str));
2091 _asn1_set_value((yyval.node),(yyvsp[(4) - (4)].str),strlen((yyvsp[(4) - (4)].str))+1);}
2092 break;
2094 case 92:
2095 #line 362 "ASN1.y"
2096 {(yyval.node)=(yyvsp[(1) - (1)].node);}
2097 break;
2099 case 93:
2100 #line 363 "ASN1.y"
2101 {(yyval.node)=(yyvsp[(1) - (1)].node);}
2102 break;
2104 case 94:
2105 #line 366 "ASN1.y"
2106 {(yyval.node)=(yyvsp[(1) - (1)].node);}
2107 break;
2109 case 95:
2110 #line 367 "ASN1.y"
2111 {(yyval.node)=(yyvsp[(1) - (2)].node);
2112 _asn1_set_right(_asn1_get_last_right((yyvsp[(1) - (2)].node)),(yyvsp[(2) - (2)].node));}
2113 break;
2115 case 96:
2116 #line 371 "ASN1.y"
2117 {(yyval.node)=_asn1_add_node(TYPE_OBJECT_ID);
2118 _asn1_set_down((yyval.node),(yyvsp[(3) - (4)].node));
2119 _asn1_set_name((yyval.node),(yyvsp[(1) - (4)].str));}
2120 break;
2122 case 97:
2123 #line 374 "ASN1.y"
2124 {(yyval.node)=_asn1_add_node(TYPE_OBJECT_ID);
2125 _asn1_set_name((yyval.node),(yyvsp[(1) - (3)].str));}
2126 break;
2128 case 98:
2129 #line 398 "ASN1.y"
2130 {(yyval.constant)=CONST_EXPLICIT;}
2131 break;
2133 case 99:
2134 #line 399 "ASN1.y"
2135 {(yyval.constant)=CONST_IMPLICIT;}
2136 break;
2139 /* Line 1267 of yacc.c. */
2140 #line 2141 "ASN1.c"
2141 default: break;
2143 YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
2145 YYPOPSTACK (yylen);
2146 yylen = 0;
2147 YY_STACK_PRINT (yyss, yyssp);
2149 *++yyvsp = yyval;
2152 /* Now `shift' the result of the reduction. Determine what state
2153 that goes to, based on the state we popped back to and the rule
2154 number reduced by. */
2156 yyn = yyr1[yyn];
2158 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
2159 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
2160 yystate = yytable[yystate];
2161 else
2162 yystate = yydefgoto[yyn - YYNTOKENS];
2164 goto yynewstate;
2167 /*------------------------------------.
2168 | yyerrlab -- here on detecting error |
2169 `------------------------------------*/
2170 yyerrlab:
2171 /* If not already recovering from an error, report this error. */
2172 if (!yyerrstatus)
2174 ++yynerrs;
2175 #if ! YYERROR_VERBOSE
2176 yyerror (YY_("syntax error"));
2177 #else
2179 YYSIZE_T yysize = yysyntax_error (0, yystate, yychar);
2180 if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM)
2182 YYSIZE_T yyalloc = 2 * yysize;
2183 if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM))
2184 yyalloc = YYSTACK_ALLOC_MAXIMUM;
2185 if (yymsg != yymsgbuf)
2186 YYSTACK_FREE (yymsg);
2187 yymsg = (char *) YYSTACK_ALLOC (yyalloc);
2188 if (yymsg)
2189 yymsg_alloc = yyalloc;
2190 else
2192 yymsg = yymsgbuf;
2193 yymsg_alloc = sizeof yymsgbuf;
2197 if (0 < yysize && yysize <= yymsg_alloc)
2199 (void) yysyntax_error (yymsg, yystate, yychar);
2200 yyerror (yymsg);
2202 else
2204 yyerror (YY_("syntax error"));
2205 if (yysize != 0)
2206 goto yyexhaustedlab;
2209 #endif
2214 if (yyerrstatus == 3)
2216 /* If just tried and failed to reuse look-ahead token after an
2217 error, discard it. */
2219 if (yychar <= YYEOF)
2221 /* Return failure if at end of input. */
2222 if (yychar == YYEOF)
2223 YYABORT;
2225 else
2227 yydestruct ("Error: discarding",
2228 yytoken, &yylval);
2229 yychar = YYEMPTY;
2233 /* Else will try to reuse look-ahead token after shifting the error
2234 token. */
2235 goto yyerrlab1;
2238 /*---------------------------------------------------.
2239 | yyerrorlab -- error raised explicitly by YYERROR. |
2240 `---------------------------------------------------*/
2241 yyerrorlab:
2243 /* Pacify compilers like GCC when the user code never invokes
2244 YYERROR and the label yyerrorlab therefore never appears in user
2245 code. */
2246 if (/*CONSTCOND*/ 0)
2247 goto yyerrorlab;
2249 /* Do not reclaim the symbols of the rule which action triggered
2250 this YYERROR. */
2251 YYPOPSTACK (yylen);
2252 yylen = 0;
2253 YY_STACK_PRINT (yyss, yyssp);
2254 yystate = *yyssp;
2255 goto yyerrlab1;
2258 /*-------------------------------------------------------------.
2259 | yyerrlab1 -- common code for both syntax error and YYERROR. |
2260 `-------------------------------------------------------------*/
2261 yyerrlab1:
2262 yyerrstatus = 3; /* Each real token shifted decrements this. */
2264 for (;;)
2266 yyn = yypact[yystate];
2267 if (yyn != YYPACT_NINF)
2269 yyn += YYTERROR;
2270 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
2272 yyn = yytable[yyn];
2273 if (0 < yyn)
2274 break;
2278 /* Pop the current state because it cannot handle the error token. */
2279 if (yyssp == yyss)
2280 YYABORT;
2283 yydestruct ("Error: popping",
2284 yystos[yystate], yyvsp);
2285 YYPOPSTACK (1);
2286 yystate = *yyssp;
2287 YY_STACK_PRINT (yyss, yyssp);
2290 if (yyn == YYFINAL)
2291 YYACCEPT;
2293 *++yyvsp = yylval;
2296 /* Shift the error token. */
2297 YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
2299 yystate = yyn;
2300 goto yynewstate;
2303 /*-------------------------------------.
2304 | yyacceptlab -- YYACCEPT comes here. |
2305 `-------------------------------------*/
2306 yyacceptlab:
2307 yyresult = 0;
2308 goto yyreturn;
2310 /*-----------------------------------.
2311 | yyabortlab -- YYABORT comes here. |
2312 `-----------------------------------*/
2313 yyabortlab:
2314 yyresult = 1;
2315 goto yyreturn;
2317 #ifndef yyoverflow
2318 /*-------------------------------------------------.
2319 | yyexhaustedlab -- memory exhaustion comes here. |
2320 `-------------------------------------------------*/
2321 yyexhaustedlab:
2322 yyerror (YY_("memory exhausted"));
2323 yyresult = 2;
2324 /* Fall through. */
2325 #endif
2327 yyreturn:
2328 if (yychar != YYEOF && yychar != YYEMPTY)
2329 yydestruct ("Cleanup: discarding lookahead",
2330 yytoken, &yylval);
2331 /* Do not reclaim the symbols of the rule which action triggered
2332 this YYABORT or YYACCEPT. */
2333 YYPOPSTACK (yylen);
2334 YY_STACK_PRINT (yyss, yyssp);
2335 while (yyssp != yyss)
2337 yydestruct ("Cleanup: popping",
2338 yystos[*yyssp], yyvsp);
2339 YYPOPSTACK (1);
2341 #ifndef yyoverflow
2342 if (yyss != yyssa)
2343 YYSTACK_FREE (yyss);
2344 #endif
2345 #if YYERROR_VERBOSE
2346 if (yymsg != yymsgbuf)
2347 YYSTACK_FREE (yymsg);
2348 #endif
2349 /* Make sure YYID is used. */
2350 return YYID (yyresult);
2354 #line 403 "ASN1.y"
2359 const char *key_word[]={"::=","OPTIONAL","INTEGER","SIZE","OCTET","STRING"
2360 ,"SEQUENCE","BIT","UNIVERSAL","PRIVATE","OPTIONAL"
2361 ,"DEFAULT","CHOICE","OF","OBJECT","IDENTIFIER"
2362 ,"BOOLEAN","TRUE","FALSE","APPLICATION","ANY","DEFINED"
2363 ,"SET","BY","EXPLICIT","IMPLICIT","DEFINITIONS","TAGS"
2364 ,"BEGIN","END","UTCTime","GeneralizedTime"
2365 ,"GeneralString","FROM","IMPORTS","NULL","ENUMERATED"};
2366 const int key_word_token[]={ASSIG,OPTIONAL,INTEGER,SIZE,OCTET,STRING
2367 ,SEQUENCE,BIT,UNIVERSAL,PRIVATE,OPTIONAL
2368 ,DEFAULT,CHOICE,OF,OBJECT,STR_IDENTIFIER
2369 ,BOOLEAN,TRUE,FALSE,APPLICATION,ANY,DEFINED
2370 ,SET,BY,EXPLICIT,IMPLICIT,DEFINITIONS,TAGS
2371 ,BEGIN,END,UTCTime,GeneralizedTime
2372 ,GeneralString,FROM,IMPORTS,TOKEN_NULL,ENUMERATED};
2374 /*************************************************************/
2375 /* Function: _asn1_yylex */
2376 /* Description: looks for tokens in file_asn1 pointer file. */
2377 /* Return: int */
2378 /* Token identifier or ASCII code or 0(zero: End Of File) */
2379 /*************************************************************/
2381 _asn1_yylex()
2383 int c,counter=0,k,lastc;
2384 char string[MAX_NAME_SIZE+1]; /* will contain the next token */
2386 while(1)
2388 while((c=fgetc(file_asn1))==' ' || c=='\t' || c=='\n')
2389 if(c=='\n') lineNumber++;
2391 if(c==EOF){
2392 strcpy(lastToken,"End Of File");
2393 return 0;
2396 if(c=='(' || c==')' || c=='[' || c==']' ||
2397 c=='{' || c=='}' || c==',' || c=='.' ||
2398 c=='+' || c=='|'){
2399 lastToken[0]=c;lastToken[1]=0;
2400 return c;
2402 if(c=='-'){ /* Maybe the first '-' of a comment */
2403 if((c=fgetc(file_asn1))!='-'){
2404 ungetc(c,file_asn1);
2405 lastToken[0]='-';lastToken[1]=0;
2406 return '-';
2408 else{ /* Comments */
2409 lastc=0;
2410 counter=0;
2411 /* A comment finishes at the next double hypen or the end of line */
2412 while((c=fgetc(file_asn1))!=EOF && c!='\n' &&
2413 (lastc!='-' || (lastc=='-' && c!='-')))
2414 lastc=c;
2415 if(c==EOF){
2416 strcpy(lastToken,"End Of File");
2417 return 0;
2419 else{
2420 if(c=='\n') lineNumber++;
2421 continue; /* next char, please! (repeat the search) */
2425 string[counter++]=c;
2426 /* Till the end of the token */
2427 while(!((c=fgetc(file_asn1))==EOF || c==' '|| c=='\t' || c=='\n' ||
2428 c=='(' || c==')' || c=='[' || c==']' ||
2429 c=='{' || c=='}' || c==',' || c=='.'))
2431 if(counter>=MAX_NAME_SIZE){
2432 result_parse=ASN1_NAME_TOO_LONG;
2433 return 0;
2435 string[counter++]=c;
2437 ungetc(c,file_asn1);
2438 string[counter]=0;
2439 strcpy(lastToken,string);
2441 /* Is STRING a number? */
2442 for(k=0;k<counter;k++)
2443 if(!isdigit(string[k])) break;
2444 if(k>=counter)
2446 strcpy(yylval.str,string);
2447 return NUM; /* return the number */
2450 /* Is STRING a keyword? */
2451 for(k=0;k<(sizeof(key_word)/sizeof(char*));k++)
2452 if(!strcmp(string,key_word[k])) return key_word_token[k];
2454 /* STRING is an IDENTIFIER */
2455 strcpy(yylval.str,string);
2456 return IDENTIFIER;
2461 /*************************************************************/
2462 /* Function: _asn1_create_errorDescription */
2463 /* Description: creates a string with the description of the*/
2464 /* error. */
2465 /* Parameters: */
2466 /* error : error to describe. */
2467 /* errorDescription: string that will contain the */
2468 /* description. */
2469 /*************************************************************/
2470 void
2471 _asn1_create_errorDescription(int error,char *errorDescription)
2473 switch(error){
2474 case ASN1_SUCCESS: case ASN1_FILE_NOT_FOUND:
2475 if (errorDescription!=NULL) errorDescription[0]=0;
2476 break;
2477 case ASN1_SYNTAX_ERROR:
2478 if (errorDescription!=NULL) {
2479 strcpy(errorDescription,fileName);
2480 strcat(errorDescription,":");
2481 _asn1_ltostr(lineNumber,errorDescription+strlen(fileName)+1);
2482 strcat(errorDescription,": parse error near '");
2483 strcat(errorDescription,lastToken);
2484 strcat(errorDescription,"'");
2486 break;
2487 case ASN1_NAME_TOO_LONG:
2488 if (errorDescription!=NULL) {
2489 strcpy(errorDescription,fileName);
2490 strcat(errorDescription,":");
2491 _asn1_ltostr(lineNumber,errorDescription+strlen(fileName)+1);
2492 strcat(errorDescription,": name too long (more than ");
2493 _asn1_ltostr(MAX_NAME_SIZE,errorDescription+strlen(errorDescription));
2494 strcat(errorDescription," characters)");
2496 break;
2497 case ASN1_IDENTIFIER_NOT_FOUND:
2498 if (errorDescription!=NULL) {
2499 strcpy(errorDescription,fileName);
2500 strcat(errorDescription,":");
2501 strcat(errorDescription,": identifier '");
2502 strcat(errorDescription,_asn1_identifierMissing);
2503 strcat(errorDescription,"' not found");
2505 break;
2506 default:
2507 if (errorDescription!=NULL) errorDescription[0]=0;
2508 break;
2515 * asn1_parser2tree - function used to start the parse algorithm.
2516 * @file_name: specify the path and the name of file that contains
2517 * ASN.1 declarations.
2518 * @definitions: return the pointer to the structure created from
2519 * "file_name" ASN.1 declarations.
2520 * @errorDescription: return the error description or an empty
2521 * string if success.
2523 * Creates the structures needed to manage the definitions included
2524 * in *FILE_NAME file.
2526 * Returns:
2528 * ASN1_SUCCESS: The file has a correct syntax and every identifier
2529 * is known.
2531 * ASN1_ELEMENT_NOT_EMPTY: *POINTER not ASN1_TYPE_EMPTY.
2533 * ASN1_FILE_NOT_FOUND: An error occured while opening FILE_NAME.
2535 * ASN1_SYNTAX_ERROR: The syntax is not correct.
2537 * ASN1_IDENTIFIER_NOT_FOUND: In the file there is an identifier that
2538 * is not defined.
2540 * ASN1_NAME_TOO_LONG: In the file there is an identifier whith more
2541 * than MAX_NAME_SIZE characters.
2543 asn1_retCode
2544 asn1_parser2tree(const char *file_name, ASN1_TYPE *definitions,
2545 char *errorDescription){
2547 p_tree=ASN1_TYPE_EMPTY;
2549 if(*definitions != ASN1_TYPE_EMPTY)
2550 return ASN1_ELEMENT_NOT_EMPTY;
2552 *definitions=ASN1_TYPE_EMPTY;
2554 fileName = file_name;
2556 /* open the file to parse */
2557 file_asn1=fopen(file_name,"r");
2559 if(file_asn1==NULL){
2560 result_parse=ASN1_FILE_NOT_FOUND;
2562 else{
2563 result_parse=ASN1_SUCCESS;
2565 lineNumber=1;
2566 yyparse();
2568 fclose(file_asn1);
2570 if(result_parse==ASN1_SUCCESS){ /* syntax OK */
2571 /* set IMPLICIT or EXPLICIT property */
2572 _asn1_set_default_tag(p_tree);
2573 /* set CONST_SET and CONST_NOT_USED */
2574 _asn1_type_set_config(p_tree);
2575 /* check the identifier definitions */
2576 result_parse=_asn1_check_identifier(p_tree);
2577 if(result_parse==ASN1_SUCCESS){ /* all identifier defined */
2578 /* Delete the list and keep the ASN1 structure */
2579 _asn1_delete_list();
2580 /* Convert into DER coding the value assign to INTEGER constants */
2581 _asn1_change_integer_value(p_tree);
2582 /* Expand the IDs of OBJECT IDENTIFIER constants */
2583 _asn1_expand_object_id(p_tree);
2585 *definitions=p_tree;
2587 else /* some identifiers not defined */
2588 /* Delete the list and the ASN1 structure */
2589 _asn1_delete_list_and_nodes();
2591 else /* syntax error */
2592 /* Delete the list and the ASN1 structure */
2593 _asn1_delete_list_and_nodes();
2596 if (errorDescription!=NULL)
2597 _asn1_create_errorDescription(result_parse,errorDescription);
2599 return result_parse;
2604 * asn1_parser2array - function that generates a C structure from an ASN1 file
2605 * @inputFileName: specify the path and the name of file that
2606 * contains ASN.1 declarations.
2607 * @outputFileName: specify the path and the name of file that will
2608 * contain the C vector definition.
2609 * @vectorName: specify the name of the C vector.
2610 * @errorDescription : return the error description or an empty
2611 * string if success.
2613 * Creates a file containing a C vector to use to manage the
2614 * definitions included in *INPUTFILENAME file. If *INPUTFILENAME is
2615 * "/aa/bb/xx.yy" and OUTPUTFILENAME is NULL, the file created is
2616 * "/aa/bb/xx_asn1_tab.c". If VECTORNAME is NULL the vector name
2617 * will be "xx_asn1_tab".
2619 * Returns:
2621 * ASN1_SUCCESS: The file has a correct syntax and every identifier
2622 * is known.
2624 * ASN1_FILE_NOT_FOUND: An error occured while opening FILE_NAME.
2626 * ASN1_SYNTAX_ERROR: The syntax is not correct.
2628 * ASN1_IDENTIFIER_NOT_FOUND: In the file there is an identifier that
2629 * is not defined.
2631 * ASN1_NAME_TOO_LONG: In the file there is an identifier whith more
2632 * than MAX_NAME_SIZE characters.
2634 int asn1_parser2array(const char *inputFileName,const char *outputFileName,
2635 const char *vectorName,char *errorDescription){
2636 char *file_out_name=NULL;
2637 char *vector_name=NULL;
2638 const char *char_p,*slash_p,*dot_p;
2640 p_tree=NULL;
2642 fileName = inputFileName;
2644 /* open the file to parse */
2645 file_asn1=fopen(inputFileName,"r");
2647 if(file_asn1==NULL)
2648 result_parse=ASN1_FILE_NOT_FOUND;
2649 else{
2650 result_parse=ASN1_SUCCESS;
2652 lineNumber=1;
2653 yyparse();
2655 fclose(file_asn1);
2657 if(result_parse==ASN1_SUCCESS){ /* syntax OK */
2658 /* set IMPLICIT or EXPLICIT property */
2659 _asn1_set_default_tag(p_tree);
2660 /* set CONST_SET and CONST_NOT_USED */
2661 _asn1_type_set_config(p_tree);
2662 /* check the identifier definitions */
2663 result_parse=_asn1_check_identifier(p_tree);
2665 if(result_parse==ASN1_SUCCESS){ /* all identifier defined */
2667 /* searching the last '/' and '.' in inputFileName */
2668 char_p=inputFileName;
2669 slash_p=inputFileName;
2670 while((char_p=strchr(char_p,'/'))){
2671 char_p++;
2672 slash_p=char_p;
2675 char_p=slash_p;
2676 dot_p=inputFileName+strlen(inputFileName);
2678 while((char_p=strchr(char_p,'.'))){
2679 dot_p=char_p;
2680 char_p++;
2683 if(outputFileName == NULL){
2684 /* file_out_name = inputFileName + _asn1_tab.c */
2685 file_out_name=(char *)malloc(dot_p-inputFileName+1+
2686 strlen("_asn1_tab.c"));
2687 memcpy(file_out_name,inputFileName,dot_p-inputFileName);
2688 file_out_name[dot_p-inputFileName]=0;
2689 strcat(file_out_name,"_asn1_tab.c");
2691 else{
2692 /* file_out_name = inputFileName */
2693 file_out_name=(char *)malloc(strlen(outputFileName)+1);
2694 strcpy(file_out_name,outputFileName);
2697 if(vectorName == NULL){
2698 /* vector_name = file name + _asn1_tab */
2699 vector_name=(char *)malloc(dot_p-slash_p+1+
2700 strlen("_asn1_tab"));
2701 memcpy(vector_name,slash_p,dot_p-slash_p);
2702 vector_name[dot_p-slash_p]=0;
2703 strcat(vector_name,"_asn1_tab");
2705 else{
2706 /* vector_name = vectorName */
2707 vector_name=(char *)malloc(strlen(vectorName)+1);
2708 strcpy(vector_name,vectorName);
2711 /* Save structure in a file */
2712 _asn1_create_static_structure(p_tree,
2713 file_out_name,vector_name);
2715 free(file_out_name);
2716 free(vector_name);
2717 } /* result == OK */
2718 } /* result == OK */
2720 /* Delete the list and the ASN1 structure */
2721 _asn1_delete_list_and_nodes();
2722 } /* inputFile exist */
2724 if (errorDescription!=NULL)
2725 _asn1_create_errorDescription(result_parse,errorDescription);
2727 return result_parse;
2731 /*************************************************************/
2732 /* Function: _asn1_yyerror */
2733 /* Description: function called when there are syntax errors*/
2734 /* Parameters: */
2735 /* char *s : error description */
2736 /* Return: int */
2737 /* */
2738 /*************************************************************/
2739 int _asn1_yyerror (char *s)
2741 /* Sends the error description to the std_out */
2743 #ifdef LIBTASN1_DEBUG_PARSER
2744 _libtasn1_log("_asn1_yyerror:%s:%d: %s (Last Token:'%s')\n",fileName,
2745 lineNumber,s,lastToken);
2746 #endif
2748 if(result_parse!=ASN1_NAME_TOO_LONG)
2749 result_parse=ASN1_SYNTAX_ERROR;
2751 return 0;