1 /* A Bison parser, made by GNU Bison 1.875a. */
3 /* Skeleton parser for Yacc-like parsing with Bison,
4 Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. */
21 /* As a special exception, when this file is copied by Bison into a
22 Bison output file, you may use that output file without restriction.
23 This special exception was added by the Free Software Foundation
24 in version 1.24 of Bison. */
26 /* Written by Richard Stallman by simplifying the original so called
27 ``semantic'' parser. */
29 /* All symbols defined below should begin with yy or YY, to avoid
30 infringing on user name space. This should be done even for local
31 variables, as they might otherwise be expanded by user macros.
32 There are some unavoidable exceptions within include files to
33 define necessary library symbols; they are noted "INFRINGES ON
34 USER NAME SPACE" below. */
36 /* Identify Bison output. */
40 #define YYSKELETON_NAME "yacc.c"
45 /* Using locations. */
46 #define YYLSP_NEEDED 0
48 /* If NAME_PREFIX is specified substitute the variables and functions
50 #define yyparse _asn1_yyparse
51 #define yylex _asn1_yylex
52 #define yyerror _asn1_yyerror
53 #define yylval _asn1_yylval
54 #define yychar _asn1_yychar
55 #define yydebug _asn1_yydebug
56 #define yynerrs _asn1_yynerrs
62 /* Put the tokens into the symbol table, so that GDB and other debuggers
98 GeneralizedTime
= 291,
107 #define IDENTIFIER 260
115 #define UNIVERSAL 268
117 #define APPLICATION 270
122 #define STR_IDENTIFIER 275
126 #define TOKEN_NULL 279
133 #define DEFINITIONS 286
138 #define GeneralizedTime 291
139 #define GeneralString 292
142 #define ENUMERATED 295
147 /* Copy the first part of user declarations. */
152 #include <parser_aux.h>
153 #include <structure.h>
156 static FILE *file_asn1
; /* Pointer to file to parse */
157 static asn1_retCode result_parse
; /* result of the parser
159 static node_asn
*p_tree
; /* pointer to the root of the
160 structure created by the
162 static unsigned long lineNumber
; /* line number describing the
163 parser position inside the
165 static char lastToken
[MAX_NAME_SIZE
+1]; /* last token find in the file
166 to parse before the 'parse
168 extern char _asn1_identifierMissing
[];
169 static const char *fileName
; /* file to parse */
171 int _asn1_yyerror (char *);
172 int _asn1_yylex(void);
176 /* Enabling traces. */
181 /* Enabling verbose error messages. */
182 #ifdef YYERROR_VERBOSE
183 # undef YYERROR_VERBOSE
184 # define YYERROR_VERBOSE 1
186 # define YYERROR_VERBOSE 0
189 #if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)
191 typedef union YYSTYPE
{
192 unsigned int constant
;
193 char str
[MAX_NAME_SIZE
+1];
196 /* Line 191 of yacc.c. */
198 # define yystype YYSTYPE /* obsolescent; will be withdrawn */
199 # define YYSTYPE_IS_DECLARED 1
200 # define YYSTYPE_IS_TRIVIAL 1
205 /* Copy the second part of user declarations. */
208 /* Line 214 of yacc.c. */
211 #if ! defined (yyoverflow) || YYERROR_VERBOSE
213 /* The parser invokes alloca or malloc; define the necessary symbols. */
215 # if YYSTACK_USE_ALLOCA
216 # define YYSTACK_ALLOC alloca
218 # ifndef YYSTACK_USE_ALLOCA
219 # if defined (alloca) || defined (_ALLOCA_H)
220 # define YYSTACK_ALLOC alloca
223 # define YYSTACK_ALLOC __builtin_alloca
229 # ifdef YYSTACK_ALLOC
230 /* Pacify GCC's `empty if-body' warning. */
231 # define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
233 # if defined (__STDC__) || defined (__cplusplus)
234 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
235 # define YYSIZE_T size_t
237 # define YYSTACK_ALLOC malloc
238 # define YYSTACK_FREE free
240 #endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */
243 #if (! defined (yyoverflow) \
244 && (! defined (__cplusplus) \
245 || (YYSTYPE_IS_TRIVIAL)))
247 /* A type that is properly aligned for any stack member. */
254 /* The size of the maximum gap between one aligned stack and the next. */
255 # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
257 /* The size of an array large to enough to hold all stacks, each with
259 # define YYSTACK_BYTES(N) \
260 ((N) * (sizeof (short) + sizeof (YYSTYPE)) \
261 + YYSTACK_GAP_MAXIMUM)
263 /* Copy COUNT objects from FROM to TO. The source and destination do
267 # define YYCOPY(To, From, Count) \
268 __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
270 # define YYCOPY(To, From, Count) \
273 register YYSIZE_T yyi; \
274 for (yyi = 0; yyi < (Count); yyi++) \
275 (To)[yyi] = (From)[yyi]; \
281 /* Relocate STACK from its old location to the new one. The
282 local variables YYSIZE and YYSTACKSIZE give the old and new number of
283 elements in the stack, and YYPTR gives the new location of the
284 stack. Advance YYPTR to a properly aligned location for the next
286 # define YYSTACK_RELOCATE(Stack) \
289 YYSIZE_T yynewbytes; \
290 YYCOPY (&yyptr->Stack, Stack, yysize); \
291 Stack = &yyptr->Stack; \
292 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
293 yyptr += yynewbytes / sizeof (*yyptr); \
299 #if defined (__STDC__) || defined (__cplusplus)
300 typedef signed char yysigned_char
;
302 typedef short yysigned_char
;
305 /* YYFINAL -- State number of the termination state. */
307 /* YYLAST -- Last index in YYTABLE. */
310 /* YYNTOKENS -- Number of terminals. */
312 /* YYNNTS -- Number of nonterminals. */
314 /* YYNRULES -- Number of rules. */
316 /* YYNRULES -- Number of states. */
317 #define YYNSTATES 189
319 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
321 #define YYMAXUTOK 295
323 #define YYTRANSLATE(YYX) \
324 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
326 /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
327 static const unsigned char yytranslate
[] =
329 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
330 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
331 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
332 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
333 43, 44, 2, 41, 45, 42, 51, 2, 2, 2,
334 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
335 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
336 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
337 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
338 2, 46, 2, 47, 2, 2, 2, 2, 2, 2,
339 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
340 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
341 2, 2, 2, 49, 48, 50, 2, 2, 2, 2,
342 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
343 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
344 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
345 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
346 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
347 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
348 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
349 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
350 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
351 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
352 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
353 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
354 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
355 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
356 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
357 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
358 35, 36, 37, 38, 39, 40
362 /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
364 static const unsigned short yyprhs
[] =
366 0, 0, 3, 12, 14, 17, 20, 22, 24, 26,
367 28, 30, 32, 36, 41, 43, 47, 49, 54, 56,
368 59, 61, 63, 65, 69, 74, 76, 79, 82, 85,
369 88, 91, 93, 97, 99, 104, 109, 117, 119, 121,
370 123, 128, 136, 138, 142, 144, 147, 150, 154, 159,
371 161, 165, 168, 174, 179, 182, 184, 187, 189, 191,
372 193, 195, 197, 199, 201, 203, 205, 207, 209, 211,
373 213, 215, 218, 220, 223, 226, 229, 231, 235, 240,
374 244, 249, 254, 258, 263, 268, 270, 275, 279, 287,
375 294, 299, 301, 303, 305, 308, 313, 317, 319
378 /* YYRHS -- A `-1'-separated list of the rules' RHS. */
379 static const yysigned_char yyrhs
[] =
381 53, 0, -1, 93, 31, 94, 32, 3, 33, 92,
382 34, -1, 4, -1, 41, 4, -1, 42, 4, -1,
383 54, -1, 55, -1, 4, -1, 5, -1, 56, -1,
384 5, -1, 43, 56, 44, -1, 5, 43, 56, 44,
385 -1, 59, -1, 60, 45, 59, -1, 57, -1, 5,
386 43, 4, 44, -1, 61, -1, 62, 61, -1, 13,
387 -1, 14, -1, 15, -1, 46, 4, 47, -1, 46,
388 63, 4, 47, -1, 64, -1, 64, 29, -1, 64,
389 30, -1, 16, 58, -1, 16, 22, -1, 16, 23,
390 -1, 56, -1, 67, 48, 56, -1, 7, -1, 7,
391 49, 60, 50, -1, 7, 43, 67, 44, -1, 7,
392 43, 57, 51, 51, 57, 44, -1, 21, -1, 35,
393 -1, 36, -1, 8, 43, 57, 44, -1, 8, 43,
394 57, 51, 51, 57, 44, -1, 71, -1, 43, 71,
395 44, -1, 37, -1, 37, 72, -1, 9, 10, -1,
396 9, 10, 72, -1, 5, 43, 4, 44, -1, 75,
397 -1, 76, 45, 75, -1, 12, 10, -1, 12, 10,
398 49, 76, 50, -1, 40, 49, 76, 50, -1, 19,
399 20, -1, 5, -1, 5, 72, -1, 68, -1, 78,
400 -1, 69, -1, 70, -1, 74, -1, 77, -1, 73,
401 -1, 85, -1, 79, -1, 87, -1, 88, -1, 86,
402 -1, 24, -1, 80, -1, 65, 80, -1, 81, -1,
403 81, 66, -1, 81, 6, -1, 5, 82, -1, 83,
404 -1, 84, 45, 83, -1, 11, 49, 84, 50, -1,
405 11, 18, 80, -1, 11, 72, 18, 80, -1, 28,
406 49, 84, 50, -1, 28, 18, 80, -1, 28, 72,
407 18, 80, -1, 17, 49, 84, 50, -1, 25, -1,
408 25, 26, 27, 5, -1, 5, 3, 81, -1, 5,
409 19, 20, 3, 49, 62, 50, -1, 5, 5, 3,
410 49, 62, 50, -1, 5, 7, 3, 56, -1, 89,
411 -1, 90, -1, 91, -1, 92, 91, -1, 5, 49,
412 62, 50, -1, 5, 49, 50, -1, 29, -1, 30,
416 /* YYRLINE[YYN] -- source line where rule number YYN was defined. */
417 static const unsigned short yyrline
[] =
419 0, 122, 122, 135, 136, 139, 143, 144, 147, 148,
420 151, 152, 155, 157, 162, 163, 167, 169, 174, 175,
421 179, 180, 181, 184, 186, 190, 191, 192, 195, 197,
422 198, 202, 203, 207, 208, 210, 211, 218, 221, 222,
423 225, 227, 233, 234, 237, 238, 242, 243, 247, 252,
424 253, 257, 258, 263, 269, 272, 274, 277, 278, 279,
425 280, 281, 282, 283, 284, 285, 286, 287, 288, 289,
426 292, 293, 298, 299, 302, 305, 308, 309, 313, 315,
427 317, 322, 324, 326, 331, 335, 336, 341, 344, 348,
428 353, 359, 360, 363, 364, 368, 371, 395, 396
432 #if YYDEBUG || YYERROR_VERBOSE
433 /* YYTNME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
434 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
435 static const char *const yytname
[] =
437 "$end", "error", "$undefined", "\"::=\"", "NUM", "IDENTIFIER", "OPTIONAL",
438 "INTEGER", "SIZE", "OCTET", "STRING", "SEQUENCE", "BIT", "UNIVERSAL",
439 "PRIVATE", "APPLICATION", "DEFAULT", "CHOICE", "OF", "OBJECT",
440 "STR_IDENTIFIER", "BOOLEAN", "TRUE", "FALSE", "TOKEN_NULL", "ANY",
441 "DEFINED", "BY", "SET", "EXPLICIT", "IMPLICIT", "DEFINITIONS", "TAGS",
442 "BEGIN", "END", "UTCTime", "GeneralizedTime", "GeneralString", "FROM",
443 "IMPORTS", "ENUMERATED", "'+'", "'-'", "'('", "')'", "','", "'['",
444 "']'", "'|'", "'{'", "'}'", "'.'", "$accept", "definitions", "pos_num",
445 "neg_num", "pos_neg_num", "num_identifier", "pos_neg_identifier",
446 "constant", "constant_list", "obj_constant", "obj_constant_list",
447 "class", "tag_type", "tag", "default", "pos_neg_list", "integer_def",
448 "boolean_def", "Time", "size_def2", "size_def", "generalstring_def",
449 "octet_string_def", "bit_element", "bit_element_list", "bit_string_def",
450 "enumerated_def", "object_def", "type_assig_right",
451 "type_assig_right_tag", "type_assig_right_tag_default", "type_assig",
452 "type_assig_list", "sequence_def", "set_def", "choise_def", "any_def",
453 "type_def", "constant_def", "type_constant", "type_constant_list",
454 "definitions_id", "explicit_implicit", 0
459 /* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
461 static const unsigned short yytoknum
[] =
463 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
464 265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
465 275, 276, 277, 278, 279, 280, 281, 282, 283, 284,
466 285, 286, 287, 288, 289, 290, 291, 292, 293, 294,
467 295, 43, 45, 40, 41, 44, 91, 93, 124, 123,
472 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
473 static const unsigned char yyr1
[] =
475 0, 52, 53, 54, 54, 55, 56, 56, 57, 57,
476 58, 58, 59, 59, 60, 60, 61, 61, 62, 62,
477 63, 63, 63, 64, 64, 65, 65, 65, 66, 66,
478 66, 67, 67, 68, 68, 68, 68, 69, 70, 70,
479 71, 71, 72, 72, 73, 73, 74, 74, 75, 76,
480 76, 77, 77, 78, 79, 80, 80, 80, 80, 80,
481 80, 80, 80, 80, 80, 80, 80, 80, 80, 80,
482 81, 81, 82, 82, 82, 83, 84, 84, 85, 85,
483 85, 86, 86, 86, 87, 88, 88, 89, 90, 90,
484 90, 91, 91, 92, 92, 93, 93, 94, 94
487 /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
488 static const unsigned char yyr2
[] =
490 0, 2, 8, 1, 2, 2, 1, 1, 1, 1,
491 1, 1, 3, 4, 1, 3, 1, 4, 1, 2,
492 1, 1, 1, 3, 4, 1, 2, 2, 2, 2,
493 2, 1, 3, 1, 4, 4, 7, 1, 1, 1,
494 4, 7, 1, 3, 1, 2, 2, 3, 4, 1,
495 3, 2, 5, 4, 2, 1, 2, 1, 1, 1,
496 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
497 1, 2, 1, 2, 2, 2, 1, 3, 4, 3,
498 4, 4, 3, 4, 4, 1, 4, 3, 7, 6,
499 4, 1, 1, 1, 2, 4, 3, 1, 1
502 /* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
503 STATE-NUM when YYTABLE doesn't specify something else to do. Zero
504 means the default is an error. */
505 static const unsigned char yydefact
[] =
507 0, 0, 0, 0, 0, 1, 0, 8, 9, 96,
508 16, 18, 0, 97, 98, 0, 0, 95, 19, 0,
509 0, 0, 17, 0, 0, 91, 92, 93, 0, 0,
510 0, 0, 0, 2, 94, 55, 33, 0, 0, 0,
511 0, 0, 37, 69, 85, 0, 38, 39, 44, 0,
512 0, 25, 0, 57, 59, 60, 63, 61, 62, 58,
513 65, 70, 87, 64, 68, 66, 67, 0, 0, 0,
514 0, 0, 42, 56, 0, 0, 46, 0, 0, 0,
515 51, 0, 54, 0, 0, 0, 0, 45, 0, 0,
516 20, 21, 22, 0, 26, 27, 71, 0, 3, 0,
517 0, 6, 7, 90, 0, 0, 0, 3, 9, 31,
518 0, 0, 0, 0, 14, 0, 47, 79, 0, 76,
519 0, 0, 0, 0, 0, 82, 0, 0, 0, 49,
520 0, 23, 0, 0, 4, 5, 0, 0, 43, 0,
521 35, 0, 0, 0, 0, 34, 72, 75, 0, 78,
522 80, 0, 84, 86, 81, 83, 0, 0, 53, 24,
523 89, 0, 40, 0, 0, 32, 0, 12, 15, 74,
524 0, 73, 77, 52, 0, 50, 88, 0, 0, 13,
525 11, 29, 30, 10, 28, 48, 0, 36, 41
528 /* YYDEFGOTO[NTERM-NUM]. */
529 static const short yydefgoto
[] =
531 -1, 2, 101, 102, 103, 10, 184, 114, 115, 11,
532 12, 93, 51, 52, 171, 111, 53, 54, 55, 72,
533 73, 56, 57, 129, 130, 58, 59, 60, 61, 62,
534 147, 119, 120, 63, 64, 65, 66, 25, 26, 27,
538 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
540 #define YYPACT_NINF -84
541 static const short yypact
[] =
543 18, -32, 33, 15, 0, -84, 90, -84, 49, -84,
544 -84, -84, 2, -84, -84, 11, 45, -84, -84, 57,
545 50, 43, -84, 100, 74, -84, -84, -84, 10, 78,
546 105, 113, 106, -84, -84, 5, -31, 126, 8, 128,
547 79, 120, -84, -84, 115, 12, -84, -84, 5, 95,
548 96, 102, 118, -84, -84, -84, -84, -84, -84, -84,
549 -84, -84, -84, -84, -84, -84, -84, 98, 23, 142,
550 107, 140, -84, -84, 32, 20, 5, 118, 146, 134,
551 108, 146, -84, 132, 118, 146, 138, -84, 155, 114,
552 -84, -84, -84, 158, -84, -84, -84, 63, -84, 159,
553 160, -84, -84, -84, 116, 129, 122, 117, -84, -84,
554 119, 38, 124, 23, -84, -3, -84, -84, 78, -84,
555 21, 118, 155, 30, 164, -84, 51, 118, 130, -84,
556 62, -84, 125, 4, -84, -84, 63, -6, -84, 123,
557 -84, 23, 23, 127, 20, -84, 13, -84, 146, -84,
558 -84, 72, -84, -84, -84, -84, 171, 155, -84, -84,
559 -84, 6, -84, 131, 129, -84, 133, -84, -84, -84,
560 17, -84, -84, -84, 135, -84, -84, 129, 136, -84,
561 -84, -84, -84, -84, -84, -84, 137, -84, -84
564 /* YYPGOTO[NTERM-NUM]. */
565 static const short yypgoto
[] =
567 -84, -84, -84, -84, -72, -73, -84, 34, -84, -12,
568 -83, -84, -84, -84, -84, -84, -84, -84, -84, 112,
569 -14, -84, -84, 19, 64, -84, -84, -84, -49, 66,
570 -84, 37, 3, -84, -84, -84, -84, -84, -84, 161,
574 /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
575 positive, shift that token. If negative, reduce the rule which
576 number is the opposite. If zero, do what YYDEFACT says.
577 If YYTABLE_NINF, syntax error. */
578 #define YYTABLE_NINF -9
579 static const short yytable
[] =
581 18, 110, 109, 96, 7, 8, 7, 8, 7, 8,
582 7, 8, 74, 70, 133, 24, 70, 4, 75, 169,
583 70, 98, 180, 1, 79, 112, 77, 98, 117, 170,
584 84, 86, 137, 5, 87, 125, 107, 108, 162, 181,
585 182, 143, 144, 19, 33, 163, 6, 145, 71, 20,
586 9, 71, 17, 161, 160, 71, 176, 78, 99, 100,
587 21, 85, 116, 113, 99, 100, 148, 7, 8, 165,
588 166, 149, 150, 99, 100, 148, 23, 29, 155, 30,
589 152, 31, 140, 35, 123, 36, 141, 37, 126, 38,
590 39, 178, 16, 32, 22, 40, 148, 41, 183, 42,
591 89, 154, 43, 44, 186, 24, 45, 157, 67, 90,
592 91, 92, 158, 46, 47, 48, 68, 157, 49, 13,
593 14, 18, 173, 35, 50, 36, 69, 37, 81, 38,
594 39, 94, 95, 7, 108, 40, 76, 41, 80, 42,
595 82, 83, 43, 44, 88, 104, 45, 97, 70, 18,
596 105, 118, 121, 46, 47, 48, 127, 122, 49, 124,
597 128, 131, 132, 134, 135, 136, 138, 142, -8, 153,
598 139, 167, 159, 156, 164, 174, 175, 179, 168, 185,
599 187, 188, 177, 106, 146, 172, 151, 0, 0, 34
602 static const short yycheck
[] =
604 12, 74, 74, 52, 4, 5, 4, 5, 4, 5,
605 4, 5, 43, 8, 97, 5, 8, 49, 49, 6,
606 8, 4, 5, 5, 38, 5, 18, 4, 77, 16,
607 18, 45, 105, 0, 48, 84, 4, 5, 44, 22,
608 23, 113, 45, 32, 34, 51, 31, 50, 43, 4,
609 50, 43, 50, 136, 50, 43, 50, 49, 41, 42,
610 3, 49, 76, 43, 41, 42, 45, 4, 5, 141,
611 142, 50, 121, 41, 42, 45, 33, 3, 127, 5,
612 50, 7, 44, 5, 81, 7, 48, 9, 85, 11,
613 12, 164, 43, 19, 44, 17, 45, 19, 170, 21,
614 4, 50, 24, 25, 177, 5, 28, 45, 3, 13,
615 14, 15, 50, 35, 36, 37, 3, 45, 40, 29,
616 30, 133, 50, 5, 46, 7, 20, 9, 49, 11,
617 12, 29, 30, 4, 5, 17, 10, 19, 10, 21,
618 20, 26, 24, 25, 49, 3, 28, 49, 8, 161,
619 43, 5, 18, 35, 36, 37, 18, 49, 40, 27,
620 5, 47, 4, 4, 4, 49, 44, 43, 51, 5,
621 51, 44, 47, 43, 51, 4, 157, 44, 144, 44,
622 44, 44, 51, 71, 118, 148, 122, -1, -1, 28
625 /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
626 symbol of state STATE-NUM. */
627 static const unsigned char yystos
[] =
629 0, 5, 53, 93, 49, 0, 31, 4, 5, 50,
630 57, 61, 62, 29, 30, 94, 43, 50, 61, 32,
631 4, 3, 44, 33, 5, 89, 90, 91, 92, 3,
632 5, 7, 19, 34, 91, 5, 7, 9, 11, 12,
633 17, 19, 21, 24, 25, 28, 35, 36, 37, 40,
634 46, 64, 65, 68, 69, 70, 73, 74, 77, 78,
635 79, 80, 81, 85, 86, 87, 88, 3, 3, 20,
636 8, 43, 71, 72, 43, 49, 10, 18, 49, 72,
637 10, 49, 20, 26, 18, 49, 72, 72, 49, 4,
638 13, 14, 15, 63, 29, 30, 80, 49, 4, 41,
639 42, 54, 55, 56, 3, 43, 71, 4, 5, 56,
640 57, 67, 5, 43, 59, 60, 72, 80, 5, 83,
641 84, 18, 49, 84, 27, 80, 84, 18, 5, 75,
642 76, 47, 4, 62, 4, 4, 49, 57, 44, 51,
643 44, 48, 43, 56, 45, 50, 81, 82, 45, 50,
644 80, 76, 50, 5, 50, 80, 43, 45, 50, 47,
645 50, 62, 44, 51, 51, 56, 56, 44, 59, 6,
646 16, 66, 83, 50, 4, 75, 50, 51, 57, 44,
647 5, 22, 23, 56, 58, 44, 57, 44, 44
650 #if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__)
651 # define YYSIZE_T __SIZE_TYPE__
653 #if ! defined (YYSIZE_T) && defined (size_t)
654 # define YYSIZE_T size_t
656 #if ! defined (YYSIZE_T)
657 # if defined (__STDC__) || defined (__cplusplus)
658 # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
659 # define YYSIZE_T size_t
662 #if ! defined (YYSIZE_T)
663 # define YYSIZE_T unsigned int
666 #define yyerrok (yyerrstatus = 0)
667 #define yyclearin (yychar = YYEMPTY)
671 #define YYACCEPT goto yyacceptlab
672 #define YYABORT goto yyabortlab
673 #define YYERROR goto yyerrlab1
676 /* Like YYERROR except do call yyerror. This remains here temporarily
677 to ease the transition to the new meaning of YYERROR, for GCC.
678 Once GCC version 2 has supplanted version 1, this can go. */
680 #define YYFAIL goto yyerrlab
682 #define YYRECOVERING() (!!yyerrstatus)
684 #define YYBACKUP(Token, Value) \
686 if (yychar == YYEMPTY && yylen == 1) \
690 yytoken = YYTRANSLATE (yychar); \
696 yyerror ("syntax error: cannot back up");\
702 #define YYERRCODE 256
704 /* YYLLOC_DEFAULT -- Compute the default location (before the actions
707 #ifndef YYLLOC_DEFAULT
708 # define YYLLOC_DEFAULT(Current, Rhs, N) \
709 Current.first_line = Rhs[1].first_line; \
710 Current.first_column = Rhs[1].first_column; \
711 Current.last_line = Rhs[N].last_line; \
712 Current.last_column = Rhs[N].last_column;
715 /* YYLEX -- calling `yylex' with the right arguments. */
718 # define YYLEX yylex (YYLEX_PARAM)
720 # define YYLEX yylex ()
723 /* Enable debugging if requested. */
727 # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
728 # define YYFPRINTF fprintf
731 # define YYDPRINTF(Args) \
737 # define YYDSYMPRINT(Args) \
743 # define YYDSYMPRINTF(Title, Token, Value, Location) \
747 YYFPRINTF (stderr, "%s ", Title); \
748 yysymprint (stderr, \
750 YYFPRINTF (stderr, "\n"); \
754 /*------------------------------------------------------------------.
755 | yy_stack_print -- Print the state stack from its BOTTOM up to its |
757 `------------------------------------------------------------------*/
759 #if defined (__STDC__) || defined (__cplusplus)
761 yy_stack_print (short *bottom
, short *top
)
764 yy_stack_print (bottom
, top
)
769 YYFPRINTF (stderr
, "Stack now");
770 for (/* Nothing. */; bottom
<= top
; ++bottom
)
771 YYFPRINTF (stderr
, " %d", *bottom
);
772 YYFPRINTF (stderr
, "\n");
775 # define YY_STACK_PRINT(Bottom, Top) \
778 yy_stack_print ((Bottom), (Top)); \
782 /*------------------------------------------------.
783 | Report that the YYRULE is going to be reduced. |
784 `------------------------------------------------*/
786 #if defined (__STDC__) || defined (__cplusplus)
788 yy_reduce_print (int yyrule
)
791 yy_reduce_print (yyrule
)
796 unsigned int yylineno
= yyrline
[yyrule
];
797 YYFPRINTF (stderr
, "Reducing stack by rule %d (line %u), ",
798 yyrule
- 1, yylineno
);
799 /* Print the symbols being reduced, and their result. */
800 for (yyi
= yyprhs
[yyrule
]; 0 <= yyrhs
[yyi
]; yyi
++)
801 YYFPRINTF (stderr
, "%s ", yytname
[yyrhs
[yyi
]]);
802 YYFPRINTF (stderr
, "-> %s\n", yytname
[yyr1
[yyrule
]]);
805 # define YY_REDUCE_PRINT(Rule) \
808 yy_reduce_print (Rule); \
811 /* Nonzero means print parse trace. It is left uninitialized so that
812 multiple parsers can coexist. */
815 # define YYDPRINTF(Args)
816 # define YYDSYMPRINT(Args)
817 # define YYDSYMPRINTF(Title, Token, Value, Location)
818 # define YY_STACK_PRINT(Bottom, Top)
819 # define YY_REDUCE_PRINT(Rule)
820 #endif /* !YYDEBUG */
823 /* YYINITDEPTH -- initial size of the parser's stacks. */
825 # define YYINITDEPTH 200
828 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
829 if the built-in stack extension method is used).
831 Do not make this value too large; the results are undefined if
832 SIZE_MAX < YYSTACK_BYTES (YYMAXDEPTH)
833 evaluated with infinite-precision integer arithmetic. */
840 # define YYMAXDEPTH 10000
848 # if defined (__GLIBC__) && defined (_STRING_H)
849 # define yystrlen strlen
851 /* Return the length of YYSTR. */
853 # if defined (__STDC__) || defined (__cplusplus)
854 yystrlen (const char *yystr
)
860 register const char *yys
= yystr
;
862 while (*yys
++ != '\0')
865 return yys
- yystr
- 1;
871 # if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE)
872 # define yystpcpy stpcpy
874 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
877 # if defined (__STDC__) || defined (__cplusplus)
878 yystpcpy (char *yydest
, const char *yysrc
)
880 yystpcpy (yydest
, yysrc
)
885 register char *yyd
= yydest
;
886 register const char *yys
= yysrc
;
888 while ((*yyd
++ = *yys
++) != '\0')
896 #endif /* !YYERROR_VERBOSE */
901 /*--------------------------------.
902 | Print this symbol on YYOUTPUT. |
903 `--------------------------------*/
905 #if defined (__STDC__) || defined (__cplusplus)
907 yysymprint (FILE *yyoutput
, int yytype
, YYSTYPE
*yyvaluep
)
910 yysymprint (yyoutput
, yytype
, yyvaluep
)
916 /* Pacify ``unused variable'' warnings. */
919 if (yytype
< YYNTOKENS
)
921 YYFPRINTF (yyoutput
, "token %s (", yytname
[yytype
]);
923 YYPRINT (yyoutput
, yytoknum
[yytype
], *yyvaluep
);
927 YYFPRINTF (yyoutput
, "nterm %s (", yytname
[yytype
]);
934 YYFPRINTF (yyoutput
, ")");
937 #endif /* ! YYDEBUG */
938 /*-----------------------------------------------.
939 | Release the memory associated to this symbol. |
940 `-----------------------------------------------*/
942 #if defined (__STDC__) || defined (__cplusplus)
944 yydestruct (int yytype
, YYSTYPE
*yyvaluep
)
947 yydestruct (yytype
, yyvaluep
)
952 /* Pacify ``unused variable'' warnings. */
964 /* Prevent warnings from -Wmissing-prototypes. */
967 # if defined (__STDC__) || defined (__cplusplus)
968 int yyparse (void *YYPARSE_PARAM
);
972 #else /* ! YYPARSE_PARAM */
973 #if defined (__STDC__) || defined (__cplusplus)
978 #endif /* ! YYPARSE_PARAM */
982 /* The lookahead symbol. */
985 /* The semantic value of the lookahead symbol. */
988 /* Number of syntax errors so far. */
998 # if defined (__STDC__) || defined (__cplusplus)
999 int yyparse (void *YYPARSE_PARAM
)
1001 int yyparse (YYPARSE_PARAM
)
1002 void *YYPARSE_PARAM
;
1004 #else /* ! YYPARSE_PARAM */
1005 #if defined (__STDC__) || defined (__cplusplus)
1016 register int yystate
;
1019 /* Number of tokens to shift before error messages enabled. */
1021 /* Lookahead token as an internal (translated) token number. */
1024 /* Three stacks and their tools:
1025 `yyss': related to states,
1026 `yyvs': related to semantic values,
1027 `yyls': related to locations.
1029 Refer to the stacks thru separate pointers, to allow yyoverflow
1030 to reallocate them elsewhere. */
1032 /* The state stack. */
1033 short yyssa
[YYINITDEPTH
];
1034 short *yyss
= yyssa
;
1035 register short *yyssp
;
1037 /* The semantic value stack. */
1038 YYSTYPE yyvsa
[YYINITDEPTH
];
1039 YYSTYPE
*yyvs
= yyvsa
;
1040 register YYSTYPE
*yyvsp
;
1044 #define YYPOPSTACK (yyvsp--, yyssp--)
1046 YYSIZE_T yystacksize
= YYINITDEPTH
;
1048 /* The variables used to return semantic value and location from the
1053 /* When reducing, the number of symbols on the RHS of the reduced
1057 YYDPRINTF ((stderr
, "Starting parse\n"));
1062 yychar
= YYEMPTY
; /* Cause a token to be read. */
1064 /* Initialize stack pointers.
1065 Waste one element of value and location stack
1066 so that they stay on the same level as the state stack.
1067 The wasted elements are never initialized. */
1074 /*------------------------------------------------------------.
1075 | yynewstate -- Push a new state, which is found in yystate. |
1076 `------------------------------------------------------------*/
1078 /* In all cases, when you get here, the value and location stacks
1079 have just been pushed. so pushing a state here evens the stacks.
1086 if (yyss
+ yystacksize
- 1 <= yyssp
)
1088 /* Get the current used size of the three stacks, in elements. */
1089 YYSIZE_T yysize
= yyssp
- yyss
+ 1;
1093 /* Give user a chance to reallocate the stack. Use copies of
1094 these so that the &'s don't force the real ones into
1096 YYSTYPE
*yyvs1
= yyvs
;
1097 short *yyss1
= yyss
;
1100 /* Each stack pointer address is followed by the size of the
1101 data in use in that stack, in bytes. This used to be a
1102 conditional around just the two extra args, but that might
1103 be undefined if yyoverflow is a macro. */
1104 yyoverflow ("parser stack overflow",
1105 &yyss1
, yysize
* sizeof (*yyssp
),
1106 &yyvs1
, yysize
* sizeof (*yyvsp
),
1113 #else /* no yyoverflow */
1114 # ifndef YYSTACK_RELOCATE
1117 /* Extend the stack our own way. */
1118 if (YYMAXDEPTH
<= yystacksize
)
1121 if (YYMAXDEPTH
< yystacksize
)
1122 yystacksize
= YYMAXDEPTH
;
1125 short *yyss1
= yyss
;
1126 union yyalloc
*yyptr
=
1127 (union yyalloc
*) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize
));
1130 YYSTACK_RELOCATE (yyss
);
1131 YYSTACK_RELOCATE (yyvs
);
1133 # undef YYSTACK_RELOCATE
1135 YYSTACK_FREE (yyss1
);
1138 #endif /* no yyoverflow */
1140 yyssp
= yyss
+ yysize
- 1;
1141 yyvsp
= yyvs
+ yysize
- 1;
1144 YYDPRINTF ((stderr
, "Stack size increased to %lu\n",
1145 (unsigned long int) yystacksize
));
1147 if (yyss
+ yystacksize
- 1 <= yyssp
)
1151 YYDPRINTF ((stderr
, "Entering state %d\n", yystate
));
1160 /* Do appropriate processing given the current state. */
1161 /* Read a lookahead token if we need one and don't already have one. */
1164 /* First try to decide what to do without reference to lookahead token. */
1166 yyn
= yypact
[yystate
];
1167 if (yyn
== YYPACT_NINF
)
1170 /* Not known => get a lookahead token if don't already have one. */
1172 /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */
1173 if (yychar
== YYEMPTY
)
1175 YYDPRINTF ((stderr
, "Reading a token: "));
1179 if (yychar
<= YYEOF
)
1181 yychar
= yytoken
= YYEOF
;
1182 YYDPRINTF ((stderr
, "Now at end of input.\n"));
1186 yytoken
= YYTRANSLATE (yychar
);
1187 YYDSYMPRINTF ("Next token is", yytoken
, &yylval
, &yylloc
);
1190 /* If the proper action on seeing token YYTOKEN is to reduce or to
1191 detect an error, take that action. */
1193 if (yyn
< 0 || YYLAST
< yyn
|| yycheck
[yyn
] != yytoken
)
1198 if (yyn
== 0 || yyn
== YYTABLE_NINF
)
1207 /* Shift the lookahead token. */
1208 YYDPRINTF ((stderr
, "Shifting token %s, ", yytname
[yytoken
]));
1210 /* Discard the token being shifted unless it is eof. */
1211 if (yychar
!= YYEOF
)
1217 /* Count tokens shifted since error; after three, turn off error
1226 /*-----------------------------------------------------------.
1227 | yydefault -- do the default action for the current state. |
1228 `-----------------------------------------------------------*/
1230 yyn
= yydefact
[yystate
];
1236 /*-----------------------------.
1237 | yyreduce -- Do a reduction. |
1238 `-----------------------------*/
1240 /* yyn is the number of a rule to reduce with. */
1243 /* If YYLEN is nonzero, implement the default value of the action:
1246 Otherwise, the following line sets YYVAL to garbage.
1247 This behavior is undocumented and Bison
1248 users should not rely upon it. Assigning to YYVAL
1249 unconditionally makes the parser a bit smaller, and it avoids a
1250 GCC warning that YYVAL may be used uninitialized. */
1251 yyval
= yyvsp
[1-yylen
];
1254 YY_REDUCE_PRINT (yyn
);
1259 {yyval
.node
=_asn1_add_node(TYPE_DEFINITIONS
|yyvsp
[-5].constant
);
1260 _asn1_set_name(yyval
.node
,_asn1_get_name(yyvsp
[-7].node
));
1261 _asn1_set_name(yyvsp
[-7].node
,"");
1262 _asn1_set_right(yyvsp
[-7].node
,yyvsp
[-1].node
);
1263 _asn1_set_down(yyval
.node
,yyvsp
[-7].node
);
1271 {strcpy(yyval
.str
,yyvsp
[0].str
);}
1276 {strcpy(yyval
.str
,yyvsp
[0].str
);}
1281 {strcpy(yyval
.str
,"-");
1282 strcat(yyval
.str
,yyvsp
[0].str
);}
1287 {strcpy(yyval
.str
,yyvsp
[0].str
);}
1292 {strcpy(yyval
.str
,yyvsp
[0].str
);}
1297 {strcpy(yyval
.str
,yyvsp
[0].str
);}
1302 {strcpy(yyval
.str
,yyvsp
[0].str
);}
1307 {strcpy(yyval
.str
,yyvsp
[0].str
);}
1312 {strcpy(yyval
.str
,yyvsp
[0].str
);}
1317 {yyval
.node
=_asn1_add_node(TYPE_CONSTANT
);
1318 _asn1_set_value(yyval
.node
,yyvsp
[-1].str
,strlen(yyvsp
[-1].str
)+1);}
1323 {yyval
.node
=_asn1_add_node(TYPE_CONSTANT
);
1324 _asn1_set_name(yyval
.node
,yyvsp
[-3].str
);
1325 _asn1_set_value(yyval
.node
,yyvsp
[-1].str
,strlen(yyvsp
[-1].str
)+1);}
1330 {yyval
.node
=yyvsp
[0].node
;}
1335 {yyval
.node
=yyvsp
[-2].node
;
1336 _asn1_set_right(_asn1_get_last_right(yyvsp
[-2].node
),yyvsp
[0].node
);}
1341 {yyval
.node
=_asn1_add_node(TYPE_CONSTANT
);
1342 _asn1_set_value(yyval
.node
,yyvsp
[0].str
,strlen(yyvsp
[0].str
)+1);}
1347 {yyval
.node
=_asn1_add_node(TYPE_CONSTANT
);
1348 _asn1_set_name(yyval
.node
,yyvsp
[-3].str
);
1349 _asn1_set_value(yyval
.node
,yyvsp
[-1].str
,strlen(yyvsp
[-1].str
)+1);}
1354 {yyval
.node
=yyvsp
[0].node
;}
1359 {yyval
.node
=yyvsp
[-1].node
;
1360 _asn1_set_right(_asn1_get_last_right(yyvsp
[-1].node
),yyvsp
[0].node
);}
1365 {yyval
.constant
=CONST_UNIVERSAL
;}
1370 {yyval
.constant
=CONST_PRIVATE
;}
1375 {yyval
.constant
=CONST_APPLICATION
;}
1380 {yyval
.node
=_asn1_add_node(TYPE_TAG
);
1381 _asn1_set_value(yyval
.node
,yyvsp
[-1].str
,strlen(yyvsp
[-1].str
)+1);}
1386 {yyval
.node
=_asn1_add_node(TYPE_TAG
| yyvsp
[-2].constant
);
1387 _asn1_set_value(yyval
.node
,yyvsp
[-1].str
,strlen(yyvsp
[-1].str
)+1);}
1392 {yyval
.node
=yyvsp
[0].node
;}
1397 {yyval
.node
=_asn1_mod_type(yyvsp
[-1].node
,CONST_EXPLICIT
);}
1402 {yyval
.node
=_asn1_mod_type(yyvsp
[-1].node
,CONST_IMPLICIT
);}
1407 {yyval
.node
=_asn1_add_node(TYPE_DEFAULT
);
1408 _asn1_set_value(yyval
.node
,yyvsp
[0].str
,strlen(yyvsp
[0].str
)+1);}
1413 {yyval
.node
=_asn1_add_node(TYPE_DEFAULT
|CONST_TRUE
);}
1418 {yyval
.node
=_asn1_add_node(TYPE_DEFAULT
|CONST_FALSE
);}
1423 {yyval
.node
=_asn1_add_node(TYPE_INTEGER
);}
1428 {yyval
.node
=_asn1_add_node(TYPE_INTEGER
|CONST_LIST
);
1429 _asn1_set_down(yyval
.node
,yyvsp
[-1].node
);}
1434 {yyval
.node
=_asn1_add_node(TYPE_INTEGER
);}
1439 {yyval
.node
=_asn1_add_node(TYPE_INTEGER
|CONST_MIN_MAX
);
1440 _asn1_set_down(yyval
.node
,_asn1_add_node(TYPE_SIZE
));
1441 _asn1_set_value(_asn1_get_down(yyval
.node
),yyvsp
[-1].str
,strlen(yyvsp
[-1].str
)+1);
1442 _asn1_set_name(_asn1_get_down(yyval
.node
),yyvsp
[-4].str
);}
1447 {yyval
.node
=_asn1_add_node(TYPE_BOOLEAN
);}
1452 {yyval
.node
=_asn1_add_node(TYPE_TIME
|CONST_UTC
);}
1457 {yyval
.node
=_asn1_add_node(TYPE_TIME
|CONST_GENERALIZED
);}
1462 {yyval
.node
=_asn1_add_node(TYPE_SIZE
|CONST_1_PARAM
);
1463 _asn1_set_value(yyval
.node
,yyvsp
[-1].str
,strlen(yyvsp
[-1].str
)+1);}
1468 {yyval
.node
=_asn1_add_node(TYPE_SIZE
|CONST_MIN_MAX
);
1469 _asn1_set_value(yyval
.node
,yyvsp
[-4].str
,strlen(yyvsp
[-4].str
)+1);
1470 _asn1_set_name(yyval
.node
,yyvsp
[-1].str
);}
1475 {yyval
.node
=yyvsp
[0].node
;}
1480 {yyval
.node
=yyvsp
[-1].node
;}
1485 {yyval
.node
=_asn1_add_node(TYPE_GENERALSTRING
);}
1490 {yyval
.node
=_asn1_add_node(TYPE_GENERALSTRING
|CONST_SIZE
);
1491 _asn1_set_down(yyval
.node
,yyvsp
[0].node
);}
1496 {yyval
.node
=_asn1_add_node(TYPE_OCTET_STRING
);}
1501 {yyval
.node
=_asn1_add_node(TYPE_OCTET_STRING
|CONST_SIZE
);
1502 _asn1_set_down(yyval
.node
,yyvsp
[0].node
);}
1507 {yyval
.node
=_asn1_add_node(TYPE_CONSTANT
);
1508 _asn1_set_name(yyval
.node
,yyvsp
[-3].str
);
1509 _asn1_set_value(yyval
.node
,yyvsp
[-1].str
,strlen(yyvsp
[-1].str
)+1);}
1514 {yyval
.node
=yyvsp
[0].node
;}
1519 {yyval
.node
=yyvsp
[-2].node
;
1520 _asn1_set_right(_asn1_get_last_right(yyvsp
[-2].node
),yyvsp
[0].node
);}
1525 {yyval
.node
=_asn1_add_node(TYPE_BIT_STRING
);}
1530 {yyval
.node
=_asn1_add_node(TYPE_BIT_STRING
|CONST_LIST
);
1531 _asn1_set_down(yyval
.node
,yyvsp
[-1].node
);}
1536 {yyval
.node
=_asn1_add_node(TYPE_ENUMERATED
|CONST_LIST
);
1537 _asn1_set_down(yyval
.node
,yyvsp
[-1].node
);}
1542 {yyval
.node
=_asn1_add_node(TYPE_OBJECT_ID
);}
1547 {yyval
.node
=_asn1_add_node(TYPE_IDENTIFIER
);
1548 _asn1_set_value(yyval
.node
,yyvsp
[0].str
,strlen(yyvsp
[0].str
)+1);}
1553 {yyval
.node
=_asn1_add_node(TYPE_IDENTIFIER
|CONST_SIZE
);
1554 _asn1_set_value(yyval
.node
,yyvsp
[-1].str
,strlen(yyvsp
[-1].str
)+1);
1555 _asn1_set_down(yyval
.node
,yyvsp
[0].node
);}
1560 {yyval
.node
=yyvsp
[0].node
;}
1565 {yyval
.node
=yyvsp
[0].node
;}
1570 {yyval
.node
=yyvsp
[0].node
;}
1575 {yyval
.node
=yyvsp
[0].node
;}
1580 {yyval
.node
=yyvsp
[0].node
;}
1585 {yyval
.node
=yyvsp
[0].node
;}
1590 {yyval
.node
=yyvsp
[0].node
;}
1595 {yyval
.node
=yyvsp
[0].node
;}
1600 {yyval
.node
=yyvsp
[0].node
;}
1605 {yyval
.node
=yyvsp
[0].node
;}
1610 {yyval
.node
=yyvsp
[0].node
;}
1615 {yyval
.node
=_asn1_add_node(TYPE_NULL
);}
1620 {yyval
.node
=yyvsp
[0].node
;}
1625 {yyval
.node
=_asn1_mod_type(yyvsp
[0].node
,CONST_TAG
);
1626 _asn1_set_right(yyvsp
[-1].node
,_asn1_get_down(yyval
.node
));
1627 _asn1_set_down(yyval
.node
,yyvsp
[-1].node
);}
1632 {yyval
.node
=yyvsp
[0].node
;}
1637 {yyval
.node
=_asn1_mod_type(yyvsp
[-1].node
,CONST_DEFAULT
);
1638 _asn1_set_right(yyvsp
[0].node
,_asn1_get_down(yyval
.node
));
1639 _asn1_set_down(yyval
.node
,yyvsp
[0].node
);}
1644 {yyval
.node
=_asn1_mod_type(yyvsp
[-1].node
,CONST_OPTION
);}
1649 {yyval
.node
=_asn1_set_name(yyvsp
[0].node
,yyvsp
[-1].str
);}
1654 {yyval
.node
=yyvsp
[0].node
;}
1659 {yyval
.node
=yyvsp
[-2].node
;
1660 _asn1_set_right(_asn1_get_last_right(yyvsp
[-2].node
),yyvsp
[0].node
);}
1665 {yyval
.node
=_asn1_add_node(TYPE_SEQUENCE
);
1666 _asn1_set_down(yyval
.node
,yyvsp
[-1].node
);}
1671 {yyval
.node
=_asn1_add_node(TYPE_SEQUENCE_OF
);
1672 _asn1_set_down(yyval
.node
,yyvsp
[0].node
);}
1677 {yyval
.node
=_asn1_add_node(TYPE_SEQUENCE_OF
|CONST_SIZE
);
1678 _asn1_set_right(yyvsp
[-2].node
,yyvsp
[0].node
);
1679 _asn1_set_down(yyval
.node
,yyvsp
[-2].node
);}
1684 {yyval
.node
=_asn1_add_node(TYPE_SET
);
1685 _asn1_set_down(yyval
.node
,yyvsp
[-1].node
);}
1690 {yyval
.node
=_asn1_add_node(TYPE_SET_OF
);
1691 _asn1_set_down(yyval
.node
,yyvsp
[0].node
);}
1696 {yyval
.node
=_asn1_add_node(TYPE_SET_OF
|CONST_SIZE
);
1697 _asn1_set_right(yyvsp
[-2].node
,yyvsp
[0].node
);
1698 _asn1_set_down(yyval
.node
,yyvsp
[-2].node
);}
1703 {yyval
.node
=_asn1_add_node(TYPE_CHOICE
);
1704 _asn1_set_down(yyval
.node
,yyvsp
[-1].node
);}
1709 {yyval
.node
=_asn1_add_node(TYPE_ANY
);}
1714 {yyval
.node
=_asn1_add_node(TYPE_ANY
|CONST_DEFINED_BY
);
1715 _asn1_set_down(yyval
.node
,_asn1_add_node(TYPE_CONSTANT
));
1716 _asn1_set_name(_asn1_get_down(yyval
.node
),yyvsp
[0].str
);}
1721 {yyval
.node
=_asn1_set_name(yyvsp
[0].node
,yyvsp
[-2].str
);}
1726 {yyval
.node
=_asn1_add_node(TYPE_OBJECT_ID
|CONST_ASSIGN
);
1727 _asn1_set_name(yyval
.node
,yyvsp
[-6].str
);
1728 _asn1_set_down(yyval
.node
,yyvsp
[-1].node
);}
1733 {yyval
.node
=_asn1_add_node(TYPE_OBJECT_ID
|CONST_ASSIGN
|CONST_1_PARAM
);
1734 _asn1_set_name(yyval
.node
,yyvsp
[-5].str
);
1735 _asn1_set_value(yyval
.node
,yyvsp
[-4].str
,strlen(yyvsp
[-4].str
)+1);
1736 _asn1_set_down(yyval
.node
,yyvsp
[-1].node
);}
1741 {yyval
.node
=_asn1_add_node(TYPE_INTEGER
|CONST_ASSIGN
);
1742 _asn1_set_name(yyval
.node
,yyvsp
[-3].str
);
1743 _asn1_set_value(yyval
.node
,yyvsp
[0].str
,strlen(yyvsp
[0].str
)+1);}
1748 {yyval
.node
=yyvsp
[0].node
;}
1753 {yyval
.node
=yyvsp
[0].node
;}
1758 {yyval
.node
=yyvsp
[0].node
;}
1763 {yyval
.node
=yyvsp
[-1].node
;
1764 _asn1_set_right(_asn1_get_last_right(yyvsp
[-1].node
),yyvsp
[0].node
);}
1769 {yyval
.node
=_asn1_add_node(TYPE_OBJECT_ID
);
1770 _asn1_set_down(yyval
.node
,yyvsp
[-1].node
);
1771 _asn1_set_name(yyval
.node
,yyvsp
[-3].str
);}
1776 {yyval
.node
=_asn1_add_node(TYPE_OBJECT_ID
);
1777 _asn1_set_name(yyval
.node
,yyvsp
[-2].str
);}
1782 {yyval
.constant
=CONST_EXPLICIT
;}
1787 {yyval
.constant
=CONST_IMPLICIT
;}
1793 /* Line 999 of yacc.c. */
1800 YY_STACK_PRINT (yyss
, yyssp
);
1805 /* Now `shift' the result of the reduction. Determine what state
1806 that goes to, based on the state we popped back to and the rule
1807 number reduced by. */
1811 yystate
= yypgoto
[yyn
- YYNTOKENS
] + *yyssp
;
1812 if (0 <= yystate
&& yystate
<= YYLAST
&& yycheck
[yystate
] == *yyssp
)
1813 yystate
= yytable
[yystate
];
1815 yystate
= yydefgoto
[yyn
- YYNTOKENS
];
1820 /*------------------------------------.
1821 | yyerrlab -- here on detecting error |
1822 `------------------------------------*/
1824 /* If not already recovering from an error, report this error. */
1829 yyn
= yypact
[yystate
];
1831 if (YYPACT_NINF
< yyn
&& yyn
< YYLAST
)
1833 YYSIZE_T yysize
= 0;
1834 int yytype
= YYTRANSLATE (yychar
);
1839 /* Start YYX at -YYN if negative to avoid negative indexes in
1841 for (yyx
= yyn
< 0 ? -yyn
: 0;
1842 yyx
< (int) (sizeof (yytname
) / sizeof (char *)); yyx
++)
1843 if (yycheck
[yyx
+ yyn
] == yyx
&& yyx
!= YYTERROR
)
1844 yysize
+= yystrlen (yytname
[yyx
]) + 15, yycount
++;
1845 yysize
+= yystrlen ("syntax error, unexpected ") + 1;
1846 yysize
+= yystrlen (yytname
[yytype
]);
1847 yymsg
= (char *) YYSTACK_ALLOC (yysize
);
1850 char *yyp
= yystpcpy (yymsg
, "syntax error, unexpected ");
1851 yyp
= yystpcpy (yyp
, yytname
[yytype
]);
1856 for (yyx
= yyn
< 0 ? -yyn
: 0;
1857 yyx
< (int) (sizeof (yytname
) / sizeof (char *));
1859 if (yycheck
[yyx
+ yyn
] == yyx
&& yyx
!= YYTERROR
)
1861 const char *yyq
= ! yycount
? ", expecting " : " or ";
1862 yyp
= yystpcpy (yyp
, yyq
);
1863 yyp
= yystpcpy (yyp
, yytname
[yyx
]);
1868 YYSTACK_FREE (yymsg
);
1871 yyerror ("syntax error; also virtual memory exhausted");
1874 #endif /* YYERROR_VERBOSE */
1875 yyerror ("syntax error");
1880 if (yyerrstatus
== 3)
1882 /* If just tried and failed to reuse lookahead token after an
1883 error, discard it. */
1885 /* Return failure if at end of input. */
1886 if (yychar
== YYEOF
)
1888 /* Pop the error token. */
1890 /* Pop the rest of the stack. */
1891 while (yyss
< yyssp
)
1893 YYDSYMPRINTF ("Error: popping", yystos
[*yyssp
], yyvsp
, yylsp
);
1894 yydestruct (yystos
[*yyssp
], yyvsp
);
1900 YYDSYMPRINTF ("Error: discarding", yytoken
, &yylval
, &yylloc
);
1901 yydestruct (yytoken
, &yylval
);
1906 /* Else will try to reuse lookahead token after shifting the error
1911 /*----------------------------------------------------.
1912 | yyerrlab1 -- error raised explicitly by an action. |
1913 `----------------------------------------------------*/
1915 yyerrstatus
= 3; /* Each real token shifted decrements this. */
1919 yyn
= yypact
[yystate
];
1920 if (yyn
!= YYPACT_NINF
)
1923 if (0 <= yyn
&& yyn
<= YYLAST
&& yycheck
[yyn
] == YYTERROR
)
1931 /* Pop the current state because it cannot handle the error token. */
1935 YYDSYMPRINTF ("Error: popping", yystos
[*yyssp
], yyvsp
, yylsp
);
1936 yydestruct (yystos
[yystate
], yyvsp
);
1940 YY_STACK_PRINT (yyss
, yyssp
);
1946 YYDPRINTF ((stderr
, "Shifting error token, "));
1955 /*-------------------------------------.
1956 | yyacceptlab -- YYACCEPT comes here. |
1957 `-------------------------------------*/
1962 /*-----------------------------------.
1963 | yyabortlab -- YYABORT comes here. |
1964 `-----------------------------------*/
1970 /*----------------------------------------------.
1971 | yyoverflowlab -- parser overflow comes here. |
1972 `----------------------------------------------*/
1974 yyerror ("parser stack overflow");
1982 YYSTACK_FREE (yyss
);
1993 const char *key_word
[]={"::=","OPTIONAL","INTEGER","SIZE","OCTET","STRING"
1994 ,"SEQUENCE","BIT","UNIVERSAL","PRIVATE","OPTIONAL"
1995 ,"DEFAULT","CHOICE","OF","OBJECT","IDENTIFIER"
1996 ,"BOOLEAN","TRUE","FALSE","APPLICATION","ANY","DEFINED"
1997 ,"SET","BY","EXPLICIT","IMPLICIT","DEFINITIONS","TAGS"
1998 ,"BEGIN","END","UTCTime","GeneralizedTime"
1999 ,"GeneralString","FROM","IMPORTS","NULL","ENUMERATED"};
2000 const int key_word_token
[]={ASSIG
,OPTIONAL
,INTEGER
,SIZE
,OCTET
,STRING
2001 ,SEQUENCE
,BIT
,UNIVERSAL
,PRIVATE
,OPTIONAL
2002 ,DEFAULT
,CHOICE
,OF
,OBJECT
,STR_IDENTIFIER
2003 ,BOOLEAN
,TRUE
,FALSE
,APPLICATION
,ANY
,DEFINED
2004 ,SET
,BY
,EXPLICIT
,IMPLICIT
,DEFINITIONS
,TAGS
2005 ,BEGIN
,END
,UTCTime
,GeneralizedTime
2006 ,GeneralString
,FROM
,IMPORTS
,TOKEN_NULL
,ENUMERATED
};
2008 /*************************************************************/
2009 /* Function: _asn1_yylex */
2010 /* Description: looks for tokens in file_asn1 pointer file. */
2012 /* Token identifier or ASCII code or 0(zero: End Of File) */
2013 /*************************************************************/
2017 int c
,counter
=0,k
,lastc
;
2018 char string
[MAX_NAME_SIZE
+1]; /* will contain the next token */
2022 while((c
=fgetc(file_asn1
))==' ' || c
=='\t' || c
=='\n')
2023 if(c
=='\n') lineNumber
++;
2026 strcpy(lastToken
,"End Of File");
2030 if(c
=='(' || c
==')' || c
=='[' || c
==']' ||
2031 c
=='{' || c
=='}' || c
==',' || c
=='.' ||
2033 lastToken
[0]=c
;lastToken
[1]=0;
2036 if(c
=='-'){ /* Maybe the first '-' of a comment */
2037 if((c
=fgetc(file_asn1
))!='-'){
2038 ungetc(c
,file_asn1
);
2039 lastToken
[0]='-';lastToken
[1]=0;
2042 else{ /* Comments */
2045 /* A comment finishes at the next double hypen or the end of line */
2046 while((c
=fgetc(file_asn1
))!=EOF
&& c
!='\n' &&
2047 (lastc
!='-' || (lastc
=='-' && c
!='-')))
2050 strcpy(lastToken
,"End Of File");
2054 if(c
=='\n') lineNumber
++;
2055 continue; /* next char, please! (repeat the search) */
2059 string
[counter
++]=c
;
2060 /* Till the end of the token */
2061 while(!((c
=fgetc(file_asn1
))==EOF
|| c
==' '|| c
=='\t' || c
=='\n' ||
2062 c
=='(' || c
==')' || c
=='[' || c
==']' ||
2063 c
=='{' || c
=='}' || c
==',' || c
=='.'))
2065 if(counter
>=MAX_NAME_SIZE
){
2066 result_parse
=ASN1_NAME_TOO_LONG
;
2069 string
[counter
++]=c
;
2071 ungetc(c
,file_asn1
);
2073 strcpy(lastToken
,string
);
2075 /* Is STRING a number? */
2076 for(k
=0;k
<counter
;k
++)
2077 if(!isdigit(string
[k
])) break;
2080 strcpy(yylval
.str
,string
);
2081 return NUM
; /* return the number */
2084 /* Is STRING a keyword? */
2085 for(k
=0;k
<(sizeof(key_word
)/sizeof(char*));k
++)
2086 if(!strcmp(string
,key_word
[k
])) return key_word_token
[k
];
2088 /* STRING is an IDENTIFIER */
2089 strcpy(yylval
.str
,string
);
2095 /*************************************************************/
2096 /* Function: _asn1_create_errorDescription */
2097 /* Description: creates a string with the description of the*/
2100 /* error : error to describe. */
2101 /* errorDescription: string that will contain the */
2103 /*************************************************************/
2105 _asn1_create_errorDescription(int error
,char *errorDescription
)
2108 case ASN1_SUCCESS
: case ASN1_FILE_NOT_FOUND
:
2109 if (errorDescription
!=NULL
) errorDescription
[0]=0;
2111 case ASN1_SYNTAX_ERROR
:
2112 if (errorDescription
!=NULL
) {
2113 strcpy(errorDescription
,fileName
);
2114 strcat(errorDescription
,":");
2115 _asn1_ltostr(lineNumber
,errorDescription
+strlen(fileName
)+1);
2116 strcat(errorDescription
,": parse error near '");
2117 strcat(errorDescription
,lastToken
);
2118 strcat(errorDescription
,"'");
2121 case ASN1_NAME_TOO_LONG
:
2122 if (errorDescription
!=NULL
) {
2123 strcpy(errorDescription
,fileName
);
2124 strcat(errorDescription
,":");
2125 _asn1_ltostr(lineNumber
,errorDescription
+strlen(fileName
)+1);
2126 strcat(errorDescription
,": name too long (more than ");
2127 _asn1_ltostr(MAX_NAME_SIZE
,errorDescription
+strlen(errorDescription
));
2128 strcat(errorDescription
," characters)");
2131 case ASN1_IDENTIFIER_NOT_FOUND
:
2132 if (errorDescription
!=NULL
) {
2133 strcpy(errorDescription
,fileName
);
2134 strcat(errorDescription
,":");
2135 strcat(errorDescription
,": identifier '");
2136 strcat(errorDescription
,_asn1_identifierMissing
);
2137 strcat(errorDescription
,"' not found");
2141 if (errorDescription
!=NULL
) errorDescription
[0]=0;
2149 * asn1_parser2tree - function used to start the parse algorithm.
2150 * @file_name: specify the path and the name of file that contains
2151 * ASN.1 declarations.
2152 * @definitions: return the pointer to the structure created from
2153 * "file_name" ASN.1 declarations.
2154 * @errorDescription: return the error description or an empty
2155 * string if success.
2157 * Creates the structures needed to manage the definitions included
2158 * in *FILE_NAME file.
2162 * ASN1_SUCCESS: The file has a correct syntax and every identifier
2165 * ASN1_ELEMENT_NOT_EMPTY: *POINTER not ASN1_TYPE_EMPTY.
2167 * ASN1_FILE_NOT_FOUND: An error occured while opening FILE_NAME.
2169 * ASN1_SYNTAX_ERROR: The syntax is not correct.
2171 * ASN1_IDENTIFIER_NOT_FOUND: In the file there is an identifier that
2174 * ASN1_NAME_TOO_LONG: In the file there is an identifier whith more
2175 * than MAX_NAME_SIZE characters.
2178 asn1_parser2tree(const char *file_name
, ASN1_TYPE
*definitions
,
2179 char *errorDescription
){
2181 p_tree
=ASN1_TYPE_EMPTY
;
2183 if(*definitions
!= ASN1_TYPE_EMPTY
)
2184 return ASN1_ELEMENT_NOT_EMPTY
;
2186 *definitions
=ASN1_TYPE_EMPTY
;
2188 fileName
= file_name
;
2190 /* open the file to parse */
2191 file_asn1
=fopen(file_name
,"r");
2193 if(file_asn1
==NULL
){
2194 result_parse
=ASN1_FILE_NOT_FOUND
;
2197 result_parse
=ASN1_SUCCESS
;
2204 if(result_parse
==ASN1_SUCCESS
){ /* syntax OK */
2205 /* set IMPLICIT or EXPLICIT property */
2206 _asn1_set_default_tag(p_tree
);
2207 /* set CONST_SET and CONST_NOT_USED */
2208 _asn1_type_set_config(p_tree
);
2209 /* check the identifier definitions */
2210 result_parse
=_asn1_check_identifier(p_tree
);
2211 if(result_parse
==ASN1_SUCCESS
){ /* all identifier defined */
2212 /* Delete the list and keep the ASN1 structure */
2213 _asn1_delete_list();
2214 /* Convert into DER coding the value assign to INTEGER constants */
2215 _asn1_change_integer_value(p_tree
);
2216 /* Expand the IDs of OBJECT IDENTIFIER constants */
2217 _asn1_expand_object_id(p_tree
);
2219 *definitions
=p_tree
;
2221 else /* some identifiers not defined */
2222 /* Delete the list and the ASN1 structure */
2223 _asn1_delete_list_and_nodes();
2225 else /* syntax error */
2226 /* Delete the list and the ASN1 structure */
2227 _asn1_delete_list_and_nodes();
2230 if (errorDescription
!=NULL
)
2231 _asn1_create_errorDescription(result_parse
,errorDescription
);
2233 return result_parse
;
2238 * asn1_parser2array - function that generates a C structure from an ASN1 file
2239 * @inputFileName: specify the path and the name of file that
2240 * contains ASN.1 declarations.
2241 * @outputFileName: specify the path and the name of file that will
2242 * contain the C vector definition.
2243 * @vectorName: specify the name of the C vector.
2244 * @errorDescription : return the error description or an empty
2245 * string if success.
2247 * Creates a file containing a C vector to use to manage the
2248 * definitions included in *INPUTFILENAME file. If *INPUTFILENAME is
2249 * "/aa/bb/xx.yy" and OUTPUTFILENAME is NULL, the file created is
2250 * "/aa/bb/xx_asn1_tab.c". If VECTORNAME is NULL the vector name
2251 * will be "xx_asn1_tab".
2255 * ASN1_SUCCESS: The file has a correct syntax and every identifier
2258 * ASN1_FILE_NOT_FOUND: An error occured while opening FILE_NAME.
2260 * ASN1_SYNTAX_ERROR: The syntax is not correct.
2262 * ASN1_IDENTIFIER_NOT_FOUND: In the file there is an identifier that
2265 * ASN1_NAME_TOO_LONG: In the file there is an identifier whith more
2266 * than MAX_NAME_SIZE characters.
2268 int asn1_parser2array(const char *inputFileName
,const char *outputFileName
,
2269 const char *vectorName
,char *errorDescription
){
2270 char *file_out_name
=NULL
;
2271 char *vector_name
=NULL
;
2272 const char *char_p
,*slash_p
,*dot_p
;
2276 fileName
= inputFileName
;
2278 /* open the file to parse */
2279 file_asn1
=fopen(inputFileName
,"r");
2282 result_parse
=ASN1_FILE_NOT_FOUND
;
2284 result_parse
=ASN1_SUCCESS
;
2291 if(result_parse
==ASN1_SUCCESS
){ /* syntax OK */
2292 /* set IMPLICIT or EXPLICIT property */
2293 _asn1_set_default_tag(p_tree
);
2294 /* set CONST_SET and CONST_NOT_USED */
2295 _asn1_type_set_config(p_tree
);
2296 /* check the identifier definitions */
2297 result_parse
=_asn1_check_identifier(p_tree
);
2299 if(result_parse
==ASN1_SUCCESS
){ /* all identifier defined */
2301 /* searching the last '/' and '.' in inputFileName */
2302 char_p
=inputFileName
;
2303 slash_p
=inputFileName
;
2304 while((char_p
=strchr(char_p
,'/'))){
2310 dot_p
=inputFileName
+strlen(inputFileName
);
2312 while((char_p
=strchr(char_p
,'.'))){
2317 if(outputFileName
== NULL
){
2318 /* file_out_name = inputFileName + _asn1_tab.c */
2319 file_out_name
=(char *)malloc(dot_p
-inputFileName
+1+
2320 strlen("_asn1_tab.c"));
2321 memcpy(file_out_name
,inputFileName
,dot_p
-inputFileName
);
2322 file_out_name
[dot_p
-inputFileName
]=0;
2323 strcat(file_out_name
,"_asn1_tab.c");
2326 /* file_out_name = inputFileName */
2327 file_out_name
=(char *)malloc(strlen(outputFileName
)+1);
2328 strcpy(file_out_name
,outputFileName
);
2331 if(vectorName
== NULL
){
2332 /* vector_name = file name + _asn1_tab */
2333 vector_name
=(char *)malloc(dot_p
-slash_p
+1+
2334 strlen("_asn1_tab"));
2335 memcpy(vector_name
,slash_p
,dot_p
-slash_p
);
2336 vector_name
[dot_p
-slash_p
]=0;
2337 strcat(vector_name
,"_asn1_tab");
2340 /* vector_name = vectorName */
2341 vector_name
=(char *)malloc(strlen(vectorName
)+1);
2342 strcpy(vector_name
,vectorName
);
2345 /* Save structure in a file */
2346 _asn1_create_static_structure(p_tree
,
2347 file_out_name
,vector_name
);
2349 free(file_out_name
);
2351 } /* result == OK */
2352 } /* result == OK */
2354 /* Delete the list and the ASN1 structure */
2355 _asn1_delete_list_and_nodes();
2356 } /* inputFile exist */
2358 if (errorDescription
!=NULL
)
2359 _asn1_create_errorDescription(result_parse
,errorDescription
);
2361 return result_parse
;
2365 /*************************************************************/
2366 /* Function: _asn1_yyerror */
2367 /* Description: function called when there are syntax errors*/
2369 /* char *s : error description */
2372 /*************************************************************/
2373 int _asn1_yyerror (char *s
)
2375 /* Sends the error description to the std_out */
2377 #ifdef LIBTASN1_DEBUG_PARSER
2378 _libtasn1_log("_asn1_yyerror:%s:%d: %s (Last Token:'%s')\n",fileName
,
2379 lineNumber
,s
,lastToken
);
2382 if(result_parse
!=ASN1_NAME_TOO_LONG
)
2383 result_parse
=ASN1_SYNTAX_ERROR
;