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 algorithm */
158 static node_asn
*p_tree
; /* pointer to the root of the structure
159 created by the parser*/
160 static unsigned long lineNumber
; /* line number describing the parser position
162 static char lastToken
[MAX_NAME_SIZE
+1]; /* last token find in the file to
163 parse before the 'parse error' */
164 extern char _asn1_identifierMissing
[];
165 static const char *fileName
; /* file to parse */
167 int _asn1_yyerror (char *);
168 int _asn1_yylex(void);
172 /* Enabling traces. */
177 /* Enabling verbose error messages. */
178 #ifdef YYERROR_VERBOSE
179 # undef YYERROR_VERBOSE
180 # define YYERROR_VERBOSE 1
182 # define YYERROR_VERBOSE 0
185 #if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)
187 typedef union YYSTYPE
{
188 unsigned int constant
;
189 char str
[MAX_NAME_SIZE
+1];
192 /* Line 191 of yacc.c. */
194 # define yystype YYSTYPE /* obsolescent; will be withdrawn */
195 # define YYSTYPE_IS_DECLARED 1
196 # define YYSTYPE_IS_TRIVIAL 1
201 /* Copy the second part of user declarations. */
204 /* Line 214 of yacc.c. */
207 #if ! defined (yyoverflow) || YYERROR_VERBOSE
209 /* The parser invokes alloca or malloc; define the necessary symbols. */
211 # if YYSTACK_USE_ALLOCA
212 # define YYSTACK_ALLOC alloca
214 # ifndef YYSTACK_USE_ALLOCA
215 # if defined (alloca) || defined (_ALLOCA_H)
216 # define YYSTACK_ALLOC alloca
219 # define YYSTACK_ALLOC __builtin_alloca
225 # ifdef YYSTACK_ALLOC
226 /* Pacify GCC's `empty if-body' warning. */
227 # define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
229 # if defined (__STDC__) || defined (__cplusplus)
230 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
231 # define YYSIZE_T size_t
233 # define YYSTACK_ALLOC malloc
234 # define YYSTACK_FREE free
236 #endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */
239 #if (! defined (yyoverflow) \
240 && (! defined (__cplusplus) \
241 || (YYSTYPE_IS_TRIVIAL)))
243 /* A type that is properly aligned for any stack member. */
250 /* The size of the maximum gap between one aligned stack and the next. */
251 # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
253 /* The size of an array large to enough to hold all stacks, each with
255 # define YYSTACK_BYTES(N) \
256 ((N) * (sizeof (short) + sizeof (YYSTYPE)) \
257 + YYSTACK_GAP_MAXIMUM)
259 /* Copy COUNT objects from FROM to TO. The source and destination do
263 # define YYCOPY(To, From, Count) \
264 __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
266 # define YYCOPY(To, From, Count) \
269 register YYSIZE_T yyi; \
270 for (yyi = 0; yyi < (Count); yyi++) \
271 (To)[yyi] = (From)[yyi]; \
277 /* Relocate STACK from its old location to the new one. The
278 local variables YYSIZE and YYSTACKSIZE give the old and new number of
279 elements in the stack, and YYPTR gives the new location of the
280 stack. Advance YYPTR to a properly aligned location for the next
282 # define YYSTACK_RELOCATE(Stack) \
285 YYSIZE_T yynewbytes; \
286 YYCOPY (&yyptr->Stack, Stack, yysize); \
287 Stack = &yyptr->Stack; \
288 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
289 yyptr += yynewbytes / sizeof (*yyptr); \
295 #if defined (__STDC__) || defined (__cplusplus)
296 typedef signed char yysigned_char
;
298 typedef short yysigned_char
;
301 /* YYFINAL -- State number of the termination state. */
303 /* YYLAST -- Last index in YYTABLE. */
306 /* YYNTOKENS -- Number of terminals. */
308 /* YYNNTS -- Number of nonterminals. */
310 /* YYNRULES -- Number of rules. */
312 /* YYNRULES -- Number of states. */
313 #define YYNSTATES 189
315 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
317 #define YYMAXUTOK 295
319 #define YYTRANSLATE(YYX) \
320 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
322 /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
323 static const unsigned char yytranslate
[] =
325 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
326 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
327 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
328 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
329 43, 44, 2, 41, 45, 42, 51, 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 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
334 2, 46, 2, 47, 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, 49, 48, 50, 2, 2, 2, 2,
338 2, 2, 2, 2, 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, 2, 2, 2, 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, 1, 2, 3, 4,
351 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
352 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
353 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
354 35, 36, 37, 38, 39, 40
358 /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
360 static const unsigned short yyprhs
[] =
362 0, 0, 3, 12, 14, 17, 20, 22, 24, 26,
363 28, 30, 32, 36, 41, 43, 47, 49, 54, 56,
364 59, 61, 63, 65, 69, 74, 76, 79, 82, 85,
365 88, 91, 93, 97, 99, 104, 109, 117, 119, 121,
366 123, 128, 136, 138, 142, 144, 147, 150, 154, 159,
367 161, 165, 168, 174, 179, 182, 184, 187, 189, 191,
368 193, 195, 197, 199, 201, 203, 205, 207, 209, 211,
369 213, 215, 218, 220, 223, 226, 229, 231, 235, 240,
370 244, 249, 254, 258, 263, 268, 270, 275, 279, 287,
371 294, 299, 301, 303, 305, 308, 313, 317, 319
374 /* YYRHS -- A `-1'-separated list of the rules' RHS. */
375 static const yysigned_char yyrhs
[] =
377 53, 0, -1, 93, 31, 94, 32, 3, 33, 92,
378 34, -1, 4, -1, 41, 4, -1, 42, 4, -1,
379 54, -1, 55, -1, 4, -1, 5, -1, 56, -1,
380 5, -1, 43, 56, 44, -1, 5, 43, 56, 44,
381 -1, 59, -1, 60, 45, 59, -1, 57, -1, 5,
382 43, 4, 44, -1, 61, -1, 62, 61, -1, 13,
383 -1, 14, -1, 15, -1, 46, 4, 47, -1, 46,
384 63, 4, 47, -1, 64, -1, 64, 29, -1, 64,
385 30, -1, 16, 58, -1, 16, 22, -1, 16, 23,
386 -1, 56, -1, 67, 48, 56, -1, 7, -1, 7,
387 49, 60, 50, -1, 7, 43, 67, 44, -1, 7,
388 43, 57, 51, 51, 57, 44, -1, 21, -1, 35,
389 -1, 36, -1, 8, 43, 57, 44, -1, 8, 43,
390 57, 51, 51, 57, 44, -1, 71, -1, 43, 71,
391 44, -1, 37, -1, 37, 72, -1, 9, 10, -1,
392 9, 10, 72, -1, 5, 43, 4, 44, -1, 75,
393 -1, 76, 45, 75, -1, 12, 10, -1, 12, 10,
394 49, 76, 50, -1, 40, 49, 76, 50, -1, 19,
395 20, -1, 5, -1, 5, 72, -1, 68, -1, 78,
396 -1, 69, -1, 70, -1, 74, -1, 77, -1, 73,
397 -1, 85, -1, 79, -1, 87, -1, 88, -1, 86,
398 -1, 24, -1, 80, -1, 65, 80, -1, 81, -1,
399 81, 66, -1, 81, 6, -1, 5, 82, -1, 83,
400 -1, 84, 45, 83, -1, 11, 49, 84, 50, -1,
401 11, 18, 80, -1, 11, 72, 18, 80, -1, 28,
402 49, 84, 50, -1, 28, 18, 80, -1, 28, 72,
403 18, 80, -1, 17, 49, 84, 50, -1, 25, -1,
404 25, 26, 27, 5, -1, 5, 3, 81, -1, 5,
405 19, 20, 3, 49, 62, 50, -1, 5, 5, 3,
406 49, 62, 50, -1, 5, 7, 3, 56, -1, 89,
407 -1, 90, -1, 91, -1, 92, 91, -1, 5, 49,
408 62, 50, -1, 5, 49, 50, -1, 29, -1, 30,
412 /* YYRLINE[YYN] -- source line where rule number YYN was defined. */
413 static const unsigned short yyrline
[] =
415 0, 117, 117, 130, 131, 134, 138, 139, 142, 143,
416 146, 147, 150, 152, 157, 158, 162, 164, 169, 170,
417 174, 175, 176, 179, 181, 185, 186, 187, 190, 192,
418 193, 197, 198, 202, 203, 205, 206, 213, 216, 217,
419 220, 222, 228, 229, 232, 233, 237, 238, 242, 247,
420 248, 252, 253, 258, 264, 267, 269, 272, 273, 274,
421 275, 276, 277, 278, 279, 280, 281, 282, 283, 284,
422 287, 288, 293, 294, 297, 300, 303, 304, 308, 310,
423 312, 317, 319, 321, 326, 330, 331, 336, 339, 343,
424 348, 354, 355, 358, 359, 363, 366, 390, 391
428 #if YYDEBUG || YYERROR_VERBOSE
429 /* YYTNME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
430 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
431 static const char *const yytname
[] =
433 "$end", "error", "$undefined", "\"::=\"", "NUM", "IDENTIFIER", "OPTIONAL",
434 "INTEGER", "SIZE", "OCTET", "STRING", "SEQUENCE", "BIT", "UNIVERSAL",
435 "PRIVATE", "APPLICATION", "DEFAULT", "CHOICE", "OF", "OBJECT",
436 "STR_IDENTIFIER", "BOOLEAN", "TRUE", "FALSE", "TOKEN_NULL", "ANY",
437 "DEFINED", "BY", "SET", "EXPLICIT", "IMPLICIT", "DEFINITIONS", "TAGS",
438 "BEGIN", "END", "UTCTime", "GeneralizedTime", "GeneralString", "FROM",
439 "IMPORTS", "ENUMERATED", "'+'", "'-'", "'('", "')'", "','", "'['",
440 "']'", "'|'", "'{'", "'}'", "'.'", "$accept", "definitions", "pos_num",
441 "neg_num", "pos_neg_num", "num_identifier", "pos_neg_identifier",
442 "constant", "constant_list", "obj_constant", "obj_constant_list",
443 "class", "tag_type", "tag", "default", "pos_neg_list", "integer_def",
444 "boolean_def", "Time", "size_def2", "size_def", "generalstring_def",
445 "octet_string_def", "bit_element", "bit_element_list", "bit_string_def",
446 "enumerated_def", "object_def", "type_assig_right",
447 "type_assig_right_tag", "type_assig_right_tag_default", "type_assig",
448 "type_assig_list", "sequence_def", "set_def", "choise_def", "any_def",
449 "type_def", "constant_def", "type_constant", "type_constant_list",
450 "definitions_id", "explicit_implicit", 0
455 /* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
457 static const unsigned short yytoknum
[] =
459 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
460 265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
461 275, 276, 277, 278, 279, 280, 281, 282, 283, 284,
462 285, 286, 287, 288, 289, 290, 291, 292, 293, 294,
463 295, 43, 45, 40, 41, 44, 91, 93, 124, 123,
468 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
469 static const unsigned char yyr1
[] =
471 0, 52, 53, 54, 54, 55, 56, 56, 57, 57,
472 58, 58, 59, 59, 60, 60, 61, 61, 62, 62,
473 63, 63, 63, 64, 64, 65, 65, 65, 66, 66,
474 66, 67, 67, 68, 68, 68, 68, 69, 70, 70,
475 71, 71, 72, 72, 73, 73, 74, 74, 75, 76,
476 76, 77, 77, 78, 79, 80, 80, 80, 80, 80,
477 80, 80, 80, 80, 80, 80, 80, 80, 80, 80,
478 81, 81, 82, 82, 82, 83, 84, 84, 85, 85,
479 85, 86, 86, 86, 87, 88, 88, 89, 90, 90,
480 90, 91, 91, 92, 92, 93, 93, 94, 94
483 /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
484 static const unsigned char yyr2
[] =
486 0, 2, 8, 1, 2, 2, 1, 1, 1, 1,
487 1, 1, 3, 4, 1, 3, 1, 4, 1, 2,
488 1, 1, 1, 3, 4, 1, 2, 2, 2, 2,
489 2, 1, 3, 1, 4, 4, 7, 1, 1, 1,
490 4, 7, 1, 3, 1, 2, 2, 3, 4, 1,
491 3, 2, 5, 4, 2, 1, 2, 1, 1, 1,
492 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
493 1, 2, 1, 2, 2, 2, 1, 3, 4, 3,
494 4, 4, 3, 4, 4, 1, 4, 3, 7, 6,
495 4, 1, 1, 1, 2, 4, 3, 1, 1
498 /* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
499 STATE-NUM when YYTABLE doesn't specify something else to do. Zero
500 means the default is an error. */
501 static const unsigned char yydefact
[] =
503 0, 0, 0, 0, 0, 1, 0, 8, 9, 96,
504 16, 18, 0, 97, 98, 0, 0, 95, 19, 0,
505 0, 0, 17, 0, 0, 91, 92, 93, 0, 0,
506 0, 0, 0, 2, 94, 55, 33, 0, 0, 0,
507 0, 0, 37, 69, 85, 0, 38, 39, 44, 0,
508 0, 25, 0, 57, 59, 60, 63, 61, 62, 58,
509 65, 70, 87, 64, 68, 66, 67, 0, 0, 0,
510 0, 0, 42, 56, 0, 0, 46, 0, 0, 0,
511 51, 0, 54, 0, 0, 0, 0, 45, 0, 0,
512 20, 21, 22, 0, 26, 27, 71, 0, 3, 0,
513 0, 6, 7, 90, 0, 0, 0, 3, 9, 31,
514 0, 0, 0, 0, 14, 0, 47, 79, 0, 76,
515 0, 0, 0, 0, 0, 82, 0, 0, 0, 49,
516 0, 23, 0, 0, 4, 5, 0, 0, 43, 0,
517 35, 0, 0, 0, 0, 34, 72, 75, 0, 78,
518 80, 0, 84, 86, 81, 83, 0, 0, 53, 24,
519 89, 0, 40, 0, 0, 32, 0, 12, 15, 74,
520 0, 73, 77, 52, 0, 50, 88, 0, 0, 13,
521 11, 29, 30, 10, 28, 48, 0, 36, 41
524 /* YYDEFGOTO[NTERM-NUM]. */
525 static const short yydefgoto
[] =
527 -1, 2, 101, 102, 103, 10, 184, 114, 115, 11,
528 12, 93, 51, 52, 171, 111, 53, 54, 55, 72,
529 73, 56, 57, 129, 130, 58, 59, 60, 61, 62,
530 147, 119, 120, 63, 64, 65, 66, 25, 26, 27,
534 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
536 #define YYPACT_NINF -84
537 static const short yypact
[] =
539 18, -32, 33, 15, 0, -84, 90, -84, 49, -84,
540 -84, -84, 2, -84, -84, 11, 45, -84, -84, 57,
541 50, 43, -84, 100, 74, -84, -84, -84, 10, 78,
542 105, 113, 106, -84, -84, 5, -31, 126, 8, 128,
543 79, 120, -84, -84, 115, 12, -84, -84, 5, 95,
544 96, 102, 118, -84, -84, -84, -84, -84, -84, -84,
545 -84, -84, -84, -84, -84, -84, -84, 98, 23, 142,
546 107, 140, -84, -84, 32, 20, 5, 118, 146, 134,
547 108, 146, -84, 132, 118, 146, 138, -84, 155, 114,
548 -84, -84, -84, 158, -84, -84, -84, 63, -84, 159,
549 160, -84, -84, -84, 116, 129, 122, 117, -84, -84,
550 119, 38, 124, 23, -84, -3, -84, -84, 78, -84,
551 21, 118, 155, 30, 164, -84, 51, 118, 130, -84,
552 62, -84, 125, 4, -84, -84, 63, -6, -84, 123,
553 -84, 23, 23, 127, 20, -84, 13, -84, 146, -84,
554 -84, 72, -84, -84, -84, -84, 171, 155, -84, -84,
555 -84, 6, -84, 131, 129, -84, 133, -84, -84, -84,
556 17, -84, -84, -84, 135, -84, -84, 129, 136, -84,
557 -84, -84, -84, -84, -84, -84, 137, -84, -84
560 /* YYPGOTO[NTERM-NUM]. */
561 static const short yypgoto
[] =
563 -84, -84, -84, -84, -72, -73, -84, 34, -84, -12,
564 -83, -84, -84, -84, -84, -84, -84, -84, -84, 112,
565 -14, -84, -84, 19, 64, -84, -84, -84, -49, 66,
566 -84, 37, 3, -84, -84, -84, -84, -84, -84, 161,
570 /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
571 positive, shift that token. If negative, reduce the rule which
572 number is the opposite. If zero, do what YYDEFACT says.
573 If YYTABLE_NINF, syntax error. */
574 #define YYTABLE_NINF -9
575 static const short yytable
[] =
577 18, 110, 109, 96, 7, 8, 7, 8, 7, 8,
578 7, 8, 74, 70, 133, 24, 70, 4, 75, 169,
579 70, 98, 180, 1, 79, 112, 77, 98, 117, 170,
580 84, 86, 137, 5, 87, 125, 107, 108, 162, 181,
581 182, 143, 144, 19, 33, 163, 6, 145, 71, 20,
582 9, 71, 17, 161, 160, 71, 176, 78, 99, 100,
583 21, 85, 116, 113, 99, 100, 148, 7, 8, 165,
584 166, 149, 150, 99, 100, 148, 23, 29, 155, 30,
585 152, 31, 140, 35, 123, 36, 141, 37, 126, 38,
586 39, 178, 16, 32, 22, 40, 148, 41, 183, 42,
587 89, 154, 43, 44, 186, 24, 45, 157, 67, 90,
588 91, 92, 158, 46, 47, 48, 68, 157, 49, 13,
589 14, 18, 173, 35, 50, 36, 69, 37, 81, 38,
590 39, 94, 95, 7, 108, 40, 76, 41, 80, 42,
591 82, 83, 43, 44, 88, 104, 45, 97, 70, 18,
592 105, 118, 121, 46, 47, 48, 127, 122, 49, 124,
593 128, 131, 132, 134, 135, 136, 138, 142, -8, 153,
594 139, 167, 159, 156, 164, 174, 175, 179, 168, 185,
595 187, 188, 177, 106, 146, 172, 151, 0, 0, 34
598 static const short yycheck
[] =
600 12, 74, 74, 52, 4, 5, 4, 5, 4, 5,
601 4, 5, 43, 8, 97, 5, 8, 49, 49, 6,
602 8, 4, 5, 5, 38, 5, 18, 4, 77, 16,
603 18, 45, 105, 0, 48, 84, 4, 5, 44, 22,
604 23, 113, 45, 32, 34, 51, 31, 50, 43, 4,
605 50, 43, 50, 136, 50, 43, 50, 49, 41, 42,
606 3, 49, 76, 43, 41, 42, 45, 4, 5, 141,
607 142, 50, 121, 41, 42, 45, 33, 3, 127, 5,
608 50, 7, 44, 5, 81, 7, 48, 9, 85, 11,
609 12, 164, 43, 19, 44, 17, 45, 19, 170, 21,
610 4, 50, 24, 25, 177, 5, 28, 45, 3, 13,
611 14, 15, 50, 35, 36, 37, 3, 45, 40, 29,
612 30, 133, 50, 5, 46, 7, 20, 9, 49, 11,
613 12, 29, 30, 4, 5, 17, 10, 19, 10, 21,
614 20, 26, 24, 25, 49, 3, 28, 49, 8, 161,
615 43, 5, 18, 35, 36, 37, 18, 49, 40, 27,
616 5, 47, 4, 4, 4, 49, 44, 43, 51, 5,
617 51, 44, 47, 43, 51, 4, 157, 44, 144, 44,
618 44, 44, 51, 71, 118, 148, 122, -1, -1, 28
621 /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
622 symbol of state STATE-NUM. */
623 static const unsigned char yystos
[] =
625 0, 5, 53, 93, 49, 0, 31, 4, 5, 50,
626 57, 61, 62, 29, 30, 94, 43, 50, 61, 32,
627 4, 3, 44, 33, 5, 89, 90, 91, 92, 3,
628 5, 7, 19, 34, 91, 5, 7, 9, 11, 12,
629 17, 19, 21, 24, 25, 28, 35, 36, 37, 40,
630 46, 64, 65, 68, 69, 70, 73, 74, 77, 78,
631 79, 80, 81, 85, 86, 87, 88, 3, 3, 20,
632 8, 43, 71, 72, 43, 49, 10, 18, 49, 72,
633 10, 49, 20, 26, 18, 49, 72, 72, 49, 4,
634 13, 14, 15, 63, 29, 30, 80, 49, 4, 41,
635 42, 54, 55, 56, 3, 43, 71, 4, 5, 56,
636 57, 67, 5, 43, 59, 60, 72, 80, 5, 83,
637 84, 18, 49, 84, 27, 80, 84, 18, 5, 75,
638 76, 47, 4, 62, 4, 4, 49, 57, 44, 51,
639 44, 48, 43, 56, 45, 50, 81, 82, 45, 50,
640 80, 76, 50, 5, 50, 80, 43, 45, 50, 47,
641 50, 62, 44, 51, 51, 56, 56, 44, 59, 6,
642 16, 66, 83, 50, 4, 75, 50, 51, 57, 44,
643 5, 22, 23, 56, 58, 44, 57, 44, 44
646 #if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__)
647 # define YYSIZE_T __SIZE_TYPE__
649 #if ! defined (YYSIZE_T) && defined (size_t)
650 # define YYSIZE_T size_t
652 #if ! defined (YYSIZE_T)
653 # if defined (__STDC__) || defined (__cplusplus)
654 # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
655 # define YYSIZE_T size_t
658 #if ! defined (YYSIZE_T)
659 # define YYSIZE_T unsigned int
662 #define yyerrok (yyerrstatus = 0)
663 #define yyclearin (yychar = YYEMPTY)
667 #define YYACCEPT goto yyacceptlab
668 #define YYABORT goto yyabortlab
669 #define YYERROR goto yyerrlab1
672 /* Like YYERROR except do call yyerror. This remains here temporarily
673 to ease the transition to the new meaning of YYERROR, for GCC.
674 Once GCC version 2 has supplanted version 1, this can go. */
676 #define YYFAIL goto yyerrlab
678 #define YYRECOVERING() (!!yyerrstatus)
680 #define YYBACKUP(Token, Value) \
682 if (yychar == YYEMPTY && yylen == 1) \
686 yytoken = YYTRANSLATE (yychar); \
692 yyerror ("syntax error: cannot back up");\
698 #define YYERRCODE 256
700 /* YYLLOC_DEFAULT -- Compute the default location (before the actions
703 #ifndef YYLLOC_DEFAULT
704 # define YYLLOC_DEFAULT(Current, Rhs, N) \
705 Current.first_line = Rhs[1].first_line; \
706 Current.first_column = Rhs[1].first_column; \
707 Current.last_line = Rhs[N].last_line; \
708 Current.last_column = Rhs[N].last_column;
711 /* YYLEX -- calling `yylex' with the right arguments. */
714 # define YYLEX yylex (YYLEX_PARAM)
716 # define YYLEX yylex ()
719 /* Enable debugging if requested. */
723 # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
724 # define YYFPRINTF fprintf
727 # define YYDPRINTF(Args) \
733 # define YYDSYMPRINT(Args) \
739 # define YYDSYMPRINTF(Title, Token, Value, Location) \
743 YYFPRINTF (stderr, "%s ", Title); \
744 yysymprint (stderr, \
746 YYFPRINTF (stderr, "\n"); \
750 /*------------------------------------------------------------------.
751 | yy_stack_print -- Print the state stack from its BOTTOM up to its |
753 `------------------------------------------------------------------*/
755 #if defined (__STDC__) || defined (__cplusplus)
757 yy_stack_print (short *bottom
, short *top
)
760 yy_stack_print (bottom
, top
)
765 YYFPRINTF (stderr
, "Stack now");
766 for (/* Nothing. */; bottom
<= top
; ++bottom
)
767 YYFPRINTF (stderr
, " %d", *bottom
);
768 YYFPRINTF (stderr
, "\n");
771 # define YY_STACK_PRINT(Bottom, Top) \
774 yy_stack_print ((Bottom), (Top)); \
778 /*------------------------------------------------.
779 | Report that the YYRULE is going to be reduced. |
780 `------------------------------------------------*/
782 #if defined (__STDC__) || defined (__cplusplus)
784 yy_reduce_print (int yyrule
)
787 yy_reduce_print (yyrule
)
792 unsigned int yylineno
= yyrline
[yyrule
];
793 YYFPRINTF (stderr
, "Reducing stack by rule %d (line %u), ",
794 yyrule
- 1, yylineno
);
795 /* Print the symbols being reduced, and their result. */
796 for (yyi
= yyprhs
[yyrule
]; 0 <= yyrhs
[yyi
]; yyi
++)
797 YYFPRINTF (stderr
, "%s ", yytname
[yyrhs
[yyi
]]);
798 YYFPRINTF (stderr
, "-> %s\n", yytname
[yyr1
[yyrule
]]);
801 # define YY_REDUCE_PRINT(Rule) \
804 yy_reduce_print (Rule); \
807 /* Nonzero means print parse trace. It is left uninitialized so that
808 multiple parsers can coexist. */
811 # define YYDPRINTF(Args)
812 # define YYDSYMPRINT(Args)
813 # define YYDSYMPRINTF(Title, Token, Value, Location)
814 # define YY_STACK_PRINT(Bottom, Top)
815 # define YY_REDUCE_PRINT(Rule)
816 #endif /* !YYDEBUG */
819 /* YYINITDEPTH -- initial size of the parser's stacks. */
821 # define YYINITDEPTH 200
824 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
825 if the built-in stack extension method is used).
827 Do not make this value too large; the results are undefined if
828 SIZE_MAX < YYSTACK_BYTES (YYMAXDEPTH)
829 evaluated with infinite-precision integer arithmetic. */
836 # define YYMAXDEPTH 10000
844 # if defined (__GLIBC__) && defined (_STRING_H)
845 # define yystrlen strlen
847 /* Return the length of YYSTR. */
849 # if defined (__STDC__) || defined (__cplusplus)
850 yystrlen (const char *yystr
)
856 register const char *yys
= yystr
;
858 while (*yys
++ != '\0')
861 return yys
- yystr
- 1;
867 # if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE)
868 # define yystpcpy stpcpy
870 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
873 # if defined (__STDC__) || defined (__cplusplus)
874 yystpcpy (char *yydest
, const char *yysrc
)
876 yystpcpy (yydest
, yysrc
)
881 register char *yyd
= yydest
;
882 register const char *yys
= yysrc
;
884 while ((*yyd
++ = *yys
++) != '\0')
892 #endif /* !YYERROR_VERBOSE */
897 /*--------------------------------.
898 | Print this symbol on YYOUTPUT. |
899 `--------------------------------*/
901 #if defined (__STDC__) || defined (__cplusplus)
903 yysymprint (FILE *yyoutput
, int yytype
, YYSTYPE
*yyvaluep
)
906 yysymprint (yyoutput
, yytype
, yyvaluep
)
912 /* Pacify ``unused variable'' warnings. */
915 if (yytype
< YYNTOKENS
)
917 YYFPRINTF (yyoutput
, "token %s (", yytname
[yytype
]);
919 YYPRINT (yyoutput
, yytoknum
[yytype
], *yyvaluep
);
923 YYFPRINTF (yyoutput
, "nterm %s (", yytname
[yytype
]);
930 YYFPRINTF (yyoutput
, ")");
933 #endif /* ! YYDEBUG */
934 /*-----------------------------------------------.
935 | Release the memory associated to this symbol. |
936 `-----------------------------------------------*/
938 #if defined (__STDC__) || defined (__cplusplus)
940 yydestruct (int yytype
, YYSTYPE
*yyvaluep
)
943 yydestruct (yytype
, yyvaluep
)
948 /* Pacify ``unused variable'' warnings. */
960 /* Prevent warnings from -Wmissing-prototypes. */
963 # if defined (__STDC__) || defined (__cplusplus)
964 int yyparse (void *YYPARSE_PARAM
);
968 #else /* ! YYPARSE_PARAM */
969 #if defined (__STDC__) || defined (__cplusplus)
974 #endif /* ! YYPARSE_PARAM */
978 /* The lookahead symbol. */
981 /* The semantic value of the lookahead symbol. */
984 /* Number of syntax errors so far. */
994 # if defined (__STDC__) || defined (__cplusplus)
995 int yyparse (void *YYPARSE_PARAM
)
997 int yyparse (YYPARSE_PARAM
)
1000 #else /* ! YYPARSE_PARAM */
1001 #if defined (__STDC__) || defined (__cplusplus)
1012 register int yystate
;
1015 /* Number of tokens to shift before error messages enabled. */
1017 /* Lookahead token as an internal (translated) token number. */
1020 /* Three stacks and their tools:
1021 `yyss': related to states,
1022 `yyvs': related to semantic values,
1023 `yyls': related to locations.
1025 Refer to the stacks thru separate pointers, to allow yyoverflow
1026 to reallocate them elsewhere. */
1028 /* The state stack. */
1029 short yyssa
[YYINITDEPTH
];
1030 short *yyss
= yyssa
;
1031 register short *yyssp
;
1033 /* The semantic value stack. */
1034 YYSTYPE yyvsa
[YYINITDEPTH
];
1035 YYSTYPE
*yyvs
= yyvsa
;
1036 register YYSTYPE
*yyvsp
;
1040 #define YYPOPSTACK (yyvsp--, yyssp--)
1042 YYSIZE_T yystacksize
= YYINITDEPTH
;
1044 /* The variables used to return semantic value and location from the
1049 /* When reducing, the number of symbols on the RHS of the reduced
1053 YYDPRINTF ((stderr
, "Starting parse\n"));
1058 yychar
= YYEMPTY
; /* Cause a token to be read. */
1060 /* Initialize stack pointers.
1061 Waste one element of value and location stack
1062 so that they stay on the same level as the state stack.
1063 The wasted elements are never initialized. */
1070 /*------------------------------------------------------------.
1071 | yynewstate -- Push a new state, which is found in yystate. |
1072 `------------------------------------------------------------*/
1074 /* In all cases, when you get here, the value and location stacks
1075 have just been pushed. so pushing a state here evens the stacks.
1082 if (yyss
+ yystacksize
- 1 <= yyssp
)
1084 /* Get the current used size of the three stacks, in elements. */
1085 YYSIZE_T yysize
= yyssp
- yyss
+ 1;
1089 /* Give user a chance to reallocate the stack. Use copies of
1090 these so that the &'s don't force the real ones into
1092 YYSTYPE
*yyvs1
= yyvs
;
1093 short *yyss1
= yyss
;
1096 /* Each stack pointer address is followed by the size of the
1097 data in use in that stack, in bytes. This used to be a
1098 conditional around just the two extra args, but that might
1099 be undefined if yyoverflow is a macro. */
1100 yyoverflow ("parser stack overflow",
1101 &yyss1
, yysize
* sizeof (*yyssp
),
1102 &yyvs1
, yysize
* sizeof (*yyvsp
),
1109 #else /* no yyoverflow */
1110 # ifndef YYSTACK_RELOCATE
1113 /* Extend the stack our own way. */
1114 if (YYMAXDEPTH
<= yystacksize
)
1117 if (YYMAXDEPTH
< yystacksize
)
1118 yystacksize
= YYMAXDEPTH
;
1121 short *yyss1
= yyss
;
1122 union yyalloc
*yyptr
=
1123 (union yyalloc
*) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize
));
1126 YYSTACK_RELOCATE (yyss
);
1127 YYSTACK_RELOCATE (yyvs
);
1129 # undef YYSTACK_RELOCATE
1131 YYSTACK_FREE (yyss1
);
1134 #endif /* no yyoverflow */
1136 yyssp
= yyss
+ yysize
- 1;
1137 yyvsp
= yyvs
+ yysize
- 1;
1140 YYDPRINTF ((stderr
, "Stack size increased to %lu\n",
1141 (unsigned long int) yystacksize
));
1143 if (yyss
+ yystacksize
- 1 <= yyssp
)
1147 YYDPRINTF ((stderr
, "Entering state %d\n", yystate
));
1156 /* Do appropriate processing given the current state. */
1157 /* Read a lookahead token if we need one and don't already have one. */
1160 /* First try to decide what to do without reference to lookahead token. */
1162 yyn
= yypact
[yystate
];
1163 if (yyn
== YYPACT_NINF
)
1166 /* Not known => get a lookahead token if don't already have one. */
1168 /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */
1169 if (yychar
== YYEMPTY
)
1171 YYDPRINTF ((stderr
, "Reading a token: "));
1175 if (yychar
<= YYEOF
)
1177 yychar
= yytoken
= YYEOF
;
1178 YYDPRINTF ((stderr
, "Now at end of input.\n"));
1182 yytoken
= YYTRANSLATE (yychar
);
1183 YYDSYMPRINTF ("Next token is", yytoken
, &yylval
, &yylloc
);
1186 /* If the proper action on seeing token YYTOKEN is to reduce or to
1187 detect an error, take that action. */
1189 if (yyn
< 0 || YYLAST
< yyn
|| yycheck
[yyn
] != yytoken
)
1194 if (yyn
== 0 || yyn
== YYTABLE_NINF
)
1203 /* Shift the lookahead token. */
1204 YYDPRINTF ((stderr
, "Shifting token %s, ", yytname
[yytoken
]));
1206 /* Discard the token being shifted unless it is eof. */
1207 if (yychar
!= YYEOF
)
1213 /* Count tokens shifted since error; after three, turn off error
1222 /*-----------------------------------------------------------.
1223 | yydefault -- do the default action for the current state. |
1224 `-----------------------------------------------------------*/
1226 yyn
= yydefact
[yystate
];
1232 /*-----------------------------.
1233 | yyreduce -- Do a reduction. |
1234 `-----------------------------*/
1236 /* yyn is the number of a rule to reduce with. */
1239 /* If YYLEN is nonzero, implement the default value of the action:
1242 Otherwise, the following line sets YYVAL to garbage.
1243 This behavior is undocumented and Bison
1244 users should not rely upon it. Assigning to YYVAL
1245 unconditionally makes the parser a bit smaller, and it avoids a
1246 GCC warning that YYVAL may be used uninitialized. */
1247 yyval
= yyvsp
[1-yylen
];
1250 YY_REDUCE_PRINT (yyn
);
1255 {yyval
.node
=_asn1_add_node(TYPE_DEFINITIONS
|yyvsp
[-5].constant
);
1256 _asn1_set_name(yyval
.node
,_asn1_get_name(yyvsp
[-7].node
));
1257 _asn1_set_name(yyvsp
[-7].node
,"");
1258 _asn1_set_right(yyvsp
[-7].node
,yyvsp
[-1].node
);
1259 _asn1_set_down(yyval
.node
,yyvsp
[-7].node
);
1267 {strcpy(yyval
.str
,yyvsp
[0].str
);}
1272 {strcpy(yyval
.str
,yyvsp
[0].str
);}
1277 {strcpy(yyval
.str
,"-");
1278 strcat(yyval
.str
,yyvsp
[0].str
);}
1283 {strcpy(yyval
.str
,yyvsp
[0].str
);}
1288 {strcpy(yyval
.str
,yyvsp
[0].str
);}
1293 {strcpy(yyval
.str
,yyvsp
[0].str
);}
1298 {strcpy(yyval
.str
,yyvsp
[0].str
);}
1303 {strcpy(yyval
.str
,yyvsp
[0].str
);}
1308 {strcpy(yyval
.str
,yyvsp
[0].str
);}
1313 {yyval
.node
=_asn1_add_node(TYPE_CONSTANT
);
1314 _asn1_set_value(yyval
.node
,yyvsp
[-1].str
,strlen(yyvsp
[-1].str
)+1);}
1319 {yyval
.node
=_asn1_add_node(TYPE_CONSTANT
);
1320 _asn1_set_name(yyval
.node
,yyvsp
[-3].str
);
1321 _asn1_set_value(yyval
.node
,yyvsp
[-1].str
,strlen(yyvsp
[-1].str
)+1);}
1326 {yyval
.node
=yyvsp
[0].node
;}
1331 {yyval
.node
=yyvsp
[-2].node
;
1332 _asn1_set_right(_asn1_get_last_right(yyvsp
[-2].node
),yyvsp
[0].node
);}
1337 {yyval
.node
=_asn1_add_node(TYPE_CONSTANT
);
1338 _asn1_set_value(yyval
.node
,yyvsp
[0].str
,strlen(yyvsp
[0].str
)+1);}
1343 {yyval
.node
=_asn1_add_node(TYPE_CONSTANT
);
1344 _asn1_set_name(yyval
.node
,yyvsp
[-3].str
);
1345 _asn1_set_value(yyval
.node
,yyvsp
[-1].str
,strlen(yyvsp
[-1].str
)+1);}
1350 {yyval
.node
=yyvsp
[0].node
;}
1355 {yyval
.node
=yyvsp
[-1].node
;
1356 _asn1_set_right(_asn1_get_last_right(yyvsp
[-1].node
),yyvsp
[0].node
);}
1361 {yyval
.constant
=CONST_UNIVERSAL
;}
1366 {yyval
.constant
=CONST_PRIVATE
;}
1371 {yyval
.constant
=CONST_APPLICATION
;}
1376 {yyval
.node
=_asn1_add_node(TYPE_TAG
);
1377 _asn1_set_value(yyval
.node
,yyvsp
[-1].str
,strlen(yyvsp
[-1].str
)+1);}
1382 {yyval
.node
=_asn1_add_node(TYPE_TAG
| yyvsp
[-2].constant
);
1383 _asn1_set_value(yyval
.node
,yyvsp
[-1].str
,strlen(yyvsp
[-1].str
)+1);}
1388 {yyval
.node
=yyvsp
[0].node
;}
1393 {yyval
.node
=_asn1_mod_type(yyvsp
[-1].node
,CONST_EXPLICIT
);}
1398 {yyval
.node
=_asn1_mod_type(yyvsp
[-1].node
,CONST_IMPLICIT
);}
1403 {yyval
.node
=_asn1_add_node(TYPE_DEFAULT
);
1404 _asn1_set_value(yyval
.node
,yyvsp
[0].str
,strlen(yyvsp
[0].str
)+1);}
1409 {yyval
.node
=_asn1_add_node(TYPE_DEFAULT
|CONST_TRUE
);}
1414 {yyval
.node
=_asn1_add_node(TYPE_DEFAULT
|CONST_FALSE
);}
1419 {yyval
.node
=_asn1_add_node(TYPE_INTEGER
);}
1424 {yyval
.node
=_asn1_add_node(TYPE_INTEGER
|CONST_LIST
);
1425 _asn1_set_down(yyval
.node
,yyvsp
[-1].node
);}
1430 {yyval
.node
=_asn1_add_node(TYPE_INTEGER
);}
1435 {yyval
.node
=_asn1_add_node(TYPE_INTEGER
|CONST_MIN_MAX
);
1436 _asn1_set_down(yyval
.node
,_asn1_add_node(TYPE_SIZE
));
1437 _asn1_set_value(_asn1_get_down(yyval
.node
),yyvsp
[-1].str
,strlen(yyvsp
[-1].str
)+1);
1438 _asn1_set_name(_asn1_get_down(yyval
.node
),yyvsp
[-4].str
);}
1443 {yyval
.node
=_asn1_add_node(TYPE_BOOLEAN
);}
1448 {yyval
.node
=_asn1_add_node(TYPE_TIME
|CONST_UTC
);}
1453 {yyval
.node
=_asn1_add_node(TYPE_TIME
|CONST_GENERALIZED
);}
1458 {yyval
.node
=_asn1_add_node(TYPE_SIZE
|CONST_1_PARAM
);
1459 _asn1_set_value(yyval
.node
,yyvsp
[-1].str
,strlen(yyvsp
[-1].str
)+1);}
1464 {yyval
.node
=_asn1_add_node(TYPE_SIZE
|CONST_MIN_MAX
);
1465 _asn1_set_value(yyval
.node
,yyvsp
[-4].str
,strlen(yyvsp
[-4].str
)+1);
1466 _asn1_set_name(yyval
.node
,yyvsp
[-1].str
);}
1471 {yyval
.node
=yyvsp
[0].node
;}
1476 {yyval
.node
=yyvsp
[-1].node
;}
1481 {yyval
.node
=_asn1_add_node(TYPE_GENERALSTRING
);}
1486 {yyval
.node
=_asn1_add_node(TYPE_GENERALSTRING
|CONST_SIZE
);
1487 _asn1_set_down(yyval
.node
,yyvsp
[0].node
);}
1492 {yyval
.node
=_asn1_add_node(TYPE_OCTET_STRING
);}
1497 {yyval
.node
=_asn1_add_node(TYPE_OCTET_STRING
|CONST_SIZE
);
1498 _asn1_set_down(yyval
.node
,yyvsp
[0].node
);}
1503 {yyval
.node
=_asn1_add_node(TYPE_CONSTANT
);
1504 _asn1_set_name(yyval
.node
,yyvsp
[-3].str
);
1505 _asn1_set_value(yyval
.node
,yyvsp
[-1].str
,strlen(yyvsp
[-1].str
)+1);}
1510 {yyval
.node
=yyvsp
[0].node
;}
1515 {yyval
.node
=yyvsp
[-2].node
;
1516 _asn1_set_right(_asn1_get_last_right(yyvsp
[-2].node
),yyvsp
[0].node
);}
1521 {yyval
.node
=_asn1_add_node(TYPE_BIT_STRING
);}
1526 {yyval
.node
=_asn1_add_node(TYPE_BIT_STRING
|CONST_LIST
);
1527 _asn1_set_down(yyval
.node
,yyvsp
[-1].node
);}
1532 {yyval
.node
=_asn1_add_node(TYPE_ENUMERATED
|CONST_LIST
);
1533 _asn1_set_down(yyval
.node
,yyvsp
[-1].node
);}
1538 {yyval
.node
=_asn1_add_node(TYPE_OBJECT_ID
);}
1543 {yyval
.node
=_asn1_add_node(TYPE_IDENTIFIER
);
1544 _asn1_set_value(yyval
.node
,yyvsp
[0].str
,strlen(yyvsp
[0].str
)+1);}
1549 {yyval
.node
=_asn1_add_node(TYPE_IDENTIFIER
|CONST_SIZE
);
1550 _asn1_set_value(yyval
.node
,yyvsp
[-1].str
,strlen(yyvsp
[-1].str
)+1);
1551 _asn1_set_down(yyval
.node
,yyvsp
[0].node
);}
1556 {yyval
.node
=yyvsp
[0].node
;}
1561 {yyval
.node
=yyvsp
[0].node
;}
1566 {yyval
.node
=yyvsp
[0].node
;}
1571 {yyval
.node
=yyvsp
[0].node
;}
1576 {yyval
.node
=yyvsp
[0].node
;}
1581 {yyval
.node
=yyvsp
[0].node
;}
1586 {yyval
.node
=yyvsp
[0].node
;}
1591 {yyval
.node
=yyvsp
[0].node
;}
1596 {yyval
.node
=yyvsp
[0].node
;}
1601 {yyval
.node
=yyvsp
[0].node
;}
1606 {yyval
.node
=yyvsp
[0].node
;}
1611 {yyval
.node
=_asn1_add_node(TYPE_NULL
);}
1616 {yyval
.node
=yyvsp
[0].node
;}
1621 {yyval
.node
=_asn1_mod_type(yyvsp
[0].node
,CONST_TAG
);
1622 _asn1_set_right(yyvsp
[-1].node
,_asn1_get_down(yyval
.node
));
1623 _asn1_set_down(yyval
.node
,yyvsp
[-1].node
);}
1628 {yyval
.node
=yyvsp
[0].node
;}
1633 {yyval
.node
=_asn1_mod_type(yyvsp
[-1].node
,CONST_DEFAULT
);
1634 _asn1_set_right(yyvsp
[0].node
,_asn1_get_down(yyval
.node
));
1635 _asn1_set_down(yyval
.node
,yyvsp
[0].node
);}
1640 {yyval
.node
=_asn1_mod_type(yyvsp
[-1].node
,CONST_OPTION
);}
1645 {yyval
.node
=_asn1_set_name(yyvsp
[0].node
,yyvsp
[-1].str
);}
1650 {yyval
.node
=yyvsp
[0].node
;}
1655 {yyval
.node
=yyvsp
[-2].node
;
1656 _asn1_set_right(_asn1_get_last_right(yyvsp
[-2].node
),yyvsp
[0].node
);}
1661 {yyval
.node
=_asn1_add_node(TYPE_SEQUENCE
);
1662 _asn1_set_down(yyval
.node
,yyvsp
[-1].node
);}
1667 {yyval
.node
=_asn1_add_node(TYPE_SEQUENCE_OF
);
1668 _asn1_set_down(yyval
.node
,yyvsp
[0].node
);}
1673 {yyval
.node
=_asn1_add_node(TYPE_SEQUENCE_OF
|CONST_SIZE
);
1674 _asn1_set_right(yyvsp
[-2].node
,yyvsp
[0].node
);
1675 _asn1_set_down(yyval
.node
,yyvsp
[-2].node
);}
1680 {yyval
.node
=_asn1_add_node(TYPE_SET
);
1681 _asn1_set_down(yyval
.node
,yyvsp
[-1].node
);}
1686 {yyval
.node
=_asn1_add_node(TYPE_SET_OF
);
1687 _asn1_set_down(yyval
.node
,yyvsp
[0].node
);}
1692 {yyval
.node
=_asn1_add_node(TYPE_SET_OF
|CONST_SIZE
);
1693 _asn1_set_right(yyvsp
[-2].node
,yyvsp
[0].node
);
1694 _asn1_set_down(yyval
.node
,yyvsp
[-2].node
);}
1699 {yyval
.node
=_asn1_add_node(TYPE_CHOICE
);
1700 _asn1_set_down(yyval
.node
,yyvsp
[-1].node
);}
1705 {yyval
.node
=_asn1_add_node(TYPE_ANY
);}
1710 {yyval
.node
=_asn1_add_node(TYPE_ANY
|CONST_DEFINED_BY
);
1711 _asn1_set_down(yyval
.node
,_asn1_add_node(TYPE_CONSTANT
));
1712 _asn1_set_name(_asn1_get_down(yyval
.node
),yyvsp
[0].str
);}
1717 {yyval
.node
=_asn1_set_name(yyvsp
[0].node
,yyvsp
[-2].str
);}
1722 {yyval
.node
=_asn1_add_node(TYPE_OBJECT_ID
|CONST_ASSIGN
);
1723 _asn1_set_name(yyval
.node
,yyvsp
[-6].str
);
1724 _asn1_set_down(yyval
.node
,yyvsp
[-1].node
);}
1729 {yyval
.node
=_asn1_add_node(TYPE_OBJECT_ID
|CONST_ASSIGN
|CONST_1_PARAM
);
1730 _asn1_set_name(yyval
.node
,yyvsp
[-5].str
);
1731 _asn1_set_value(yyval
.node
,yyvsp
[-4].str
,strlen(yyvsp
[-4].str
)+1);
1732 _asn1_set_down(yyval
.node
,yyvsp
[-1].node
);}
1737 {yyval
.node
=_asn1_add_node(TYPE_INTEGER
|CONST_ASSIGN
);
1738 _asn1_set_name(yyval
.node
,yyvsp
[-3].str
);
1739 _asn1_set_value(yyval
.node
,yyvsp
[0].str
,strlen(yyvsp
[0].str
)+1);}
1744 {yyval
.node
=yyvsp
[0].node
;}
1749 {yyval
.node
=yyvsp
[0].node
;}
1754 {yyval
.node
=yyvsp
[0].node
;}
1759 {yyval
.node
=yyvsp
[-1].node
;
1760 _asn1_set_right(_asn1_get_last_right(yyvsp
[-1].node
),yyvsp
[0].node
);}
1765 {yyval
.node
=_asn1_add_node(TYPE_OBJECT_ID
);
1766 _asn1_set_down(yyval
.node
,yyvsp
[-1].node
);
1767 _asn1_set_name(yyval
.node
,yyvsp
[-3].str
);}
1772 {yyval
.node
=_asn1_add_node(TYPE_OBJECT_ID
);
1773 _asn1_set_name(yyval
.node
,yyvsp
[-2].str
);}
1778 {yyval
.constant
=CONST_EXPLICIT
;}
1783 {yyval
.constant
=CONST_IMPLICIT
;}
1789 /* Line 999 of yacc.c. */
1796 YY_STACK_PRINT (yyss
, yyssp
);
1801 /* Now `shift' the result of the reduction. Determine what state
1802 that goes to, based on the state we popped back to and the rule
1803 number reduced by. */
1807 yystate
= yypgoto
[yyn
- YYNTOKENS
] + *yyssp
;
1808 if (0 <= yystate
&& yystate
<= YYLAST
&& yycheck
[yystate
] == *yyssp
)
1809 yystate
= yytable
[yystate
];
1811 yystate
= yydefgoto
[yyn
- YYNTOKENS
];
1816 /*------------------------------------.
1817 | yyerrlab -- here on detecting error |
1818 `------------------------------------*/
1820 /* If not already recovering from an error, report this error. */
1825 yyn
= yypact
[yystate
];
1827 if (YYPACT_NINF
< yyn
&& yyn
< YYLAST
)
1829 YYSIZE_T yysize
= 0;
1830 int yytype
= YYTRANSLATE (yychar
);
1835 /* Start YYX at -YYN if negative to avoid negative indexes in
1837 for (yyx
= yyn
< 0 ? -yyn
: 0;
1838 yyx
< (int) (sizeof (yytname
) / sizeof (char *)); yyx
++)
1839 if (yycheck
[yyx
+ yyn
] == yyx
&& yyx
!= YYTERROR
)
1840 yysize
+= yystrlen (yytname
[yyx
]) + 15, yycount
++;
1841 yysize
+= yystrlen ("syntax error, unexpected ") + 1;
1842 yysize
+= yystrlen (yytname
[yytype
]);
1843 yymsg
= (char *) YYSTACK_ALLOC (yysize
);
1846 char *yyp
= yystpcpy (yymsg
, "syntax error, unexpected ");
1847 yyp
= yystpcpy (yyp
, yytname
[yytype
]);
1852 for (yyx
= yyn
< 0 ? -yyn
: 0;
1853 yyx
< (int) (sizeof (yytname
) / sizeof (char *));
1855 if (yycheck
[yyx
+ yyn
] == yyx
&& yyx
!= YYTERROR
)
1857 const char *yyq
= ! yycount
? ", expecting " : " or ";
1858 yyp
= yystpcpy (yyp
, yyq
);
1859 yyp
= yystpcpy (yyp
, yytname
[yyx
]);
1864 YYSTACK_FREE (yymsg
);
1867 yyerror ("syntax error; also virtual memory exhausted");
1870 #endif /* YYERROR_VERBOSE */
1871 yyerror ("syntax error");
1876 if (yyerrstatus
== 3)
1878 /* If just tried and failed to reuse lookahead token after an
1879 error, discard it. */
1881 /* Return failure if at end of input. */
1882 if (yychar
== YYEOF
)
1884 /* Pop the error token. */
1886 /* Pop the rest of the stack. */
1887 while (yyss
< yyssp
)
1889 YYDSYMPRINTF ("Error: popping", yystos
[*yyssp
], yyvsp
, yylsp
);
1890 yydestruct (yystos
[*yyssp
], yyvsp
);
1896 YYDSYMPRINTF ("Error: discarding", yytoken
, &yylval
, &yylloc
);
1897 yydestruct (yytoken
, &yylval
);
1902 /* Else will try to reuse lookahead token after shifting the error
1907 /*----------------------------------------------------.
1908 | yyerrlab1 -- error raised explicitly by an action. |
1909 `----------------------------------------------------*/
1911 yyerrstatus
= 3; /* Each real token shifted decrements this. */
1915 yyn
= yypact
[yystate
];
1916 if (yyn
!= YYPACT_NINF
)
1919 if (0 <= yyn
&& yyn
<= YYLAST
&& yycheck
[yyn
] == YYTERROR
)
1927 /* Pop the current state because it cannot handle the error token. */
1931 YYDSYMPRINTF ("Error: popping", yystos
[*yyssp
], yyvsp
, yylsp
);
1932 yydestruct (yystos
[yystate
], yyvsp
);
1936 YY_STACK_PRINT (yyss
, yyssp
);
1942 YYDPRINTF ((stderr
, "Shifting error token, "));
1951 /*-------------------------------------.
1952 | yyacceptlab -- YYACCEPT comes here. |
1953 `-------------------------------------*/
1958 /*-----------------------------------.
1959 | yyabortlab -- YYABORT comes here. |
1960 `-----------------------------------*/
1966 /*----------------------------------------------.
1967 | yyoverflowlab -- parser overflow comes here. |
1968 `----------------------------------------------*/
1970 yyerror ("parser stack overflow");
1978 YYSTACK_FREE (yyss
);
1989 const char *key_word
[]={"::=","OPTIONAL","INTEGER","SIZE","OCTET","STRING"
1990 ,"SEQUENCE","BIT","UNIVERSAL","PRIVATE","OPTIONAL"
1991 ,"DEFAULT","CHOICE","OF","OBJECT","IDENTIFIER"
1992 ,"BOOLEAN","TRUE","FALSE","APPLICATION","ANY","DEFINED"
1993 ,"SET","BY","EXPLICIT","IMPLICIT","DEFINITIONS","TAGS"
1994 ,"BEGIN","END","UTCTime","GeneralizedTime"
1995 ,"GeneralString","FROM","IMPORTS","NULL","ENUMERATED"};
1996 const int key_word_token
[]={ASSIG
,OPTIONAL
,INTEGER
,SIZE
,OCTET
,STRING
1997 ,SEQUENCE
,BIT
,UNIVERSAL
,PRIVATE
,OPTIONAL
1998 ,DEFAULT
,CHOICE
,OF
,OBJECT
,STR_IDENTIFIER
1999 ,BOOLEAN
,TRUE
,FALSE
,APPLICATION
,ANY
,DEFINED
2000 ,SET
,BY
,EXPLICIT
,IMPLICIT
,DEFINITIONS
,TAGS
2001 ,BEGIN
,END
,UTCTime
,GeneralizedTime
2002 ,GeneralString
,FROM
,IMPORTS
,TOKEN_NULL
,ENUMERATED
};
2004 /*************************************************************/
2005 /* Function: _asn1_yylex */
2006 /* Description: looks for tokens in file_asn1 pointer file. */
2008 /* Token identifier or ASCII code or 0(zero: End Of File) */
2009 /*************************************************************/
2013 int c
,counter
=0,k
,lastc
;
2014 char string
[MAX_NAME_SIZE
+1]; /* will contain the next token */
2018 while((c
=fgetc(file_asn1
))==' ' || c
=='\t' || c
=='\n')
2019 if(c
=='\n') lineNumber
++;
2022 strcpy(lastToken
,"End Of File");
2026 if(c
=='(' || c
==')' || c
=='[' || c
==']' ||
2027 c
=='{' || c
=='}' || c
==',' || c
=='.' ||
2029 lastToken
[0]=c
;lastToken
[1]=0;
2032 if(c
=='-'){ /* Maybe the first '-' of a comment */
2033 if((c
=fgetc(file_asn1
))!='-'){
2034 ungetc(c
,file_asn1
);
2035 lastToken
[0]='-';lastToken
[1]=0;
2038 else{ /* Comments */
2041 /* A comment finishes at the next double hypen or the end of line */
2042 while((c
=fgetc(file_asn1
))!=EOF
&& c
!='\n' &&
2043 (lastc
!='-' || (lastc
=='-' && c
!='-')))
2046 strcpy(lastToken
,"End Of File");
2050 if(c
=='\n') lineNumber
++;
2051 continue; /* next char, please! (repeat the search) */
2055 string
[counter
++]=c
;
2056 /* Till the end of the token */
2057 while(!((c
=fgetc(file_asn1
))==EOF
|| c
==' '|| c
=='\t' || c
=='\n' ||
2058 c
=='(' || c
==')' || c
=='[' || c
==']' ||
2059 c
=='{' || c
=='}' || c
==',' || c
=='.'))
2061 if(counter
>=MAX_NAME_SIZE
){
2062 result_parse
=ASN1_NAME_TOO_LONG
;
2065 string
[counter
++]=c
;
2067 ungetc(c
,file_asn1
);
2069 strcpy(lastToken
,string
);
2071 /* Is STRING a number? */
2072 for(k
=0;k
<counter
;k
++)
2073 if(!isdigit(string
[k
])) break;
2076 strcpy(yylval
.str
,string
);
2077 return NUM
; /* return the number */
2080 /* Is STRING a keyword? */
2081 for(k
=0;k
<(sizeof(key_word
)/sizeof(char*));k
++)
2082 if(!strcmp(string
,key_word
[k
])) return key_word_token
[k
];
2084 /* STRING is an IDENTIFIER */
2085 strcpy(yylval
.str
,string
);
2091 /*************************************************************/
2092 /* Function: _asn1_create_errorDescription */
2093 /* Description: creates a string with the description of the*/
2096 /* error : error to describe. */
2097 /* errorDescription: string that will contain the */
2099 /*************************************************************/
2101 _asn1_create_errorDescription(int error
,char *errorDescription
)
2104 case ASN1_SUCCESS
: case ASN1_FILE_NOT_FOUND
:
2105 if (errorDescription
!=NULL
) errorDescription
[0]=0;
2107 case ASN1_SYNTAX_ERROR
:
2108 if (errorDescription
!=NULL
) {
2109 strcpy(errorDescription
,fileName
);
2110 strcat(errorDescription
,":");
2111 _asn1_ltostr(lineNumber
,errorDescription
+strlen(fileName
)+1);
2112 strcat(errorDescription
,": parse error near '");
2113 strcat(errorDescription
,lastToken
);
2114 strcat(errorDescription
,"'");
2117 case ASN1_NAME_TOO_LONG
:
2118 if (errorDescription
!=NULL
) {
2119 strcpy(errorDescription
,fileName
);
2120 strcat(errorDescription
,":");
2121 _asn1_ltostr(lineNumber
,errorDescription
+strlen(fileName
)+1);
2122 strcat(errorDescription
,": name too long (more than ");
2123 _asn1_ltostr(MAX_NAME_SIZE
,errorDescription
+strlen(errorDescription
));
2124 strcat(errorDescription
," characters)");
2127 case ASN1_IDENTIFIER_NOT_FOUND
:
2128 if (errorDescription
!=NULL
) {
2129 strcpy(errorDescription
,fileName
);
2130 strcat(errorDescription
,":");
2131 strcat(errorDescription
,": identifier '");
2132 strcat(errorDescription
,_asn1_identifierMissing
);
2133 strcat(errorDescription
,"' not found");
2137 if (errorDescription
!=NULL
) errorDescription
[0]=0;
2145 * asn1_parser2tree - function used to start the parse algorithm.
2146 * @file_name: specify the path and the name of file that contains ASN.1 declarations.
2147 * @definitions: return the pointer to the structure created from
2148 * "file_name" ASN.1 declarations.
2149 * @errorDescription : return the error description or an empty string if success.
2152 * Creates the structures needed to manage the definitions included in *FILE_NAME file.
2156 * ASN1_SUCCESS\: the file has a correct syntax and every identifier is known.
2158 * ASN1_ELEMENT_NOT_EMPTY\: *POINTER not ASN1_TYPE_EMPTY.
2160 * ASN1_FILE_NOT_FOUND\: an error occured while opening FILE_NAME.
2162 * ASN1_SYNTAX_ERROR\: the syntax is not correct.
2164 * ASN1_IDENTIFIER_NOT_FOUND\: in the file there is an identifier that is not defined.
2165 * ASN1_NAME_TOO_LONG\: in the file there is an identifier whith more than MAX_NAME_SIZE characters.
2168 asn1_parser2tree(const char *file_name
,ASN1_TYPE
*definitions
,char *errorDescription
){
2170 p_tree
=ASN1_TYPE_EMPTY
;
2172 if(*definitions
!= ASN1_TYPE_EMPTY
)
2173 return ASN1_ELEMENT_NOT_EMPTY
;
2175 *definitions
=ASN1_TYPE_EMPTY
;
2177 fileName
= file_name
;
2179 /* open the file to parse */
2180 file_asn1
=fopen(file_name
,"r");
2182 if(file_asn1
==NULL
){
2183 result_parse
=ASN1_FILE_NOT_FOUND
;
2186 result_parse
=ASN1_SUCCESS
;
2193 if(result_parse
==ASN1_SUCCESS
){ /* syntax OK */
2194 /* set IMPLICIT or EXPLICIT property */
2195 _asn1_set_default_tag(p_tree
);
2196 /* set CONST_SET and CONST_NOT_USED */
2197 _asn1_type_set_config(p_tree
);
2198 /* check the identifier definitions */
2199 result_parse
=_asn1_check_identifier(p_tree
);
2200 if(result_parse
==ASN1_SUCCESS
){ /* all identifier defined */
2201 /* Delete the list and keep the ASN1 structure */
2202 _asn1_delete_list();
2203 /* Convert into DER coding the value assign to INTEGER constants */
2204 _asn1_change_integer_value(p_tree
);
2205 /* Expand the IDs of OBJECT IDENTIFIER constants */
2206 _asn1_expand_object_id(p_tree
);
2208 *definitions
=p_tree
;
2210 else /* some identifiers not defined */
2211 /* Delete the list and the ASN1 structure */
2212 _asn1_delete_list_and_nodes();
2214 else /* syntax error */
2215 /* Delete the list and the ASN1 structure */
2216 _asn1_delete_list_and_nodes();
2219 if (errorDescription
!=NULL
)
2220 _asn1_create_errorDescription(result_parse
,errorDescription
);
2222 return result_parse
;
2227 * asn1_parser2array - function that generates a C structure from an ASN1 file
2228 * @inputFileName: specify the path and the name of file that contains ASN.1 declarations.
2229 * @outputFileName: specify the path and the name of file that will contain the C vector definition.
2230 * @vectorName: specify the name of the C vector.
2231 * @errorDescription : return the error description or an empty string if success.
2234 * Creates a file containing a C vector to use to manage the definitions included in
2235 * *INPUTFILENAME file. If *INPUTFILENAME is "/aa/bb/xx.yy" and OUTPUTFILENAME is NULL, the file created is "/aa/bb/xx_asn1_tab.c".
2236 * If VECTORNAME is NULL the vector name will be "xx_asn1_tab".
2240 * ASN1_SUCCESS\: the file has a correct syntax and every identifier is known.
2242 * ASN1_FILE_NOT_FOUND\: an error occured while opening FILE_NAME.
2244 * ASN1_SYNTAX_ERROR\: the syntax is not correct.
2246 * ASN1_IDENTIFIER_NOT_FOUND\: in the file there is an identifier that is not defined.
2247 * ASN1_NAME_TOO_LONG\: in the file there is an identifier whith more than MAX_NAME_SIZE characters.
2249 int asn1_parser2array(const char *inputFileName
,const char *outputFileName
,
2250 const char *vectorName
,char *errorDescription
){
2251 char *file_out_name
=NULL
;
2252 char *vector_name
=NULL
;
2253 const char *char_p
,*slash_p
,*dot_p
;
2257 fileName
= inputFileName
;
2259 /* open the file to parse */
2260 file_asn1
=fopen(inputFileName
,"r");
2263 result_parse
=ASN1_FILE_NOT_FOUND
;
2265 result_parse
=ASN1_SUCCESS
;
2272 if(result_parse
==ASN1_SUCCESS
){ /* syntax OK */
2273 /* set IMPLICIT or EXPLICIT property */
2274 _asn1_set_default_tag(p_tree
);
2275 /* set CONST_SET and CONST_NOT_USED */
2276 _asn1_type_set_config(p_tree
);
2277 /* check the identifier definitions */
2278 result_parse
=_asn1_check_identifier(p_tree
);
2280 if(result_parse
==ASN1_SUCCESS
){ /* all identifier defined */
2282 /* searching the last '/' and '.' in inputFileName */
2283 char_p
=inputFileName
;
2284 slash_p
=inputFileName
;
2285 while((char_p
=strchr(char_p
,'/'))){
2291 dot_p
=inputFileName
+strlen(inputFileName
);
2293 while((char_p
=strchr(char_p
,'.'))){
2298 if(outputFileName
== NULL
){
2299 /* file_out_name = inputFileName + _asn1_tab.c */
2300 file_out_name
=(char *)malloc(dot_p
-inputFileName
+1+
2301 strlen("_asn1_tab.c"));
2302 memcpy(file_out_name
,inputFileName
,dot_p
-inputFileName
);
2303 file_out_name
[dot_p
-inputFileName
]=0;
2304 strcat(file_out_name
,"_asn1_tab.c");
2307 /* file_out_name = inputFileName */
2308 file_out_name
=(char *)malloc(strlen(outputFileName
)+1);
2309 strcpy(file_out_name
,outputFileName
);
2312 if(vectorName
== NULL
){
2313 /* vector_name = file name + _asn1_tab */
2314 vector_name
=(char *)malloc(dot_p
-slash_p
+1+
2315 strlen("_asn1_tab"));
2316 memcpy(vector_name
,slash_p
,dot_p
-slash_p
);
2317 vector_name
[dot_p
-slash_p
]=0;
2318 strcat(vector_name
,"_asn1_tab");
2321 /* vector_name = vectorName */
2322 vector_name
=(char *)malloc(strlen(vectorName
)+1);
2323 strcpy(vector_name
,vectorName
);
2326 /* Save structure in a file */
2327 _asn1_create_static_structure(p_tree
,
2328 file_out_name
,vector_name
);
2330 free(file_out_name
);
2332 } /* result == OK */
2333 } /* result == OK */
2335 /* Delete the list and the ASN1 structure */
2336 _asn1_delete_list_and_nodes();
2337 } /* inputFile exist */
2339 if (errorDescription
!=NULL
)
2340 _asn1_create_errorDescription(result_parse
,errorDescription
);
2342 return result_parse
;
2346 /*************************************************************/
2347 /* Function: _asn1_yyerror */
2348 /* Description: function called when there are syntax errors*/
2350 /* char *s : error description */
2353 /*************************************************************/
2354 int _asn1_yyerror (char *s
)
2356 /* Sends the error description to the std_out */
2358 #ifdef LIBTASN1_DEBUG_PARSER
2359 _libtasn1_log("_asn1_yyerror:%s:%d: %s (Last Token:'%s')\n",fileName
,
2360 lineNumber
,s
,lastToken
);
2363 if(result_parse
!=ASN1_NAME_TOO_LONG
)
2364 result_parse
=ASN1_SYNTAX_ERROR
;