1 /* A Bison parser, made from ASN1.y
4 #define YYBISON 1 /* Identify Bison output. */
6 #define yyparse _asn1_yyparse
7 #define yylex _asn1_yylex
8 #define yyerror _asn1_yyerror
9 #define yylval _asn1_yylval
10 #define yychar _asn1_yychar
11 #define yydebug _asn1_yydebug
12 #define yynerrs _asn1_yynerrs
15 # define IDENTIFIER 259
23 # define UNIVERSAL 267
25 # define APPLICATION 269
30 # define STR_IDENTIFIER 274
34 # define TOKEN_NULL 278
41 # define DEFINITIONS 285
46 # define GeneralizedTime 290
47 # define GeneralString 291
50 # define ENUMERATED 294
56 #include <parser_aux.h>
57 #include <structure.h>
60 static FILE *file_asn1
; /* Pointer to file to parse */
61 static asn1_retCode result_parse
; /* result of the parser algorithm */
62 static node_asn
*p_tree
; /* pointer to the root of the structure
63 created by the parser*/
64 static unsigned long lineNumber
; /* line number describing the parser position
66 static char lastToken
[MAX_NAME_SIZE
+1]; /* last token find in the file to
67 parse before the 'parse error' */
68 char _asn1_identifierMissing
[MAX_NAME_SIZE
+1]; /* identifier name not found */
69 static const char *fileName
; /* file to parse */
71 int _asn1_yyerror (char *);
72 int _asn1_yylex(void);
78 unsigned int constant
;
79 char str
[MAX_NAME_SIZE
+1];
82 # define YYSTYPE yystype
94 /* YYTRANSLATE(YYLEX) -- Bison token number corresponding to YYLEX. */
95 #define YYTRANSLATE(x) ((unsigned)(x) <= 294 ? yytranslate[x] : 92)
97 /* YYTRANSLATE[YYLEX] -- Bison token number corresponding to YYLEX. */
98 static const char yytranslate
[] =
100 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
101 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
102 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
103 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
104 43, 44, 2, 41, 45, 42, 50, 2, 2, 2,
105 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
106 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
107 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
108 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
109 2, 46, 2, 47, 2, 2, 2, 2, 2, 2,
110 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
111 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
112 2, 2, 2, 48, 2, 49, 2, 2, 2, 2,
113 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
114 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
115 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
116 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
117 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
118 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
119 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
120 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
121 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
122 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
123 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
124 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
125 2, 2, 2, 2, 2, 2, 1, 3, 4, 5,
126 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
127 16, 17, 18, 19, 20, 21, 22, 23, 24, 25,
128 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
133 static const short yyprhs
[] =
135 0, 0, 9, 11, 14, 17, 19, 21, 23, 25,
136 27, 29, 33, 38, 40, 44, 46, 51, 53, 56,
137 58, 60, 62, 66, 71, 73, 76, 79, 82, 85,
138 88, 90, 95, 103, 105, 107, 109, 114, 122, 124,
139 128, 130, 133, 136, 140, 145, 147, 151, 154, 160,
140 165, 168, 170, 173, 175, 177, 179, 181, 183, 185,
141 187, 189, 191, 193, 195, 197, 199, 201, 204, 206,
142 209, 212, 215, 217, 221, 226, 230, 235, 240, 244,
143 249, 254, 256, 261, 265, 273, 280, 285, 287, 289,
144 291, 294, 299, 303, 305
146 static const short yyrhs
[] =
148 90, 31, 91, 32, 3, 33, 89, 34, 0, 4,
149 0, 41, 4, 0, 42, 4, 0, 52, 0, 53,
150 0, 4, 0, 5, 0, 54, 0, 5, 0, 43,
151 54, 44, 0, 5, 43, 54, 44, 0, 57, 0,
152 58, 45, 57, 0, 55, 0, 5, 43, 4, 44,
153 0, 59, 0, 60, 59, 0, 13, 0, 14, 0,
154 15, 0, 46, 4, 47, 0, 46, 61, 4, 47,
155 0, 62, 0, 62, 29, 0, 62, 30, 0, 16,
156 56, 0, 16, 22, 0, 16, 23, 0, 7, 0,
157 7, 48, 58, 49, 0, 65, 43, 55, 50, 50,
158 55, 44, 0, 21, 0, 35, 0, 36, 0, 8,
159 43, 55, 44, 0, 8, 43, 55, 50, 50, 55,
160 44, 0, 68, 0, 43, 68, 44, 0, 37, 0,
161 37, 69, 0, 9, 10, 0, 9, 10, 69, 0,
162 5, 43, 4, 44, 0, 72, 0, 73, 45, 72,
163 0, 12, 10, 0, 12, 10, 48, 73, 49, 0,
164 40, 48, 73, 49, 0, 19, 20, 0, 5, 0,
165 5, 69, 0, 65, 0, 75, 0, 66, 0, 67,
166 0, 71, 0, 74, 0, 70, 0, 82, 0, 76,
167 0, 84, 0, 85, 0, 83, 0, 24, 0, 77,
168 0, 63, 77, 0, 78, 0, 78, 64, 0, 78,
169 6, 0, 5, 79, 0, 80, 0, 81, 45, 80,
170 0, 11, 48, 81, 49, 0, 11, 18, 77, 0,
171 11, 69, 18, 77, 0, 28, 48, 81, 49, 0,
172 28, 18, 77, 0, 28, 69, 18, 77, 0, 17,
173 48, 81, 49, 0, 25, 0, 25, 26, 27, 5,
174 0, 5, 3, 78, 0, 5, 19, 20, 3, 48,
175 60, 49, 0, 5, 5, 3, 48, 60, 49, 0,
176 5, 7, 3, 54, 0, 86, 0, 87, 0, 88,
177 0, 89, 88, 0, 5, 48, 60, 49, 0, 5,
178 48, 49, 0, 29, 0, 30, 0
184 /* YYRLINE[YYN] -- source line where rule number YYN was defined. */
185 static const short yyrline
[] =
187 0, 116, 129, 130, 133, 137, 138, 141, 142, 145,
188 146, 149, 151, 156, 157, 161, 163, 168, 169, 173,
189 174, 175, 178, 180, 184, 185, 186, 189, 191, 192,
190 195, 196, 198, 205, 208, 209, 212, 214, 220, 221,
191 224, 225, 229, 230, 234, 239, 240, 244, 245, 250,
192 256, 259, 261, 264, 265, 266, 267, 268, 269, 270,
193 271, 272, 273, 274, 275, 276, 279, 280, 285, 286,
194 289, 292, 295, 296, 300, 302, 304, 309, 311, 313,
195 318, 322, 323, 328, 331, 335, 340, 346, 347, 350,
196 351, 355, 358, 382, 383
201 #if (YYDEBUG) || defined YYERROR_VERBOSE
203 /* YYTNAME[TOKEN_NUM] -- String name of the token TOKEN_NUM. */
204 static const char *const yytname
[] =
206 "$", "error", "$undefined.", "\"::=\"", "NUM", "IDENTIFIER", "OPTIONAL",
207 "INTEGER", "SIZE", "OCTET", "STRING", "SEQUENCE", "BIT", "UNIVERSAL",
208 "PRIVATE", "APPLICATION", "DEFAULT", "CHOICE", "OF", "OBJECT",
209 "STR_IDENTIFIER", "BOOLEAN", "TRUE", "FALSE", "TOKEN_NULL", "ANY",
210 "DEFINED", "BY", "SET", "EXPLICIT", "IMPLICIT", "DEFINITIONS", "TAGS",
211 "BEGIN", "END", "UTCTime", "GeneralizedTime", "GeneralString", "FROM",
212 "IMPORTS", "ENUMERATED", "'+'", "'-'", "'('", "')'", "','", "'['",
213 "']'", "'{'", "'}'", "'.'", "definitions", "pos_num", "neg_num",
214 "pos_neg_num", "num_identifier", "pos_neg_identifier", "constant",
215 "constant_list", "obj_constant", "obj_constant_list", "class",
216 "tag_type", "tag", "default", "integer_def", "boolean_def", "Time",
217 "size_def2", "size_def", "generalstring_def", "octet_string_def",
218 "bit_element", "bit_element_list", "bit_string_def", "enumerated_def",
219 "object_def", "type_assig_right", "type_assig_right_tag",
220 "type_assig_right_tag_default", "type_assig", "type_assig_list",
221 "sequence_def", "set_def", "choise_def", "any_def", "type_def",
222 "constant_def", "type_constant", "type_constant_list", "definitions_id",
223 "explicit_implicit", NULL
227 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
228 static const short yyr1
[] =
230 0, 51, 52, 52, 53, 54, 54, 55, 55, 56,
231 56, 57, 57, 58, 58, 59, 59, 60, 60, 61,
232 61, 61, 62, 62, 63, 63, 63, 64, 64, 64,
233 65, 65, 65, 66, 67, 67, 68, 68, 69, 69,
234 70, 70, 71, 71, 72, 73, 73, 74, 74, 75,
235 76, 77, 77, 77, 77, 77, 77, 77, 77, 77,
236 77, 77, 77, 77, 77, 77, 78, 78, 79, 79,
237 79, 80, 81, 81, 82, 82, 82, 83, 83, 83,
238 84, 85, 85, 86, 87, 87, 87, 88, 88, 89,
242 /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
243 static const short yyr2
[] =
245 0, 8, 1, 2, 2, 1, 1, 1, 1, 1,
246 1, 3, 4, 1, 3, 1, 4, 1, 2, 1,
247 1, 1, 3, 4, 1, 2, 2, 2, 2, 2,
248 1, 4, 7, 1, 1, 1, 4, 7, 1, 3,
249 1, 2, 2, 3, 4, 1, 3, 2, 5, 4,
250 2, 1, 2, 1, 1, 1, 1, 1, 1, 1,
251 1, 1, 1, 1, 1, 1, 1, 2, 1, 2,
252 2, 2, 1, 3, 4, 3, 4, 4, 3, 4,
253 4, 1, 4, 3, 7, 6, 4, 1, 1, 1,
257 /* YYDEFACT[S] -- default rule to reduce with in state S when YYTABLE
258 doesn't specify something else to do. Zero means the default is an
260 static const short yydefact
[] =
262 0, 0, 0, 0, 0, 7, 8, 92, 15, 17,
263 0, 93, 94, 0, 0, 91, 18, 0, 0, 0,
264 16, 0, 0, 87, 88, 89, 0, 0, 0, 0,
265 0, 1, 90, 51, 30, 0, 0, 0, 0, 0,
266 33, 65, 81, 0, 34, 35, 40, 0, 0, 24,
267 0, 53, 55, 56, 59, 57, 58, 54, 61, 66,
268 83, 60, 64, 62, 63, 0, 0, 0, 0, 0,
269 38, 52, 0, 42, 0, 0, 0, 47, 0, 50,
270 0, 0, 0, 0, 41, 0, 0, 19, 20, 21,
271 0, 25, 26, 67, 0, 0, 2, 0, 0, 5,
272 6, 86, 0, 0, 0, 0, 0, 13, 0, 43,
273 75, 0, 72, 0, 0, 0, 0, 0, 78, 0,
274 0, 0, 45, 0, 22, 0, 8, 0, 0, 3,
275 4, 0, 0, 39, 0, 0, 0, 31, 68, 71,
276 0, 74, 76, 0, 80, 82, 77, 79, 0, 0,
277 49, 23, 0, 85, 0, 36, 0, 0, 11, 14,
278 70, 0, 69, 73, 48, 0, 46, 0, 84, 0,
279 12, 10, 28, 29, 9, 27, 44, 0, 0, 32,
283 static const short yydefgoto
[] =
285 181, 99, 100, 101, 8, 175, 107, 108, 9, 10,
286 90, 49, 50, 162, 51, 52, 53, 70, 71, 54,
287 55, 122, 123, 56, 57, 58, 59, 60, 139, 112,
288 113, 61, 62, 63, 64, 23, 24, 25, 26, 2,
292 static const short yypact
[] =
294 14, -27, 44, 0, 15,-32768, 3,-32768,-32768,-32768,
295 2,-32768,-32768, 56, 100,-32768,-32768, 105, 65, 77,
296 -32768, 106, 10,-32768,-32768,-32768, 9, 43, 109, 110,
297 94,-32768,-32768, 30, 67, 107, 22, 114, 68, 99,
298 -32768,-32768, 108, 39,-32768,-32768, 30, 72, 21, 63,
299 118, 83,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
300 -32768,-32768,-32768,-32768,-32768, 84, 55, 125, 88, 128,
301 -32768,-32768, 18, 30, 118, 133, 115, 92, 133,-32768,
302 120, 118, 133, 123,-32768, 140, 101,-32768,-32768,-32768,
303 145,-32768,-32768,-32768, 95, 102,-32768, 146, 147,-32768,
304 -32768,-32768, 104, 95, 112, 116, 55,-32768, -25,-32768,
305 -32768, 43,-32768, -8, 118, 140, 32, 152,-32768, 41,
306 118, 117,-32768, 46,-32768, 119,-32768, 111, 4,-32768,
307 -32768, 102, -28,-32768, 55, 121, 18,-32768, 12,-32768,
308 133,-32768,-32768, 49,-32768,-32768,-32768,-32768, 158, 140,
309 -32768,-32768, 113,-32768, 7,-32768, 122, 124,-32768,-32768,
310 -32768, 80,-32768,-32768,-32768, 126,-32768, 95,-32768, 95,
311 -32768,-32768,-32768,-32768,-32768,-32768,-32768, 127, 129,-32768,
312 -32768, 164, 167,-32768
315 static const short yypgoto
[] =
317 -32768,-32768,-32768, -103, -93,-32768, 33,-32768, -10, -68,
318 -32768,-32768,-32768,-32768,-32768,-32768,-32768, 130, -4,-32768,
319 -32768, 25, 60,-32768,-32768,-32768, -48, 66,-32768, 36,
320 23,-32768,-32768,-32768,-32768,-32768,-32768, 153,-32768,-32768,
328 static const short yytable
[] =
330 16, 127, 93, 135, 5, 6, 5, 6, 5, 6,
331 132, 5, 6, 27, 22, 28, 155, 29, 160, 1,
332 136, 3, 156, 105, 137, 86, 110, 128, 161, 30,
333 68, 157, 76, 118, 87, 88, 89, 140, 68, 83,
334 74, 141, 84, 31, 11, 12, 14, 68, 33, 7,
335 34, 15, 35, 153, 36, 37, 168, 81, 174, 96,
336 38, 106, 39, 154, 40, 69, 142, 41, 42, 109,
337 75, 43, 147, 69, 177, 4, 178, 140, 44, 45,
338 46, 144, 69, 47, 96, 171, 140, 82, 17, 48,
339 146, 149, 91, 92, 149, 150, 97, 98, 164, 5,
340 126, 116, 172, 173, 18, 119, 5, 6, 19, 20,
341 21, 22, 65, 66, 67, 72, 78, 73, 16, 79,
342 85, 97, 98, 33, 77, 34, 94, 35, 102, 36,
343 37, 103, 95, 114, 80, 38, 68, 39, 111, 40,
344 115, 120, 41, 42, 16, 121, 43, 117, 124, 125,
345 129, 130, 131, 44, 45, 46, 133, 145, 47, 134,
346 148, 152, 165, 167, 182, 158, 151, 183, 170, 159,
347 176, 179, 169, 180, 166, 143, 163, 138, 0, 32,
348 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
349 0, 0, 0, 0, 0, 0, 0, 0, 0, 104
352 static const short yycheck
[] =
354 10, 94, 50, 106, 4, 5, 4, 5, 4, 5,
355 103, 4, 5, 3, 5, 5, 44, 7, 6, 5,
356 45, 48, 50, 5, 49, 4, 74, 95, 16, 19,
357 8, 134, 36, 81, 13, 14, 15, 45, 8, 43,
358 18, 49, 46, 34, 29, 30, 43, 8, 5, 49,
359 7, 49, 9, 49, 11, 12, 49, 18, 161, 4,
360 17, 43, 19, 131, 21, 43, 114, 24, 25, 73,
361 48, 28, 120, 43, 167, 31, 169, 45, 35, 36,
362 37, 49, 43, 40, 4, 5, 45, 48, 32, 46,
363 49, 45, 29, 30, 45, 49, 41, 42, 49, 4,
364 5, 78, 22, 23, 4, 82, 4, 5, 3, 44,
365 33, 5, 3, 3, 20, 48, 48, 10, 128, 20,
366 48, 41, 42, 5, 10, 7, 43, 9, 3, 11,
367 12, 43, 48, 18, 26, 17, 8, 19, 5, 21,
368 48, 18, 24, 25, 154, 5, 28, 27, 47, 4,
369 4, 4, 48, 35, 36, 37, 44, 5, 40, 43,
370 43, 50, 4, 50, 0, 44, 47, 0, 44, 136,
371 44, 44, 50, 44, 149, 115, 140, 111, -1, 26,
372 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
373 -1, -1, -1, -1, -1, -1, -1, -1, -1, 69
375 /* -*-C-*- Note some compilers choke on comments on `#line' lines. */
376 #line 3 "/usr/local/share/bison/bison.simple"
378 /* Skeleton output parser for bison,
380 Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002 Free Software
383 This program is free software; you can redistribute it and/or modify
384 it under the terms of the GNU General Public License as published by
385 the Free Software Foundation; either version 2, or (at your option)
388 This program is distributed in the hope that it will be useful,
389 but WITHOUT ANY WARRANTY; without even the implied warranty of
390 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
391 GNU General Public License for more details.
393 You should have received a copy of the GNU General Public License
394 along with this program; if not, write to the Free Software
395 Foundation, Inc., 59 Temple Place - Suite 330,
396 Boston, MA 02111-1307, USA. */
398 /* As a special exception, when this file is copied by Bison into a
399 Bison output file, you may use that output file without restriction.
400 This special exception was added by the Free Software Foundation
401 in version 1.24 of Bison. */
403 /* This is the parser code that is written into each bison parser when
404 the %semantic_parser declaration is not specified in the grammar.
405 It was written by Richard Stallman by simplifying the hairy parser
406 used when %semantic_parser is specified. */
408 /* All symbols defined below should begin with yy or YY, to avoid
409 infringing on user name space. This should be done even for local
410 variables, as they might otherwise be expanded by user macros.
411 There are some unavoidable exceptions within include files to
412 define necessary library symbols; they are noted "INFRINGES ON
413 USER NAME SPACE" below. */
416 # define YYSTD(x) std::x
421 #if ! defined (yyoverflow) || defined (YYERROR_VERBOSE)
423 /* The parser invokes alloca or malloc; define the necessary symbols. */
425 # if YYSTACK_USE_ALLOCA
426 # define YYSTACK_ALLOC alloca
428 # ifndef YYSTACK_USE_ALLOCA
429 # if defined (alloca) || defined (_ALLOCA_H)
430 # define YYSTACK_ALLOC alloca
433 # define YYSTACK_ALLOC __builtin_alloca
439 # ifdef YYSTACK_ALLOC
440 /* Pacify GCC's `empty if-body' warning. */
441 # define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
444 # include <cstdlib> /* INFRINGES ON USER NAME SPACE */
445 # define YYSIZE_T std::size_t
448 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
449 # define YYSIZE_T size_t
452 # define YYSTACK_ALLOC YYSTD (malloc)
453 # define YYSTACK_FREE YYSTD (free)
456 /* A type that is properly aligned for any stack member. */
466 /* The size of the maximum gap between one aligned stack and the next. */
467 # define YYSTACK_GAP_MAX (sizeof (union yyalloc) - 1)
469 /* The size of an array large to enough to hold all stacks, each with
472 # define YYSTACK_BYTES(N) \
473 ((N) * (sizeof (short) + sizeof (YYSTYPE) + sizeof (YYLTYPE)) \
474 + 2 * YYSTACK_GAP_MAX)
476 # define YYSTACK_BYTES(N) \
477 ((N) * (sizeof (short) + sizeof (YYSTYPE)) \
481 /* Relocate the TYPE STACK from its old location to the new one. The
482 local variables YYSIZE and YYSTACKSIZE give the old and new number of
483 elements in the stack, and YYPTR gives the new location of the
484 stack. Advance YYPTR to a properly aligned location for the next
486 # define YYSTACK_RELOCATE(Type, Stack) \
489 YYSIZE_T yynewbytes; \
490 yymemcpy ((char *) yyptr, (char *) (Stack), \
491 yysize * (YYSIZE_T) sizeof (Type)); \
492 Stack = &yyptr->Stack; \
493 yynewbytes = yystacksize * sizeof (Type) + YYSTACK_GAP_MAX; \
494 yyptr += yynewbytes / sizeof (*yyptr); \
498 #endif /* ! defined (yyoverflow) || defined (YYERROR_VERBOSE) */
501 #if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__)
502 # define YYSIZE_T __SIZE_TYPE__
504 #if ! defined (YYSIZE_T) && defined (size_t)
505 # define YYSIZE_T size_t
507 #if ! defined (YYSIZE_T)
509 # include <cstddef> /* INFRINGES ON USER NAME SPACE */
510 # define YYSIZE_T std::size_t
513 # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
514 # define YYSIZE_T size_t
518 #if ! defined (YYSIZE_T)
519 # define YYSIZE_T unsigned int
522 #define yyerrok (yyerrstatus = 0)
523 #define yyclearin (yychar = YYEMPTY)
526 #define YYACCEPT goto yyacceptlab
527 #define YYABORT goto yyabortlab
528 #define YYERROR goto yyerrlab1
529 /* Like YYERROR except do call yyerror. This remains here temporarily
530 to ease the transition to the new meaning of YYERROR, for GCC.
531 Once GCC version 2 has supplanted version 1, this can go. */
532 #define YYFAIL goto yyerrlab
533 #define YYRECOVERING() (!!yyerrstatus)
534 #define YYBACKUP(Token, Value) \
536 if (yychar == YYEMPTY && yylen == 1) \
540 yychar1 = YYTRANSLATE (yychar); \
546 yyerror ("syntax error: cannot back up"); \
552 #define YYERRCODE 256
555 /* YYLLOC_DEFAULT -- Compute the default location (before the actions
558 When YYLLOC_DEFAULT is run, CURRENT is set the location of the
559 first token. By default, to implement support for ranges, extend
560 its range to the last symbol. */
562 #ifndef YYLLOC_DEFAULT
563 # define YYLLOC_DEFAULT(Current, Rhs, N) \
564 Current.last_line = Rhs[N].last_line; \
565 Current.last_column = Rhs[N].last_column;
569 /* YYLEX -- calling `yylex' with the right arguments. */
574 # define YYLEX yylex (&yylval, &yylloc, YYLEX_PARAM)
576 # define YYLEX yylex (&yylval, &yylloc)
578 # else /* !YYLSP_NEEDED */
580 # define YYLEX yylex (&yylval, YYLEX_PARAM)
582 # define YYLEX yylex (&yylval)
584 # endif /* !YYLSP_NEEDED */
586 # define YYLEX yylex ()
590 /* Enable debugging if requested. */
595 # include <cstdio> /* INFRINGES ON USER NAME SPACE */
597 # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
599 # define YYFPRINTF YYSTD (fprintf)
602 # define YYDPRINTF(Args) \
607 /* Nonzero means print parse trace. [The following comment makes no
608 sense to me. Could someone clarify it? --akim] Since this is
609 uninitialized, it does not stop multiple parsers from coexisting.
613 # define YYDPRINTF(Args)
614 #endif /* !YYDEBUG */
616 /* YYINITDEPTH -- initial size of the parser's stacks. */
618 # define YYINITDEPTH 200
621 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
622 if the built-in stack extension method is used).
624 Do not make this value too large; the results are undefined if
625 SIZE_MAX < YYSTACK_BYTES (YYMAXDEPTH)
626 evaluated with infinite-precision integer arithmetic. */
633 # define YYMAXDEPTH 10000
636 #if ! defined (yyoverflow) && ! defined (yymemcpy)
637 # if __GNUC__ > 1 /* GNU C and GNU C++ define this. */
638 # define yymemcpy __builtin_memcpy
639 # else /* not GNU C or C++ */
641 /* This is the most reliable way to avoid incompatibilities
642 in available built-in functions on various systems. */
644 # if defined (__STDC__) || defined (__cplusplus)
645 yymemcpy (char *yyto
, const char *yyfrom
, YYSIZE_T yycount
)
647 yymemcpy (yyto
, yyfrom
, yycount
)
653 register const char *yyf
= yyfrom
;
654 register char *yyt
= yyto
;
655 register YYSIZE_T yyi
= yycount
;
663 #ifdef YYERROR_VERBOSE
666 # if defined (__GLIBC__) && defined (_STRING_H)
667 # define yystrlen strlen
669 /* Return the length of YYSTR. */
671 # if defined (__STDC__) || defined (__cplusplus)
672 yystrlen (const char *yystr
)
678 register const char *yys
= yystr
;
680 while (*yys
++ != '\0')
683 return yys
- yystr
- 1;
689 # if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE)
690 # define yystpcpy stpcpy
692 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
695 # if defined (__STDC__) || defined (__cplusplus)
696 yystpcpy (char *yydest
, const char *yysrc
)
698 yystpcpy (yydest
, yysrc
)
703 register char *yyd
= yydest
;
704 register const char *yys
= yysrc
;
706 while ((*yyd
++ = *yys
++) != '\0')
715 #line 341 "/usr/local/share/bison/bison.simple"
718 /* The user can define YYPARSE_PARAM as the name of an argument to be passed
719 into yyparse. The argument should have type void *.
720 It should actually point to an object.
721 Grammar actions can access the variable by casting it
722 to the proper pointer type. */
726 # define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
727 # define YYPARSE_PARAM_DECL
728 # else /* !__cplusplus */
729 # define YYPARSE_PARAM_ARG YYPARSE_PARAM
730 # define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
731 # endif /* !__cplusplus */
732 #else /* !YYPARSE_PARAM */
733 # define YYPARSE_PARAM_ARG
734 # define YYPARSE_PARAM_DECL
735 #endif /* !YYPARSE_PARAM */
737 /* Prevent warning if -Wstrict-prototypes. */
739 # ifdef YYPARSE_PARAM
740 int yyparse (void *);
746 /* YY_DECL_VARIABLES -- depending whether we use a pure parser,
747 variables are global, or local to YYPARSE. */
749 #define YY_DECL_NON_LSP_VARIABLES \
750 /* The lookahead symbol. */ \
753 /* The semantic value of the lookahead symbol. */ \
756 /* Number of parse errors so far. */ \
760 # define YY_DECL_VARIABLES \
761 YY_DECL_NON_LSP_VARIABLES \
763 /* Location data for the lookahead symbol. */ \
766 # define YY_DECL_VARIABLES \
767 YY_DECL_NON_LSP_VARIABLES
771 /* If nonreentrant, generate the variables here. */
778 yyparse (YYPARSE_PARAM_ARG
)
781 /* If reentrant, generate the variables here. */
786 register int yystate
;
789 /* Number of tokens to shift before error messages enabled. */
791 /* Lookahead token as an internal (translated) token number. */
794 /* Three stacks and their tools:
795 `yyss': related to states,
796 `yyvs': related to semantic values,
797 `yyls': related to locations.
799 Refer to the stacks thru separate pointers, to allow yyoverflow
800 to reallocate them elsewhere. */
802 /* The state stack. */
803 short yyssa
[YYINITDEPTH
];
805 register short *yyssp
;
807 /* The semantic value stack. */
808 YYSTYPE yyvsa
[YYINITDEPTH
];
809 YYSTYPE
*yyvs
= yyvsa
;
810 register YYSTYPE
*yyvsp
;
813 /* The location stack. */
814 YYLTYPE yylsa
[YYINITDEPTH
];
815 YYLTYPE
*yyls
= yylsa
;
820 # define YYPOPSTACK (yyvsp--, yyssp--, yylsp--)
822 # define YYPOPSTACK (yyvsp--, yyssp--)
825 YYSIZE_T yystacksize
= YYINITDEPTH
;
828 /* The variables used to return semantic value and location from the
835 /* When reducing, the number of symbols on the RHS of the reduced
839 YYDPRINTF ((stderr
, "Starting parse\n"));
844 yychar
= YYEMPTY
; /* Cause a token to be read. */
846 /* Initialize stack pointers.
847 Waste one element of value and location stack
848 so that they stay on the same level as the state stack.
849 The wasted elements are never initialized. */
858 /*------------------------------------------------------------.
859 | yynewstate -- Push a new state, which is found in yystate. |
860 `------------------------------------------------------------*/
862 /* In all cases, when you get here, the value and location stacks
863 have just been pushed. so pushing a state here evens the stacks.
870 if (yyssp
>= yyss
+ yystacksize
- 1)
872 /* Get the current used size of the three stacks, in elements. */
873 YYSIZE_T yysize
= yyssp
- yyss
+ 1;
877 /* Give user a chance to reallocate the stack. Use copies of
878 these so that the &'s don't force the real ones into
880 YYSTYPE
*yyvs1
= yyvs
;
883 /* Each stack pointer address is followed by the size of the
884 data in use in that stack, in bytes. */
886 YYLTYPE
*yyls1
= yyls
;
887 /* This used to be a conditional around just the two extra args,
888 but that might be undefined if yyoverflow is a macro. */
889 yyoverflow ("parser stack overflow",
890 &yyss1
, yysize
* sizeof (*yyssp
),
891 &yyvs1
, yysize
* sizeof (*yyvsp
),
892 &yyls1
, yysize
* sizeof (*yylsp
),
896 yyoverflow ("parser stack overflow",
897 &yyss1
, yysize
* sizeof (*yyssp
),
898 &yyvs1
, yysize
* sizeof (*yyvsp
),
904 #else /* no yyoverflow */
905 /* Extend the stack our own way. */
906 if (yystacksize
>= YYMAXDEPTH
)
909 if (yystacksize
> YYMAXDEPTH
)
910 yystacksize
= YYMAXDEPTH
;
914 union yyalloc
*yyptr
=
915 (union yyalloc
*) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize
));
918 YYSTACK_RELOCATE (short, yyss
);
919 YYSTACK_RELOCATE (YYSTYPE
, yyvs
);
921 YYSTACK_RELOCATE (YYLTYPE
, yyls
);
923 # undef YYSTACK_RELOCATE
925 YYSTACK_FREE (yyss1
);
927 #endif /* no yyoverflow */
929 yyssp
= yyss
+ yysize
- 1;
930 yyvsp
= yyvs
+ yysize
- 1;
932 yylsp
= yyls
+ yysize
- 1;
935 YYDPRINTF ((stderr
, "Stack size increased to %lu\n",
936 (unsigned long int) yystacksize
));
938 if (yyssp
>= yyss
+ yystacksize
- 1)
942 YYDPRINTF ((stderr
, "Entering state %d\n", yystate
));
952 /* Do appropriate processing given the current state. */
953 /* Read a lookahead token if we need one and don't already have one. */
956 /* First try to decide what to do without reference to lookahead token. */
958 yyn
= yypact
[yystate
];
962 /* Not known => get a lookahead token if don't already have one. */
964 /* yychar is either YYEMPTY or YYEOF
965 or a valid token in external form. */
967 if (yychar
== YYEMPTY
)
969 YYDPRINTF ((stderr
, "Reading a token: "));
973 /* Convert token to internal form (in yychar1) for indexing tables with */
975 if (yychar
<= 0) /* This means end of input. */
978 yychar
= YYEOF
; /* Don't call YYLEX any more */
980 YYDPRINTF ((stderr
, "Now at end of input.\n"));
984 yychar1
= YYTRANSLATE (yychar
);
987 /* We have to keep this `#if YYDEBUG', since we use variables
988 which are defined only if `YYDEBUG' is set. */
991 YYFPRINTF (stderr
, "Next token is %d (%s",
992 yychar
, yytname
[yychar1
]);
993 /* Give the individual parser a way to print the precise
994 meaning of a token, for further debugging info. */
996 YYPRINT (stderr
, yychar
, yylval
);
998 YYFPRINTF (stderr
, ")\n");
1004 if (yyn
< 0 || yyn
> YYLAST
|| yycheck
[yyn
] != yychar1
)
1009 /* yyn is what to do for this token type in this state.
1010 Negative => reduce, -yyn is rule number.
1011 Positive => shift, yyn is new state.
1012 New state is final state => don't bother to shift,
1013 just return success.
1014 0, or most negative number => error. */
1029 /* Shift the lookahead token. */
1030 YYDPRINTF ((stderr
, "Shifting token %d (%s), ",
1031 yychar
, yytname
[yychar1
]));
1033 /* Discard the token being shifted unless it is eof. */
1034 if (yychar
!= YYEOF
)
1042 /* Count tokens shifted since error; after three, turn off error
1051 /*-----------------------------------------------------------.
1052 | yydefault -- do the default action for the current state. |
1053 `-----------------------------------------------------------*/
1055 yyn
= yydefact
[yystate
];
1061 /*-----------------------------.
1062 | yyreduce -- Do a reduction. |
1063 `-----------------------------*/
1065 /* yyn is the number of a rule to reduce with. */
1068 /* If YYLEN is nonzero, implement the default value of the action:
1071 Otherwise, the following line sets YYVAL to the semantic value of
1072 the lookahead token. This behavior is undocumented and Bison
1073 users should not rely upon it. Assigning to YYVAL
1074 unconditionally makes the parser a bit smaller, and it avoids a
1075 GCC warning that YYVAL may be used uninitialized. */
1076 yyval
= yyvsp
[1-yylen
];
1079 /* Similarly for the default location. Let the user run additional
1080 commands if for instance locations are ranges. */
1081 yyloc
= yylsp
[1-yylen
];
1082 YYLLOC_DEFAULT (yyloc
, (yylsp
- yylen
), yylen
);
1086 /* We have to keep this `#if YYDEBUG', since we use variables which
1087 are defined only if `YYDEBUG' is set. */
1092 YYFPRINTF (stderr
, "Reducing via rule %d (line %d), ",
1095 /* Print the symbols being reduced, and their result. */
1096 for (yyi
= yyprhs
[yyn
]; yyrhs
[yyi
] > 0; yyi
++)
1097 YYFPRINTF (stderr
, "%s ", yytname
[yyrhs
[yyi
]]);
1098 YYFPRINTF (stderr
, " -> %s\n", yytname
[yyr1
[yyn
]]);
1106 {yyval
.node
=_asn1_add_node(TYPE_DEFINITIONS
|yyvsp
[-5].constant
);
1107 _asn1_set_name(yyval
.node
,_asn1_get_name(yyvsp
[-7].node
));
1108 _asn1_set_name(yyvsp
[-7].node
,"");
1109 _asn1_set_right(yyvsp
[-7].node
,yyvsp
[-1].node
);
1110 _asn1_set_down(yyval
.node
,yyvsp
[-7].node
);
1117 {strcpy(yyval
.str
,yyvsp
[0].str
);}
1121 {strcpy(yyval
.str
,yyvsp
[0].str
);}
1125 {strcpy(yyval
.str
,"-");
1126 strcat(yyval
.str
,yyvsp
[0].str
);}
1130 {strcpy(yyval
.str
,yyvsp
[0].str
);}
1134 {strcpy(yyval
.str
,yyvsp
[0].str
);}
1138 {strcpy(yyval
.str
,yyvsp
[0].str
);}
1142 {strcpy(yyval
.str
,yyvsp
[0].str
);}
1146 {strcpy(yyval
.str
,yyvsp
[0].str
);}
1150 {strcpy(yyval
.str
,yyvsp
[0].str
);}
1154 {yyval
.node
=_asn1_add_node(TYPE_CONSTANT
);
1155 _asn1_set_value(yyval
.node
,yyvsp
[-1].str
,strlen(yyvsp
[-1].str
)+1);}
1159 {yyval
.node
=_asn1_add_node(TYPE_CONSTANT
);
1160 _asn1_set_name(yyval
.node
,yyvsp
[-3].str
);
1161 _asn1_set_value(yyval
.node
,yyvsp
[-1].str
,strlen(yyvsp
[-1].str
)+1);}
1165 {yyval
.node
=yyvsp
[0].node
;}
1169 {yyval
.node
=yyvsp
[-2].node
;
1170 _asn1_set_right(_asn1_get_last_right(yyvsp
[-2].node
),yyvsp
[0].node
);}
1174 {yyval
.node
=_asn1_add_node(TYPE_CONSTANT
);
1175 _asn1_set_value(yyval
.node
,yyvsp
[0].str
,strlen(yyvsp
[0].str
)+1);}
1179 {yyval
.node
=_asn1_add_node(TYPE_CONSTANT
);
1180 _asn1_set_name(yyval
.node
,yyvsp
[-3].str
);
1181 _asn1_set_value(yyval
.node
,yyvsp
[-1].str
,strlen(yyvsp
[-1].str
)+1);}
1185 {yyval
.node
=yyvsp
[0].node
;}
1189 {yyval
.node
=yyvsp
[-1].node
;
1190 _asn1_set_right(_asn1_get_last_right(yyvsp
[-1].node
),yyvsp
[0].node
);}
1194 {yyval
.constant
=CONST_UNIVERSAL
;}
1198 {yyval
.constant
=CONST_PRIVATE
;}
1202 {yyval
.constant
=CONST_APPLICATION
;}
1206 {yyval
.node
=_asn1_add_node(TYPE_TAG
);
1207 _asn1_set_value(yyval
.node
,yyvsp
[-1].str
,strlen(yyvsp
[-1].str
)+1);}
1211 {yyval
.node
=_asn1_add_node(TYPE_TAG
| yyvsp
[-2].constant
);
1212 _asn1_set_value(yyval
.node
,yyvsp
[-1].str
,strlen(yyvsp
[-1].str
)+1);}
1216 {yyval
.node
=yyvsp
[0].node
;}
1220 {yyval
.node
=_asn1_mod_type(yyvsp
[-1].node
,CONST_EXPLICIT
);}
1224 {yyval
.node
=_asn1_mod_type(yyvsp
[-1].node
,CONST_IMPLICIT
);}
1228 {yyval
.node
=_asn1_add_node(TYPE_DEFAULT
);
1229 _asn1_set_value(yyval
.node
,yyvsp
[0].str
,strlen(yyvsp
[0].str
)+1);}
1233 {yyval
.node
=_asn1_add_node(TYPE_DEFAULT
|CONST_TRUE
);}
1237 {yyval
.node
=_asn1_add_node(TYPE_DEFAULT
|CONST_FALSE
);}
1241 {yyval
.node
=_asn1_add_node(TYPE_INTEGER
);}
1245 {yyval
.node
=_asn1_add_node(TYPE_INTEGER
|CONST_LIST
);
1246 _asn1_set_down(yyval
.node
,yyvsp
[-1].node
);}
1250 {yyval
.node
=_asn1_add_node(TYPE_INTEGER
|CONST_MIN_MAX
);
1251 _asn1_set_down(yyval
.node
,_asn1_add_node(TYPE_SIZE
));
1252 _asn1_set_value(_asn1_get_down(yyval
.node
),yyvsp
[-1].str
,strlen(yyvsp
[-1].str
)+1);
1253 _asn1_set_name(_asn1_get_down(yyval
.node
),yyvsp
[-4].str
);}
1257 {yyval
.node
=_asn1_add_node(TYPE_BOOLEAN
);}
1261 {yyval
.node
=_asn1_add_node(TYPE_TIME
|CONST_UTC
);}
1265 {yyval
.node
=_asn1_add_node(TYPE_TIME
|CONST_GENERALIZED
);}
1269 {yyval
.node
=_asn1_add_node(TYPE_SIZE
|CONST_1_PARAM
);
1270 _asn1_set_value(yyval
.node
,yyvsp
[-1].str
,strlen(yyvsp
[-1].str
)+1);}
1274 {yyval
.node
=_asn1_add_node(TYPE_SIZE
|CONST_MIN_MAX
);
1275 _asn1_set_value(yyval
.node
,yyvsp
[-4].str
,strlen(yyvsp
[-4].str
)+1);
1276 _asn1_set_name(yyval
.node
,yyvsp
[-1].str
);}
1280 {yyval
.node
=yyvsp
[0].node
;}
1284 {yyval
.node
=yyvsp
[-1].node
;}
1288 {yyval
.node
=_asn1_add_node(TYPE_GENERALSTRING
);}
1292 {yyval
.node
=_asn1_add_node(TYPE_GENERALSTRING
|CONST_SIZE
);
1293 _asn1_set_down(yyval
.node
,yyvsp
[0].node
);}
1297 {yyval
.node
=_asn1_add_node(TYPE_OCTET_STRING
);}
1301 {yyval
.node
=_asn1_add_node(TYPE_OCTET_STRING
|CONST_SIZE
);
1302 _asn1_set_down(yyval
.node
,yyvsp
[0].node
);}
1306 {yyval
.node
=_asn1_add_node(TYPE_CONSTANT
);
1307 _asn1_set_name(yyval
.node
,yyvsp
[-3].str
);
1308 _asn1_set_value(yyval
.node
,yyvsp
[-1].str
,strlen(yyvsp
[-1].str
)+1);}
1312 {yyval
.node
=yyvsp
[0].node
;}
1316 {yyval
.node
=yyvsp
[-2].node
;
1317 _asn1_set_right(_asn1_get_last_right(yyvsp
[-2].node
),yyvsp
[0].node
);}
1321 {yyval
.node
=_asn1_add_node(TYPE_BIT_STRING
);}
1325 {yyval
.node
=_asn1_add_node(TYPE_BIT_STRING
|CONST_LIST
);
1326 _asn1_set_down(yyval
.node
,yyvsp
[-1].node
);}
1330 {yyval
.node
=_asn1_add_node(TYPE_ENUMERATED
|CONST_LIST
);
1331 _asn1_set_down(yyval
.node
,yyvsp
[-1].node
);}
1335 {yyval
.node
=_asn1_add_node(TYPE_OBJECT_ID
);}
1339 {yyval
.node
=_asn1_add_node(TYPE_IDENTIFIER
);
1340 _asn1_set_value(yyval
.node
,yyvsp
[0].str
,strlen(yyvsp
[0].str
)+1);}
1344 {yyval
.node
=_asn1_add_node(TYPE_IDENTIFIER
|CONST_SIZE
);
1345 _asn1_set_value(yyval
.node
,yyvsp
[-1].str
,strlen(yyvsp
[-1].str
)+1);
1346 _asn1_set_down(yyval
.node
,yyvsp
[0].node
);}
1350 {yyval
.node
=yyvsp
[0].node
;}
1354 {yyval
.node
=yyvsp
[0].node
;}
1358 {yyval
.node
=yyvsp
[0].node
;}
1362 {yyval
.node
=yyvsp
[0].node
;}
1366 {yyval
.node
=yyvsp
[0].node
;}
1370 {yyval
.node
=yyvsp
[0].node
;}
1374 {yyval
.node
=yyvsp
[0].node
;}
1378 {yyval
.node
=yyvsp
[0].node
;}
1382 {yyval
.node
=yyvsp
[0].node
;}
1386 {yyval
.node
=yyvsp
[0].node
;}
1390 {yyval
.node
=yyvsp
[0].node
;}
1394 {yyval
.node
=_asn1_add_node(TYPE_NULL
);}
1398 {yyval
.node
=yyvsp
[0].node
;}
1402 {yyval
.node
=_asn1_mod_type(yyvsp
[0].node
,CONST_TAG
);
1403 _asn1_set_right(yyvsp
[-1].node
,_asn1_get_down(yyval
.node
));
1404 _asn1_set_down(yyval
.node
,yyvsp
[-1].node
);}
1408 {yyval
.node
=yyvsp
[0].node
;}
1412 {yyval
.node
=_asn1_mod_type(yyvsp
[-1].node
,CONST_DEFAULT
);
1413 _asn1_set_right(yyvsp
[0].node
,_asn1_get_down(yyval
.node
));
1414 _asn1_set_down(yyval
.node
,yyvsp
[0].node
);}
1418 {yyval
.node
=_asn1_mod_type(yyvsp
[-1].node
,CONST_OPTION
);}
1422 {yyval
.node
=_asn1_set_name(yyvsp
[0].node
,yyvsp
[-1].str
);}
1426 {yyval
.node
=yyvsp
[0].node
;}
1430 {yyval
.node
=yyvsp
[-2].node
;
1431 _asn1_set_right(_asn1_get_last_right(yyvsp
[-2].node
),yyvsp
[0].node
);}
1435 {yyval
.node
=_asn1_add_node(TYPE_SEQUENCE
);
1436 _asn1_set_down(yyval
.node
,yyvsp
[-1].node
);}
1440 {yyval
.node
=_asn1_add_node(TYPE_SEQUENCE_OF
);
1441 _asn1_set_down(yyval
.node
,yyvsp
[0].node
);}
1445 {yyval
.node
=_asn1_add_node(TYPE_SEQUENCE_OF
|CONST_SIZE
);
1446 _asn1_set_right(yyvsp
[-2].node
,yyvsp
[0].node
);
1447 _asn1_set_down(yyval
.node
,yyvsp
[-2].node
);}
1451 {yyval
.node
=_asn1_add_node(TYPE_SET
);
1452 _asn1_set_down(yyval
.node
,yyvsp
[-1].node
);}
1456 {yyval
.node
=_asn1_add_node(TYPE_SET_OF
);
1457 _asn1_set_down(yyval
.node
,yyvsp
[0].node
);}
1461 {yyval
.node
=_asn1_add_node(TYPE_SET_OF
|CONST_SIZE
);
1462 _asn1_set_right(yyvsp
[-2].node
,yyvsp
[0].node
);
1463 _asn1_set_down(yyval
.node
,yyvsp
[-2].node
);}
1467 {yyval
.node
=_asn1_add_node(TYPE_CHOICE
);
1468 _asn1_set_down(yyval
.node
,yyvsp
[-1].node
);}
1472 {yyval
.node
=_asn1_add_node(TYPE_ANY
);}
1476 {yyval
.node
=_asn1_add_node(TYPE_ANY
|CONST_DEFINED_BY
);
1477 _asn1_set_down(yyval
.node
,_asn1_add_node(TYPE_CONSTANT
));
1478 _asn1_set_name(_asn1_get_down(yyval
.node
),yyvsp
[0].str
);}
1482 {yyval
.node
=_asn1_set_name(yyvsp
[0].node
,yyvsp
[-2].str
);}
1486 {yyval
.node
=_asn1_add_node(TYPE_OBJECT_ID
|CONST_ASSIGN
);
1487 _asn1_set_name(yyval
.node
,yyvsp
[-6].str
);
1488 _asn1_set_down(yyval
.node
,yyvsp
[-1].node
);}
1492 {yyval
.node
=_asn1_add_node(TYPE_OBJECT_ID
|CONST_ASSIGN
|CONST_1_PARAM
);
1493 _asn1_set_name(yyval
.node
,yyvsp
[-5].str
);
1494 _asn1_set_value(yyval
.node
,yyvsp
[-4].str
,strlen(yyvsp
[-4].str
)+1);
1495 _asn1_set_down(yyval
.node
,yyvsp
[-1].node
);}
1499 {yyval
.node
=_asn1_add_node(TYPE_INTEGER
|CONST_ASSIGN
);
1500 _asn1_set_name(yyval
.node
,yyvsp
[-3].str
);
1501 _asn1_set_value(yyval
.node
,yyvsp
[0].str
,strlen(yyvsp
[0].str
)+1);}
1505 {yyval
.node
=yyvsp
[0].node
;}
1509 {yyval
.node
=yyvsp
[0].node
;}
1513 {yyval
.node
=yyvsp
[0].node
;}
1517 {yyval
.node
=yyvsp
[-1].node
;
1518 _asn1_set_right(_asn1_get_last_right(yyvsp
[-1].node
),yyvsp
[0].node
);}
1522 {yyval
.node
=_asn1_add_node(TYPE_OBJECT_ID
);
1523 _asn1_set_down(yyval
.node
,yyvsp
[-1].node
);
1524 _asn1_set_name(yyval
.node
,yyvsp
[-3].str
);}
1528 {yyval
.node
=_asn1_add_node(TYPE_OBJECT_ID
);
1529 _asn1_set_name(yyval
.node
,yyvsp
[-2].str
);}
1533 {yyval
.constant
=CONST_EXPLICIT
;}
1537 {yyval
.constant
=CONST_IMPLICIT
;}
1541 #line 727 "/usr/local/share/bison/bison.simple"
1553 short *yyssp1
= yyss
- 1;
1554 YYFPRINTF (stderr
, "state stack now");
1555 while (yyssp1
!= yyssp
)
1556 YYFPRINTF (stderr
, " %d", *++yyssp1
);
1557 YYFPRINTF (stderr
, "\n");
1566 /* Now `shift' the result of the reduction. Determine what state
1567 that goes to, based on the state we popped back to and the rule
1568 number reduced by. */
1572 yystate
= yypgoto
[yyn
- YYNTBASE
] + *yyssp
;
1573 if (yystate
>= 0 && yystate
<= YYLAST
&& yycheck
[yystate
] == *yyssp
)
1574 yystate
= yytable
[yystate
];
1576 yystate
= yydefgoto
[yyn
- YYNTBASE
];
1581 /*------------------------------------.
1582 | yyerrlab -- here on detecting error |
1583 `------------------------------------*/
1585 /* If not already recovering from an error, report this error. */
1590 #ifdef YYERROR_VERBOSE
1591 yyn
= yypact
[yystate
];
1593 if (yyn
> YYFLAG
&& yyn
< YYLAST
)
1595 YYSIZE_T yysize
= 0;
1600 /* Start YYX at -YYN if negative to avoid negative indexes in
1602 for (yyx
= yyn
< 0 ? -yyn
: 0;
1603 yyx
< (int) (sizeof (yytname
) / sizeof (char *)); yyx
++)
1604 if (yycheck
[yyx
+ yyn
] == yyx
)
1605 yysize
+= yystrlen (yytname
[yyx
]) + 15, yycount
++;
1606 yysize
+= yystrlen ("parse error, unexpected ") + 1;
1607 yysize
+= yystrlen (yytname
[YYTRANSLATE (yychar
)]);
1608 yymsg
= (char *) YYSTACK_ALLOC (yysize
);
1611 char *yyp
= yystpcpy (yymsg
, "parse error, unexpected ");
1612 yyp
= yystpcpy (yyp
, yytname
[YYTRANSLATE (yychar
)]);
1617 for (yyx
= yyn
< 0 ? -yyn
: 0;
1618 yyx
< (int) (sizeof (yytname
) / sizeof (char *));
1620 if (yycheck
[yyx
+ yyn
] == yyx
)
1622 const char *yyq
= ! yycount
? ", expecting " : " or ";
1623 yyp
= yystpcpy (yyp
, yyq
);
1624 yyp
= yystpcpy (yyp
, yytname
[yyx
]);
1629 YYSTACK_FREE (yymsg
);
1632 yyerror ("parse error; also virtual memory exhausted");
1635 #endif /* defined (YYERROR_VERBOSE) */
1636 yyerror ("parse error");
1641 /*--------------------------------------------------.
1642 | yyerrlab1 -- error raised explicitly by an action |
1643 `--------------------------------------------------*/
1645 if (yyerrstatus
== 3)
1647 /* If just tried and failed to reuse lookahead token after an
1648 error, discard it. */
1650 /* return failure if at end of input */
1651 if (yychar
== YYEOF
)
1653 YYDPRINTF ((stderr
, "Discarding token %d (%s).\n",
1654 yychar
, yytname
[yychar1
]));
1658 /* Else will try to reuse lookahead token after shifting the error
1661 yyerrstatus
= 3; /* Each real token shifted decrements this */
1666 /*-------------------------------------------------------------------.
1667 | yyerrdefault -- current state does not do anything special for the |
1669 `-------------------------------------------------------------------*/
1672 /* This is wrong; only states that explicitly want error tokens
1673 should shift them. */
1675 /* If its default is to accept any token, ok. Otherwise pop it. */
1676 yyn
= yydefact
[yystate
];
1682 /*---------------------------------------------------------------.
1683 | yyerrpop -- pop the current state because it cannot handle the |
1685 `---------------------------------------------------------------*/
1698 short *yyssp1
= yyss
- 1;
1699 YYFPRINTF (stderr
, "Error: state stack now");
1700 while (yyssp1
!= yyssp
)
1701 YYFPRINTF (stderr
, " %d", *++yyssp1
);
1702 YYFPRINTF (stderr
, "\n");
1710 yyn
= yypact
[yystate
];
1715 if (yyn
< 0 || yyn
> YYLAST
|| yycheck
[yyn
] != YYTERROR
)
1732 YYDPRINTF ((stderr
, "Shifting error token, "));
1743 /*-------------------------------------.
1744 | yyacceptlab -- YYACCEPT comes here. |
1745 `-------------------------------------*/
1750 /*-----------------------------------.
1751 | yyabortlab -- YYABORT comes here. |
1752 `-----------------------------------*/
1757 /*---------------------------------------------.
1758 | yyoverflowab -- parser overflow comes here. |
1759 `---------------------------------------------*/
1761 yyerror ("parser stack overflow");
1768 YYSTACK_FREE (yyss
);
1777 const char *key_word
[]={"::=","OPTIONAL","INTEGER","SIZE","OCTET","STRING"
1778 ,"SEQUENCE","BIT","UNIVERSAL","PRIVATE","OPTIONAL"
1779 ,"DEFAULT","CHOICE","OF","OBJECT","IDENTIFIER"
1780 ,"BOOLEAN","TRUE","FALSE","APPLICATION","ANY","DEFINED"
1781 ,"SET","BY","EXPLICIT","IMPLICIT","DEFINITIONS","TAGS"
1782 ,"BEGIN","END","UTCTime","GeneralizedTime"
1783 ,"GeneralString","FROM","IMPORTS","NULL","ENUMERATED"};
1784 const int key_word_token
[]={ASSIG
,OPTIONAL
,INTEGER
,SIZE
,OCTET
,STRING
1785 ,SEQUENCE
,BIT
,UNIVERSAL
,PRIVATE
,OPTIONAL
1786 ,DEFAULT
,CHOICE
,OF
,OBJECT
,STR_IDENTIFIER
1787 ,BOOLEAN
,TRUE
,FALSE
,APPLICATION
,ANY
,DEFINED
1788 ,SET
,BY
,EXPLICIT
,IMPLICIT
,DEFINITIONS
,TAGS
1789 ,BEGIN
,END
,UTCTime
,GeneralizedTime
1790 ,GeneralString
,FROM
,IMPORTS
,TOKEN_NULL
,ENUMERATED
};
1792 /*************************************************************/
1793 /* Function: _asn1_yylex */
1794 /* Description: looks for tokens in file_asn1 pointer file. */
1796 /* Token identifier or ASCII code or 0(zero: End Of File) */
1797 /*************************************************************/
1802 char string
[MAX_NAME_SIZE
+1]; /* will contain the next token */
1806 while((c
=fgetc(file_asn1
))==' ' || c
=='\t' || c
=='\n')
1807 if(c
=='\n') lineNumber
++;
1810 strcpy(lastToken
,"End Of File");
1814 if(c
=='(' || c
==')' || c
=='[' || c
==']' ||
1815 c
=='{' || c
=='}' || c
==',' || c
=='.' ||
1817 lastToken
[0]=c
;lastToken
[1]=0;
1820 if(c
=='-'){ /* Maybe the first '-' of a comment */
1821 if((c
=fgetc(file_asn1
))!='-'){
1822 ungetc(c
,file_asn1
);
1823 lastToken
[0]='-';lastToken
[1]=0;
1826 else{ /* Comments */
1828 /* A comment finishes at the end of line */
1829 while((c
=fgetc(file_asn1
))!=EOF
&& c
!='\n');
1831 strcpy(lastToken
,"End Of File");
1836 continue; /* next char, please! (repeat the search) */
1840 string
[counter
++]=c
;
1841 /* Till the end of the token */
1842 while(!((c
=fgetc(file_asn1
))==EOF
|| c
==' '|| c
=='\t' || c
=='\n' ||
1843 c
=='(' || c
==')' || c
=='[' || c
==']' ||
1844 c
=='{' || c
=='}' || c
==',' || c
=='.'))
1846 if(counter
>=MAX_NAME_SIZE
){
1847 result_parse
=ASN1_NAME_TOO_LONG
;
1850 string
[counter
++]=c
;
1852 ungetc(c
,file_asn1
);
1854 strcpy(lastToken
,string
);
1856 /* Is STRING a number? */
1857 for(k
=0;k
<counter
;k
++)
1858 if(!isdigit(string
[k
])) break;
1861 strcpy(yylval
.str
,string
);
1862 return NUM
; /* return the number */
1865 /* Is STRING a keyword? */
1866 for(k
=0;k
<(sizeof(key_word
)/sizeof(char*));k
++)
1867 if(!strcmp(string
,key_word
[k
])) return key_word_token
[k
];
1869 /* STRING is an IDENTIFIER */
1870 strcpy(yylval
.str
,string
);
1876 /*************************************************************/
1877 /* Function: _asn1_create_errorDescription */
1878 /* Description: creates a string with the description of the*/
1881 /* error : error to describe. */
1882 /* errorDescription: string that will contain the */
1884 /*************************************************************/
1886 _asn1_create_errorDescription(int error
,char *errorDescription
)
1889 case ASN1_SUCCESS
: case ASN1_FILE_NOT_FOUND
:
1890 if (errorDescription
!=NULL
) errorDescription
[0]=0;
1892 case ASN1_SYNTAX_ERROR
:
1893 if (errorDescription
!=NULL
) {
1894 strcpy(errorDescription
,fileName
);
1895 strcat(errorDescription
,":");
1896 _asn1_ltostr(lineNumber
,errorDescription
+strlen(fileName
)+1);
1897 strcat(errorDescription
,": parse error near '");
1898 strcat(errorDescription
,lastToken
);
1899 strcat(errorDescription
,"'");
1902 case ASN1_NAME_TOO_LONG
:
1903 if (errorDescription
!=NULL
) {
1904 strcpy(errorDescription
,fileName
);
1905 strcat(errorDescription
,":");
1906 _asn1_ltostr(lineNumber
,errorDescription
+strlen(fileName
)+1);
1907 strcat(errorDescription
,": name too long (more than ");
1908 _asn1_ltostr(MAX_NAME_SIZE
,errorDescription
+strlen(errorDescription
));
1909 strcat(errorDescription
," characters)");
1912 case ASN1_IDENTIFIER_NOT_FOUND
:
1913 if (errorDescription
!=NULL
) {
1914 strcpy(errorDescription
,fileName
);
1915 strcat(errorDescription
,":");
1916 strcat(errorDescription
,": identifier '");
1917 strcat(errorDescription
,_asn1_identifierMissing
);
1918 strcat(errorDescription
,"' not found");
1922 if (errorDescription
!=NULL
) errorDescription
[0]=0;
1930 * asn1_parser2tree - function used to start the parse algorithm.
1931 * @file_name: specify the path and the name of file that contains ASN.1 declarations.
1932 * @definitions: return the pointer to the structure created from
1933 * "file_name" ASN.1 declarations.
1934 * @errorDescription : return the error description or an empty string if success.
1937 * Creates the structures needed to manage the definitions included in *FILE_NAME file.
1941 * ASN1_SUCCESS\: the file has a correct syntax and every identifier is known.
1943 * ASN1_ELEMENT_NOT_EMPTY\: *POINTER not ASN1_TYPE_EMPTY.
1945 * ASN1_FILE_NOT_FOUND\: an error occured while opening FILE_NAME.
1947 * ASN1_SYNTAX_ERROR\: the syntax is not correct.
1949 * ASN1_IDENTIFIER_NOT_FOUND\: in the file there is an identifier that is not defined.
1950 * ASN1_NAME_TOO_LONG\: in the file there is an identifier whith more than MAX_NAME_SIZE characters.
1953 asn1_parser2tree(const char *file_name
,ASN1_TYPE
*definitions
,char *errorDescription
){
1955 p_tree
=ASN1_TYPE_EMPTY
;
1957 if(*definitions
!= ASN1_TYPE_EMPTY
)
1958 return ASN1_ELEMENT_NOT_EMPTY
;
1960 *definitions
=ASN1_TYPE_EMPTY
;
1962 fileName
= file_name
;
1964 /* open the file to parse */
1965 file_asn1
=fopen(file_name
,"r");
1967 if(file_asn1
==NULL
){
1968 result_parse
=ASN1_FILE_NOT_FOUND
;
1971 result_parse
=ASN1_SUCCESS
;
1978 if(result_parse
==ASN1_SUCCESS
){ /* syntax OK */
1979 /* set IMPLICIT or EXPLICIT property */
1980 _asn1_set_default_tag(p_tree
);
1981 /* set CONST_SET and CONST_NOT_USED */
1982 _asn1_type_set_config(p_tree
);
1983 /* check the identifier definitions */
1984 result_parse
=_asn1_check_identifier(p_tree
);
1985 if(result_parse
==ASN1_SUCCESS
){ /* all identifier defined */
1986 /* Delete the list and keep the ASN1 structure */
1987 _asn1_delete_list();
1988 /* Convert into DER coding the value assign to INTEGER constants */
1989 _asn1_change_integer_value(p_tree
);
1990 /* Expand the IDs of OBJECT IDENTIFIER constants */
1991 _asn1_expand_object_id(p_tree
);
1993 *definitions
=p_tree
;
1995 else /* some identifiers not defined */
1996 /* Delete the list and the ASN1 structure */
1997 _asn1_delete_list_and_nodes();
1999 else /* syntax error */
2000 /* Delete the list and the ASN1 structure */
2001 _asn1_delete_list_and_nodes();
2004 if (errorDescription
!=NULL
)
2005 _asn1_create_errorDescription(result_parse
,errorDescription
);
2007 return result_parse
;
2012 * asn1_parser2array - function that generates a C structure from an ASN1 file
2013 * @inputFileName: specify the path and the name of file that contains ASN.1 declarations.
2014 * @outputFileName: specify the path and the name of file that will contain the C vector definition.
2015 * @vectorName: specify the name of the C vector.
2016 * @errorDescription : return the error description or an empty string if success.
2019 * Creates a file containing a C vector to use to manage the definitions included in
2020 * *INPUTFILENAME file. If *INPUTFILENAME is "/aa/bb/xx.yy" and OUTPUTFILENAME is NULL, the file created is "/aa/bb/xx_asn1_tab.c".
2021 * If VECTORNAME is NULL the vector name will be "xx_asn1_tab".
2025 * ASN1_SUCCESS\: the file has a correct syntax and every identifier is known.
2027 * ASN1_FILE_NOT_FOUND\: an error occured while opening FILE_NAME.
2029 * ASN1_SYNTAX_ERROR\: the syntax is not correct.
2031 * ASN1_IDENTIFIER_NOT_FOUND\: in the file there is an identifier that is not defined.
2032 * ASN1_NAME_TOO_LONG\: in the file there is an identifier whith more than MAX_NAME_SIZE characters.
2034 int asn1_parser2array(const char *inputFileName
,const char *outputFileName
,
2035 const char *vectorName
,char *errorDescription
){
2036 char *file_out_name
=NULL
;
2037 char *vector_name
=NULL
;
2038 const char *char_p
,*slash_p
,*dot_p
;
2042 fileName
= inputFileName
;
2044 /* open the file to parse */
2045 file_asn1
=fopen(inputFileName
,"r");
2048 result_parse
=ASN1_FILE_NOT_FOUND
;
2050 result_parse
=ASN1_SUCCESS
;
2057 if(result_parse
==ASN1_SUCCESS
){ /* syntax OK */
2058 /* set IMPLICIT or EXPLICIT property */
2059 _asn1_set_default_tag(p_tree
);
2060 /* set CONST_SET and CONST_NOT_USED */
2061 _asn1_type_set_config(p_tree
);
2062 /* check the identifier definitions */
2063 result_parse
=_asn1_check_identifier(p_tree
);
2065 if(result_parse
==ASN1_SUCCESS
){ /* all identifier defined */
2067 /* searching the last '/' and '.' in inputFileName */
2068 char_p
=inputFileName
;
2069 slash_p
=inputFileName
;
2070 while((char_p
=strchr(char_p
,'/'))){
2076 dot_p
=inputFileName
+strlen(inputFileName
);
2078 while((char_p
=strchr(char_p
,'.'))){
2083 if(outputFileName
== NULL
){
2084 /* file_out_name = inputFileName + _asn1_tab.c */
2085 file_out_name
=(char *)malloc(dot_p
-inputFileName
+1+
2086 strlen("_asn1_tab.c"));
2087 memcpy(file_out_name
,inputFileName
,dot_p
-inputFileName
);
2088 file_out_name
[dot_p
-inputFileName
]=0;
2089 strcat(file_out_name
,"_asn1_tab.c");
2092 /* file_out_name = inputFileName */
2093 file_out_name
=(char *)malloc(strlen(outputFileName
)+1);
2094 strcpy(file_out_name
,outputFileName
);
2097 if(vectorName
== NULL
){
2098 /* vector_name = file name + _asn1_tab */
2099 vector_name
=(char *)malloc(dot_p
-slash_p
+1+
2100 strlen("_asn1_tab"));
2101 memcpy(vector_name
,slash_p
,dot_p
-slash_p
);
2102 vector_name
[dot_p
-slash_p
]=0;
2103 strcat(vector_name
,"_asn1_tab");
2106 /* vector_name = vectorName */
2107 vector_name
=(char *)malloc(strlen(vectorName
)+1);
2108 strcpy(vector_name
,vectorName
);
2111 /* Save structure in a file */
2112 _asn1_create_static_structure(p_tree
,
2113 file_out_name
,vector_name
);
2115 free(file_out_name
);
2117 } /* result == OK */
2118 } /* result == OK */
2120 /* Delete the list and the ASN1 structure */
2121 _asn1_delete_list_and_nodes();
2122 } /* inputFile exist */
2124 if (errorDescription
!=NULL
)
2125 _asn1_create_errorDescription(result_parse
,errorDescription
);
2127 return result_parse
;
2131 /*************************************************************/
2132 /* Function: _asn1_yyerror */
2133 /* Description: function called when there are syntax errors*/
2135 /* char *s : error description */
2138 /*************************************************************/
2139 int _asn1_yyerror (char *s
)
2141 /* Sends the error description to the std_out */
2143 #ifdef LIBTASN1_DEBUG_PARSER
2144 _libtasn1_log("_asn1_yyerror:%s:%d: %s (Last Token:'%s')\n",fileName
,
2145 lineNumber
,s
,lastToken
);
2148 if(result_parse
!=ASN1_NAME_TOO_LONG
)
2149 result_parse
=ASN1_SYNTAX_ERROR
;