Update.
[libtasn1.git] / lib / ASN1.c
blob1a2e8bdacf6431aec3e8b330a64317bffc183438
1 /* A Bison parser, made by GNU Bison 2.1b. */
3 /* Skeleton parser for Yacc-like parsing with Bison,
4 Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 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)
9 any later version.
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., 51 Franklin Street, Fifth Floor,
19 Boston, MA 02110-1301, 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 /* C LALR(1) parser skeleton written by Richard Stallman, by
27 simplifying the original so-called "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. */
37 #define YYBISON 1
39 /* Bison version. */
40 #define YYBISON_VERSION "2.1b"
42 /* Skeleton name. */
43 #define YYSKELETON_NAME "yacc.c"
45 /* Pure parsers. */
46 #define YYPURE 0
48 /* Using locations. */
49 #define YYLSP_NEEDED 0
51 /* Substitute the variable and function names. */
52 #define yyparse _asn1_yyparse
53 #define yylex _asn1_yylex
54 #define yyerror _asn1_yyerror
55 #define yylval _asn1_yylval
56 #define yychar _asn1_yychar
57 #define yydebug _asn1_yydebug
58 #define yynerrs _asn1_yynerrs
61 /* Tokens. */
62 #ifndef YYTOKENTYPE
63 # define YYTOKENTYPE
64 /* Put the tokens into the symbol table, so that GDB and other debuggers
65 know about them. */
66 enum yytokentype {
67 ASSIG = 258,
68 NUM = 259,
69 IDENTIFIER = 260,
70 OPTIONAL = 261,
71 INTEGER = 262,
72 SIZE = 263,
73 OCTET = 264,
74 STRING = 265,
75 SEQUENCE = 266,
76 BIT = 267,
77 UNIVERSAL = 268,
78 PRIVATE = 269,
79 APPLICATION = 270,
80 DEFAULT = 271,
81 CHOICE = 272,
82 OF = 273,
83 OBJECT = 274,
84 STR_IDENTIFIER = 275,
85 BOOLEAN = 276,
86 TRUE = 277,
87 FALSE = 278,
88 TOKEN_NULL = 279,
89 ANY = 280,
90 DEFINED = 281,
91 BY = 282,
92 SET = 283,
93 EXPLICIT = 284,
94 IMPLICIT = 285,
95 DEFINITIONS = 286,
96 TAGS = 287,
97 BEGIN = 288,
98 END = 289,
99 UTCTime = 290,
100 GeneralizedTime = 291,
101 GeneralString = 292,
102 FROM = 293,
103 IMPORTS = 294,
104 ENUMERATED = 295
106 #endif
107 /* Tokens. */
108 #define ASSIG 258
109 #define NUM 259
110 #define IDENTIFIER 260
111 #define OPTIONAL 261
112 #define INTEGER 262
113 #define SIZE 263
114 #define OCTET 264
115 #define STRING 265
116 #define SEQUENCE 266
117 #define BIT 267
118 #define UNIVERSAL 268
119 #define PRIVATE 269
120 #define APPLICATION 270
121 #define DEFAULT 271
122 #define CHOICE 272
123 #define OF 273
124 #define OBJECT 274
125 #define STR_IDENTIFIER 275
126 #define BOOLEAN 276
127 #define TRUE 277
128 #define FALSE 278
129 #define TOKEN_NULL 279
130 #define ANY 280
131 #define DEFINED 281
132 #define BY 282
133 #define SET 283
134 #define EXPLICIT 284
135 #define IMPLICIT 285
136 #define DEFINITIONS 286
137 #define TAGS 287
138 #define BEGIN 288
139 #define END 289
140 #define UTCTime 290
141 #define GeneralizedTime 291
142 #define GeneralString 292
143 #define FROM 293
144 #define IMPORTS 294
145 #define ENUMERATED 295
150 /* Copy the first part of user declarations. */
151 #line 32 "ASN1.y"
153 #include <int.h>
154 #include <errors.h>
155 #include <parser_aux.h>
156 #include <structure.h>
159 static FILE *file_asn1; /* Pointer to file to parse */
160 static asn1_retCode result_parse; /* result of the parser
161 algorithm */
162 static node_asn *p_tree; /* pointer to the root of the
163 structure created by the
164 parser*/
165 static unsigned long lineNumber; /* line number describing the
166 parser position inside the
167 file */
168 static char lastToken[MAX_NAME_SIZE+1]; /* last token find in the file
169 to parse before the 'parse
170 error' */
171 extern char _asn1_identifierMissing[];
172 static const char *fileName; /* file to parse */
174 int _asn1_yyerror (char *);
175 int _asn1_yylex(void);
179 /* Enabling traces. */
180 #ifndef YYDEBUG
181 # define YYDEBUG 0
182 #endif
184 /* Enabling verbose error messages. */
185 #ifdef YYERROR_VERBOSE
186 # undef YYERROR_VERBOSE
187 # define YYERROR_VERBOSE 1
188 #else
189 # define YYERROR_VERBOSE 0
190 #endif
192 /* Enabling the token table. */
193 #ifndef YYTOKEN_TABLE
194 # define YYTOKEN_TABLE 0
195 #endif
197 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
198 typedef union YYSTYPE
199 #line 62 "ASN1.y"
201 unsigned int constant;
202 char str[MAX_NAME_SIZE+1];
203 node_asn* node;
205 /* Line 198 of yacc.c. */
206 #line 207 "ASN1.c"
207 YYSTYPE;
208 # define yystype YYSTYPE /* obsolescent; will be withdrawn */
209 # define YYSTYPE_IS_DECLARED 1
210 # define YYSTYPE_IS_TRIVIAL 1
211 #endif
215 /* Copy the second part of user declarations. */
218 /* Line 221 of yacc.c. */
219 #line 220 "ASN1.c"
221 #ifdef short
222 # undef short
223 #endif
225 #ifdef YYTYPE_UINT8
226 typedef YYTYPE_UINT8 yytype_uint8;
227 #else
228 typedef unsigned char yytype_uint8;
229 #endif
231 #ifdef YYTYPE_INT8
232 typedef YYTYPE_INT8 yytype_int8;
233 #elif (defined __STDC__ || defined __C99__FUNC__ \
234 || defined __cplusplus || defined _MSC_VER)
235 typedef signed char yytype_int8;
236 #else
237 typedef short int yytype_int8;
238 #endif
240 #ifdef YYTYPE_UINT16
241 typedef YYTYPE_UINT16 yytype_uint16;
242 #else
243 typedef unsigned short int yytype_uint16;
244 #endif
246 #ifdef YYTYPE_INT16
247 typedef YYTYPE_INT16 yytype_int16;
248 #else
249 typedef short int yytype_int16;
250 #endif
252 #ifndef YYSIZE_T
253 # ifdef __SIZE_TYPE__
254 # define YYSIZE_T __SIZE_TYPE__
255 # elif defined size_t
256 # define YYSIZE_T size_t
257 # elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \
258 || defined __cplusplus || defined _MSC_VER)
259 # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
260 # define YYSIZE_T size_t
261 # else
262 # define YYSIZE_T unsigned int
263 # endif
264 #endif
266 #define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
268 #ifndef YY_
269 # if YYENABLE_NLS
270 # if ENABLE_NLS
271 # include <libintl.h> /* INFRINGES ON USER NAME SPACE */
272 # define YY_(msgid) dgettext ("bison-runtime", msgid)
273 # endif
274 # endif
275 # ifndef YY_
276 # define YY_(msgid) msgid
277 # endif
278 #endif
280 /* Suppress unused-variable warnings by "using" E. */
281 #if ! defined lint || defined __GNUC__
282 # define YYUSE(e) ((void) (e))
283 #else
284 # define YYUSE(e) /* empty */
285 #endif
287 /* Identity function, used to suppress warnings about constant conditions. */
288 #ifndef lint
289 # define YYID(n) (n)
290 #else
291 #if (defined __STDC__ || defined __C99__FUNC__ \
292 || defined __cplusplus || defined _MSC_VER)
293 static int
294 YYID (int i)
295 #else
296 static int
297 YYID (i)
298 int i;
299 #endif
301 return i;
303 #endif
305 #if ! defined yyoverflow || YYERROR_VERBOSE
307 /* The parser invokes alloca or malloc; define the necessary symbols. */
309 # ifdef YYSTACK_USE_ALLOCA
310 # if YYSTACK_USE_ALLOCA
311 # ifdef __GNUC__
312 # define YYSTACK_ALLOC __builtin_alloca
313 # elif defined __BUILTIN_VA_ARG_INCR
314 # include <alloca.h> /* INFRINGES ON USER NAME SPACE */
315 # elif defined _AIX
316 # define YYSTACK_ALLOC __alloca
317 # elif defined _MSC_VER
318 # include <malloc.h> /* INFRINGES ON USER NAME SPACE */
319 # define alloca _alloca
320 # else
321 # define YYSTACK_ALLOC alloca
322 # if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
323 || defined __cplusplus || defined _MSC_VER)
324 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
325 # ifndef _STDLIB_H
326 # define _STDLIB_H 1
327 # endif
328 # endif
329 # endif
330 # endif
331 # endif
333 # ifdef YYSTACK_ALLOC
334 /* Pacify GCC's `empty if-body' warning. */
335 # define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0))
336 # ifndef YYSTACK_ALLOC_MAXIMUM
337 /* The OS might guarantee only one guard page at the bottom of the stack,
338 and a page size can be as small as 4096 bytes. So we cannot safely
339 invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
340 to allow for a few compiler-allocated temporary stack slots. */
341 # define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
342 # endif
343 # else
344 # define YYSTACK_ALLOC YYMALLOC
345 # define YYSTACK_FREE YYFREE
346 # ifndef YYSTACK_ALLOC_MAXIMUM
347 # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
348 # endif
349 # if (defined __cplusplus && ! defined _STDLIB_H \
350 && ! ((defined YYMALLOC || defined malloc) \
351 && (defined YYFREE || defined free)))
352 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
353 # ifndef _STDLIB_H
354 # define _STDLIB_H 1
355 # endif
356 # endif
357 # ifndef YYMALLOC
358 # define YYMALLOC malloc
359 # if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
360 || defined __cplusplus || defined _MSC_VER)
361 void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
362 # endif
363 # endif
364 # ifndef YYFREE
365 # define YYFREE free
366 # if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
367 || defined __cplusplus || defined _MSC_VER)
368 void free (void *); /* INFRINGES ON USER NAME SPACE */
369 # endif
370 # endif
371 # endif
372 #endif /* ! defined yyoverflow || YYERROR_VERBOSE */
375 #if (! defined yyoverflow \
376 && (! defined __cplusplus \
377 || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
379 /* A type that is properly aligned for any stack member. */
380 union yyalloc
382 yytype_int16 yyss;
383 YYSTYPE yyvs;
386 /* The size of the maximum gap between one aligned stack and the next. */
387 # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
389 /* The size of an array large to enough to hold all stacks, each with
390 N elements. */
391 # define YYSTACK_BYTES(N) \
392 ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
393 + YYSTACK_GAP_MAXIMUM)
395 /* Copy COUNT objects from FROM to TO. The source and destination do
396 not overlap. */
397 # ifndef YYCOPY
398 # if defined __GNUC__ && 1 < __GNUC__
399 # define YYCOPY(To, From, Count) \
400 __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
401 # else
402 # define YYCOPY(To, From, Count) \
403 do \
405 YYSIZE_T yyi; \
406 for (yyi = 0; yyi < (Count); yyi++) \
407 (To)[yyi] = (From)[yyi]; \
409 while (YYID (0))
410 # endif
411 # endif
413 /* Relocate STACK from its old location to the new one. The
414 local variables YYSIZE and YYSTACKSIZE give the old and new number of
415 elements in the stack, and YYPTR gives the new location of the
416 stack. Advance YYPTR to a properly aligned location for the next
417 stack. */
418 # define YYSTACK_RELOCATE(Stack) \
419 do \
421 YYSIZE_T yynewbytes; \
422 YYCOPY (&yyptr->Stack, Stack, yysize); \
423 Stack = &yyptr->Stack; \
424 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
425 yyptr += yynewbytes / sizeof (*yyptr); \
427 while (YYID (0))
429 #endif
431 /* YYFINAL -- State number of the termination state. */
432 #define YYFINAL 5
433 /* YYLAST -- Last index in YYTABLE. */
434 #define YYLAST 190
436 /* YYNTOKENS -- Number of terminals. */
437 #define YYNTOKENS 52
438 /* YYNNTS -- Number of nonterminals. */
439 #define YYNNTS 43
440 /* YYNRULES -- Number of rules. */
441 #define YYNRULES 99
442 /* YYNRULES -- Number of states. */
443 #define YYNSTATES 190
445 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
446 #define YYUNDEFTOK 2
447 #define YYMAXUTOK 295
449 #define YYTRANSLATE(YYX) \
450 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
452 /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
453 static const yytype_uint8 yytranslate[] =
455 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
456 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
457 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
458 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
459 43, 44, 2, 41, 45, 42, 51, 2, 2, 2,
460 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
461 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
462 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
463 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
464 2, 46, 2, 47, 2, 2, 2, 2, 2, 2,
465 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
466 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
467 2, 2, 2, 49, 48, 50, 2, 2, 2, 2,
468 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
469 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
470 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
471 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
472 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
473 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
474 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
475 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
476 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
477 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
478 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
479 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
480 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
481 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
482 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
483 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
484 35, 36, 37, 38, 39, 40
487 #if YYDEBUG
488 /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
489 YYRHS. */
490 static const yytype_uint16 yyprhs[] =
492 0, 0, 3, 12, 14, 17, 20, 22, 24, 26,
493 28, 30, 32, 36, 41, 43, 47, 49, 54, 56,
494 59, 61, 63, 65, 69, 74, 76, 79, 82, 85,
495 88, 91, 93, 97, 99, 104, 109, 117, 119, 121,
496 123, 128, 136, 138, 142, 144, 147, 150, 154, 159,
497 161, 165, 168, 172, 178, 183, 186, 188, 191, 193,
498 195, 197, 199, 201, 203, 205, 207, 209, 211, 213,
499 215, 217, 219, 222, 224, 227, 230, 233, 235, 239,
500 244, 248, 253, 258, 262, 267, 272, 274, 279, 283,
501 291, 298, 303, 305, 307, 309, 312, 317, 321, 323
504 /* YYRHS -- A `-1'-separated list of the rules' RHS. */
505 static const yytype_int8 yyrhs[] =
507 53, 0, -1, 93, 31, 94, 32, 3, 33, 92,
508 34, -1, 4, -1, 41, 4, -1, 42, 4, -1,
509 54, -1, 55, -1, 4, -1, 5, -1, 56, -1,
510 5, -1, 43, 56, 44, -1, 5, 43, 56, 44,
511 -1, 59, -1, 60, 45, 59, -1, 57, -1, 5,
512 43, 4, 44, -1, 61, -1, 62, 61, -1, 13,
513 -1, 14, -1, 15, -1, 46, 4, 47, -1, 46,
514 63, 4, 47, -1, 64, -1, 64, 29, -1, 64,
515 30, -1, 16, 58, -1, 16, 22, -1, 16, 23,
516 -1, 56, -1, 67, 48, 56, -1, 7, -1, 7,
517 49, 60, 50, -1, 7, 43, 67, 44, -1, 7,
518 43, 57, 51, 51, 57, 44, -1, 21, -1, 35,
519 -1, 36, -1, 8, 43, 57, 44, -1, 8, 43,
520 57, 51, 51, 57, 44, -1, 71, -1, 43, 71,
521 44, -1, 37, -1, 37, 72, -1, 9, 10, -1,
522 9, 10, 72, -1, 5, 43, 4, 44, -1, 75,
523 -1, 76, 45, 75, -1, 12, 10, -1, 12, 10,
524 72, -1, 12, 10, 49, 76, 50, -1, 40, 49,
525 76, 50, -1, 19, 20, -1, 5, -1, 5, 72,
526 -1, 68, -1, 78, -1, 69, -1, 70, -1, 74,
527 -1, 77, -1, 73, -1, 85, -1, 79, -1, 87,
528 -1, 88, -1, 86, -1, 24, -1, 80, -1, 65,
529 80, -1, 81, -1, 81, 66, -1, 81, 6, -1,
530 5, 82, -1, 83, -1, 84, 45, 83, -1, 11,
531 49, 84, 50, -1, 11, 18, 80, -1, 11, 72,
532 18, 80, -1, 28, 49, 84, 50, -1, 28, 18,
533 80, -1, 28, 72, 18, 80, -1, 17, 49, 84,
534 50, -1, 25, -1, 25, 26, 27, 5, -1, 5,
535 3, 81, -1, 5, 19, 20, 3, 49, 62, 50,
536 -1, 5, 5, 3, 49, 62, 50, -1, 5, 7,
537 3, 56, -1, 89, -1, 90, -1, 91, -1, 92,
538 91, -1, 5, 49, 62, 50, -1, 5, 49, 50,
539 -1, 29, -1, 30, -1
542 /* YYRLINE[YYN] -- source line where rule number YYN was defined. */
543 static const yytype_uint16 yyrline[] =
545 0, 124, 124, 137, 138, 141, 145, 146, 149, 150,
546 153, 154, 157, 159, 164, 165, 169, 171, 176, 177,
547 181, 182, 183, 186, 188, 192, 193, 194, 197, 199,
548 200, 204, 205, 209, 210, 212, 213, 220, 223, 224,
549 227, 229, 235, 236, 239, 240, 244, 245, 249, 254,
550 255, 259, 260, 261, 266, 272, 275, 277, 280, 281,
551 282, 283, 284, 285, 286, 287, 288, 289, 290, 291,
552 292, 295, 296, 301, 302, 305, 308, 311, 312, 316,
553 318, 320, 325, 327, 329, 334, 338, 339, 344, 347,
554 351, 356, 362, 363, 366, 367, 371, 374, 398, 399
556 #endif
558 #if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
559 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
560 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
561 static const char *const yytname[] =
563 "$end", "error", "$undefined", "\"::=\"", "NUM", "IDENTIFIER",
564 "OPTIONAL", "INTEGER", "SIZE", "OCTET", "STRING", "SEQUENCE", "BIT",
565 "UNIVERSAL", "PRIVATE", "APPLICATION", "DEFAULT", "CHOICE", "OF",
566 "OBJECT", "STR_IDENTIFIER", "BOOLEAN", "TRUE", "FALSE", "TOKEN_NULL",
567 "ANY", "DEFINED", "BY", "SET", "EXPLICIT", "IMPLICIT", "DEFINITIONS",
568 "TAGS", "BEGIN", "END", "UTCTime", "GeneralizedTime", "GeneralString",
569 "FROM", "IMPORTS", "ENUMERATED", "'+'", "'-'", "'('", "')'", "','",
570 "'['", "']'", "'|'", "'{'", "'}'", "'.'", "$accept", "definitions",
571 "pos_num", "neg_num", "pos_neg_num", "num_identifier",
572 "pos_neg_identifier", "constant", "constant_list", "obj_constant",
573 "obj_constant_list", "class", "tag_type", "tag", "default",
574 "pos_neg_list", "integer_def", "boolean_def", "Time", "size_def2",
575 "size_def", "generalstring_def", "octet_string_def", "bit_element",
576 "bit_element_list", "bit_string_def", "enumerated_def", "object_def",
577 "type_assig_right", "type_assig_right_tag",
578 "type_assig_right_tag_default", "type_assig", "type_assig_list",
579 "sequence_def", "set_def", "choise_def", "any_def", "type_def",
580 "constant_def", "type_constant", "type_constant_list", "definitions_id",
581 "explicit_implicit", 0
583 #endif
585 # ifdef YYPRINT
586 /* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
587 token YYLEX-NUM. */
588 static const yytype_uint16 yytoknum[] =
590 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
591 265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
592 275, 276, 277, 278, 279, 280, 281, 282, 283, 284,
593 285, 286, 287, 288, 289, 290, 291, 292, 293, 294,
594 295, 43, 45, 40, 41, 44, 91, 93, 124, 123,
595 125, 46
597 # endif
599 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
600 static const yytype_uint8 yyr1[] =
602 0, 52, 53, 54, 54, 55, 56, 56, 57, 57,
603 58, 58, 59, 59, 60, 60, 61, 61, 62, 62,
604 63, 63, 63, 64, 64, 65, 65, 65, 66, 66,
605 66, 67, 67, 68, 68, 68, 68, 69, 70, 70,
606 71, 71, 72, 72, 73, 73, 74, 74, 75, 76,
607 76, 77, 77, 77, 78, 79, 80, 80, 80, 80,
608 80, 80, 80, 80, 80, 80, 80, 80, 80, 80,
609 80, 81, 81, 82, 82, 82, 83, 84, 84, 85,
610 85, 85, 86, 86, 86, 87, 88, 88, 89, 90,
611 90, 90, 91, 91, 92, 92, 93, 93, 94, 94
614 /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
615 static const yytype_uint8 yyr2[] =
617 0, 2, 8, 1, 2, 2, 1, 1, 1, 1,
618 1, 1, 3, 4, 1, 3, 1, 4, 1, 2,
619 1, 1, 1, 3, 4, 1, 2, 2, 2, 2,
620 2, 1, 3, 1, 4, 4, 7, 1, 1, 1,
621 4, 7, 1, 3, 1, 2, 2, 3, 4, 1,
622 3, 2, 3, 5, 4, 2, 1, 2, 1, 1,
623 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
624 1, 1, 2, 1, 2, 2, 2, 1, 3, 4,
625 3, 4, 4, 3, 4, 4, 1, 4, 3, 7,
626 6, 4, 1, 1, 1, 2, 4, 3, 1, 1
629 /* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
630 STATE-NUM when YYTABLE doesn't specify something else to do. Zero
631 means the default is an error. */
632 static const yytype_uint8 yydefact[] =
634 0, 0, 0, 0, 0, 1, 0, 8, 9, 97,
635 16, 18, 0, 98, 99, 0, 0, 96, 19, 0,
636 0, 0, 17, 0, 0, 92, 93, 94, 0, 0,
637 0, 0, 0, 2, 95, 56, 33, 0, 0, 0,
638 0, 0, 37, 70, 86, 0, 38, 39, 44, 0,
639 0, 25, 0, 58, 60, 61, 64, 62, 63, 59,
640 66, 71, 88, 65, 69, 67, 68, 0, 0, 0,
641 0, 0, 42, 57, 0, 0, 46, 0, 0, 0,
642 51, 0, 55, 0, 0, 0, 0, 45, 0, 0,
643 20, 21, 22, 0, 26, 27, 72, 0, 3, 0,
644 0, 6, 7, 91, 0, 0, 0, 3, 9, 31,
645 0, 0, 0, 0, 14, 0, 47, 80, 0, 77,
646 0, 0, 0, 52, 0, 0, 83, 0, 0, 0,
647 49, 0, 23, 0, 0, 4, 5, 0, 0, 43,
648 0, 35, 0, 0, 0, 0, 34, 73, 76, 0,
649 79, 81, 0, 85, 87, 82, 84, 0, 0, 54,
650 24, 90, 0, 40, 0, 0, 32, 0, 12, 15,
651 75, 0, 74, 78, 53, 0, 50, 89, 0, 0,
652 13, 11, 29, 30, 10, 28, 48, 0, 36, 41
655 /* YYDEFGOTO[NTERM-NUM]. */
656 static const yytype_int16 yydefgoto[] =
658 -1, 2, 101, 102, 103, 10, 185, 114, 115, 11,
659 12, 93, 51, 52, 172, 111, 53, 54, 55, 72,
660 73, 56, 57, 130, 131, 58, 59, 60, 61, 62,
661 148, 119, 120, 63, 64, 65, 66, 25, 26, 27,
662 28, 3, 15
665 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
666 STATE-NUM. */
667 #define YYPACT_NINF -80
668 static const yytype_int16 yypact[] =
670 9, -19, 33, 54, 0, -80, 44, -80, 40, -80,
671 -80, -80, 2, -80, -80, 55, 45, -80, -80, 86,
672 51, 75, -80, 106, 59, -80, -80, -80, 11, 79,
673 117, 130, 115, -80, -80, 17, -1, 127, 16, 129,
674 96, 126, -80, -80, 122, 18, -80, -80, 17, 100,
675 25, 80, 119, -80, -80, -80, -80, -80, -80, -80,
676 -80, -80, -80, -80, -80, -80, -80, 102, 27, 149,
677 110, 150, -80, -80, 39, 10, 17, 119, 152, 142,
678 14, 152, -80, 134, 119, 152, 144, -80, 158, 118,
679 -80, -80, -80, 160, -80, -80, -80, 42, -80, 162,
680 163, -80, -80, -80, 120, 137, 124, 121, -80, -80,
681 123, -27, 128, 27, -80, 32, -80, -80, 79, -80,
682 52, 119, 158, -80, 56, 165, -80, 73, 119, 132,
683 -80, 82, -80, 131, 4, -80, -80, 42, -32, -80,
684 125, -80, 27, 27, 133, 10, -80, 21, -80, 152,
685 -80, -80, 84, -80, -80, -80, -80, 169, 158, -80,
686 -80, -80, 6, -80, 135, 137, -80, 136, -80, -80,
687 -80, 71, -80, -80, -80, 138, -80, -80, 137, 139,
688 -80, -80, -80, -80, -80, -80, -80, 140, -80, -80
691 /* YYPGOTO[NTERM-NUM]. */
692 static const yytype_int16 yypgoto[] =
694 -80, -80, -80, -80, -72, -73, -80, 34, -80, -12,
695 -79, -80, -80, -80, -80, -80, -80, -80, -80, 114,
696 -25, -80, -80, 23, 65, -80, -80, -80, -49, 70,
697 -80, 41, 36, -80, -80, -80, -80, -80, -80, 161,
698 -80, -80, -80
701 /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
702 positive, shift that token. If negative, reduce the rule which
703 number is the opposite. If zero, do what YYDEFACT says.
704 If YYTABLE_NINF, syntax error. */
705 #define YYTABLE_NINF -9
706 static const yytype_int16 yytable[] =
708 18, 110, 109, 96, 7, 8, 7, 8, 7, 8,
709 7, 8, 163, 79, 1, 112, 24, 141, 134, 164,
710 86, 142, 70, 87, 70, 70, 70, 170, 117, 89,
711 4, 98, 138, 5, 77, 126, 84, 171, 90, 91,
712 92, 144, 74, 107, 108, 33, 7, 8, 75, 20,
713 9, 116, 17, 113, 161, 123, 177, 71, 162, 71,
714 71, 71, 29, 122, 30, 78, 31, 85, 99, 100,
715 166, 167, 151, 13, 14, 98, 181, 145, 32, 156,
716 99, 100, 146, 16, 35, 6, 36, 19, 37, 21,
717 38, 39, 179, 182, 183, 22, 40, 149, 41, 184,
718 42, 149, 150, 43, 44, 187, 153, 45, 23, 94,
719 95, 24, 99, 100, 46, 47, 48, 124, 149, 49,
720 67, 127, 18, 155, 35, 50, 36, 158, 37, 158,
721 38, 39, 159, 68, 174, 69, 40, 76, 41, 80,
722 42, 7, 108, 43, 44, 81, 82, 45, 83, 88,
723 18, 97, 104, 105, 46, 47, 48, 118, 70, 49,
724 121, 125, 128, 129, 133, 132, 135, 136, 139, 137,
725 154, 143, -8, 175, 140, 157, 165, 168, 160, 169,
726 180, 176, 186, 188, 189, 106, 178, 152, 147, 34,
730 static const yytype_uint8 yycheck[] =
732 12, 74, 74, 52, 4, 5, 4, 5, 4, 5,
733 4, 5, 44, 38, 5, 5, 5, 44, 97, 51,
734 45, 48, 8, 48, 8, 8, 8, 6, 77, 4,
735 49, 4, 105, 0, 18, 84, 18, 16, 13, 14,
736 15, 113, 43, 4, 5, 34, 4, 5, 49, 4,
737 50, 76, 50, 43, 50, 80, 50, 43, 137, 43,
738 43, 43, 3, 49, 5, 49, 7, 49, 41, 42,
739 142, 143, 121, 29, 30, 4, 5, 45, 19, 128,
740 41, 42, 50, 43, 5, 31, 7, 32, 9, 3,
741 11, 12, 165, 22, 23, 44, 17, 45, 19, 171,
742 21, 45, 50, 24, 25, 178, 50, 28, 33, 29,
743 30, 5, 41, 42, 35, 36, 37, 81, 45, 40,
744 3, 85, 134, 50, 5, 46, 7, 45, 9, 45,
745 11, 12, 50, 3, 50, 20, 17, 10, 19, 10,
746 21, 4, 5, 24, 25, 49, 20, 28, 26, 49,
747 162, 49, 3, 43, 35, 36, 37, 5, 8, 40,
748 18, 27, 18, 5, 4, 47, 4, 4, 44, 49,
749 5, 43, 51, 4, 51, 43, 51, 44, 47, 145,
750 44, 158, 44, 44, 44, 71, 51, 122, 118, 28,
754 /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
755 symbol of state STATE-NUM. */
756 static const yytype_uint8 yystos[] =
758 0, 5, 53, 93, 49, 0, 31, 4, 5, 50,
759 57, 61, 62, 29, 30, 94, 43, 50, 61, 32,
760 4, 3, 44, 33, 5, 89, 90, 91, 92, 3,
761 5, 7, 19, 34, 91, 5, 7, 9, 11, 12,
762 17, 19, 21, 24, 25, 28, 35, 36, 37, 40,
763 46, 64, 65, 68, 69, 70, 73, 74, 77, 78,
764 79, 80, 81, 85, 86, 87, 88, 3, 3, 20,
765 8, 43, 71, 72, 43, 49, 10, 18, 49, 72,
766 10, 49, 20, 26, 18, 49, 72, 72, 49, 4,
767 13, 14, 15, 63, 29, 30, 80, 49, 4, 41,
768 42, 54, 55, 56, 3, 43, 71, 4, 5, 56,
769 57, 67, 5, 43, 59, 60, 72, 80, 5, 83,
770 84, 18, 49, 72, 84, 27, 80, 84, 18, 5,
771 75, 76, 47, 4, 62, 4, 4, 49, 57, 44,
772 51, 44, 48, 43, 56, 45, 50, 81, 82, 45,
773 50, 80, 76, 50, 5, 50, 80, 43, 45, 50,
774 47, 50, 62, 44, 51, 51, 56, 56, 44, 59,
775 6, 16, 66, 83, 50, 4, 75, 50, 51, 57,
776 44, 5, 22, 23, 56, 58, 44, 57, 44, 44
779 #define yyerrok (yyerrstatus = 0)
780 #define yyclearin (yychar = YYEMPTY)
781 #define YYEMPTY (-2)
782 #define YYEOF 0
784 #define YYACCEPT goto yyacceptlab
785 #define YYABORT goto yyabortlab
786 #define YYERROR goto yyerrorlab
789 /* Like YYERROR except do call yyerror. This remains here temporarily
790 to ease the transition to the new meaning of YYERROR, for GCC.
791 Once GCC version 2 has supplanted version 1, this can go. */
793 #define YYFAIL goto yyerrlab
795 #define YYRECOVERING() (!!yyerrstatus)
797 #define YYBACKUP(Token, Value) \
798 do \
799 if (yychar == YYEMPTY && yylen == 1) \
801 yychar = (Token); \
802 yylval = (Value); \
803 yytoken = YYTRANSLATE (yychar); \
804 YYPOPSTACK (1); \
805 goto yybackup; \
807 else \
809 yyerror (YY_("syntax error: cannot back up")); \
810 YYERROR; \
812 while (YYID (0))
815 #define YYTERROR 1
816 #define YYERRCODE 256
819 /* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
820 If N is 0, then set CURRENT to the empty location which ends
821 the previous symbol: RHS[0] (always defined). */
823 #define YYRHSLOC(Rhs, K) ((Rhs)[K])
824 #ifndef YYLLOC_DEFAULT
825 # define YYLLOC_DEFAULT(Current, Rhs, N) \
826 do \
827 if (YYID (N)) \
829 (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
830 (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
831 (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
832 (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
834 else \
836 (Current).first_line = (Current).last_line = \
837 YYRHSLOC (Rhs, 0).last_line; \
838 (Current).first_column = (Current).last_column = \
839 YYRHSLOC (Rhs, 0).last_column; \
841 while (YYID (0))
842 #endif
845 /* YY_LOCATION_PRINT -- Print the location on the stream.
846 This macro was not mandated originally: define only if we know
847 we won't break user code: when these are the locations we know. */
849 #ifndef YY_LOCATION_PRINT
850 # if YYLTYPE_IS_TRIVIAL
851 # define YY_LOCATION_PRINT(File, Loc) \
852 fprintf (File, "%d.%d-%d.%d", \
853 (Loc).first_line, (Loc).first_column, \
854 (Loc).last_line, (Loc).last_column)
855 # else
856 # define YY_LOCATION_PRINT(File, Loc) ((void) 0)
857 # endif
858 #endif
861 /* YYLEX -- calling `yylex' with the right arguments. */
863 #ifdef YYLEX_PARAM
864 # define YYLEX yylex (YYLEX_PARAM)
865 #else
866 # define YYLEX yylex ()
867 #endif
869 /* Enable debugging if requested. */
870 #if YYDEBUG
872 # ifndef YYFPRINTF
873 # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
874 # define YYFPRINTF fprintf
875 # endif
877 # define YYDPRINTF(Args) \
878 do { \
879 if (yydebug) \
880 YYFPRINTF Args; \
881 } while (YYID (0))
883 # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
884 do { \
885 if (yydebug) \
887 YYFPRINTF (stderr, "%s ", Title); \
888 yy_symbol_print (stderr, \
889 Type, Value); \
890 YYFPRINTF (stderr, "\n"); \
892 } while (YYID (0))
895 /*--------------------------------.
896 | Print this symbol on YYOUTPUT. |
897 `--------------------------------*/
899 /*ARGSUSED*/
900 #if (defined __STDC__ || defined __C99__FUNC__ \
901 || defined __cplusplus || defined _MSC_VER)
902 static void
903 yy_symbol_value_print (FILE *yyoutput, int yytype, const YYSTYPE * const yyvaluep)
904 #else
905 static void
906 yy_symbol_value_print (yyoutput, yytype, yyvaluep)
907 FILE *yyoutput;
908 int yytype;
909 const YYSTYPE * const yyvaluep;
910 #endif
912 if (!yyvaluep)
913 return;
914 # ifdef YYPRINT
915 if (yytype < YYNTOKENS)
916 YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
917 # else
918 YYUSE (yyoutput);
919 # endif
920 switch (yytype)
922 default:
923 break;
928 /*--------------------------------.
929 | Print this symbol on YYOUTPUT. |
930 `--------------------------------*/
932 #if (defined __STDC__ || defined __C99__FUNC__ \
933 || defined __cplusplus || defined _MSC_VER)
934 static void
935 yy_symbol_print (FILE *yyoutput, int yytype, const YYSTYPE * const yyvaluep)
936 #else
937 static void
938 yy_symbol_print (yyoutput, yytype, yyvaluep)
939 FILE *yyoutput;
940 int yytype;
941 const YYSTYPE * const yyvaluep;
942 #endif
944 if (yytype < YYNTOKENS)
945 YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
946 else
947 YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
949 yy_symbol_value_print (yyoutput, yytype, yyvaluep);
950 YYFPRINTF (yyoutput, ")");
953 /*------------------------------------------------------------------.
954 | yy_stack_print -- Print the state stack from its BOTTOM up to its |
955 | TOP (included). |
956 `------------------------------------------------------------------*/
958 #if (defined __STDC__ || defined __C99__FUNC__ \
959 || defined __cplusplus || defined _MSC_VER)
960 static void
961 yy_stack_print (yytype_int16 *bottom, yytype_int16 *top)
962 #else
963 static void
964 yy_stack_print (bottom, top)
965 yytype_int16 *bottom;
966 yytype_int16 *top;
967 #endif
969 YYFPRINTF (stderr, "Stack now");
970 for (; bottom <= top; ++bottom)
971 YYFPRINTF (stderr, " %d", *bottom);
972 YYFPRINTF (stderr, "\n");
975 # define YY_STACK_PRINT(Bottom, Top) \
976 do { \
977 if (yydebug) \
978 yy_stack_print ((Bottom), (Top)); \
979 } while (YYID (0))
982 /*------------------------------------------------.
983 | Report that the YYRULE is going to be reduced. |
984 `------------------------------------------------*/
986 #if (defined __STDC__ || defined __C99__FUNC__ \
987 || defined __cplusplus || defined _MSC_VER)
988 static void
989 yy_reduce_print (YYSTYPE *yyvsp,
990 int yyrule)
991 #else
992 static void
993 yy_reduce_print (yyvsp, yyrule
995 YYSTYPE *yyvsp;
997 int yyrule;
998 #endif
1000 int yynrhs = yyr2[yyrule];
1001 int yyi;
1002 unsigned long int yylno = yyrline[yyrule];
1003 YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
1004 yyrule - 1, yylno);
1005 /* The symbols being reduced. */
1006 for (yyi = 0; yyi < yynrhs; yyi++)
1008 fprintf (stderr, " $%d = ", yyi + 1);
1009 yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
1010 &(yyvsp[(yyi + 1) - (yynrhs)])
1012 fprintf (stderr, "\n");
1016 # define YY_REDUCE_PRINT(Rule) \
1017 do { \
1018 if (yydebug) \
1019 yy_reduce_print (yyvsp, Rule); \
1020 } while (YYID (0))
1022 /* Nonzero means print parse trace. It is left uninitialized so that
1023 multiple parsers can coexist. */
1024 int yydebug;
1025 #else /* !YYDEBUG */
1026 # define YYDPRINTF(Args)
1027 # define YY_SYMBOL_PRINT(Title, Type, Value, Location)
1028 # define YY_STACK_PRINT(Bottom, Top)
1029 # define YY_REDUCE_PRINT(Rule)
1030 #endif /* !YYDEBUG */
1033 /* YYINITDEPTH -- initial size of the parser's stacks. */
1034 #ifndef YYINITDEPTH
1035 # define YYINITDEPTH 200
1036 #endif
1038 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
1039 if the built-in stack extension method is used).
1041 Do not make this value too large; the results are undefined if
1042 YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
1043 evaluated with infinite-precision integer arithmetic. */
1045 #ifndef YYMAXDEPTH
1046 # define YYMAXDEPTH 10000
1047 #endif
1051 #if YYERROR_VERBOSE
1053 # ifndef yystrlen
1054 # if defined __GLIBC__ && defined _STRING_H
1055 # define yystrlen strlen
1056 # else
1057 /* Return the length of YYSTR. */
1058 #if (defined __STDC__ || defined __C99__FUNC__ \
1059 || defined __cplusplus || defined _MSC_VER)
1060 static YYSIZE_T
1061 yystrlen (const char *yystr)
1062 #else
1063 static YYSIZE_T
1064 yystrlen (yystr)
1065 const char *yystr;
1066 #endif
1068 YYSIZE_T yylen;
1069 for (yylen = 0; yystr[yylen]; yylen++)
1070 continue;
1071 return yylen;
1073 # endif
1074 # endif
1076 # ifndef yystpcpy
1077 # if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
1078 # define yystpcpy stpcpy
1079 # else
1080 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
1081 YYDEST. */
1082 #if (defined __STDC__ || defined __C99__FUNC__ \
1083 || defined __cplusplus || defined _MSC_VER)
1084 static char *
1085 yystpcpy (char *yydest, const char *yysrc)
1086 #else
1087 static char *
1088 yystpcpy (yydest, yysrc)
1089 char *yydest;
1090 const char *yysrc;
1091 #endif
1093 char *yyd = yydest;
1094 const char *yys = yysrc;
1096 while ((*yyd++ = *yys++) != '\0')
1097 continue;
1099 return yyd - 1;
1101 # endif
1102 # endif
1104 # ifndef yytnamerr
1105 /* Copy to YYRES the contents of YYSTR after stripping away unnecessary
1106 quotes and backslashes, so that it's suitable for yyerror. The
1107 heuristic is that double-quoting is unnecessary unless the string
1108 contains an apostrophe, a comma, or backslash (other than
1109 backslash-backslash). YYSTR is taken from yytname. If YYRES is
1110 null, do not copy; instead, return the length of what the result
1111 would have been. */
1112 static YYSIZE_T
1113 yytnamerr (char *yyres, const char *yystr)
1115 if (*yystr == '"')
1117 size_t yyn = 0;
1118 char const *yyp = yystr;
1120 for (;;)
1121 switch (*++yyp)
1123 case '\'':
1124 case ',':
1125 goto do_not_strip_quotes;
1127 case '\\':
1128 if (*++yyp != '\\')
1129 goto do_not_strip_quotes;
1130 /* Fall through. */
1131 default:
1132 if (yyres)
1133 yyres[yyn] = *yyp;
1134 yyn++;
1135 break;
1137 case '"':
1138 if (yyres)
1139 yyres[yyn] = '\0';
1140 return yyn;
1142 do_not_strip_quotes: ;
1145 if (! yyres)
1146 return yystrlen (yystr);
1148 return yystpcpy (yyres, yystr) - yyres;
1150 # endif
1152 /* Copy into YYRESULT an error message about the unexpected token
1153 YYCHAR while in state YYSTATE. Return the number of bytes copied,
1154 including the terminating null byte. If YYRESULT is null, do not
1155 copy anything; just return the number of bytes that would be
1156 copied. As a special case, return 0 if an ordinary "syntax error"
1157 message will do. Return YYSIZE_MAXIMUM if overflow occurs during
1158 size calculation. */
1159 static YYSIZE_T
1160 yysyntax_error (char *yyresult, int yystate, int yychar)
1162 int yyn = yypact[yystate];
1164 if (! (YYPACT_NINF < yyn && yyn < YYLAST))
1165 return 0;
1166 else
1168 int yytype = YYTRANSLATE (yychar);
1169 YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]);
1170 YYSIZE_T yysize = yysize0;
1171 YYSIZE_T yysize1;
1172 int yysize_overflow = 0;
1173 enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
1174 char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
1175 int yyx;
1177 # if 0
1178 /* This is so xgettext sees the translatable formats that are
1179 constructed on the fly. */
1180 YY_("syntax error, unexpected %s");
1181 YY_("syntax error, unexpected %s, expecting %s");
1182 YY_("syntax error, unexpected %s, expecting %s or %s");
1183 YY_("syntax error, unexpected %s, expecting %s or %s or %s");
1184 YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s");
1185 # endif
1186 char *yyfmt;
1187 char const *yyf;
1188 static char const yyunexpected[] = "syntax error, unexpected %s";
1189 static char const yyexpecting[] = ", expecting %s";
1190 static char const yyor[] = " or %s";
1191 char yyformat[sizeof yyunexpected
1192 + sizeof yyexpecting - 1
1193 + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2)
1194 * (sizeof yyor - 1))];
1195 char const *yyprefix = yyexpecting;
1197 /* Start YYX at -YYN if negative to avoid negative indexes in
1198 YYCHECK. */
1199 int yyxbegin = yyn < 0 ? -yyn : 0;
1201 /* Stay within bounds of both yycheck and yytname. */
1202 int yychecklim = YYLAST - yyn;
1203 int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
1204 int yycount = 1;
1206 yyarg[0] = yytname[yytype];
1207 yyfmt = yystpcpy (yyformat, yyunexpected);
1209 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
1210 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
1212 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
1214 yycount = 1;
1215 yysize = yysize0;
1216 yyformat[sizeof yyunexpected - 1] = '\0';
1217 break;
1219 yyarg[yycount++] = yytname[yyx];
1220 yysize1 = yysize + yytnamerr (0, yytname[yyx]);
1221 yysize_overflow |= (yysize1 < yysize);
1222 yysize = yysize1;
1223 yyfmt = yystpcpy (yyfmt, yyprefix);
1224 yyprefix = yyor;
1227 yyf = YY_(yyformat);
1228 yysize1 = yysize + yystrlen (yyf);
1229 yysize_overflow |= (yysize1 < yysize);
1230 yysize = yysize1;
1232 if (yysize_overflow)
1233 return YYSIZE_MAXIMUM;
1235 if (yyresult)
1237 /* Avoid sprintf, as that infringes on the user's name space.
1238 Don't have undefined behavior even if the translation
1239 produced a string with the wrong number of "%s"s. */
1240 char *yyp = yyresult;
1241 int yyi = 0;
1242 while ((*yyp = *yyf) != '\0')
1244 if (*yyp == '%' && yyf[1] == 's' && yyi < yycount)
1246 yyp += yytnamerr (yyp, yyarg[yyi++]);
1247 yyf += 2;
1249 else
1251 yyp++;
1252 yyf++;
1256 return yysize;
1259 #endif /* YYERROR_VERBOSE */
1262 /*-----------------------------------------------.
1263 | Release the memory associated to this symbol. |
1264 `-----------------------------------------------*/
1266 /*ARGSUSED*/
1267 #if (defined __STDC__ || defined __C99__FUNC__ \
1268 || defined __cplusplus || defined _MSC_VER)
1269 static void
1270 yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
1271 #else
1272 static void
1273 yydestruct (yymsg, yytype, yyvaluep)
1274 const char *yymsg;
1275 int yytype;
1276 YYSTYPE *yyvaluep;
1277 #endif
1279 YYUSE (yyvaluep);
1281 if (!yymsg)
1282 yymsg = "Deleting";
1283 YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
1285 switch (yytype)
1288 default:
1289 break;
1294 /* Prevent warnings from -Wmissing-prototypes. */
1296 #ifdef YYPARSE_PARAM
1297 #if defined __STDC__ || defined __cplusplus
1298 int yyparse (void *YYPARSE_PARAM);
1299 #else
1300 int yyparse ();
1301 #endif
1302 #else /* ! YYPARSE_PARAM */
1303 #if defined __STDC__ || defined __cplusplus
1304 int yyparse (void);
1305 #else
1306 int yyparse ();
1307 #endif
1308 #endif /* ! YYPARSE_PARAM */
1312 /* The look-ahead symbol. */
1313 int yychar;
1315 /* The semantic value of the look-ahead symbol. */
1316 YYSTYPE yylval;
1318 /* Number of syntax errors so far. */
1319 int yynerrs;
1323 /*----------.
1324 | yyparse. |
1325 `----------*/
1327 #ifdef YYPARSE_PARAM
1328 #if (defined __STDC__ || defined __C99__FUNC__ \
1329 || defined __cplusplus || defined _MSC_VER)
1331 yyparse (void *YYPARSE_PARAM)
1332 #else
1334 yyparse (YYPARSE_PARAM)
1335 void *YYPARSE_PARAM;
1336 #endif
1337 #else /* ! YYPARSE_PARAM */
1338 #if (defined __STDC__ || defined __C99__FUNC__ \
1339 || defined __cplusplus || defined _MSC_VER)
1341 yyparse (void)
1342 #else
1344 yyparse ()
1346 #endif
1347 #endif
1350 int yystate;
1351 int yyn;
1352 int yyresult;
1353 /* Number of tokens to shift before error messages enabled. */
1354 int yyerrstatus;
1355 /* Look-ahead token as an internal (translated) token number. */
1356 int yytoken = 0;
1357 #if YYERROR_VERBOSE
1358 /* Buffer for error messages, and its allocated size. */
1359 char yymsgbuf[128];
1360 char *yymsg = yymsgbuf;
1361 YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
1362 #endif
1364 /* Three stacks and their tools:
1365 `yyss': related to states,
1366 `yyvs': related to semantic values,
1367 `yyls': related to locations.
1369 Refer to the stacks thru separate pointers, to allow yyoverflow
1370 to reallocate them elsewhere. */
1372 /* The state stack. */
1373 yytype_int16 yyssa[YYINITDEPTH];
1374 yytype_int16 *yyss = yyssa;
1375 yytype_int16 *yyssp;
1377 /* The semantic value stack. */
1378 YYSTYPE yyvsa[YYINITDEPTH];
1379 YYSTYPE *yyvs = yyvsa;
1380 YYSTYPE *yyvsp;
1384 #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
1386 YYSIZE_T yystacksize = YYINITDEPTH;
1388 /* The variables used to return semantic value and location from the
1389 action routines. */
1390 YYSTYPE yyval;
1393 /* The number of symbols on the RHS of the reduced rule.
1394 Keep to zero when no symbol should be popped. */
1395 int yylen = 0;
1397 YYDPRINTF ((stderr, "Starting parse\n"));
1399 yystate = 0;
1400 yyerrstatus = 0;
1401 yynerrs = 0;
1402 yychar = YYEMPTY; /* Cause a token to be read. */
1404 /* Initialize stack pointers.
1405 Waste one element of value and location stack
1406 so that they stay on the same level as the state stack.
1407 The wasted elements are never initialized. */
1409 yyssp = yyss;
1410 yyvsp = yyvs;
1412 goto yysetstate;
1414 /*------------------------------------------------------------.
1415 | yynewstate -- Push a new state, which is found in yystate. |
1416 `------------------------------------------------------------*/
1417 yynewstate:
1418 /* In all cases, when you get here, the value and location stacks
1419 have just been pushed. So pushing a state here evens the stacks. */
1420 yyssp++;
1422 yysetstate:
1423 *yyssp = yystate;
1425 if (yyss + yystacksize - 1 <= yyssp)
1427 /* Get the current used size of the three stacks, in elements. */
1428 YYSIZE_T yysize = yyssp - yyss + 1;
1430 #ifdef yyoverflow
1432 /* Give user a chance to reallocate the stack. Use copies of
1433 these so that the &'s don't force the real ones into
1434 memory. */
1435 YYSTYPE *yyvs1 = yyvs;
1436 yytype_int16 *yyss1 = yyss;
1439 /* Each stack pointer address is followed by the size of the
1440 data in use in that stack, in bytes. This used to be a
1441 conditional around just the two extra args, but that might
1442 be undefined if yyoverflow is a macro. */
1443 yyoverflow (YY_("memory exhausted"),
1444 &yyss1, yysize * sizeof (*yyssp),
1445 &yyvs1, yysize * sizeof (*yyvsp),
1447 &yystacksize);
1449 yyss = yyss1;
1450 yyvs = yyvs1;
1452 #else /* no yyoverflow */
1453 # ifndef YYSTACK_RELOCATE
1454 goto yyexhaustedlab;
1455 # else
1456 /* Extend the stack our own way. */
1457 if (YYMAXDEPTH <= yystacksize)
1458 goto yyexhaustedlab;
1459 yystacksize *= 2;
1460 if (YYMAXDEPTH < yystacksize)
1461 yystacksize = YYMAXDEPTH;
1464 yytype_int16 *yyss1 = yyss;
1465 union yyalloc *yyptr =
1466 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
1467 if (! yyptr)
1468 goto yyexhaustedlab;
1469 YYSTACK_RELOCATE (yyss);
1470 YYSTACK_RELOCATE (yyvs);
1472 # undef YYSTACK_RELOCATE
1473 if (yyss1 != yyssa)
1474 YYSTACK_FREE (yyss1);
1476 # endif
1477 #endif /* no yyoverflow */
1479 yyssp = yyss + yysize - 1;
1480 yyvsp = yyvs + yysize - 1;
1483 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
1484 (unsigned long int) yystacksize));
1486 if (yyss + yystacksize - 1 <= yyssp)
1487 YYABORT;
1490 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
1492 goto yybackup;
1494 /*-----------.
1495 | yybackup. |
1496 `-----------*/
1497 yybackup:
1499 /* Do appropriate processing given the current state. Read a
1500 look-ahead token if we need one and don't already have one. */
1502 /* First try to decide what to do without reference to look-ahead token. */
1503 yyn = yypact[yystate];
1504 if (yyn == YYPACT_NINF)
1505 goto yydefault;
1507 /* Not known => get a look-ahead token if don't already have one. */
1509 /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */
1510 if (yychar == YYEMPTY)
1512 YYDPRINTF ((stderr, "Reading a token: "));
1513 yychar = YYLEX;
1516 if (yychar <= YYEOF)
1518 yychar = yytoken = YYEOF;
1519 YYDPRINTF ((stderr, "Now at end of input.\n"));
1521 else
1523 yytoken = YYTRANSLATE (yychar);
1524 YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
1527 /* If the proper action on seeing token YYTOKEN is to reduce or to
1528 detect an error, take that action. */
1529 yyn += yytoken;
1530 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
1531 goto yydefault;
1532 yyn = yytable[yyn];
1533 if (yyn <= 0)
1535 if (yyn == 0 || yyn == YYTABLE_NINF)
1536 goto yyerrlab;
1537 yyn = -yyn;
1538 goto yyreduce;
1541 if (yyn == YYFINAL)
1542 YYACCEPT;
1544 /* Count tokens shifted since error; after three, turn off error
1545 status. */
1546 if (yyerrstatus)
1547 yyerrstatus--;
1549 /* Shift the look-ahead token. */
1550 YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
1552 /* Discard the shifted token unless it is eof. */
1553 if (yychar != YYEOF)
1554 yychar = YYEMPTY;
1556 yystate = yyn;
1557 *++yyvsp = yylval;
1559 goto yynewstate;
1562 /*-----------------------------------------------------------.
1563 | yydefault -- do the default action for the current state. |
1564 `-----------------------------------------------------------*/
1565 yydefault:
1566 yyn = yydefact[yystate];
1567 if (yyn == 0)
1568 goto yyerrlab;
1569 goto yyreduce;
1572 /*-----------------------------.
1573 | yyreduce -- Do a reduction. |
1574 `-----------------------------*/
1575 yyreduce:
1576 /* yyn is the number of a rule to reduce with. */
1577 yylen = yyr2[yyn];
1579 /* If YYLEN is nonzero, implement the default value of the action:
1580 `$$ = $1'.
1582 Otherwise, the following line sets YYVAL to garbage.
1583 This behavior is undocumented and Bison
1584 users should not rely upon it. Assigning to YYVAL
1585 unconditionally makes the parser a bit smaller, and it avoids a
1586 GCC warning that YYVAL may be used uninitialized. */
1587 yyval = yyvsp[1-yylen];
1590 YY_REDUCE_PRINT (yyn);
1591 switch (yyn)
1593 case 2:
1594 #line 127 "ASN1.y"
1595 {(yyval.node)=_asn1_add_node(TYPE_DEFINITIONS|(yyvsp[(3) - (8)].constant));
1596 _asn1_set_name((yyval.node),_asn1_get_name((yyvsp[(1) - (8)].node)));
1597 _asn1_set_name((yyvsp[(1) - (8)].node),"");
1598 _asn1_set_right((yyvsp[(1) - (8)].node),(yyvsp[(7) - (8)].node));
1599 _asn1_set_down((yyval.node),(yyvsp[(1) - (8)].node));
1601 p_tree=(yyval.node);
1603 break;
1605 case 3:
1606 #line 137 "ASN1.y"
1607 {strcpy((yyval.str),(yyvsp[(1) - (1)].str));}
1608 break;
1610 case 4:
1611 #line 138 "ASN1.y"
1612 {strcpy((yyval.str),(yyvsp[(2) - (2)].str));}
1613 break;
1615 case 5:
1616 #line 141 "ASN1.y"
1617 {strcpy((yyval.str),"-");
1618 strcat((yyval.str),(yyvsp[(2) - (2)].str));}
1619 break;
1621 case 6:
1622 #line 145 "ASN1.y"
1623 {strcpy((yyval.str),(yyvsp[(1) - (1)].str));}
1624 break;
1626 case 7:
1627 #line 146 "ASN1.y"
1628 {strcpy((yyval.str),(yyvsp[(1) - (1)].str));}
1629 break;
1631 case 8:
1632 #line 149 "ASN1.y"
1633 {strcpy((yyval.str),(yyvsp[(1) - (1)].str));}
1634 break;
1636 case 9:
1637 #line 150 "ASN1.y"
1638 {strcpy((yyval.str),(yyvsp[(1) - (1)].str));}
1639 break;
1641 case 10:
1642 #line 153 "ASN1.y"
1643 {strcpy((yyval.str),(yyvsp[(1) - (1)].str));}
1644 break;
1646 case 11:
1647 #line 154 "ASN1.y"
1648 {strcpy((yyval.str),(yyvsp[(1) - (1)].str));}
1649 break;
1651 case 12:
1652 #line 157 "ASN1.y"
1653 {(yyval.node)=_asn1_add_node(TYPE_CONSTANT);
1654 _asn1_set_value((yyval.node),(yyvsp[(2) - (3)].str),strlen((yyvsp[(2) - (3)].str))+1);}
1655 break;
1657 case 13:
1658 #line 159 "ASN1.y"
1659 {(yyval.node)=_asn1_add_node(TYPE_CONSTANT);
1660 _asn1_set_name((yyval.node),(yyvsp[(1) - (4)].str));
1661 _asn1_set_value((yyval.node),(yyvsp[(3) - (4)].str),strlen((yyvsp[(3) - (4)].str))+1);}
1662 break;
1664 case 14:
1665 #line 164 "ASN1.y"
1666 {(yyval.node)=(yyvsp[(1) - (1)].node);}
1667 break;
1669 case 15:
1670 #line 165 "ASN1.y"
1671 {(yyval.node)=(yyvsp[(1) - (3)].node);
1672 _asn1_set_right(_asn1_get_last_right((yyvsp[(1) - (3)].node)),(yyvsp[(3) - (3)].node));}
1673 break;
1675 case 16:
1676 #line 169 "ASN1.y"
1677 {(yyval.node)=_asn1_add_node(TYPE_CONSTANT);
1678 _asn1_set_value((yyval.node),(yyvsp[(1) - (1)].str),strlen((yyvsp[(1) - (1)].str))+1);}
1679 break;
1681 case 17:
1682 #line 171 "ASN1.y"
1683 {(yyval.node)=_asn1_add_node(TYPE_CONSTANT);
1684 _asn1_set_name((yyval.node),(yyvsp[(1) - (4)].str));
1685 _asn1_set_value((yyval.node),(yyvsp[(3) - (4)].str),strlen((yyvsp[(3) - (4)].str))+1);}
1686 break;
1688 case 18:
1689 #line 176 "ASN1.y"
1690 {(yyval.node)=(yyvsp[(1) - (1)].node);}
1691 break;
1693 case 19:
1694 #line 177 "ASN1.y"
1695 {(yyval.node)=(yyvsp[(1) - (2)].node);
1696 _asn1_set_right(_asn1_get_last_right((yyvsp[(1) - (2)].node)),(yyvsp[(2) - (2)].node));}
1697 break;
1699 case 20:
1700 #line 181 "ASN1.y"
1701 {(yyval.constant)=CONST_UNIVERSAL;}
1702 break;
1704 case 21:
1705 #line 182 "ASN1.y"
1706 {(yyval.constant)=CONST_PRIVATE;}
1707 break;
1709 case 22:
1710 #line 183 "ASN1.y"
1711 {(yyval.constant)=CONST_APPLICATION;}
1712 break;
1714 case 23:
1715 #line 186 "ASN1.y"
1716 {(yyval.node)=_asn1_add_node(TYPE_TAG);
1717 _asn1_set_value((yyval.node),(yyvsp[(2) - (3)].str),strlen((yyvsp[(2) - (3)].str))+1);}
1718 break;
1720 case 24:
1721 #line 188 "ASN1.y"
1722 {(yyval.node)=_asn1_add_node(TYPE_TAG | (yyvsp[(2) - (4)].constant));
1723 _asn1_set_value((yyval.node),(yyvsp[(3) - (4)].str),strlen((yyvsp[(3) - (4)].str))+1);}
1724 break;
1726 case 25:
1727 #line 192 "ASN1.y"
1728 {(yyval.node)=(yyvsp[(1) - (1)].node);}
1729 break;
1731 case 26:
1732 #line 193 "ASN1.y"
1733 {(yyval.node)=_asn1_mod_type((yyvsp[(1) - (2)].node),CONST_EXPLICIT);}
1734 break;
1736 case 27:
1737 #line 194 "ASN1.y"
1738 {(yyval.node)=_asn1_mod_type((yyvsp[(1) - (2)].node),CONST_IMPLICIT);}
1739 break;
1741 case 28:
1742 #line 197 "ASN1.y"
1743 {(yyval.node)=_asn1_add_node(TYPE_DEFAULT);
1744 _asn1_set_value((yyval.node),(yyvsp[(2) - (2)].str),strlen((yyvsp[(2) - (2)].str))+1);}
1745 break;
1747 case 29:
1748 #line 199 "ASN1.y"
1749 {(yyval.node)=_asn1_add_node(TYPE_DEFAULT|CONST_TRUE);}
1750 break;
1752 case 30:
1753 #line 200 "ASN1.y"
1754 {(yyval.node)=_asn1_add_node(TYPE_DEFAULT|CONST_FALSE);}
1755 break;
1757 case 33:
1758 #line 209 "ASN1.y"
1759 {(yyval.node)=_asn1_add_node(TYPE_INTEGER);}
1760 break;
1762 case 34:
1763 #line 210 "ASN1.y"
1764 {(yyval.node)=_asn1_add_node(TYPE_INTEGER|CONST_LIST);
1765 _asn1_set_down((yyval.node),(yyvsp[(3) - (4)].node));}
1766 break;
1768 case 35:
1769 #line 212 "ASN1.y"
1770 {(yyval.node)=_asn1_add_node(TYPE_INTEGER);}
1771 break;
1773 case 36:
1774 #line 214 "ASN1.y"
1775 {(yyval.node)=_asn1_add_node(TYPE_INTEGER|CONST_MIN_MAX);
1776 _asn1_set_down((yyval.node),_asn1_add_node(TYPE_SIZE));
1777 _asn1_set_value(_asn1_get_down((yyval.node)),(yyvsp[(6) - (7)].str),strlen((yyvsp[(6) - (7)].str))+1);
1778 _asn1_set_name(_asn1_get_down((yyval.node)),(yyvsp[(3) - (7)].str));}
1779 break;
1781 case 37:
1782 #line 220 "ASN1.y"
1783 {(yyval.node)=_asn1_add_node(TYPE_BOOLEAN);}
1784 break;
1786 case 38:
1787 #line 223 "ASN1.y"
1788 {(yyval.node)=_asn1_add_node(TYPE_TIME|CONST_UTC);}
1789 break;
1791 case 39:
1792 #line 224 "ASN1.y"
1793 {(yyval.node)=_asn1_add_node(TYPE_TIME|CONST_GENERALIZED);}
1794 break;
1796 case 40:
1797 #line 227 "ASN1.y"
1798 {(yyval.node)=_asn1_add_node(TYPE_SIZE|CONST_1_PARAM);
1799 _asn1_set_value((yyval.node),(yyvsp[(3) - (4)].str),strlen((yyvsp[(3) - (4)].str))+1);}
1800 break;
1802 case 41:
1803 #line 230 "ASN1.y"
1804 {(yyval.node)=_asn1_add_node(TYPE_SIZE|CONST_MIN_MAX);
1805 _asn1_set_value((yyval.node),(yyvsp[(3) - (7)].str),strlen((yyvsp[(3) - (7)].str))+1);
1806 _asn1_set_name((yyval.node),(yyvsp[(6) - (7)].str));}
1807 break;
1809 case 42:
1810 #line 235 "ASN1.y"
1811 {(yyval.node)=(yyvsp[(1) - (1)].node);}
1812 break;
1814 case 43:
1815 #line 236 "ASN1.y"
1816 {(yyval.node)=(yyvsp[(2) - (3)].node);}
1817 break;
1819 case 44:
1820 #line 239 "ASN1.y"
1821 {(yyval.node)=_asn1_add_node(TYPE_GENERALSTRING);}
1822 break;
1824 case 45:
1825 #line 240 "ASN1.y"
1826 {(yyval.node)=_asn1_add_node(TYPE_GENERALSTRING|CONST_SIZE);
1827 _asn1_set_down((yyval.node),(yyvsp[(2) - (2)].node));}
1828 break;
1830 case 46:
1831 #line 244 "ASN1.y"
1832 {(yyval.node)=_asn1_add_node(TYPE_OCTET_STRING);}
1833 break;
1835 case 47:
1836 #line 245 "ASN1.y"
1837 {(yyval.node)=_asn1_add_node(TYPE_OCTET_STRING|CONST_SIZE);
1838 _asn1_set_down((yyval.node),(yyvsp[(3) - (3)].node));}
1839 break;
1841 case 48:
1842 #line 249 "ASN1.y"
1843 {(yyval.node)=_asn1_add_node(TYPE_CONSTANT);
1844 _asn1_set_name((yyval.node),(yyvsp[(1) - (4)].str));
1845 _asn1_set_value((yyval.node),(yyvsp[(3) - (4)].str),strlen((yyvsp[(3) - (4)].str))+1);}
1846 break;
1848 case 49:
1849 #line 254 "ASN1.y"
1850 {(yyval.node)=(yyvsp[(1) - (1)].node);}
1851 break;
1853 case 50:
1854 #line 255 "ASN1.y"
1855 {(yyval.node)=(yyvsp[(1) - (3)].node);
1856 _asn1_set_right(_asn1_get_last_right((yyvsp[(1) - (3)].node)),(yyvsp[(3) - (3)].node));}
1857 break;
1859 case 51:
1860 #line 259 "ASN1.y"
1861 {(yyval.node)=_asn1_add_node(TYPE_BIT_STRING);}
1862 break;
1864 case 52:
1865 #line 260 "ASN1.y"
1866 {(yyval.node)=_asn1_add_node(TYPE_BIT_STRING|CONST_SIZE);}
1867 break;
1869 case 53:
1870 #line 262 "ASN1.y"
1871 {(yyval.node)=_asn1_add_node(TYPE_BIT_STRING|CONST_LIST);
1872 _asn1_set_down((yyval.node),(yyvsp[(4) - (5)].node));}
1873 break;
1875 case 54:
1876 #line 267 "ASN1.y"
1877 {(yyval.node)=_asn1_add_node(TYPE_ENUMERATED|CONST_LIST);
1878 _asn1_set_down((yyval.node),(yyvsp[(3) - (4)].node));}
1879 break;
1881 case 55:
1882 #line 272 "ASN1.y"
1883 {(yyval.node)=_asn1_add_node(TYPE_OBJECT_ID);}
1884 break;
1886 case 56:
1887 #line 275 "ASN1.y"
1888 {(yyval.node)=_asn1_add_node(TYPE_IDENTIFIER);
1889 _asn1_set_value((yyval.node),(yyvsp[(1) - (1)].str),strlen((yyvsp[(1) - (1)].str))+1);}
1890 break;
1892 case 57:
1893 #line 277 "ASN1.y"
1894 {(yyval.node)=_asn1_add_node(TYPE_IDENTIFIER|CONST_SIZE);
1895 _asn1_set_value((yyval.node),(yyvsp[(1) - (2)].str),strlen((yyvsp[(1) - (2)].str))+1);
1896 _asn1_set_down((yyval.node),(yyvsp[(2) - (2)].node));}
1897 break;
1899 case 58:
1900 #line 280 "ASN1.y"
1901 {(yyval.node)=(yyvsp[(1) - (1)].node);}
1902 break;
1904 case 59:
1905 #line 281 "ASN1.y"
1906 {(yyval.node)=(yyvsp[(1) - (1)].node);}
1907 break;
1909 case 60:
1910 #line 282 "ASN1.y"
1911 {(yyval.node)=(yyvsp[(1) - (1)].node);}
1912 break;
1914 case 62:
1915 #line 284 "ASN1.y"
1916 {(yyval.node)=(yyvsp[(1) - (1)].node);}
1917 break;
1919 case 63:
1920 #line 285 "ASN1.y"
1921 {(yyval.node)=(yyvsp[(1) - (1)].node);}
1922 break;
1924 case 64:
1925 #line 286 "ASN1.y"
1926 {(yyval.node)=(yyvsp[(1) - (1)].node);}
1927 break;
1929 case 65:
1930 #line 287 "ASN1.y"
1931 {(yyval.node)=(yyvsp[(1) - (1)].node);}
1932 break;
1934 case 66:
1935 #line 288 "ASN1.y"
1936 {(yyval.node)=(yyvsp[(1) - (1)].node);}
1937 break;
1939 case 67:
1940 #line 289 "ASN1.y"
1941 {(yyval.node)=(yyvsp[(1) - (1)].node);}
1942 break;
1944 case 68:
1945 #line 290 "ASN1.y"
1946 {(yyval.node)=(yyvsp[(1) - (1)].node);}
1947 break;
1949 case 69:
1950 #line 291 "ASN1.y"
1951 {(yyval.node)=(yyvsp[(1) - (1)].node);}
1952 break;
1954 case 70:
1955 #line 292 "ASN1.y"
1956 {(yyval.node)=_asn1_add_node(TYPE_NULL);}
1957 break;
1959 case 71:
1960 #line 295 "ASN1.y"
1961 {(yyval.node)=(yyvsp[(1) - (1)].node);}
1962 break;
1964 case 72:
1965 #line 296 "ASN1.y"
1966 {(yyval.node)=_asn1_mod_type((yyvsp[(2) - (2)].node),CONST_TAG);
1967 _asn1_set_right((yyvsp[(1) - (2)].node),_asn1_get_down((yyval.node)));
1968 _asn1_set_down((yyval.node),(yyvsp[(1) - (2)].node));}
1969 break;
1971 case 73:
1972 #line 301 "ASN1.y"
1973 {(yyval.node)=(yyvsp[(1) - (1)].node);}
1974 break;
1976 case 74:
1977 #line 302 "ASN1.y"
1978 {(yyval.node)=_asn1_mod_type((yyvsp[(1) - (2)].node),CONST_DEFAULT);
1979 _asn1_set_right((yyvsp[(2) - (2)].node),_asn1_get_down((yyval.node)));
1980 _asn1_set_down((yyval.node),(yyvsp[(2) - (2)].node));}
1981 break;
1983 case 75:
1984 #line 305 "ASN1.y"
1985 {(yyval.node)=_asn1_mod_type((yyvsp[(1) - (2)].node),CONST_OPTION);}
1986 break;
1988 case 76:
1989 #line 308 "ASN1.y"
1990 {(yyval.node)=_asn1_set_name((yyvsp[(2) - (2)].node),(yyvsp[(1) - (2)].str));}
1991 break;
1993 case 77:
1994 #line 311 "ASN1.y"
1995 {(yyval.node)=(yyvsp[(1) - (1)].node);}
1996 break;
1998 case 78:
1999 #line 312 "ASN1.y"
2000 {(yyval.node)=(yyvsp[(1) - (3)].node);
2001 _asn1_set_right(_asn1_get_last_right((yyvsp[(1) - (3)].node)),(yyvsp[(3) - (3)].node));}
2002 break;
2004 case 79:
2005 #line 316 "ASN1.y"
2006 {(yyval.node)=_asn1_add_node(TYPE_SEQUENCE);
2007 _asn1_set_down((yyval.node),(yyvsp[(3) - (4)].node));}
2008 break;
2010 case 80:
2011 #line 318 "ASN1.y"
2012 {(yyval.node)=_asn1_add_node(TYPE_SEQUENCE_OF);
2013 _asn1_set_down((yyval.node),(yyvsp[(3) - (3)].node));}
2014 break;
2016 case 81:
2017 #line 320 "ASN1.y"
2018 {(yyval.node)=_asn1_add_node(TYPE_SEQUENCE_OF|CONST_SIZE);
2019 _asn1_set_right((yyvsp[(2) - (4)].node),(yyvsp[(4) - (4)].node));
2020 _asn1_set_down((yyval.node),(yyvsp[(2) - (4)].node));}
2021 break;
2023 case 82:
2024 #line 325 "ASN1.y"
2025 {(yyval.node)=_asn1_add_node(TYPE_SET);
2026 _asn1_set_down((yyval.node),(yyvsp[(3) - (4)].node));}
2027 break;
2029 case 83:
2030 #line 327 "ASN1.y"
2031 {(yyval.node)=_asn1_add_node(TYPE_SET_OF);
2032 _asn1_set_down((yyval.node),(yyvsp[(3) - (3)].node));}
2033 break;
2035 case 84:
2036 #line 329 "ASN1.y"
2037 {(yyval.node)=_asn1_add_node(TYPE_SET_OF|CONST_SIZE);
2038 _asn1_set_right((yyvsp[(2) - (4)].node),(yyvsp[(4) - (4)].node));
2039 _asn1_set_down((yyval.node),(yyvsp[(2) - (4)].node));}
2040 break;
2042 case 85:
2043 #line 334 "ASN1.y"
2044 {(yyval.node)=_asn1_add_node(TYPE_CHOICE);
2045 _asn1_set_down((yyval.node),(yyvsp[(3) - (4)].node));}
2046 break;
2048 case 86:
2049 #line 338 "ASN1.y"
2050 {(yyval.node)=_asn1_add_node(TYPE_ANY);}
2051 break;
2053 case 87:
2054 #line 339 "ASN1.y"
2055 {(yyval.node)=_asn1_add_node(TYPE_ANY|CONST_DEFINED_BY);
2056 _asn1_set_down((yyval.node),_asn1_add_node(TYPE_CONSTANT));
2057 _asn1_set_name(_asn1_get_down((yyval.node)),(yyvsp[(4) - (4)].str));}
2058 break;
2060 case 88:
2061 #line 344 "ASN1.y"
2062 {(yyval.node)=_asn1_set_name((yyvsp[(3) - (3)].node),(yyvsp[(1) - (3)].str));}
2063 break;
2065 case 89:
2066 #line 348 "ASN1.y"
2067 {(yyval.node)=_asn1_add_node(TYPE_OBJECT_ID|CONST_ASSIGN);
2068 _asn1_set_name((yyval.node),(yyvsp[(1) - (7)].str));
2069 _asn1_set_down((yyval.node),(yyvsp[(6) - (7)].node));}
2070 break;
2072 case 90:
2073 #line 352 "ASN1.y"
2074 {(yyval.node)=_asn1_add_node(TYPE_OBJECT_ID|CONST_ASSIGN|CONST_1_PARAM);
2075 _asn1_set_name((yyval.node),(yyvsp[(1) - (6)].str));
2076 _asn1_set_value((yyval.node),(yyvsp[(2) - (6)].str),strlen((yyvsp[(2) - (6)].str))+1);
2077 _asn1_set_down((yyval.node),(yyvsp[(5) - (6)].node));}
2078 break;
2080 case 91:
2081 #line 357 "ASN1.y"
2082 {(yyval.node)=_asn1_add_node(TYPE_INTEGER|CONST_ASSIGN);
2083 _asn1_set_name((yyval.node),(yyvsp[(1) - (4)].str));
2084 _asn1_set_value((yyval.node),(yyvsp[(4) - (4)].str),strlen((yyvsp[(4) - (4)].str))+1);}
2085 break;
2087 case 92:
2088 #line 362 "ASN1.y"
2089 {(yyval.node)=(yyvsp[(1) - (1)].node);}
2090 break;
2092 case 93:
2093 #line 363 "ASN1.y"
2094 {(yyval.node)=(yyvsp[(1) - (1)].node);}
2095 break;
2097 case 94:
2098 #line 366 "ASN1.y"
2099 {(yyval.node)=(yyvsp[(1) - (1)].node);}
2100 break;
2102 case 95:
2103 #line 367 "ASN1.y"
2104 {(yyval.node)=(yyvsp[(1) - (2)].node);
2105 _asn1_set_right(_asn1_get_last_right((yyvsp[(1) - (2)].node)),(yyvsp[(2) - (2)].node));}
2106 break;
2108 case 96:
2109 #line 371 "ASN1.y"
2110 {(yyval.node)=_asn1_add_node(TYPE_OBJECT_ID);
2111 _asn1_set_down((yyval.node),(yyvsp[(3) - (4)].node));
2112 _asn1_set_name((yyval.node),(yyvsp[(1) - (4)].str));}
2113 break;
2115 case 97:
2116 #line 374 "ASN1.y"
2117 {(yyval.node)=_asn1_add_node(TYPE_OBJECT_ID);
2118 _asn1_set_name((yyval.node),(yyvsp[(1) - (3)].str));}
2119 break;
2121 case 98:
2122 #line 398 "ASN1.y"
2123 {(yyval.constant)=CONST_EXPLICIT;}
2124 break;
2126 case 99:
2127 #line 399 "ASN1.y"
2128 {(yyval.constant)=CONST_IMPLICIT;}
2129 break;
2132 /* Line 1272 of yacc.c. */
2133 #line 2134 "ASN1.c"
2134 default: break;
2136 YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
2138 YYPOPSTACK (yylen);
2139 yylen = 0;
2140 YY_STACK_PRINT (yyss, yyssp);
2142 *++yyvsp = yyval;
2145 /* Now `shift' the result of the reduction. Determine what state
2146 that goes to, based on the state we popped back to and the rule
2147 number reduced by. */
2149 yyn = yyr1[yyn];
2151 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
2152 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
2153 yystate = yytable[yystate];
2154 else
2155 yystate = yydefgoto[yyn - YYNTOKENS];
2157 goto yynewstate;
2160 /*------------------------------------.
2161 | yyerrlab -- here on detecting error |
2162 `------------------------------------*/
2163 yyerrlab:
2164 /* If not already recovering from an error, report this error. */
2165 if (!yyerrstatus)
2167 ++yynerrs;
2168 #if ! YYERROR_VERBOSE
2169 yyerror (YY_("syntax error"));
2170 #else
2172 YYSIZE_T yysize = yysyntax_error (0, yystate, yychar);
2173 if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM)
2175 YYSIZE_T yyalloc = 2 * yysize;
2176 if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM))
2177 yyalloc = YYSTACK_ALLOC_MAXIMUM;
2178 if (yymsg != yymsgbuf)
2179 YYSTACK_FREE (yymsg);
2180 yymsg = (char *) YYSTACK_ALLOC (yyalloc);
2181 if (yymsg)
2182 yymsg_alloc = yyalloc;
2183 else
2185 yymsg = yymsgbuf;
2186 yymsg_alloc = sizeof yymsgbuf;
2190 if (0 < yysize && yysize <= yymsg_alloc)
2192 (void) yysyntax_error (yymsg, yystate, yychar);
2193 yyerror (yymsg);
2195 else
2197 yyerror (YY_("syntax error"));
2198 if (yysize != 0)
2199 goto yyexhaustedlab;
2202 #endif
2207 if (yyerrstatus == 3)
2209 /* If just tried and failed to reuse look-ahead token after an
2210 error, discard it. */
2212 if (yychar <= YYEOF)
2214 /* Return failure if at end of input. */
2215 if (yychar == YYEOF)
2216 YYABORT;
2218 else
2220 yydestruct ("Error: discarding",
2221 yytoken, &yylval);
2222 yychar = YYEMPTY;
2226 /* Else will try to reuse look-ahead token after shifting the error
2227 token. */
2228 goto yyerrlab1;
2231 /*---------------------------------------------------.
2232 | yyerrorlab -- error raised explicitly by YYERROR. |
2233 `---------------------------------------------------*/
2234 yyerrorlab:
2236 /* Pacify compilers like GCC when the user code never invokes
2237 YYERROR and the label yyerrorlab therefore never appears in user
2238 code. */
2239 if (/*CONSTCOND*/ 0)
2240 goto yyerrorlab;
2242 /* Do not reclaim the symbols of the rule which action triggered
2243 this YYERROR. */
2244 YYPOPSTACK (yylen);
2245 yylen = 0;
2246 YY_STACK_PRINT (yyss, yyssp);
2247 yystate = *yyssp;
2248 goto yyerrlab1;
2251 /*-------------------------------------------------------------.
2252 | yyerrlab1 -- common code for both syntax error and YYERROR. |
2253 `-------------------------------------------------------------*/
2254 yyerrlab1:
2255 yyerrstatus = 3; /* Each real token shifted decrements this. */
2257 for (;;)
2259 yyn = yypact[yystate];
2260 if (yyn != YYPACT_NINF)
2262 yyn += YYTERROR;
2263 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
2265 yyn = yytable[yyn];
2266 if (0 < yyn)
2267 break;
2271 /* Pop the current state because it cannot handle the error token. */
2272 if (yyssp == yyss)
2273 YYABORT;
2276 yydestruct ("Error: popping",
2277 yystos[yystate], yyvsp);
2278 YYPOPSTACK (1);
2279 yystate = *yyssp;
2280 YY_STACK_PRINT (yyss, yyssp);
2283 if (yyn == YYFINAL)
2284 YYACCEPT;
2286 *++yyvsp = yylval;
2289 /* Shift the error token. */
2290 YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
2292 yystate = yyn;
2293 goto yynewstate;
2296 /*-------------------------------------.
2297 | yyacceptlab -- YYACCEPT comes here. |
2298 `-------------------------------------*/
2299 yyacceptlab:
2300 yyresult = 0;
2301 goto yyreturn;
2303 /*-----------------------------------.
2304 | yyabortlab -- YYABORT comes here. |
2305 `-----------------------------------*/
2306 yyabortlab:
2307 yyresult = 1;
2308 goto yyreturn;
2310 #ifndef yyoverflow
2311 /*-------------------------------------------------.
2312 | yyexhaustedlab -- memory exhaustion comes here. |
2313 `-------------------------------------------------*/
2314 yyexhaustedlab:
2315 yyerror (YY_("memory exhausted"));
2316 yyresult = 2;
2317 /* Fall through. */
2318 #endif
2320 yyreturn:
2321 if (yychar != YYEOF && yychar != YYEMPTY)
2322 yydestruct ("Cleanup: discarding lookahead",
2323 yytoken, &yylval);
2324 /* Do not reclaim the symbols of the rule which action triggered
2325 this YYABORT or YYACCEPT. */
2326 YYPOPSTACK (yylen);
2327 YY_STACK_PRINT (yyss, yyssp);
2328 while (yyssp != yyss)
2330 yydestruct ("Cleanup: popping",
2331 yystos[*yyssp], yyvsp);
2332 YYPOPSTACK (1);
2334 #ifndef yyoverflow
2335 if (yyss != yyssa)
2336 YYSTACK_FREE (yyss);
2337 #endif
2338 #if YYERROR_VERBOSE
2339 if (yymsg != yymsgbuf)
2340 YYSTACK_FREE (yymsg);
2341 #endif
2342 return yyresult;
2346 #line 403 "ASN1.y"
2351 const char *key_word[]={"::=","OPTIONAL","INTEGER","SIZE","OCTET","STRING"
2352 ,"SEQUENCE","BIT","UNIVERSAL","PRIVATE","OPTIONAL"
2353 ,"DEFAULT","CHOICE","OF","OBJECT","IDENTIFIER"
2354 ,"BOOLEAN","TRUE","FALSE","APPLICATION","ANY","DEFINED"
2355 ,"SET","BY","EXPLICIT","IMPLICIT","DEFINITIONS","TAGS"
2356 ,"BEGIN","END","UTCTime","GeneralizedTime"
2357 ,"GeneralString","FROM","IMPORTS","NULL","ENUMERATED"};
2358 const int key_word_token[]={ASSIG,OPTIONAL,INTEGER,SIZE,OCTET,STRING
2359 ,SEQUENCE,BIT,UNIVERSAL,PRIVATE,OPTIONAL
2360 ,DEFAULT,CHOICE,OF,OBJECT,STR_IDENTIFIER
2361 ,BOOLEAN,TRUE,FALSE,APPLICATION,ANY,DEFINED
2362 ,SET,BY,EXPLICIT,IMPLICIT,DEFINITIONS,TAGS
2363 ,BEGIN,END,UTCTime,GeneralizedTime
2364 ,GeneralString,FROM,IMPORTS,TOKEN_NULL,ENUMERATED};
2366 /*************************************************************/
2367 /* Function: _asn1_yylex */
2368 /* Description: looks for tokens in file_asn1 pointer file. */
2369 /* Return: int */
2370 /* Token identifier or ASCII code or 0(zero: End Of File) */
2371 /*************************************************************/
2373 _asn1_yylex()
2375 int c,counter=0,k,lastc;
2376 char string[MAX_NAME_SIZE+1]; /* will contain the next token */
2378 while(1)
2380 while((c=fgetc(file_asn1))==' ' || c=='\t' || c=='\n')
2381 if(c=='\n') lineNumber++;
2383 if(c==EOF){
2384 strcpy(lastToken,"End Of File");
2385 return 0;
2388 if(c=='(' || c==')' || c=='[' || c==']' ||
2389 c=='{' || c=='}' || c==',' || c=='.' ||
2390 c=='+' || c=='|'){
2391 lastToken[0]=c;lastToken[1]=0;
2392 return c;
2394 if(c=='-'){ /* Maybe the first '-' of a comment */
2395 if((c=fgetc(file_asn1))!='-'){
2396 ungetc(c,file_asn1);
2397 lastToken[0]='-';lastToken[1]=0;
2398 return '-';
2400 else{ /* Comments */
2401 lastc=0;
2402 counter=0;
2403 /* A comment finishes at the next double hypen or the end of line */
2404 while((c=fgetc(file_asn1))!=EOF && c!='\n' &&
2405 (lastc!='-' || (lastc=='-' && c!='-')))
2406 lastc=c;
2407 if(c==EOF){
2408 strcpy(lastToken,"End Of File");
2409 return 0;
2411 else{
2412 if(c=='\n') lineNumber++;
2413 continue; /* next char, please! (repeat the search) */
2417 string[counter++]=c;
2418 /* Till the end of the token */
2419 while(!((c=fgetc(file_asn1))==EOF || c==' '|| c=='\t' || c=='\n' ||
2420 c=='(' || c==')' || c=='[' || c==']' ||
2421 c=='{' || c=='}' || c==',' || c=='.'))
2423 if(counter>=MAX_NAME_SIZE){
2424 result_parse=ASN1_NAME_TOO_LONG;
2425 return 0;
2427 string[counter++]=c;
2429 ungetc(c,file_asn1);
2430 string[counter]=0;
2431 strcpy(lastToken,string);
2433 /* Is STRING a number? */
2434 for(k=0;k<counter;k++)
2435 if(!isdigit(string[k])) break;
2436 if(k>=counter)
2438 strcpy(yylval.str,string);
2439 return NUM; /* return the number */
2442 /* Is STRING a keyword? */
2443 for(k=0;k<(sizeof(key_word)/sizeof(char*));k++)
2444 if(!strcmp(string,key_word[k])) return key_word_token[k];
2446 /* STRING is an IDENTIFIER */
2447 strcpy(yylval.str,string);
2448 return IDENTIFIER;
2453 /*************************************************************/
2454 /* Function: _asn1_create_errorDescription */
2455 /* Description: creates a string with the description of the*/
2456 /* error. */
2457 /* Parameters: */
2458 /* error : error to describe. */
2459 /* errorDescription: string that will contain the */
2460 /* description. */
2461 /*************************************************************/
2462 void
2463 _asn1_create_errorDescription(int error,char *errorDescription)
2465 switch(error){
2466 case ASN1_SUCCESS: case ASN1_FILE_NOT_FOUND:
2467 if (errorDescription!=NULL) errorDescription[0]=0;
2468 break;
2469 case ASN1_SYNTAX_ERROR:
2470 if (errorDescription!=NULL) {
2471 strcpy(errorDescription,fileName);
2472 strcat(errorDescription,":");
2473 _asn1_ltostr(lineNumber,errorDescription+strlen(fileName)+1);
2474 strcat(errorDescription,": parse error near '");
2475 strcat(errorDescription,lastToken);
2476 strcat(errorDescription,"'");
2478 break;
2479 case ASN1_NAME_TOO_LONG:
2480 if (errorDescription!=NULL) {
2481 strcpy(errorDescription,fileName);
2482 strcat(errorDescription,":");
2483 _asn1_ltostr(lineNumber,errorDescription+strlen(fileName)+1);
2484 strcat(errorDescription,": name too long (more than ");
2485 _asn1_ltostr(MAX_NAME_SIZE,errorDescription+strlen(errorDescription));
2486 strcat(errorDescription," characters)");
2488 break;
2489 case ASN1_IDENTIFIER_NOT_FOUND:
2490 if (errorDescription!=NULL) {
2491 strcpy(errorDescription,fileName);
2492 strcat(errorDescription,":");
2493 strcat(errorDescription,": identifier '");
2494 strcat(errorDescription,_asn1_identifierMissing);
2495 strcat(errorDescription,"' not found");
2497 break;
2498 default:
2499 if (errorDescription!=NULL) errorDescription[0]=0;
2500 break;
2507 * asn1_parser2tree - function used to start the parse algorithm.
2508 * @file_name: specify the path and the name of file that contains
2509 * ASN.1 declarations.
2510 * @definitions: return the pointer to the structure created from
2511 * "file_name" ASN.1 declarations.
2512 * @errorDescription: return the error description or an empty
2513 * string if success.
2515 * Creates the structures needed to manage the definitions included
2516 * in *FILE_NAME file.
2518 * Returns:
2520 * ASN1_SUCCESS: The file has a correct syntax and every identifier
2521 * is known.
2523 * ASN1_ELEMENT_NOT_EMPTY: *POINTER not ASN1_TYPE_EMPTY.
2525 * ASN1_FILE_NOT_FOUND: An error occured while opening FILE_NAME.
2527 * ASN1_SYNTAX_ERROR: The syntax is not correct.
2529 * ASN1_IDENTIFIER_NOT_FOUND: In the file there is an identifier that
2530 * is not defined.
2532 * ASN1_NAME_TOO_LONG: In the file there is an identifier whith more
2533 * than MAX_NAME_SIZE characters.
2535 asn1_retCode
2536 asn1_parser2tree(const char *file_name, ASN1_TYPE *definitions,
2537 char *errorDescription){
2539 p_tree=ASN1_TYPE_EMPTY;
2541 if(*definitions != ASN1_TYPE_EMPTY)
2542 return ASN1_ELEMENT_NOT_EMPTY;
2544 *definitions=ASN1_TYPE_EMPTY;
2546 fileName = file_name;
2548 /* open the file to parse */
2549 file_asn1=fopen(file_name,"r");
2551 if(file_asn1==NULL){
2552 result_parse=ASN1_FILE_NOT_FOUND;
2554 else{
2555 result_parse=ASN1_SUCCESS;
2557 lineNumber=1;
2558 yyparse();
2560 fclose(file_asn1);
2562 if(result_parse==ASN1_SUCCESS){ /* syntax OK */
2563 /* set IMPLICIT or EXPLICIT property */
2564 _asn1_set_default_tag(p_tree);
2565 /* set CONST_SET and CONST_NOT_USED */
2566 _asn1_type_set_config(p_tree);
2567 /* check the identifier definitions */
2568 result_parse=_asn1_check_identifier(p_tree);
2569 if(result_parse==ASN1_SUCCESS){ /* all identifier defined */
2570 /* Delete the list and keep the ASN1 structure */
2571 _asn1_delete_list();
2572 /* Convert into DER coding the value assign to INTEGER constants */
2573 _asn1_change_integer_value(p_tree);
2574 /* Expand the IDs of OBJECT IDENTIFIER constants */
2575 _asn1_expand_object_id(p_tree);
2577 *definitions=p_tree;
2579 else /* some identifiers not defined */
2580 /* Delete the list and the ASN1 structure */
2581 _asn1_delete_list_and_nodes();
2583 else /* syntax error */
2584 /* Delete the list and the ASN1 structure */
2585 _asn1_delete_list_and_nodes();
2588 if (errorDescription!=NULL)
2589 _asn1_create_errorDescription(result_parse,errorDescription);
2591 return result_parse;
2596 * asn1_parser2array - function that generates a C structure from an ASN1 file
2597 * @inputFileName: specify the path and the name of file that
2598 * contains ASN.1 declarations.
2599 * @outputFileName: specify the path and the name of file that will
2600 * contain the C vector definition.
2601 * @vectorName: specify the name of the C vector.
2602 * @errorDescription : return the error description or an empty
2603 * string if success.
2605 * Creates a file containing a C vector to use to manage the
2606 * definitions included in *INPUTFILENAME file. If *INPUTFILENAME is
2607 * "/aa/bb/xx.yy" and OUTPUTFILENAME is NULL, the file created is
2608 * "/aa/bb/xx_asn1_tab.c". If VECTORNAME is NULL the vector name
2609 * will be "xx_asn1_tab".
2611 * Returns:
2613 * ASN1_SUCCESS: The file has a correct syntax and every identifier
2614 * is known.
2616 * ASN1_FILE_NOT_FOUND: An error occured while opening FILE_NAME.
2618 * ASN1_SYNTAX_ERROR: The syntax is not correct.
2620 * ASN1_IDENTIFIER_NOT_FOUND: In the file there is an identifier that
2621 * is not defined.
2623 * ASN1_NAME_TOO_LONG: In the file there is an identifier whith more
2624 * than MAX_NAME_SIZE characters.
2626 int asn1_parser2array(const char *inputFileName,const char *outputFileName,
2627 const char *vectorName,char *errorDescription){
2628 char *file_out_name=NULL;
2629 char *vector_name=NULL;
2630 const char *char_p,*slash_p,*dot_p;
2632 p_tree=NULL;
2634 fileName = inputFileName;
2636 /* open the file to parse */
2637 file_asn1=fopen(inputFileName,"r");
2639 if(file_asn1==NULL)
2640 result_parse=ASN1_FILE_NOT_FOUND;
2641 else{
2642 result_parse=ASN1_SUCCESS;
2644 lineNumber=1;
2645 yyparse();
2647 fclose(file_asn1);
2649 if(result_parse==ASN1_SUCCESS){ /* syntax OK */
2650 /* set IMPLICIT or EXPLICIT property */
2651 _asn1_set_default_tag(p_tree);
2652 /* set CONST_SET and CONST_NOT_USED */
2653 _asn1_type_set_config(p_tree);
2654 /* check the identifier definitions */
2655 result_parse=_asn1_check_identifier(p_tree);
2657 if(result_parse==ASN1_SUCCESS){ /* all identifier defined */
2659 /* searching the last '/' and '.' in inputFileName */
2660 char_p=inputFileName;
2661 slash_p=inputFileName;
2662 while((char_p=strchr(char_p,'/'))){
2663 char_p++;
2664 slash_p=char_p;
2667 char_p=slash_p;
2668 dot_p=inputFileName+strlen(inputFileName);
2670 while((char_p=strchr(char_p,'.'))){
2671 dot_p=char_p;
2672 char_p++;
2675 if(outputFileName == NULL){
2676 /* file_out_name = inputFileName + _asn1_tab.c */
2677 file_out_name=(char *)malloc(dot_p-inputFileName+1+
2678 strlen("_asn1_tab.c"));
2679 memcpy(file_out_name,inputFileName,dot_p-inputFileName);
2680 file_out_name[dot_p-inputFileName]=0;
2681 strcat(file_out_name,"_asn1_tab.c");
2683 else{
2684 /* file_out_name = inputFileName */
2685 file_out_name=(char *)malloc(strlen(outputFileName)+1);
2686 strcpy(file_out_name,outputFileName);
2689 if(vectorName == NULL){
2690 /* vector_name = file name + _asn1_tab */
2691 vector_name=(char *)malloc(dot_p-slash_p+1+
2692 strlen("_asn1_tab"));
2693 memcpy(vector_name,slash_p,dot_p-slash_p);
2694 vector_name[dot_p-slash_p]=0;
2695 strcat(vector_name,"_asn1_tab");
2697 else{
2698 /* vector_name = vectorName */
2699 vector_name=(char *)malloc(strlen(vectorName)+1);
2700 strcpy(vector_name,vectorName);
2703 /* Save structure in a file */
2704 _asn1_create_static_structure(p_tree,
2705 file_out_name,vector_name);
2707 free(file_out_name);
2708 free(vector_name);
2709 } /* result == OK */
2710 } /* result == OK */
2712 /* Delete the list and the ASN1 structure */
2713 _asn1_delete_list_and_nodes();
2714 } /* inputFile exist */
2716 if (errorDescription!=NULL)
2717 _asn1_create_errorDescription(result_parse,errorDescription);
2719 return result_parse;
2723 /*************************************************************/
2724 /* Function: _asn1_yyerror */
2725 /* Description: function called when there are syntax errors*/
2726 /* Parameters: */
2727 /* char *s : error description */
2728 /* Return: int */
2729 /* */
2730 /*************************************************************/
2731 int _asn1_yyerror (char *s)
2733 /* Sends the error description to the std_out */
2735 #ifdef LIBTASN1_DEBUG_PARSER
2736 _libtasn1_log("_asn1_yyerror:%s:%d: %s (Last Token:'%s')\n",fileName,
2737 lineNumber,s,lastToken);
2738 #endif
2740 if(result_parse!=ASN1_NAME_TOO_LONG)
2741 result_parse=ASN1_SYNTAX_ERROR;
2743 return 0;