libc sync
[shishi.git] / asn1 / ASN1.c
blob7094adeba05865635cdb6e831d1d5885b8151002
1 /* A Bison parser, made from ASN1.y
2 by GNU bison 1.33. */
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
13 # define ASSIG 257
14 # define NUM 258
15 # define IDENTIFIER 259
16 # define OPTIONAL 260
17 # define INTEGER 261
18 # define SIZE 262
19 # define OCTET 263
20 # define STRING 264
21 # define SEQUENCE 265
22 # define BIT 266
23 # define UNIVERSAL 267
24 # define PRIVATE 268
25 # define APPLICATION 269
26 # define DEFAULT 270
27 # define CHOICE 271
28 # define OF 272
29 # define OBJECT 273
30 # define STR_IDENTIFIER 274
31 # define BOOLEAN 275
32 # define TRUE 276
33 # define FALSE 277
34 # define TOKEN_NULL 278
35 # define ANY 279
36 # define DEFINED 280
37 # define BY 281
38 # define SET 282
39 # define EXPLICIT 283
40 # define IMPLICIT 284
41 # define DEFINITIONS 285
42 # define TAGS 286
43 # define BEGIN 287
44 # define END 288
45 # define UTCTime 289
46 # define GeneralizedTime 290
47 # define GeneralString 291
48 # define FROM 292
49 # define IMPORTS 293
50 # define ENUMERATED 294
52 #line 29 "ASN1.y"
54 #include <int.h>
55 #include <errors.h>
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
65 inside the file */
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);
75 #line 55 "ASN1.y"
76 #ifndef YYSTYPE
77 typedef union {
78 unsigned int constant;
79 char str[MAX_NAME_SIZE+1];
80 node_asn* node;
81 } yystype;
82 # define YYSTYPE yystype
83 #endif
84 #ifndef YYDEBUG
85 # define YYDEBUG 0
86 #endif
90 #define YYFINAL 183
91 #define YYFLAG -32768
92 #define YYNTBASE 51
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,
129 36, 37, 38, 39, 40
132 #if YYDEBUG
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
181 #endif
183 #if YYDEBUG
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
198 #endif
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
225 #endif
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,
239 89, 90, 90, 91, 91
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,
254 2, 4, 3, 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
259 error. */
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,
280 37, 0, 0, 0
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,
321 -32768
325 #define YYLAST 199
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
381 Foundation, Inc.
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)
386 any later version.
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. */
415 #ifdef __cplusplus
416 # define YYSTD(x) std::x
417 #else
418 # define YYSTD(x) x
419 #endif
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
427 # else
428 # ifndef YYSTACK_USE_ALLOCA
429 # if defined (alloca) || defined (_ALLOCA_H)
430 # define YYSTACK_ALLOC alloca
431 # else
432 # ifdef __GNUC__
433 # define YYSTACK_ALLOC __builtin_alloca
434 # endif
435 # endif
436 # endif
437 # endif
439 # ifdef YYSTACK_ALLOC
440 /* Pacify GCC's `empty if-body' warning. */
441 # define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
442 # else
443 # ifdef __cplusplus
444 # include <cstdlib> /* INFRINGES ON USER NAME SPACE */
445 # define YYSIZE_T std::size_t
446 # else
447 # ifdef __STDC__
448 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
449 # define YYSIZE_T size_t
450 # endif
451 # endif
452 # define YYSTACK_ALLOC YYSTD (malloc)
453 # define YYSTACK_FREE YYSTD (free)
454 # endif
456 /* A type that is properly aligned for any stack member. */
457 union yyalloc
459 short yyss;
460 YYSTYPE yyvs;
461 # if YYLSP_NEEDED
462 YYLTYPE yyls;
463 # endif
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
470 N elements. */
471 # if YYLSP_NEEDED
472 # define YYSTACK_BYTES(N) \
473 ((N) * (sizeof (short) + sizeof (YYSTYPE) + sizeof (YYLTYPE)) \
474 + 2 * YYSTACK_GAP_MAX)
475 # else
476 # define YYSTACK_BYTES(N) \
477 ((N) * (sizeof (short) + sizeof (YYSTYPE)) \
478 + YYSTACK_GAP_MAX)
479 # endif
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
485 stack. */
486 # define YYSTACK_RELOCATE(Type, Stack) \
487 do \
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); \
496 while (0)
498 #endif /* ! defined (yyoverflow) || defined (YYERROR_VERBOSE) */
501 #if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__)
502 # define YYSIZE_T __SIZE_TYPE__
503 #endif
504 #if ! defined (YYSIZE_T) && defined (size_t)
505 # define YYSIZE_T size_t
506 #endif
507 #if ! defined (YYSIZE_T)
508 # ifdef __cplusplus
509 # include <cstddef> /* INFRINGES ON USER NAME SPACE */
510 # define YYSIZE_T std::size_t
511 # else
512 # ifdef __STDC__
513 # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
514 # define YYSIZE_T size_t
515 # endif
516 # endif
517 #endif
518 #if ! defined (YYSIZE_T)
519 # define YYSIZE_T unsigned int
520 #endif
522 #define yyerrok (yyerrstatus = 0)
523 #define yyclearin (yychar = YYEMPTY)
524 #define YYEMPTY -2
525 #define YYEOF 0
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) \
535 do \
536 if (yychar == YYEMPTY && yylen == 1) \
538 yychar = (Token); \
539 yylval = (Value); \
540 yychar1 = YYTRANSLATE (yychar); \
541 YYPOPSTACK; \
542 goto yybackup; \
544 else \
546 yyerror ("syntax error: cannot back up"); \
547 YYERROR; \
549 while (0)
551 #define YYTERROR 1
552 #define YYERRCODE 256
555 /* YYLLOC_DEFAULT -- Compute the default location (before the actions
556 are run).
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;
566 #endif
569 /* YYLEX -- calling `yylex' with the right arguments. */
571 #if YYPURE
572 # if YYLSP_NEEDED
573 # ifdef YYLEX_PARAM
574 # define YYLEX yylex (&yylval, &yylloc, YYLEX_PARAM)
575 # else
576 # define YYLEX yylex (&yylval, &yylloc)
577 # endif
578 # else /* !YYLSP_NEEDED */
579 # ifdef YYLEX_PARAM
580 # define YYLEX yylex (&yylval, YYLEX_PARAM)
581 # else
582 # define YYLEX yylex (&yylval)
583 # endif
584 # endif /* !YYLSP_NEEDED */
585 #else /* !YYPURE */
586 # define YYLEX yylex ()
587 #endif /* !YYPURE */
590 /* Enable debugging if requested. */
591 #if YYDEBUG
593 # ifndef YYFPRINTF
594 # ifdef __cplusplus
595 # include <cstdio> /* INFRINGES ON USER NAME SPACE */
596 # else
597 # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
598 # endif
599 # define YYFPRINTF YYSTD (fprintf)
600 # endif
602 # define YYDPRINTF(Args) \
603 do { \
604 if (yydebug) \
605 YYFPRINTF Args; \
606 } while (0)
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.
611 int yydebug;
612 #else /* !YYDEBUG */
613 # define YYDPRINTF(Args)
614 #endif /* !YYDEBUG */
616 /* YYINITDEPTH -- initial size of the parser's stacks. */
617 #ifndef YYINITDEPTH
618 # define YYINITDEPTH 200
619 #endif
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. */
628 #if YYMAXDEPTH == 0
629 # undef YYMAXDEPTH
630 #endif
632 #ifndef YYMAXDEPTH
633 # define YYMAXDEPTH 10000
634 #endif
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. */
643 static void
644 # if defined (__STDC__) || defined (__cplusplus)
645 yymemcpy (char *yyto, const char *yyfrom, YYSIZE_T yycount)
646 # else
647 yymemcpy (yyto, yyfrom, yycount)
648 char *yyto;
649 const char *yyfrom;
650 YYSIZE_T yycount;
651 # endif
653 register const char *yyf = yyfrom;
654 register char *yyt = yyto;
655 register YYSIZE_T yyi = yycount;
657 while (yyi-- != 0)
658 *yyt++ = *yyf++;
660 # endif
661 #endif
663 #ifdef YYERROR_VERBOSE
665 # ifndef yystrlen
666 # if defined (__GLIBC__) && defined (_STRING_H)
667 # define yystrlen strlen
668 # else
669 /* Return the length of YYSTR. */
670 static YYSIZE_T
671 # if defined (__STDC__) || defined (__cplusplus)
672 yystrlen (const char *yystr)
673 # else
674 yystrlen (yystr)
675 const char *yystr;
676 # endif
678 register const char *yys = yystr;
680 while (*yys++ != '\0')
681 continue;
683 return yys - yystr - 1;
685 # endif
686 # endif
688 # ifndef yystpcpy
689 # if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE)
690 # define yystpcpy stpcpy
691 # else
692 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
693 YYDEST. */
694 static char *
695 # if defined (__STDC__) || defined (__cplusplus)
696 yystpcpy (char *yydest, const char *yysrc)
697 # else
698 yystpcpy (yydest, yysrc)
699 char *yydest;
700 const char *yysrc;
701 # endif
703 register char *yyd = yydest;
704 register const char *yys = yysrc;
706 while ((*yyd++ = *yys++) != '\0')
707 continue;
709 return yyd - 1;
711 # endif
712 # endif
713 #endif
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. */
724 #ifdef YYPARSE_PARAM
725 # ifdef __cplusplus
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. */
738 #ifdef __GNUC__
739 # ifdef YYPARSE_PARAM
740 int yyparse (void *);
741 # else
742 int yyparse (void);
743 # endif
744 #endif
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. */ \
751 int yychar; \
753 /* The semantic value of the lookahead symbol. */ \
754 YYSTYPE yylval; \
756 /* Number of parse errors so far. */ \
757 int yynerrs;
759 #if YYLSP_NEEDED
760 # define YY_DECL_VARIABLES \
761 YY_DECL_NON_LSP_VARIABLES \
763 /* Location data for the lookahead symbol. */ \
764 YYLTYPE yylloc;
765 #else
766 # define YY_DECL_VARIABLES \
767 YY_DECL_NON_LSP_VARIABLES
768 #endif
771 /* If nonreentrant, generate the variables here. */
773 #if !YYPURE
774 YY_DECL_VARIABLES
775 #endif /* !YYPURE */
778 yyparse (YYPARSE_PARAM_ARG)
779 YYPARSE_PARAM_DECL
781 /* If reentrant, generate the variables here. */
782 #if YYPURE
783 YY_DECL_VARIABLES
784 #endif /* !YYPURE */
786 register int yystate;
787 register int yyn;
788 int yyresult;
789 /* Number of tokens to shift before error messages enabled. */
790 int yyerrstatus;
791 /* Lookahead token as an internal (translated) token number. */
792 int yychar1 = 0;
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];
804 short *yyss = yyssa;
805 register short *yyssp;
807 /* The semantic value stack. */
808 YYSTYPE yyvsa[YYINITDEPTH];
809 YYSTYPE *yyvs = yyvsa;
810 register YYSTYPE *yyvsp;
812 #if YYLSP_NEEDED
813 /* The location stack. */
814 YYLTYPE yylsa[YYINITDEPTH];
815 YYLTYPE *yyls = yylsa;
816 YYLTYPE *yylsp;
817 #endif
819 #if YYLSP_NEEDED
820 # define YYPOPSTACK (yyvsp--, yyssp--, yylsp--)
821 #else
822 # define YYPOPSTACK (yyvsp--, yyssp--)
823 #endif
825 YYSIZE_T yystacksize = YYINITDEPTH;
828 /* The variables used to return semantic value and location from the
829 action routines. */
830 YYSTYPE yyval;
831 #if YYLSP_NEEDED
832 YYLTYPE yyloc;
833 #endif
835 /* When reducing, the number of symbols on the RHS of the reduced
836 rule. */
837 int yylen;
839 YYDPRINTF ((stderr, "Starting parse\n"));
841 yystate = 0;
842 yyerrstatus = 0;
843 yynerrs = 0;
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. */
851 yyssp = yyss;
852 yyvsp = yyvs;
853 #if YYLSP_NEEDED
854 yylsp = yyls;
855 #endif
856 goto yysetstate;
858 /*------------------------------------------------------------.
859 | yynewstate -- Push a new state, which is found in yystate. |
860 `------------------------------------------------------------*/
861 yynewstate:
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.
865 yyssp++;
867 yysetstate:
868 *yyssp = yystate;
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;
875 #ifdef yyoverflow
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
879 memory. */
880 YYSTYPE *yyvs1 = yyvs;
881 short *yyss1 = yyss;
883 /* Each stack pointer address is followed by the size of the
884 data in use in that stack, in bytes. */
885 # if YYLSP_NEEDED
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),
893 &yystacksize);
894 yyls = yyls1;
895 # else
896 yyoverflow ("parser stack overflow",
897 &yyss1, yysize * sizeof (*yyssp),
898 &yyvs1, yysize * sizeof (*yyvsp),
899 &yystacksize);
900 # endif
901 yyss = yyss1;
902 yyvs = yyvs1;
904 #else /* no yyoverflow */
905 /* Extend the stack our own way. */
906 if (yystacksize >= YYMAXDEPTH)
907 goto yyoverflowlab;
908 yystacksize *= 2;
909 if (yystacksize > YYMAXDEPTH)
910 yystacksize = YYMAXDEPTH;
913 short *yyss1 = yyss;
914 union yyalloc *yyptr =
915 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
916 if (! yyptr)
917 goto yyoverflowlab;
918 YYSTACK_RELOCATE (short, yyss);
919 YYSTACK_RELOCATE (YYSTYPE, yyvs);
920 # if YYLSP_NEEDED
921 YYSTACK_RELOCATE (YYLTYPE, yyls);
922 # endif
923 # undef YYSTACK_RELOCATE
924 if (yyss1 != yyssa)
925 YYSTACK_FREE (yyss1);
927 #endif /* no yyoverflow */
929 yyssp = yyss + yysize - 1;
930 yyvsp = yyvs + yysize - 1;
931 #if YYLSP_NEEDED
932 yylsp = yyls + yysize - 1;
933 #endif
935 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
936 (unsigned long int) yystacksize));
938 if (yyssp >= yyss + yystacksize - 1)
939 YYABORT;
942 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
944 goto yybackup;
947 /*-----------.
948 | yybackup. |
949 `-----------*/
950 yybackup:
952 /* Do appropriate processing given the current state. */
953 /* Read a lookahead token if we need one and don't already have one. */
954 /* yyresume: */
956 /* First try to decide what to do without reference to lookahead token. */
958 yyn = yypact[yystate];
959 if (yyn == YYFLAG)
960 goto yydefault;
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: "));
970 yychar = YYLEX;
973 /* Convert token to internal form (in yychar1) for indexing tables with */
975 if (yychar <= 0) /* This means end of input. */
977 yychar1 = 0;
978 yychar = YYEOF; /* Don't call YYLEX any more */
980 YYDPRINTF ((stderr, "Now at end of input.\n"));
982 else
984 yychar1 = YYTRANSLATE (yychar);
986 #if YYDEBUG
987 /* We have to keep this `#if YYDEBUG', since we use variables
988 which are defined only if `YYDEBUG' is set. */
989 if (yydebug)
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. */
995 # ifdef YYPRINT
996 YYPRINT (stderr, yychar, yylval);
997 # endif
998 YYFPRINTF (stderr, ")\n");
1000 #endif
1003 yyn += yychar1;
1004 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
1005 goto yydefault;
1007 yyn = yytable[yyn];
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. */
1016 if (yyn < 0)
1018 if (yyn == YYFLAG)
1019 goto yyerrlab;
1020 yyn = -yyn;
1021 goto yyreduce;
1023 else if (yyn == 0)
1024 goto yyerrlab;
1026 if (yyn == YYFINAL)
1027 YYACCEPT;
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)
1035 yychar = YYEMPTY;
1037 *++yyvsp = yylval;
1038 #if YYLSP_NEEDED
1039 *++yylsp = yylloc;
1040 #endif
1042 /* Count tokens shifted since error; after three, turn off error
1043 status. */
1044 if (yyerrstatus)
1045 yyerrstatus--;
1047 yystate = yyn;
1048 goto yynewstate;
1051 /*-----------------------------------------------------------.
1052 | yydefault -- do the default action for the current state. |
1053 `-----------------------------------------------------------*/
1054 yydefault:
1055 yyn = yydefact[yystate];
1056 if (yyn == 0)
1057 goto yyerrlab;
1058 goto yyreduce;
1061 /*-----------------------------.
1062 | yyreduce -- Do a reduction. |
1063 `-----------------------------*/
1064 yyreduce:
1065 /* yyn is the number of a rule to reduce with. */
1066 yylen = yyr2[yyn];
1068 /* If YYLEN is nonzero, implement the default value of the action:
1069 `$$ = $1'.
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];
1078 #if YYLSP_NEEDED
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);
1083 #endif
1085 #if YYDEBUG
1086 /* We have to keep this `#if YYDEBUG', since we use variables which
1087 are defined only if `YYDEBUG' is set. */
1088 if (yydebug)
1090 int yyi;
1092 YYFPRINTF (stderr, "Reducing via rule %d (line %d), ",
1093 yyn, yyrline[yyn]);
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]]);
1100 #endif
1102 switch (yyn) {
1104 case 1:
1105 #line 119 "ASN1.y"
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);
1112 p_tree=yyval.node;
1114 break;
1115 case 2:
1116 #line 129 "ASN1.y"
1117 {strcpy(yyval.str,yyvsp[0].str);}
1118 break;
1119 case 3:
1120 #line 130 "ASN1.y"
1121 {strcpy(yyval.str,yyvsp[0].str);}
1122 break;
1123 case 4:
1124 #line 133 "ASN1.y"
1125 {strcpy(yyval.str,"-");
1126 strcat(yyval.str,yyvsp[0].str);}
1127 break;
1128 case 5:
1129 #line 137 "ASN1.y"
1130 {strcpy(yyval.str,yyvsp[0].str);}
1131 break;
1132 case 6:
1133 #line 138 "ASN1.y"
1134 {strcpy(yyval.str,yyvsp[0].str);}
1135 break;
1136 case 7:
1137 #line 141 "ASN1.y"
1138 {strcpy(yyval.str,yyvsp[0].str);}
1139 break;
1140 case 8:
1141 #line 142 "ASN1.y"
1142 {strcpy(yyval.str,yyvsp[0].str);}
1143 break;
1144 case 9:
1145 #line 145 "ASN1.y"
1146 {strcpy(yyval.str,yyvsp[0].str);}
1147 break;
1148 case 10:
1149 #line 146 "ASN1.y"
1150 {strcpy(yyval.str,yyvsp[0].str);}
1151 break;
1152 case 11:
1153 #line 149 "ASN1.y"
1154 {yyval.node=_asn1_add_node(TYPE_CONSTANT);
1155 _asn1_set_value(yyval.node,yyvsp[-1].str,strlen(yyvsp[-1].str)+1);}
1156 break;
1157 case 12:
1158 #line 151 "ASN1.y"
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);}
1162 break;
1163 case 13:
1164 #line 156 "ASN1.y"
1165 {yyval.node=yyvsp[0].node;}
1166 break;
1167 case 14:
1168 #line 157 "ASN1.y"
1169 {yyval.node=yyvsp[-2].node;
1170 _asn1_set_right(_asn1_get_last_right(yyvsp[-2].node),yyvsp[0].node);}
1171 break;
1172 case 15:
1173 #line 161 "ASN1.y"
1174 {yyval.node=_asn1_add_node(TYPE_CONSTANT);
1175 _asn1_set_value(yyval.node,yyvsp[0].str,strlen(yyvsp[0].str)+1);}
1176 break;
1177 case 16:
1178 #line 163 "ASN1.y"
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);}
1182 break;
1183 case 17:
1184 #line 168 "ASN1.y"
1185 {yyval.node=yyvsp[0].node;}
1186 break;
1187 case 18:
1188 #line 169 "ASN1.y"
1189 {yyval.node=yyvsp[-1].node;
1190 _asn1_set_right(_asn1_get_last_right(yyvsp[-1].node),yyvsp[0].node);}
1191 break;
1192 case 19:
1193 #line 173 "ASN1.y"
1194 {yyval.constant=CONST_UNIVERSAL;}
1195 break;
1196 case 20:
1197 #line 174 "ASN1.y"
1198 {yyval.constant=CONST_PRIVATE;}
1199 break;
1200 case 21:
1201 #line 175 "ASN1.y"
1202 {yyval.constant=CONST_APPLICATION;}
1203 break;
1204 case 22:
1205 #line 178 "ASN1.y"
1206 {yyval.node=_asn1_add_node(TYPE_TAG);
1207 _asn1_set_value(yyval.node,yyvsp[-1].str,strlen(yyvsp[-1].str)+1);}
1208 break;
1209 case 23:
1210 #line 180 "ASN1.y"
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);}
1213 break;
1214 case 24:
1215 #line 184 "ASN1.y"
1216 {yyval.node=yyvsp[0].node;}
1217 break;
1218 case 25:
1219 #line 185 "ASN1.y"
1220 {yyval.node=_asn1_mod_type(yyvsp[-1].node,CONST_EXPLICIT);}
1221 break;
1222 case 26:
1223 #line 186 "ASN1.y"
1224 {yyval.node=_asn1_mod_type(yyvsp[-1].node,CONST_IMPLICIT);}
1225 break;
1226 case 27:
1227 #line 189 "ASN1.y"
1228 {yyval.node=_asn1_add_node(TYPE_DEFAULT);
1229 _asn1_set_value(yyval.node,yyvsp[0].str,strlen(yyvsp[0].str)+1);}
1230 break;
1231 case 28:
1232 #line 191 "ASN1.y"
1233 {yyval.node=_asn1_add_node(TYPE_DEFAULT|CONST_TRUE);}
1234 break;
1235 case 29:
1236 #line 192 "ASN1.y"
1237 {yyval.node=_asn1_add_node(TYPE_DEFAULT|CONST_FALSE);}
1238 break;
1239 case 30:
1240 #line 195 "ASN1.y"
1241 {yyval.node=_asn1_add_node(TYPE_INTEGER);}
1242 break;
1243 case 31:
1244 #line 196 "ASN1.y"
1245 {yyval.node=_asn1_add_node(TYPE_INTEGER|CONST_LIST);
1246 _asn1_set_down(yyval.node,yyvsp[-1].node);}
1247 break;
1248 case 32:
1249 #line 199 "ASN1.y"
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);}
1254 break;
1255 case 33:
1256 #line 205 "ASN1.y"
1257 {yyval.node=_asn1_add_node(TYPE_BOOLEAN);}
1258 break;
1259 case 34:
1260 #line 208 "ASN1.y"
1261 {yyval.node=_asn1_add_node(TYPE_TIME|CONST_UTC);}
1262 break;
1263 case 35:
1264 #line 209 "ASN1.y"
1265 {yyval.node=_asn1_add_node(TYPE_TIME|CONST_GENERALIZED);}
1266 break;
1267 case 36:
1268 #line 212 "ASN1.y"
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);}
1271 break;
1272 case 37:
1273 #line 215 "ASN1.y"
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);}
1277 break;
1278 case 38:
1279 #line 220 "ASN1.y"
1280 {yyval.node=yyvsp[0].node;}
1281 break;
1282 case 39:
1283 #line 221 "ASN1.y"
1284 {yyval.node=yyvsp[-1].node;}
1285 break;
1286 case 40:
1287 #line 224 "ASN1.y"
1288 {yyval.node=_asn1_add_node(TYPE_GENERALSTRING);}
1289 break;
1290 case 41:
1291 #line 225 "ASN1.y"
1292 {yyval.node=_asn1_add_node(TYPE_GENERALSTRING|CONST_SIZE);
1293 _asn1_set_down(yyval.node,yyvsp[0].node);}
1294 break;
1295 case 42:
1296 #line 229 "ASN1.y"
1297 {yyval.node=_asn1_add_node(TYPE_OCTET_STRING);}
1298 break;
1299 case 43:
1300 #line 230 "ASN1.y"
1301 {yyval.node=_asn1_add_node(TYPE_OCTET_STRING|CONST_SIZE);
1302 _asn1_set_down(yyval.node,yyvsp[0].node);}
1303 break;
1304 case 44:
1305 #line 234 "ASN1.y"
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);}
1309 break;
1310 case 45:
1311 #line 239 "ASN1.y"
1312 {yyval.node=yyvsp[0].node;}
1313 break;
1314 case 46:
1315 #line 240 "ASN1.y"
1316 {yyval.node=yyvsp[-2].node;
1317 _asn1_set_right(_asn1_get_last_right(yyvsp[-2].node),yyvsp[0].node);}
1318 break;
1319 case 47:
1320 #line 244 "ASN1.y"
1321 {yyval.node=_asn1_add_node(TYPE_BIT_STRING);}
1322 break;
1323 case 48:
1324 #line 246 "ASN1.y"
1325 {yyval.node=_asn1_add_node(TYPE_BIT_STRING|CONST_LIST);
1326 _asn1_set_down(yyval.node,yyvsp[-1].node);}
1327 break;
1328 case 49:
1329 #line 251 "ASN1.y"
1330 {yyval.node=_asn1_add_node(TYPE_ENUMERATED|CONST_LIST);
1331 _asn1_set_down(yyval.node,yyvsp[-1].node);}
1332 break;
1333 case 50:
1334 #line 256 "ASN1.y"
1335 {yyval.node=_asn1_add_node(TYPE_OBJECT_ID);}
1336 break;
1337 case 51:
1338 #line 259 "ASN1.y"
1339 {yyval.node=_asn1_add_node(TYPE_IDENTIFIER);
1340 _asn1_set_value(yyval.node,yyvsp[0].str,strlen(yyvsp[0].str)+1);}
1341 break;
1342 case 52:
1343 #line 261 "ASN1.y"
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);}
1347 break;
1348 case 53:
1349 #line 264 "ASN1.y"
1350 {yyval.node=yyvsp[0].node;}
1351 break;
1352 case 54:
1353 #line 265 "ASN1.y"
1354 {yyval.node=yyvsp[0].node;}
1355 break;
1356 case 55:
1357 #line 266 "ASN1.y"
1358 {yyval.node=yyvsp[0].node;}
1359 break;
1360 case 57:
1361 #line 268 "ASN1.y"
1362 {yyval.node=yyvsp[0].node;}
1363 break;
1364 case 58:
1365 #line 269 "ASN1.y"
1366 {yyval.node=yyvsp[0].node;}
1367 break;
1368 case 59:
1369 #line 270 "ASN1.y"
1370 {yyval.node=yyvsp[0].node;}
1371 break;
1372 case 60:
1373 #line 271 "ASN1.y"
1374 {yyval.node=yyvsp[0].node;}
1375 break;
1376 case 61:
1377 #line 272 "ASN1.y"
1378 {yyval.node=yyvsp[0].node;}
1379 break;
1380 case 62:
1381 #line 273 "ASN1.y"
1382 {yyval.node=yyvsp[0].node;}
1383 break;
1384 case 63:
1385 #line 274 "ASN1.y"
1386 {yyval.node=yyvsp[0].node;}
1387 break;
1388 case 64:
1389 #line 275 "ASN1.y"
1390 {yyval.node=yyvsp[0].node;}
1391 break;
1392 case 65:
1393 #line 276 "ASN1.y"
1394 {yyval.node=_asn1_add_node(TYPE_NULL);}
1395 break;
1396 case 66:
1397 #line 279 "ASN1.y"
1398 {yyval.node=yyvsp[0].node;}
1399 break;
1400 case 67:
1401 #line 280 "ASN1.y"
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);}
1405 break;
1406 case 68:
1407 #line 285 "ASN1.y"
1408 {yyval.node=yyvsp[0].node;}
1409 break;
1410 case 69:
1411 #line 286 "ASN1.y"
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);}
1415 break;
1416 case 70:
1417 #line 289 "ASN1.y"
1418 {yyval.node=_asn1_mod_type(yyvsp[-1].node,CONST_OPTION);}
1419 break;
1420 case 71:
1421 #line 292 "ASN1.y"
1422 {yyval.node=_asn1_set_name(yyvsp[0].node,yyvsp[-1].str);}
1423 break;
1424 case 72:
1425 #line 295 "ASN1.y"
1426 {yyval.node=yyvsp[0].node;}
1427 break;
1428 case 73:
1429 #line 296 "ASN1.y"
1430 {yyval.node=yyvsp[-2].node;
1431 _asn1_set_right(_asn1_get_last_right(yyvsp[-2].node),yyvsp[0].node);}
1432 break;
1433 case 74:
1434 #line 300 "ASN1.y"
1435 {yyval.node=_asn1_add_node(TYPE_SEQUENCE);
1436 _asn1_set_down(yyval.node,yyvsp[-1].node);}
1437 break;
1438 case 75:
1439 #line 302 "ASN1.y"
1440 {yyval.node=_asn1_add_node(TYPE_SEQUENCE_OF);
1441 _asn1_set_down(yyval.node,yyvsp[0].node);}
1442 break;
1443 case 76:
1444 #line 304 "ASN1.y"
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);}
1448 break;
1449 case 77:
1450 #line 309 "ASN1.y"
1451 {yyval.node=_asn1_add_node(TYPE_SET);
1452 _asn1_set_down(yyval.node,yyvsp[-1].node);}
1453 break;
1454 case 78:
1455 #line 311 "ASN1.y"
1456 {yyval.node=_asn1_add_node(TYPE_SET_OF);
1457 _asn1_set_down(yyval.node,yyvsp[0].node);}
1458 break;
1459 case 79:
1460 #line 313 "ASN1.y"
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);}
1464 break;
1465 case 80:
1466 #line 318 "ASN1.y"
1467 {yyval.node=_asn1_add_node(TYPE_CHOICE);
1468 _asn1_set_down(yyval.node,yyvsp[-1].node);}
1469 break;
1470 case 81:
1471 #line 322 "ASN1.y"
1472 {yyval.node=_asn1_add_node(TYPE_ANY);}
1473 break;
1474 case 82:
1475 #line 323 "ASN1.y"
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);}
1479 break;
1480 case 83:
1481 #line 328 "ASN1.y"
1482 {yyval.node=_asn1_set_name(yyvsp[0].node,yyvsp[-2].str);}
1483 break;
1484 case 84:
1485 #line 332 "ASN1.y"
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);}
1489 break;
1490 case 85:
1491 #line 336 "ASN1.y"
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);}
1496 break;
1497 case 86:
1498 #line 341 "ASN1.y"
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);}
1502 break;
1503 case 87:
1504 #line 346 "ASN1.y"
1505 {yyval.node=yyvsp[0].node;}
1506 break;
1507 case 88:
1508 #line 347 "ASN1.y"
1509 {yyval.node=yyvsp[0].node;}
1510 break;
1511 case 89:
1512 #line 350 "ASN1.y"
1513 {yyval.node=yyvsp[0].node;}
1514 break;
1515 case 90:
1516 #line 351 "ASN1.y"
1517 {yyval.node=yyvsp[-1].node;
1518 _asn1_set_right(_asn1_get_last_right(yyvsp[-1].node),yyvsp[0].node);}
1519 break;
1520 case 91:
1521 #line 355 "ASN1.y"
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);}
1525 break;
1526 case 92:
1527 #line 358 "ASN1.y"
1528 {yyval.node=_asn1_add_node(TYPE_OBJECT_ID);
1529 _asn1_set_name(yyval.node,yyvsp[-2].str);}
1530 break;
1531 case 93:
1532 #line 382 "ASN1.y"
1533 {yyval.constant=CONST_EXPLICIT;}
1534 break;
1535 case 94:
1536 #line 383 "ASN1.y"
1537 {yyval.constant=CONST_IMPLICIT;}
1538 break;
1541 #line 727 "/usr/local/share/bison/bison.simple"
1544 yyvsp -= yylen;
1545 yyssp -= yylen;
1546 #if YYLSP_NEEDED
1547 yylsp -= yylen;
1548 #endif
1550 #if YYDEBUG
1551 if (yydebug)
1553 short *yyssp1 = yyss - 1;
1554 YYFPRINTF (stderr, "state stack now");
1555 while (yyssp1 != yyssp)
1556 YYFPRINTF (stderr, " %d", *++yyssp1);
1557 YYFPRINTF (stderr, "\n");
1559 #endif
1561 *++yyvsp = yyval;
1562 #if YYLSP_NEEDED
1563 *++yylsp = yyloc;
1564 #endif
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. */
1570 yyn = yyr1[yyn];
1572 yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
1573 if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
1574 yystate = yytable[yystate];
1575 else
1576 yystate = yydefgoto[yyn - YYNTBASE];
1578 goto yynewstate;
1581 /*------------------------------------.
1582 | yyerrlab -- here on detecting error |
1583 `------------------------------------*/
1584 yyerrlab:
1585 /* If not already recovering from an error, report this error. */
1586 if (!yyerrstatus)
1588 ++yynerrs;
1590 #ifdef YYERROR_VERBOSE
1591 yyn = yypact[yystate];
1593 if (yyn > YYFLAG && yyn < YYLAST)
1595 YYSIZE_T yysize = 0;
1596 char *yymsg;
1597 int yyx, yycount;
1599 yycount = 0;
1600 /* Start YYX at -YYN if negative to avoid negative indexes in
1601 YYCHECK. */
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);
1609 if (yymsg != 0)
1611 char *yyp = yystpcpy (yymsg, "parse error, unexpected ");
1612 yyp = yystpcpy (yyp, yytname[YYTRANSLATE (yychar)]);
1614 if (yycount < 5)
1616 yycount = 0;
1617 for (yyx = yyn < 0 ? -yyn : 0;
1618 yyx < (int) (sizeof (yytname) / sizeof (char *));
1619 yyx++)
1620 if (yycheck[yyx + yyn] == yyx)
1622 const char *yyq = ! yycount ? ", expecting " : " or ";
1623 yyp = yystpcpy (yyp, yyq);
1624 yyp = yystpcpy (yyp, yytname[yyx]);
1625 yycount++;
1628 yyerror (yymsg);
1629 YYSTACK_FREE (yymsg);
1631 else
1632 yyerror ("parse error; also virtual memory exhausted");
1634 else
1635 #endif /* defined (YYERROR_VERBOSE) */
1636 yyerror ("parse error");
1638 goto yyerrlab1;
1641 /*--------------------------------------------------.
1642 | yyerrlab1 -- error raised explicitly by an action |
1643 `--------------------------------------------------*/
1644 yyerrlab1:
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)
1652 YYABORT;
1653 YYDPRINTF ((stderr, "Discarding token %d (%s).\n",
1654 yychar, yytname[yychar1]));
1655 yychar = YYEMPTY;
1658 /* Else will try to reuse lookahead token after shifting the error
1659 token. */
1661 yyerrstatus = 3; /* Each real token shifted decrements this */
1663 goto yyerrhandle;
1666 /*-------------------------------------------------------------------.
1667 | yyerrdefault -- current state does not do anything special for the |
1668 | error token. |
1669 `-------------------------------------------------------------------*/
1670 yyerrdefault:
1671 #if 0
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];
1677 if (yyn)
1678 goto yydefault;
1679 #endif
1682 /*---------------------------------------------------------------.
1683 | yyerrpop -- pop the current state because it cannot handle the |
1684 | error token |
1685 `---------------------------------------------------------------*/
1686 yyerrpop:
1687 if (yyssp == yyss)
1688 YYABORT;
1689 yyvsp--;
1690 yystate = *--yyssp;
1691 #if YYLSP_NEEDED
1692 yylsp--;
1693 #endif
1695 #if YYDEBUG
1696 if (yydebug)
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");
1704 #endif
1706 /*--------------.
1707 | yyerrhandle. |
1708 `--------------*/
1709 yyerrhandle:
1710 yyn = yypact[yystate];
1711 if (yyn == YYFLAG)
1712 goto yyerrdefault;
1714 yyn += YYTERROR;
1715 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
1716 goto yyerrdefault;
1718 yyn = yytable[yyn];
1719 if (yyn < 0)
1721 if (yyn == YYFLAG)
1722 goto yyerrpop;
1723 yyn = -yyn;
1724 goto yyreduce;
1726 else if (yyn == 0)
1727 goto yyerrpop;
1729 if (yyn == YYFINAL)
1730 YYACCEPT;
1732 YYDPRINTF ((stderr, "Shifting error token, "));
1734 *++yyvsp = yylval;
1735 #if YYLSP_NEEDED
1736 *++yylsp = yylloc;
1737 #endif
1739 yystate = yyn;
1740 goto yynewstate;
1743 /*-------------------------------------.
1744 | yyacceptlab -- YYACCEPT comes here. |
1745 `-------------------------------------*/
1746 yyacceptlab:
1747 yyresult = 0;
1748 goto yyreturn;
1750 /*-----------------------------------.
1751 | yyabortlab -- YYABORT comes here. |
1752 `-----------------------------------*/
1753 yyabortlab:
1754 yyresult = 1;
1755 goto yyreturn;
1757 /*---------------------------------------------.
1758 | yyoverflowab -- parser overflow comes here. |
1759 `---------------------------------------------*/
1760 yyoverflowlab:
1761 yyerror ("parser stack overflow");
1762 yyresult = 2;
1763 /* Fall through. */
1765 yyreturn:
1766 #ifndef yyoverflow
1767 if (yyss != yyssa)
1768 YYSTACK_FREE (yyss);
1769 #endif
1770 return yyresult;
1772 #line 387 "ASN1.y"
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. */
1795 /* Return: int */
1796 /* Token identifier or ASCII code or 0(zero: End Of File) */
1797 /*************************************************************/
1798 int
1799 _asn1_yylex()
1801 int c,counter=0,k;
1802 char string[MAX_NAME_SIZE+1]; /* will contain the next token */
1804 while(1)
1806 while((c=fgetc(file_asn1))==' ' || c=='\t' || c=='\n')
1807 if(c=='\n') lineNumber++;
1809 if(c==EOF){
1810 strcpy(lastToken,"End Of File");
1811 return 0;
1814 if(c=='(' || c==')' || c=='[' || c==']' ||
1815 c=='{' || c=='}' || c==',' || c=='.' ||
1816 c=='+'){
1817 lastToken[0]=c;lastToken[1]=0;
1818 return c;
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;
1824 return '-';
1826 else{ /* Comments */
1827 counter=0;
1828 /* A comment finishes at the end of line */
1829 while((c=fgetc(file_asn1))!=EOF && c!='\n');
1830 if(c==EOF){
1831 strcpy(lastToken,"End Of File");
1832 return 0;
1834 else{
1835 lineNumber++;
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;
1848 return 0;
1850 string[counter++]=c;
1852 ungetc(c,file_asn1);
1853 string[counter]=0;
1854 strcpy(lastToken,string);
1856 /* Is STRING a number? */
1857 for(k=0;k<counter;k++)
1858 if(!isdigit(string[k])) break;
1859 if(k>=counter)
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);
1871 return IDENTIFIER;
1876 /*************************************************************/
1877 /* Function: _asn1_create_errorDescription */
1878 /* Description: creates a string with the description of the*/
1879 /* error. */
1880 /* Parameters: */
1881 /* error : error to describe. */
1882 /* errorDescription: string that will contain the */
1883 /* description. */
1884 /*************************************************************/
1885 void
1886 _asn1_create_errorDescription(int error,char *errorDescription)
1888 switch(error){
1889 case ASN1_SUCCESS: case ASN1_FILE_NOT_FOUND:
1890 if (errorDescription!=NULL) errorDescription[0]=0;
1891 break;
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,"'");
1901 break;
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)");
1911 break;
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");
1920 break;
1921 default:
1922 if (errorDescription!=NULL) errorDescription[0]=0;
1923 break;
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.
1935 * Description:
1937 * Creates the structures needed to manage the definitions included in *FILE_NAME file.
1939 * Returns:
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.
1952 asn1_retCode
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;
1970 else{
1971 result_parse=ASN1_SUCCESS;
1973 lineNumber=1;
1974 yyparse();
1976 fclose(file_asn1);
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.
2017 * Description:
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".
2023 * Returns:
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;
2040 p_tree=NULL;
2042 fileName = inputFileName;
2044 /* open the file to parse */
2045 file_asn1=fopen(inputFileName,"r");
2047 if(file_asn1==NULL)
2048 result_parse=ASN1_FILE_NOT_FOUND;
2049 else{
2050 result_parse=ASN1_SUCCESS;
2052 lineNumber=1;
2053 yyparse();
2055 fclose(file_asn1);
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,'/'))){
2071 char_p++;
2072 slash_p=char_p;
2075 char_p=slash_p;
2076 dot_p=inputFileName+strlen(inputFileName);
2078 while((char_p=strchr(char_p,'.'))){
2079 dot_p=char_p;
2080 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");
2091 else{
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");
2105 else{
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);
2116 free(vector_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*/
2134 /* Parameters: */
2135 /* char *s : error description */
2136 /* Return: int */
2137 /* */
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);
2146 #endif
2148 if(result_parse!=ASN1_NAME_TOO_LONG)
2149 result_parse=ASN1_SYNTAX_ERROR;
2151 return 0;