1 /* A Bison parser, made by GNU Bison 2.1. */
2
3 /* Skeleton parser for Yacc-like parsing with Bison,
4 Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
9 any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 Boston, MA 02110-1301, USA. */
20
21 /* As a special exception, when this file is copied by Bison into a
22 Bison output file, you may use that output file without restriction.
23 This special exception was added by the Free Software Foundation
24 in version 1.24 of Bison. */
25
26 /* Written by Richard Stallman by simplifying the original so called
27 ``semantic'' parser. */
28
29 /* All symbols defined below should begin with yy or YY, to avoid
30 infringing on user name space. This should be done even for local
31 variables, as they might otherwise be expanded by user macros.
32 There are some unavoidable exceptions within include files to
33 define necessary library symbols; they are noted "INFRINGES ON
34 USER NAME SPACE" below. */
35
36 /* Identify Bison output. */
37 #define YYBISON 1
38
39 /* Bison version. */
40 #define YYBISON_VERSION "2.1"
41
42 /* Skeleton name. */
43 #define YYSKELETON_NAME "yacc.c"
44
45 /* Pure parsers. */
46 #define YYPURE 0
47
48 /* Using locations. */
49 #define YYLSP_NEEDED 0
50
51
52
53 /* Tokens. */
54 #ifndef YYTOKENTYPE
55 # define YYTOKENTYPE
56 /* Put the tokens into the symbol table, so that GDB and other debuggers
57 know about them. */
58 enum yytokentype {
59 kw_ABSENT = 258,
60 kw_ABSTRACT_SYNTAX = 259,
61 kw_ALL = 260,
62 kw_APPLICATION = 261,
63 kw_AUTOMATIC = 262,
64 kw_BEGIN = 263,
65 kw_BIT = 264,
66 kw_BMPString = 265,
67 kw_BOOLEAN = 266,
68 kw_BY = 267,
69 kw_CHARACTER = 268,
70 kw_CHOICE = 269,
71 kw_CLASS = 270,
72 kw_COMPONENT = 271,
73 kw_COMPONENTS = 272,
74 kw_CONSTRAINED = 273,
75 kw_CONTAINING = 274,
76 kw_DEFAULT = 275,
77 kw_DEFINITIONS = 276,
78 kw_EMBEDDED = 277,
79 kw_ENCODED = 278,
80 kw_END = 279,
81 kw_ENUMERATED = 280,
82 kw_EXCEPT = 281,
83 kw_EXPLICIT = 282,
84 kw_EXPORTS = 283,
85 kw_EXTENSIBILITY = 284,
86 kw_EXTERNAL = 285,
87 kw_FALSE = 286,
88 kw_FROM = 287,
89 kw_GeneralString = 288,
90 kw_GeneralizedTime = 289,
91 kw_GraphicString = 290,
92 kw_IA5String = 291,
93 kw_IDENTIFIER = 292,
94 kw_IMPLICIT = 293,
95 kw_IMPLIED = 294,
96 kw_IMPORTS = 295,
97 kw_INCLUDES = 296,
98 kw_INSTANCE = 297,
99 kw_INTEGER = 298,
100 kw_INTERSECTION = 299,
101 kw_ISO646String = 300,
102 kw_MAX = 301,
103 kw_MIN = 302,
104 kw_MINUS_INFINITY = 303,
105 kw_NULL = 304,
106 kw_NumericString = 305,
107 kw_OBJECT = 306,
108 kw_OCTET = 307,
109 kw_OF = 308,
110 kw_OPTIONAL = 309,
111 kw_ObjectDescriptor = 310,
112 kw_PATTERN = 311,
113 kw_PDV = 312,
114 kw_PLUS_INFINITY = 313,
115 kw_PRESENT = 314,
116 kw_PRIVATE = 315,
117 kw_PrintableString = 316,
118 kw_REAL = 317,
119 kw_RELATIVE_OID = 318,
120 kw_SEQUENCE = 319,
121 kw_SET = 320,
122 kw_SIZE = 321,
123 kw_STRING = 322,
124 kw_SYNTAX = 323,
125 kw_T61String = 324,
126 kw_TAGS = 325,
127 kw_TRUE = 326,
128 kw_TYPE_IDENTIFIER = 327,
129 kw_TeletexString = 328,
130 kw_UNION = 329,
131 kw_UNIQUE = 330,
132 kw_UNIVERSAL = 331,
133 kw_UTCTime = 332,
134 kw_UTF8String = 333,
135 kw_UniversalString = 334,
136 kw_VideotexString = 335,
137 kw_VisibleString = 336,
138 kw_WITH = 337,
139 RANGE = 338,
140 EEQUAL = 339,
141 ELLIPSIS = 340,
142 IDENTIFIER = 341,
143 referencename = 342,
144 STRING = 343,
145 NUMBER = 344
146 };
147 #endif
148 /* Tokens. */
149 #define kw_ABSENT 258
150 #define kw_ABSTRACT_SYNTAX 259
151 #define kw_ALL 260
152 #define kw_APPLICATION 261
153 #define kw_AUTOMATIC 262
154 #define kw_BEGIN 263
155 #define kw_BIT 264
156 #define kw_BMPString 265
157 #define kw_BOOLEAN 266
158 #define kw_BY 267
159 #define kw_CHARACTER 268
160 #define kw_CHOICE 269
161 #define kw_CLASS 270
162 #define kw_COMPONENT 271
163 #define kw_COMPONENTS 272
164 #define kw_CONSTRAINED 273
165 #define kw_CONTAINING 274
166 #define kw_DEFAULT 275
167 #define kw_DEFINITIONS 276
168 #define kw_EMBEDDED 277
169 #define kw_ENCODED 278
170 #define kw_END 279
171 #define kw_ENUMERATED 280
172 #define kw_EXCEPT 281
173 #define kw_EXPLICIT 282
174 #define kw_EXPORTS 283
175 #define kw_EXTENSIBILITY 284
176 #define kw_EXTERNAL 285
177 #define kw_FALSE 286
178 #define kw_FROM 287
179 #define kw_GeneralString 288
180 #define kw_GeneralizedTime 289
181 #define kw_GraphicString 290
182 #define kw_IA5String 291
183 #define kw_IDENTIFIER 292
184 #define kw_IMPLICIT 293
185 #define kw_IMPLIED 294
186 #define kw_IMPORTS 295
187 #define kw_INCLUDES 296
188 #define kw_INSTANCE 297
189 #define kw_INTEGER 298
190 #define kw_INTERSECTION 299
191 #define kw_ISO646String 300
192 #define kw_MAX 301
193 #define kw_MIN 302
194 #define kw_MINUS_INFINITY 303
195 #define kw_NULL 304
196 #define kw_NumericString 305
197 #define kw_OBJECT 306
198 #define kw_OCTET 307
199 #define kw_OF 308
200 #define kw_OPTIONAL 309
201 #define kw_ObjectDescriptor 310
202 #define kw_PATTERN 311
203 #define kw_PDV 312
204 #define kw_PLUS_INFINITY 313
205 #define kw_PRESENT 314
206 #define kw_PRIVATE 315
207 #define kw_PrintableString 316
208 #define kw_REAL 317
209 #define kw_RELATIVE_OID 318
210 #define kw_SEQUENCE 319
211 #define kw_SET 320
212 #define kw_SIZE 321
213 #define kw_STRING 322
214 #define kw_SYNTAX 323
215 #define kw_T61String 324
216 #define kw_TAGS 325
217 #define kw_TRUE 326
218 #define kw_TYPE_IDENTIFIER 327
219 #define kw_TeletexString 328
220 #define kw_UNION 329
221 #define kw_UNIQUE 330
222 #define kw_UNIVERSAL 331
223 #define kw_UTCTime 332
224 #define kw_UTF8String 333
225 #define kw_UniversalString 334
226 #define kw_VideotexString 335
227 #define kw_VisibleString 336
228 #define kw_WITH 337
229 #define RANGE 338
230 #define EEQUAL 339
231 #define ELLIPSIS 340
232 #define IDENTIFIER 341
233 #define referencename 342
234 #define STRING 343
235 #define NUMBER 344
236
237
238
239
240 /* Copy the first part of user declarations. */
241 #line 36 "parse.y"
242
243 #ifdef HAVE_CONFIG_H
244 #include <config.h>
245 #endif
246 #include <stdio.h>
247 #include <stdlib.h>
248 #include <string.h>
249 #include "symbol.h"
250 #include "lex.h"
251 #include "gen_locl.h"
252 #include "der.h"
253
254 RCSID("$Id: parse.y,v 1.28 2006/04/28 10:51:35 lha Exp $");
255
256 static Type *new_type (Typetype t);
257 static struct constraint_spec *new_constraint_spec(enum ctype);
258 static Type *new_tag(int tagclass, int tagvalue, int tagenv, Type *oldtype);
259 void yyerror (const char *);
260 static struct objid *new_objid(const char *label, int value);
261 static void add_oid_to_tail(struct objid *, struct objid *);
262 static void fix_labels(Symbol *s);
263
264 struct string_list {
265 char *string;
266 struct string_list *next;
267 };
268
269
270
271 /* Enabling traces. */
272 #ifndef YYDEBUG
273 # define YYDEBUG 1
274 #endif
275
276 /* Enabling verbose error messages. */
277 #ifdef YYERROR_VERBOSE
278 # undef YYERROR_VERBOSE
279 # define YYERROR_VERBOSE 1
280 #else
281 # define YYERROR_VERBOSE 0
282 #endif
283
284 /* Enabling the token table. */
285 #ifndef YYTOKEN_TABLE
286 # define YYTOKEN_TABLE 0
287 #endif
288
289 #if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)
290 #line 65 "parse.y"
291 typedef union YYSTYPE {
292 int constant;
293 struct value *value;
294 struct range range;
295 char *name;
296 Type *type;
297 Member *member;
298 struct objid *objid;
299 char *defval;
300 struct string_list *sl;
301 struct tagtype tag;
302 struct memhead *members;
303 struct constraint_spec *constraint_spec;
304 } YYSTYPE;
305 /* Line 196 of yacc.c. */
306 #line 307 "parse.c"
307 # define yystype YYSTYPE /* obsolescent; will be withdrawn */
308 # define YYSTYPE_IS_DECLARED 1
309 # define YYSTYPE_IS_TRIVIAL 1
310 #endif
311
312
313
314 /* Copy the second part of user declarations. */
315
316
317 /* Line 219 of yacc.c. */
318 #line 319 "parse.c"
319
320 #if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__)
321 # define YYSIZE_T __SIZE_TYPE__
322 #endif
323 #if ! defined (YYSIZE_T) && defined (size_t)
324 # define YYSIZE_T size_t
325 #endif
326 #if ! defined (YYSIZE_T) && (defined (__STDC__) || defined (__cplusplus))
327 # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
328 # define YYSIZE_T size_t
329 #endif
330 #if ! defined (YYSIZE_T)
331 # define YYSIZE_T unsigned int
332 #endif
333
334 #ifndef YY_
335 # if YYENABLE_NLS
336 # if ENABLE_NLS
337 # include <libintl.h> /* INFRINGES ON USER NAME SPACE */
338 # define YY_(msgid) dgettext ("bison-runtime", msgid)
339 # endif
340 # endif
341 # ifndef YY_
342 # define YY_(msgid) msgid
343 # endif
344 #endif
345
346 #if ! defined (yyoverflow) || YYERROR_VERBOSE
347
348 /* The parser invokes alloca or malloc; define the necessary symbols. */
349
350 # ifdef YYSTACK_USE_ALLOCA
351 # if YYSTACK_USE_ALLOCA
352 # ifdef __GNUC__
353 # define YYSTACK_ALLOC __builtin_alloca
354 # else
355 # define YYSTACK_ALLOC alloca
356 # if defined (__STDC__) || defined (__cplusplus)
357 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
358 # define YYINCLUDED_STDLIB_H
359 # endif
360 # endif
361 # endif
362 # endif
363
364 # ifdef YYSTACK_ALLOC
365 /* Pacify GCC's `empty if-body' warning. */
366 # define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
367 # ifndef YYSTACK_ALLOC_MAXIMUM
368 /* The OS might guarantee only one guard page at the bottom of the stack,
369 and a page size can be as small as 4096 bytes. So we cannot safely
370 invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
371 to allow for a few compiler-allocated temporary stack slots. */
372 # define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2005 */
373 # endif
374 # else
375 # define YYSTACK_ALLOC YYMALLOC
376 # define YYSTACK_FREE YYFREE
377 # ifndef YYSTACK_ALLOC_MAXIMUM
378 # define YYSTACK_ALLOC_MAXIMUM ((YYSIZE_T) -1)
379 # endif
380 # ifdef __cplusplus
381 extern "C" {
382 # endif
383 # ifndef YYMALLOC
384 # define YYMALLOC malloc
385 # if (! defined (malloc) && ! defined (YYINCLUDED_STDLIB_H) \
386 && (defined (__STDC__) || defined (__cplusplus)))
387 void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
388 # endif
389 # endif
390 # ifndef YYFREE
391 # define YYFREE free
392 # if (! defined (free) && ! defined (YYINCLUDED_STDLIB_H) \
393 && (defined (__STDC__) || defined (__cplusplus)))
394 void free (void *); /* INFRINGES ON USER NAME SPACE */
395 # endif
396 # endif
397 # ifdef __cplusplus
398 }
399 # endif
400 # endif
401 #endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */
402
403
404 #if (! defined (yyoverflow) \
405 && (! defined (__cplusplus) \
406 || (defined (YYSTYPE_IS_TRIVIAL) && YYSTYPE_IS_TRIVIAL)))
407
408 /* A type that is properly aligned for any stack member. */
409 union yyalloc
410 {
411 short int yyss;
412 YYSTYPE yyvs;
413 };
414
415 /* The size of the maximum gap between one aligned stack and the next. */
416 # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
417
418 /* The size of an array large to enough to hold all stacks, each with
419 N elements. */
420 # define YYSTACK_BYTES(N) \
421 ((N) * (sizeof (short int) + sizeof (YYSTYPE)) \
422 + YYSTACK_GAP_MAXIMUM)
423
424 /* Copy COUNT objects from FROM to TO. The source and destination do
425 not overlap. */
426 # ifndef YYCOPY
427 # if defined (__GNUC__) && 1 < __GNUC__
428 # define YYCOPY(To, From, Count) \
429 __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
430 # else
431 # define YYCOPY(To, From, Count) \
432 do \
433 { \
434 YYSIZE_T yyi; \
435 for (yyi = 0; yyi < (Count); yyi++) \
436 (To)[yyi] = (From)[yyi]; \
437 } \
438 while (0)
439 # endif
440 # endif
441
442 /* Relocate STACK from its old location to the new one. The
443 local variables YYSIZE and YYSTACKSIZE give the old and new number of
444 elements in the stack, and YYPTR gives the new location of the
445 stack. Advance YYPTR to a properly aligned location for the next
446 stack. */
447 # define YYSTACK_RELOCATE(Stack) \
448 do \
449 { \
450 YYSIZE_T yynewbytes; \
451 YYCOPY (&yyptr->Stack, Stack, yysize); \
452 Stack = &yyptr->Stack; \
453 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
454 yyptr += yynewbytes / sizeof (*yyptr); \
455 } \
456 while (0)
457
458 #endif
459
460 #if defined (__STDC__) || defined (__cplusplus)
461 typedef signed char yysigned_char;
462 #else
463 typedef short int yysigned_char;
464 #endif
465
466 /* YYFINAL -- State number of the termination state. */
467 #define YYFINAL 4
468 /* YYLAST -- Last index in YYTABLE. */
469 #define YYLAST 168
470
471 /* YYNTOKENS -- Number of terminals. */
472 #define YYNTOKENS 98
473 /* YYNNTS -- Number of nonterminals. */
474 #define YYNNTS 67
475 /* YYNRULES -- Number of rules. */
476 #define YYNRULES 130
477 /* YYNRULES -- Number of states. */
478 #define YYNSTATES 201
479
480 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
481 #define YYUNDEFTOK 2
482 #define YYMAXUTOK 344
483
484 #define YYTRANSLATE(YYX) \
485 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
486
487 /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
488 static const unsigned char yytranslate[] =
489 {
490 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
491 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
492 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
493 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
494 92, 93, 2, 2, 91, 2, 2, 2, 2, 2,
495 2, 2, 2, 2, 2, 2, 2, 2, 2, 90,
496 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
497 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
498 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
499 2, 96, 2, 97, 2, 2, 2, 2, 2, 2,
500 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
501 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
502 2, 2, 2, 94, 2, 95, 2, 2, 2, 2,
503 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
504 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
505 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
506 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
507 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
508 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
509 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
510 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
511 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
512 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
513 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
514 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
515 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
516 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
517 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
518 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
519 35, 36, 37, 38, 39, 40, 41, 42, 43, 44,
520 45, 46, 47, 48, 49, 50, 51, 52, 53, 54,
521 55, 56, 57, 58, 59, 60, 61, 62, 63, 64,
522 65, 66, 67, 68, 69, 70, 71, 72, 73, 74,
523 75, 76, 77, 78, 79, 80, 81, 82, 83, 84,
524 85, 86, 87, 88, 89
525 };
526
527 #if YYDEBUG
528 /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
529 YYRHS. */
530 static const unsigned short int yyprhs[] =
531 {
532 0, 0, 3, 12, 15, 18, 21, 22, 25, 26,
533 29, 30, 34, 35, 37, 38, 40, 43, 48, 50,
534 53, 55, 57, 61, 63, 67, 69, 71, 73, 75,
535 77, 79, 81, 83, 85, 87, 89, 91, 93, 95,
536 97, 99, 101, 103, 109, 111, 114, 119, 121, 125,
537 129, 134, 139, 141, 144, 150, 153, 156, 158, 163,
538 167, 171, 176, 180, 184, 189, 191, 193, 195, 197,
539 199, 202, 206, 208, 210, 212, 215, 219, 225, 230,
540 234, 239, 240, 242, 244, 246, 247, 249, 251, 256,
541 258, 260, 262, 264, 266, 268, 270, 272, 276, 280,
542 283, 285, 288, 292, 294, 298, 303, 305, 306, 310,
543 311, 314, 319, 321, 323, 325, 327, 329, 331, 333,
544 335, 337, 339, 341, 343, 345, 347, 349, 351, 353,
545 355
546 };
547
548 /* YYRHS -- A `-1'-separated list of the rules' RHS. */
549 static const short int yyrhs[] =
550 {
551 99, 0, -1, 86, 21, 100, 101, 84, 8, 102,
552 24, -1, 27, 70, -1, 38, 70, -1, 7, 70,
553 -1, -1, 29, 39, -1, -1, 103, 107, -1, -1,
554 40, 104, 90, -1, -1, 105, -1, -1, 106, -1,
555 105, 106, -1, 109, 32, 86, 150, -1, 108, -1,
556 108, 107, -1, 110, -1, 142, -1, 86, 91, 109,
557 -1, 86, -1, 86, 84, 111, -1, 112, -1, 129,
558 -1, 132, -1, 120, -1, 113, -1, 143, -1, 128,
559 -1, 118, -1, 115, -1, 123, -1, 121, -1, 122,
560 -1, 124, -1, 125, -1, 126, -1, 127, -1, 138,
561 -1, 11, -1, 92, 154, 83, 154, 93, -1, 43,
562 -1, 43, 114, -1, 43, 94, 116, 95, -1, 117,
563 -1, 116, 91, 117, -1, 116, 91, 85, -1, 86,
564 92, 162, 93, -1, 25, 94, 119, 95, -1, 116,
565 -1, 9, 67, -1, 9, 67, 94, 148, 95, -1,
566 51, 37, -1, 52, 67, -1, 49, -1, 64, 94,
567 145, 95, -1, 64, 94, 95, -1, 64, 53, 111,
568 -1, 65, 94, 145, 95, -1, 65, 94, 95, -1,
569 65, 53, 111, -1, 14, 94, 145, 95, -1, 130,
570 -1, 131, -1, 86, -1, 34, -1, 77, -1, 111,
571 133, -1, 92, 134, 93, -1, 135, -1, 136, -1,
572 137, -1, 19, 111, -1, 23, 12, 154, -1, 19,
573 111, 23, 12, 154, -1, 18, 12, 94, 95, -1,
574 139, 141, 111, -1, 96, 140, 89, 97, -1, -1,
575 76, -1, 6, -1, 60, -1, -1, 27, -1, 38,
576 -1, 86, 111, 84, 154, -1, 144, -1, 33, -1,
577 78, -1, 61, -1, 36, -1, 10, -1, 79, -1,
578 147, -1, 145, 91, 147, -1, 145, 91, 85, -1,
579 86, 111, -1, 146, -1, 146, 54, -1, 146, 20,
580 154, -1, 149, -1, 148, 91, 149, -1, 86, 92,
581 89, 93, -1, 151, -1, -1, 94, 152, 95, -1,
582 -1, 153, 152, -1, 86, 92, 89, 93, -1, 86,
583 -1, 89, -1, 155, -1, 156, -1, 160, -1, 159,
584 -1, 161, -1, 164, -1, 163, -1, 157, -1, 158,
585 -1, 86, -1, 88, -1, 71, -1, 31, -1, 162,
586 -1, 89, -1, 49, -1, 151, -1
587 };
588
589 /* YYRLINE[YYN] -- source line where rule number YYN was defined. */
590 static const unsigned short int yyrline[] =
591 {
592 0, 231, 231, 238, 239, 241, 243, 246, 248, 251,
593 252, 255, 256, 259, 260, 263, 264, 267, 278, 279,
594 282, 283, 286, 292, 300, 310, 311, 312, 315, 316,
595 317, 318, 319, 320, 321, 322, 323, 324, 325, 326,
596 327, 328, 331, 338, 348, 353, 360, 368, 374, 379,
597 383, 396, 404, 407, 414, 422, 428, 435, 442, 448,
598 456, 464, 470, 478, 486, 493, 494, 497, 508, 513,
599 520, 536, 542, 545, 546, 549, 555, 563, 573, 579,
600 592, 601, 604, 608, 612, 619, 622, 626, 633, 644,
601 647, 652, 657, 662, 667, 672, 680, 686, 691, 702,
602 713, 719, 725, 733, 739, 746, 759, 760, 763, 770,
603 773, 784, 788, 799, 805, 806, 809, 810, 811, 812,
604 813, 816, 819, 822, 833, 841, 847, 855, 863, 866,
605 871
606 };
607 #endif
608
609 #if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
610 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
611 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
612 static const char *const yytname[] =
613 {
614 "$end", "error", "$undefined", "kw_ABSENT", "kw_ABSTRACT_SYNTAX",
615 "kw_ALL", "kw_APPLICATION", "kw_AUTOMATIC", "kw_BEGIN", "kw_BIT",
616 "kw_BMPString", "kw_BOOLEAN", "kw_BY", "kw_CHARACTER", "kw_CHOICE",
617 "kw_CLASS", "kw_COMPONENT", "kw_COMPONENTS", "kw_CONSTRAINED",
618 "kw_CONTAINING", "kw_DEFAULT", "kw_DEFINITIONS", "kw_EMBEDDED",
619 "kw_ENCODED", "kw_END", "kw_ENUMERATED", "kw_EXCEPT", "kw_EXPLICIT",
620 "kw_EXPORTS", "kw_EXTENSIBILITY", "kw_EXTERNAL", "kw_FALSE", "kw_FROM",
621 "kw_GeneralString", "kw_GeneralizedTime", "kw_GraphicString",
622 "kw_IA5String", "kw_IDENTIFIER", "kw_IMPLICIT", "kw_IMPLIED",
623 "kw_IMPORTS", "kw_INCLUDES", "kw_INSTANCE", "kw_INTEGER",
624 "kw_INTERSECTION", "kw_ISO646String", "kw_MAX", "kw_MIN",
625 "kw_MINUS_INFINITY", "kw_NULL", "kw_NumericString", "kw_OBJECT",
626 "kw_OCTET", "kw_OF", "kw_OPTIONAL", "kw_ObjectDescriptor", "kw_PATTERN",
627 "kw_PDV", "kw_PLUS_INFINITY", "kw_PRESENT", "kw_PRIVATE",
628 "kw_PrintableString", "kw_REAL", "kw_RELATIVE_OID", "kw_SEQUENCE",
629 "kw_SET", "kw_SIZE", "kw_STRING", "kw_SYNTAX", "kw_T61String", "kw_TAGS",
630 "kw_TRUE", "kw_TYPE_IDENTIFIER", "kw_TeletexString", "kw_UNION",
631 "kw_UNIQUE", "kw_UNIVERSAL", "kw_UTCTime", "kw_UTF8String",
632 "kw_UniversalString", "kw_VideotexString", "kw_VisibleString", "kw_WITH",
633 "RANGE", "EEQUAL", "ELLIPSIS", "IDENTIFIER", "referencename", "STRING",
634 "NUMBER", "';'", "','", "'('", "')'", "'{'", "'}'", "'['", "']'",
635 "$accept", "ModuleDefinition", "TagDefault", "ExtensionDefault",
636 "ModuleBody", "Imports", "SymbolsImported", "SymbolsFromModuleList",
637 "SymbolsFromModule", "AssignmentList", "Assignment", "referencenames",
638 "TypeAssignment", "Type", "BuiltinType", "BooleanType", "range",
639 "IntegerType", "NamedNumberList", "NamedNumber", "EnumeratedType",
640 "Enumerations", "BitStringType", "ObjectIdentifierType",
641 "OctetStringType", "NullType", "SequenceType", "SequenceOfType",
642 "SetType", "SetOfType", "ChoiceType", "ReferencedType", "DefinedType",
643 "UsefulType", "ConstrainedType", "Constraint", "ConstraintSpec",
644 "GeneralConstraint", "ContentsConstraint", "UserDefinedConstraint",
645 "TaggedType", "Tag", "Class", "tagenv", "ValueAssignment",
646 "CharacterStringType", "RestrictedCharactedStringType",
647 "ComponentTypeList", "NamedType", "ComponentType", "NamedBitList",
648 "NamedBit", "objid_opt", "objid", "objid_list", "objid_element", "Value",
649 "BuiltinValue", "ReferencedValue", "DefinedValue", "Valuereference",
650 "CharacterStringValue", "BooleanValue", "IntegerValue", "SignedNumber",
651 "NullValue", "ObjectIdentifierValue", 0
652 };
653 #endif
654
655 # ifdef YYPRINT
656 /* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
657 token YYLEX-NUM. */
658 static const unsigned short int yytoknum[] =
659 {
660 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
661 265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
662 275, 276, 277, 278, 279, 280, 281, 282, 283, 284,
663 285, 286, 287, 288, 289, 290, 291, 292, 293, 294,
664 295, 296, 297, 298, 299, 300, 301, 302, 303, 304,
665 305, 306, 307, 308, 309, 310, 311, 312, 313, 314,
666 315, 316, 317, 318, 319, 320, 321, 322, 323, 324,
667 325, 326, 327, 328, 329, 330, 331, 332, 333, 334,
668 335, 336, 337, 338, 339, 340, 341, 342, 343, 344,
669 59, 44, 40, 41, 123, 125, 91, 93
670 };
671 # endif
672
673 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
674 static const unsigned char yyr1[] =
675 {
676 0, 98, 99, 100, 100, 100, 100, 101, 101, 102,
677 102, 103, 103, 104, 104, 105, 105, 106, 107, 107,
678 108, 108, 109, 109, 110, 111, 111, 111, 112, 112,
679 112, 112, 112, 112, 112, 112, 112, 112, 112, 112,
680 112, 112, 113, 114, 115, 115, 115, 116, 116, 116,
681 117, 118, 119, 120, 120, 121, 122, 123, 124, 124,
682 125, 126, 126, 127, 128, 129, 129, 130, 131, 131,
683 132, 133, 134, 135, 135, 136, 136, 136, 137, 138,
684 139, 140, 140, 140, 140, 141, 141, 141, 142, 143,
685 144, 144, 144, 144, 144, 144, 145, 145, 145, 146,
686 147, 147, 147, 148, 148, 149, 150, 150, 151, 152,
687 152, 153, 153, 153, 154, 154, 155, 155, 155, 155,
688 155, 156, 157, 158, 159, 160, 160, 161, 162, 163,
689 164
690 };
691
692 /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
693 static const unsigned char yyr2[] =
694 {
695 0, 2, 8, 2, 2, 2, 0, 2, 0, 2,
696 0, 3, 0, 1, 0, 1, 2, 4, 1, 2,
697 1, 1, 3, 1, 3, 1, 1, 1, 1, 1,
698 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
699 1, 1, 1, 5, 1, 2, 4, 1, 3, 3,
700 4, 4, 1, 2, 5, 2, 2, 1, 4, 3,
701 3, 4, 3, 3, 4, 1, 1, 1, 1, 1,
702 2, 3, 1, 1, 1, 2, 3, 5, 4, 3,
703 4, 0, 1, 1, 1, 0, 1, 1, 4, 1,
704 1, 1, 1, 1, 1, 1, 1, 3, 3, 2,
705 1, 2, 3, 1, 3, 4, 1, 0, 3, 0,
706 2, 4, 1, 1, 1, 1, 1, 1, 1, 1,
707 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
708 1
709 };
710
711 /* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
712 STATE-NUM when YYTABLE doesn't specify something else to do. Zero
713 means the default is an error. */
714 static const unsigned char yydefact[] =
715 {
716 0, 0, 0, 6, 1, 0, 0, 0, 8, 5,
717 3, 4, 0, 0, 7, 0, 10, 14, 0, 0,
718 23, 0, 13, 15, 0, 2, 0, 9, 18, 20,
719 21, 0, 11, 16, 0, 0, 94, 42, 0, 0,
720 90, 68, 93, 44, 57, 0, 0, 92, 0, 0,
721 69, 91, 95, 0, 67, 81, 0, 25, 29, 33,
722 32, 28, 35, 36, 34, 37, 38, 39, 40, 31,
723 26, 65, 66, 27, 41, 85, 30, 89, 19, 22,
724 107, 53, 0, 0, 0, 0, 45, 55, 56, 0,
725 0, 0, 0, 24, 83, 84, 82, 0, 0, 0,
726 70, 86, 87, 0, 109, 17, 106, 0, 0, 0,
727 100, 96, 0, 52, 47, 0, 126, 129, 125, 123,
728 124, 128, 130, 0, 114, 115, 121, 122, 117, 116,
729 118, 127, 120, 119, 0, 60, 59, 0, 63, 62,
730 0, 0, 88, 0, 0, 0, 0, 72, 73, 74,
731 79, 112, 113, 0, 109, 0, 0, 103, 99, 0,
732 64, 0, 101, 0, 0, 51, 0, 46, 58, 61,
733 80, 0, 75, 0, 71, 0, 108, 110, 0, 0,
734 54, 98, 97, 102, 0, 49, 48, 0, 0, 0,
735 76, 0, 0, 104, 50, 43, 78, 0, 111, 105,
736 77
737 };
738
739 /* YYDEFGOTO[NTERM-NUM]. */
740 static const short int yydefgoto[] =
741 {
742 -1, 2, 8, 13, 18, 19, 21, 22, 23, 27,
743 28, 24, 29, 56, 57, 58, 86, 59, 113, 114,
744 60, 115, 61, 62, 63, 64, 65, 66, 67, 68,
745 69, 70, 71, 72, 73, 100, 146, 147, 148, 149,
746 74, 75, 97, 103, 30, 76, 77, 109, 110, 111,
747 156, 157, 105, 122, 153, 154, 123, 124, 125, 126,
748 127, 128, 129, 130, 131, 132, 133
749 };
750
751 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
752 STATE-NUM. */
753 #define YYPACT_NINF -99
754 static const short int yypact[] =
755 {
756 -46, 20, 13, 21, -99, 11, 23, 25, 54, -99,
757 -99, -99, 58, 6, -99, 90, -34, 15, 80, 19,
758 16, 18, 15, -99, 74, -99, -7, -99, 19, -99,
759 -99, 15, -99, -99, 24, 42, -99, -99, 17, 26,
760 -99, -99, -99, -73, -99, 76, 50, -99, -45, -44,
761 -99, -99, -99, 51, -99, 4, -67, -99, -99, -99,
762 -99, -99, -99, -99, -99, -99, -99, -99, -99, -99,
763 -99, -99, -99, -99, -99, -16, -99, -99, -99, -99,
764 27, 28, 33, 37, 47, 37, -99, -99, -99, 51,
765 -72, 51, -71, 22, -99, -99, -99, 35, 47, 12,
766 -99, -99, -99, 51, 2, -99, -99, 39, 51, -75,
767 -8, -99, 34, 36, -99, 43, -99, -99, -99, -99,
768 -99, -99, -99, 48, -99, -99, -99, -99, -99, -99,
769 -99, -99, -99, -99, -57, 22, -99, -48, 22, -99,
770 -22, 45, -99, 120, 51, 122, 46, -99, -99, -99,
771 22, 52, -99, 53, 2, 57, -9, -99, 22, -53,
772 -99, 47, -99, 56, -19, -99, 47, -99, -99, -99,
773 -99, 49, -18, 47, -99, 61, -99, -99, 62, 39,
774 -99, -99, -99, -99, 59, -99, -99, 60, 63, 128,
775 -99, 64, 66, -99, -99, -99, -99, 47, -99, -99,
776 -99
777 };
778
779 /* YYPGOTO[NTERM-NUM]. */
780 static const yysigned_char yypgoto[] =
781 {
782 -99, -99, -99, -99, -99, -99, -99, -99, 124, 126,
783 -99, 125, -99, -52, -99, -99, -99, -99, 70, -4,
784 -99, -99, -99, -99, -99, -99, -99, -99, -99, -99,
785 -99, -99, -99, -99, -99, -99, -99, -99, -99, -99,
786 -99, -99, -99, -99, -99, -99, -99, -37, -99, 3,
787 -99, -15, -99, 81, 9, -99, -98, -99, -99, -99,
788 -99, -99, -99, -99, 5, -99, -99
789 };
790
791 /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
792 positive, shift that token. If negative, reduce the rule which
793 number is the opposite. If zero, do what YYDEFACT says.
794 If YYTABLE_NINF, syntax error. */
795 #define YYTABLE_NINF -13
796 static const short int yytable[] =
797 {
798 142, 93, 35, 36, 37, 189, 17, 38, 89, 91,
799 94, 101, 161, 4, 108, 108, 159, 98, 39, 84,
800 160, 85, 102, 136, 139, 99, 40, 41, 5, 42,
801 143, 144, 181, 108, 164, 145, 43, 135, 167, 138,
802 1, 3, 44, 159, 45, 46, 162, 168, 6, 90,
803 92, 150, -12, 137, 47, 140, 158, 48, 49, 7,
804 35, 36, 37, 183, 95, 38, 185, 112, 187, 159,
805 50, 51, 52, 169, 99, 190, 39, 53, 116, 54,
806 96, 9, 179, 12, 40, 41, 180, 42, 151, 55,
807 15, 152, 172, 10, 43, 11, 117, 14, 16, 200,
808 44, 20, 45, 46, 25, 26, 34, 31, 32, 81,
809 80, 82, 47, 87, 99, 48, 49, 88, 118, 108,
810 83, 104, 107, 112, 141, 155, 163, 164, 50, 51,
811 52, 166, 171, 119, 173, 120, 121, 54, 165, 174,
812 197, 104, 170, 188, 175, 121, 33, 55, 176, 178,
813 191, 192, 194, 195, 78, 134, 79, 198, 196, 199,
814 186, 106, 182, 177, 193, 0, 0, 0, 184
815 };
816
817 static const short int yycheck[] =
818 {
819 98, 53, 9, 10, 11, 23, 40, 14, 53, 53,
820 6, 27, 20, 0, 86, 86, 91, 84, 25, 92,
821 95, 94, 38, 95, 95, 92, 33, 34, 7, 36,
822 18, 19, 85, 86, 91, 23, 43, 89, 95, 91,
823 86, 21, 49, 91, 51, 52, 54, 95, 27, 94,
824 94, 103, 86, 90, 61, 92, 108, 64, 65, 38,
825 9, 10, 11, 161, 60, 14, 85, 86, 166, 91,
826 77, 78, 79, 95, 92, 173, 25, 84, 31, 86,
827 76, 70, 91, 29, 33, 34, 95, 36, 86, 96,
828 84, 89, 144, 70, 43, 70, 49, 39, 8, 197,
829 49, 86, 51, 52, 24, 86, 32, 91, 90, 67,
830 86, 94, 61, 37, 92, 64, 65, 67, 71, 86,
831 94, 94, 94, 86, 89, 86, 92, 91, 77, 78,
832 79, 83, 12, 86, 12, 88, 89, 86, 95, 93,
833 12, 94, 97, 94, 92, 89, 22, 96, 95, 92,
834 89, 89, 93, 93, 28, 85, 31, 93, 95, 93,
835 164, 80, 159, 154, 179, -1, -1, -1, 163
836 };
837
838 /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
839 symbol of state STATE-NUM. */
840 static const unsigned char yystos[] =
841 {
842 0, 86, 99, 21, 0, 7, 27, 38, 100, 70,
843 70, 70, 29, 101, 39, 84, 8, 40, 102, 103,
844 86, 104, 105, 106, 109, 24, 86, 107, 108, 110,
845 142, 91, 90, 106, 32, 9, 10, 11, 14, 25,
846 33, 34, 36, 43, 49, 51, 52, 61, 64, 65,
847 77, 78, 79, 84, 86, 96, 111, 112, 113, 115,
848 118, 120, 121, 122, 123, 124, 125, 126, 127, 128,
849 129, 130, 131, 132, 138, 139, 143, 144, 107, 109,
850 86, 67, 94, 94, 92, 94, 114, 37, 67, 53,
851 94, 53, 94, 111, 6, 60, 76, 140, 84, 92,
852 133, 27, 38, 141, 94, 150, 151, 94, 86, 145,
853 146, 147, 86, 116, 117, 119, 31, 49, 71, 86,
854 88, 89, 151, 154, 155, 156, 157, 158, 159, 160,
855 161, 162, 163, 164, 116, 111, 95, 145, 111, 95,
856 145, 89, 154, 18, 19, 23, 134, 135, 136, 137,
857 111, 86, 89, 152, 153, 86, 148, 149, 111, 91,
858 95, 20, 54, 92, 91, 95, 83, 95, 95, 95,
859 97, 12, 111, 12, 93, 92, 95, 152, 92, 91,
860 95, 85, 147, 154, 162, 85, 117, 154, 94, 23,
861 154, 89, 89, 149, 93, 93, 95, 12, 93, 93,
862 154
863 };
864
865 #define yyerrok (yyerrstatus = 0)
866 #define yyclearin (yychar = YYEMPTY)
867 #define YYEMPTY (-2)
868 #define YYEOF 0
869
870 #define YYACCEPT goto yyacceptlab
871 #define YYABORT goto yyabortlab
872 #define YYERROR goto yyerrorlab
873
874
875 /* Like YYERROR except do call yyerror. This remains here temporarily
876 to ease the transition to the new meaning of YYERROR, for GCC.
877 Once GCC version 2 has supplanted version 1, this can go. */
878
879 #define YYFAIL goto yyerrlab
880
881 #define YYRECOVERING() (!!yyerrstatus)
882
883 #define YYBACKUP(Token, Value) \
884 do \
885 if (yychar == YYEMPTY && yylen == 1) \
886 { \
887 yychar = (Token); \
888 yylval = (Value); \
889 yytoken = YYTRANSLATE (yychar); \
890 YYPOPSTACK; \
891 goto yybackup; \
892 } \
893 else \
894 { \
895 yyerror (YY_("syntax error: cannot back up")); \
896 YYERROR; \
897 } \
898 while (0)
899
900
901 #define YYTERROR 1
902 #define YYERRCODE 256
903
904
905 /* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
906 If N is 0, then set CURRENT to the empty location which ends
907 the previous symbol: RHS[0] (always defined). */
908
909 #define YYRHSLOC(Rhs, K) ((Rhs)[K])
910 #ifndef YYLLOC_DEFAULT
911 # define YYLLOC_DEFAULT(Current, Rhs, N) \
912 do \
913 if (N) \
914 { \
915 (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
916 (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
917 (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
918 (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
919 } \
920 else \
921 { \
922 (Current).first_line = (Current).last_line = \
923 YYRHSLOC (Rhs, 0).last_line; \
924 (Current).first_column = (Current).last_column = \
925 YYRHSLOC (Rhs, 0).last_column; \
926 } \
927 while (0)
928 #endif
929
930
931 /* YY_LOCATION_PRINT -- Print the location on the stream.
932 This macro was not mandated originally: define only if we know
933 we won't break user code: when these are the locations we know. */
934
935 #ifndef YY_LOCATION_PRINT
936 # if YYLTYPE_IS_TRIVIAL
937 # define YY_LOCATION_PRINT(File, Loc) \
938 fprintf (File, "%d.%d-%d.%d", \
939 (Loc).first_line, (Loc).first_column, \
940 (Loc).last_line, (Loc).last_column)
941 # else
942 # define YY_LOCATION_PRINT(File, Loc) ((void) 0)
943 # endif
944 #endif
945
946
947 /* YYLEX -- calling `yylex' with the right arguments. */
948
949 #ifdef YYLEX_PARAM
950 # define YYLEX yylex (YYLEX_PARAM)
951 #else
952 # define YYLEX yylex ()
953 #endif
954
955 /* Enable debugging if requested. */
956 #if YYDEBUG
957
958 # ifndef YYFPRINTF
959 # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
960 # define YYFPRINTF fprintf
961 # endif
962
963 # define YYDPRINTF(Args) \
964 do { \
965 if (yydebug) \
966 YYFPRINTF Args; \
967 } while (0)
968
969 # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
970 do { \
971 if (yydebug) \
972 { \
973 YYFPRINTF (stderr, "%s ", Title); \
974 yysymprint (stderr, \
975 Type, Value); \
976 YYFPRINTF (stderr, "\n"); \
977 } \
978 } while (0)
979
980 /*------------------------------------------------------------------.
981 | yy_stack_print -- Print the state stack from its BOTTOM up to its |
982 | TOP (included). |
983 `------------------------------------------------------------------*/
984
985 #if defined (__STDC__) || defined (__cplusplus)
986 static void
yy_stack_print(short int * bottom,short int * top)987 yy_stack_print (short int *bottom, short int *top)
988 #else
989 static void
990 yy_stack_print (bottom, top)
991 short int *bottom;
992 short int *top;
993 #endif
994 {
995 YYFPRINTF (stderr, "Stack now");
996 for (/* Nothing. */; bottom <= top; ++bottom)
997 YYFPRINTF (stderr, " %d", *bottom);
998 YYFPRINTF (stderr, "\n");
999 }
1000
1001 # define YY_STACK_PRINT(Bottom, Top) \
1002 do { \
1003 if (yydebug) \
1004 yy_stack_print ((Bottom), (Top)); \
1005 } while (0)
1006
1007
1008 /*------------------------------------------------.
1009 | Report that the YYRULE is going to be reduced. |
1010 `------------------------------------------------*/
1011
1012 #if defined (__STDC__) || defined (__cplusplus)
1013 static void
yy_reduce_print(int yyrule)1014 yy_reduce_print (int yyrule)
1015 #else
1016 static void
1017 yy_reduce_print (yyrule)
1018 int yyrule;
1019 #endif
1020 {
1021 int yyi;
1022 unsigned long int yylno = yyrline[yyrule];
1023 YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu), ",
1024 yyrule - 1, yylno);
1025 /* Print the symbols being reduced, and their result. */
1026 for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++)
1027 YYFPRINTF (stderr, "%s ", yytname[yyrhs[yyi]]);
1028 YYFPRINTF (stderr, "-> %s\n", yytname[yyr1[yyrule]]);
1029 }
1030
1031 # define YY_REDUCE_PRINT(Rule) \
1032 do { \
1033 if (yydebug) \
1034 yy_reduce_print (Rule); \
1035 } while (0)
1036
1037 /* Nonzero means print parse trace. It is left uninitialized so that
1038 multiple parsers can coexist. */
1039 int yydebug;
1040 #else /* !YYDEBUG */
1041 # define YYDPRINTF(Args)
1042 # define YY_SYMBOL_PRINT(Title, Type, Value, Location)
1043 # define YY_STACK_PRINT(Bottom, Top)
1044 # define YY_REDUCE_PRINT(Rule)
1045 #endif /* !YYDEBUG */
1046
1047
1048 /* YYINITDEPTH -- initial size of the parser's stacks. */
1049 #ifndef YYINITDEPTH
1050 # define YYINITDEPTH 200
1051 #endif
1052
1053 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
1054 if the built-in stack extension method is used).
1055
1056 Do not make this value too large; the results are undefined if
1057 YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
1058 evaluated with infinite-precision integer arithmetic. */
1059
1060 #ifndef YYMAXDEPTH
1061 # define YYMAXDEPTH 10000
1062 #endif
1063
1064
1065
1066 #if YYERROR_VERBOSE
1067
1068 # ifndef yystrlen
1069 # if defined (__GLIBC__) && defined (_STRING_H)
1070 # define yystrlen strlen
1071 # else
1072 /* Return the length of YYSTR. */
1073 static YYSIZE_T
1074 # if defined (__STDC__) || defined (__cplusplus)
yystrlen(const char * yystr)1075 yystrlen (const char *yystr)
1076 # else
1077 yystrlen (yystr)
1078 const char *yystr;
1079 # endif
1080 {
1081 const char *yys = yystr;
1082
1083 while (*yys++ != '\0')
1084 continue;
1085
1086 return yys - yystr - 1;
1087 }
1088 # endif
1089 # endif
1090
1091 # ifndef yystpcpy
1092 # if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE)
1093 # define yystpcpy stpcpy
1094 # else
1095 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
1096 YYDEST. */
1097 static char *
1098 # if defined (__STDC__) || defined (__cplusplus)
yystpcpy(char * yydest,const char * yysrc)1099 yystpcpy (char *yydest, const char *yysrc)
1100 # else
1101 yystpcpy (yydest, yysrc)
1102 char *yydest;
1103 const char *yysrc;
1104 # endif
1105 {
1106 char *yyd = yydest;
1107 const char *yys = yysrc;
1108
1109 while ((*yyd++ = *yys++) != '\0')
1110 continue;
1111
1112 return yyd - 1;
1113 }
1114 # endif
1115 # endif
1116
1117 # ifndef yytnamerr
1118 /* Copy to YYRES the contents of YYSTR after stripping away unnecessary
1119 quotes and backslashes, so that it's suitable for yyerror. The
1120 heuristic is that double-quoting is unnecessary unless the string
1121 contains an apostrophe, a comma, or backslash (other than
1122 backslash-backslash). YYSTR is taken from yytname. If YYRES is
1123 null, do not copy; instead, return the length of what the result
1124 would have been. */
1125 static YYSIZE_T
yytnamerr(char * yyres,const char * yystr)1126 yytnamerr (char *yyres, const char *yystr)
1127 {
1128 if (*yystr == '"')
1129 {
1130 size_t yyn = 0;
1131 char const *yyp = yystr;
1132
1133 for (;;)
1134 switch (*++yyp)
1135 {
1136 case '\'':
1137 case ',':
1138 goto do_not_strip_quotes;
1139
1140 case '\\':
1141 if (*++yyp != '\\')
1142 goto do_not_strip_quotes;
1143 /* Fall through. */
1144 default:
1145 if (yyres)
1146 yyres[yyn] = *yyp;
1147 yyn++;
1148 break;
1149
1150 case '"':
1151 if (yyres)
1152 yyres[yyn] = '\0';
1153 return yyn;
1154 }
1155 do_not_strip_quotes: ;
1156 }
1157
1158 if (! yyres)
1159 return yystrlen (yystr);
1160
1161 return yystpcpy (yyres, yystr) - yyres;
1162 }
1163 # endif
1164
1165 #endif /* YYERROR_VERBOSE */
1166
1167
1168
1169 #if YYDEBUG
1170 /*--------------------------------.
1171 | Print this symbol on YYOUTPUT. |
1172 `--------------------------------*/
1173
1174 #if defined (__STDC__) || defined (__cplusplus)
1175 static void
yysymprint(FILE * yyoutput,int yytype,YYSTYPE * yyvaluep)1176 yysymprint (FILE *yyoutput, int yytype, YYSTYPE *yyvaluep)
1177 #else
1178 static void
1179 yysymprint (yyoutput, yytype, yyvaluep)
1180 FILE *yyoutput;
1181 int yytype;
1182 YYSTYPE *yyvaluep;
1183 #endif
1184 {
1185 /* Pacify ``unused variable'' warnings. */
1186 (void) yyvaluep;
1187
1188 if (yytype < YYNTOKENS)
1189 YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
1190 else
1191 YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
1192
1193
1194 # ifdef YYPRINT
1195 if (yytype < YYNTOKENS)
1196 YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
1197 # endif
1198 switch (yytype)
1199 {
1200 default:
1201 break;
1202 }
1203 YYFPRINTF (yyoutput, ")");
1204 }
1205
1206 #endif /* ! YYDEBUG */
1207 /*-----------------------------------------------.
1208 | Release the memory associated to this symbol. |
1209 `-----------------------------------------------*/
1210
1211 #if defined (__STDC__) || defined (__cplusplus)
1212 static void
yydestruct(const char * yymsg,int yytype,YYSTYPE * yyvaluep)1213 yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
1214 #else
1215 static void
1216 yydestruct (yymsg, yytype, yyvaluep)
1217 const char *yymsg;
1218 int yytype;
1219 YYSTYPE *yyvaluep;
1220 #endif
1221 {
1222 /* Pacify ``unused variable'' warnings. */
1223 (void) yyvaluep;
1224
1225 if (!yymsg)
1226 yymsg = "Deleting";
1227 YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
1228
1229 switch (yytype)
1230 {
1231
1232 default:
1233 break;
1234 }
1235 }
1236
1237
1238 /* Prevent warnings from -Wmissing-prototypes. */
1239
1240 #ifdef YYPARSE_PARAM
1241 # if defined (__STDC__) || defined (__cplusplus)
1242 int yyparse (void *YYPARSE_PARAM);
1243 # else
1244 int yyparse ();
1245 # endif
1246 #else /* ! YYPARSE_PARAM */
1247 #if defined (__STDC__) || defined (__cplusplus)
1248 int yyparse (void);
1249 #else
1250 int yyparse ();
1251 #endif
1252 #endif /* ! YYPARSE_PARAM */
1253
1254
1255
1256 /* The look-ahead symbol. */
1257 int yychar;
1258
1259 /* The semantic value of the look-ahead symbol. */
1260 YYSTYPE yylval;
1261
1262 /* Number of syntax errors so far. */
1263 int yynerrs;
1264
1265
1266
1267 /*----------.
1268 | yyparse. |
1269 `----------*/
1270
1271 #ifdef YYPARSE_PARAM
1272 # if defined (__STDC__) || defined (__cplusplus)
yyparse(void * YYPARSE_PARAM)1273 int yyparse (void *YYPARSE_PARAM)
1274 # else
1275 int yyparse (YYPARSE_PARAM)
1276 void *YYPARSE_PARAM;
1277 # endif
1278 #else /* ! YYPARSE_PARAM */
1279 #if defined (__STDC__) || defined (__cplusplus)
1280 int
1281 yyparse (void)
1282 #else
1283 int
1284 yyparse ()
1285
1286 #endif
1287 #endif
1288 {
1289
1290 int yystate;
1291 int yyn;
1292 int yyresult;
1293 /* Number of tokens to shift before error messages enabled. */
1294 int yyerrstatus;
1295 /* Look-ahead token as an internal (translated) token number. */
1296 int yytoken = 0;
1297
1298 /* Three stacks and their tools:
1299 `yyss': related to states,
1300 `yyvs': related to semantic values,
1301 `yyls': related to locations.
1302
1303 Refer to the stacks thru separate pointers, to allow yyoverflow
1304 to reallocate them elsewhere. */
1305
1306 /* The state stack. */
1307 short int yyssa[YYINITDEPTH];
1308 short int *yyss = yyssa;
1309 short int *yyssp;
1310
1311 /* The semantic value stack. */
1312 YYSTYPE yyvsa[YYINITDEPTH];
1313 YYSTYPE *yyvs = yyvsa;
1314 YYSTYPE *yyvsp;
1315
1316
1317
1318 #define YYPOPSTACK (yyvsp--, yyssp--)
1319
1320 YYSIZE_T yystacksize = YYINITDEPTH;
1321
1322 /* The variables used to return semantic value and location from the
1323 action routines. */
1324 YYSTYPE yyval;
1325
1326
1327 /* When reducing, the number of symbols on the RHS of the reduced
1328 rule. */
1329 int yylen;
1330
1331 YYDPRINTF ((stderr, "Starting parse\n"));
1332
1333 yystate = 0;
1334 yyerrstatus = 0;
1335 yynerrs = 0;
1336 yychar = YYEMPTY; /* Cause a token to be read. */
1337
1338 /* Initialize stack pointers.
1339 Waste one element of value and location stack
1340 so that they stay on the same level as the state stack.
1341 The wasted elements are never initialized. */
1342
1343 yyssp = yyss;
1344 yyvsp = yyvs;
1345
1346 goto yysetstate;
1347
1348 /*------------------------------------------------------------.
1349 | yynewstate -- Push a new state, which is found in yystate. |
1350 `------------------------------------------------------------*/
1351 yynewstate:
1352 /* In all cases, when you get here, the value and location stacks
1353 have just been pushed. so pushing a state here evens the stacks.
1354 */
1355 yyssp++;
1356
1357 yysetstate:
1358 *yyssp = yystate;
1359
1360 if (yyss + yystacksize - 1 <= yyssp)
1361 {
1362 /* Get the current used size of the three stacks, in elements. */
1363 YYSIZE_T yysize = yyssp - yyss + 1;
1364
1365 #ifdef yyoverflow
1366 {
1367 /* Give user a chance to reallocate the stack. Use copies of
1368 these so that the &'s don't force the real ones into
1369 memory. */
1370 YYSTYPE *yyvs1 = yyvs;
1371 short int *yyss1 = yyss;
1372
1373
1374 /* Each stack pointer address is followed by the size of the
1375 data in use in that stack, in bytes. This used to be a
1376 conditional around just the two extra args, but that might
1377 be undefined if yyoverflow is a macro. */
1378 yyoverflow (YY_("memory exhausted"),
1379 &yyss1, yysize * sizeof (*yyssp),
1380 &yyvs1, yysize * sizeof (*yyvsp),
1381
1382 &yystacksize);
1383
1384 yyss = yyss1;
1385 yyvs = yyvs1;
1386 }
1387 #else /* no yyoverflow */
1388 # ifndef YYSTACK_RELOCATE
1389 goto yyexhaustedlab;
1390 # else
1391 /* Extend the stack our own way. */
1392 if (YYMAXDEPTH <= yystacksize)
1393 goto yyexhaustedlab;
1394 yystacksize *= 2;
1395 if (YYMAXDEPTH < yystacksize)
1396 yystacksize = YYMAXDEPTH;
1397
1398 {
1399 short int *yyss1 = yyss;
1400 union yyalloc *yyptr =
1401 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
1402 if (! yyptr)
1403 goto yyexhaustedlab;
1404 YYSTACK_RELOCATE (yyss);
1405 YYSTACK_RELOCATE (yyvs);
1406
1407 # undef YYSTACK_RELOCATE
1408 if (yyss1 != yyssa)
1409 YYSTACK_FREE (yyss1);
1410 }
1411 # endif
1412 #endif /* no yyoverflow */
1413
1414 yyssp = yyss + yysize - 1;
1415 yyvsp = yyvs + yysize - 1;
1416
1417
1418 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
1419 (unsigned long int) yystacksize));
1420
1421 if (yyss + yystacksize - 1 <= yyssp)
1422 YYABORT;
1423 }
1424
1425 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
1426
1427 goto yybackup;
1428
1429 /*-----------.
1430 | yybackup. |
1431 `-----------*/
1432 yybackup:
1433
1434 /* Do appropriate processing given the current state. */
1435 /* Read a look-ahead token if we need one and don't already have one. */
1436 /* yyresume: */
1437
1438 /* First try to decide what to do without reference to look-ahead token. */
1439
1440 yyn = yypact[yystate];
1441 if (yyn == YYPACT_NINF)
1442 goto yydefault;
1443
1444 /* Not known => get a look-ahead token if don't already have one. */
1445
1446 /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */
1447 if (yychar == YYEMPTY)
1448 {
1449 YYDPRINTF ((stderr, "Reading a token: "));
1450 yychar = YYLEX;
1451 }
1452
1453 if (yychar <= YYEOF)
1454 {
1455 yychar = yytoken = YYEOF;
1456 YYDPRINTF ((stderr, "Now at end of input.\n"));
1457 }
1458 else
1459 {
1460 yytoken = YYTRANSLATE (yychar);
1461 YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
1462 }
1463
1464 /* If the proper action on seeing token YYTOKEN is to reduce or to
1465 detect an error, take that action. */
1466 yyn += yytoken;
1467 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
1468 goto yydefault;
1469 yyn = yytable[yyn];
1470 if (yyn <= 0)
1471 {
1472 if (yyn == 0 || yyn == YYTABLE_NINF)
1473 goto yyerrlab;
1474 yyn = -yyn;
1475 goto yyreduce;
1476 }
1477
1478 if (yyn == YYFINAL)
1479 YYACCEPT;
1480
1481 /* Shift the look-ahead token. */
1482 YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
1483
1484 /* Discard the token being shifted unless it is eof. */
1485 if (yychar != YYEOF)
1486 yychar = YYEMPTY;
1487
1488 *++yyvsp = yylval;
1489
1490
1491 /* Count tokens shifted since error; after three, turn off error
1492 status. */
1493 if (yyerrstatus)
1494 yyerrstatus--;
1495
1496 yystate = yyn;
1497 goto yynewstate;
1498
1499
1500 /*-----------------------------------------------------------.
1501 | yydefault -- do the default action for the current state. |
1502 `-----------------------------------------------------------*/
1503 yydefault:
1504 yyn = yydefact[yystate];
1505 if (yyn == 0)
1506 goto yyerrlab;
1507 goto yyreduce;
1508
1509
1510 /*-----------------------------.
1511 | yyreduce -- Do a reduction. |
1512 `-----------------------------*/
1513 yyreduce:
1514 /* yyn is the number of a rule to reduce with. */
1515 yylen = yyr2[yyn];
1516
1517 /* If YYLEN is nonzero, implement the default value of the action:
1518 `$$ = $1'.
1519
1520 Otherwise, the following line sets YYVAL to garbage.
1521 This behavior is undocumented and Bison
1522 users should not rely upon it. Assigning to YYVAL
1523 unconditionally makes the parser a bit smaller, and it avoids a
1524 GCC warning that YYVAL may be used uninitialized. */
1525 yyval = yyvsp[1-yylen];
1526
1527
1528 YY_REDUCE_PRINT (yyn);
1529 switch (yyn)
1530 {
1531 case 2:
1532 #line 233 "parse.y"
1533 {
1534 checkundefined();
1535 }
1536 break;
1537
1538 case 4:
1539 #line 240 "parse.y"
1540 { error_message("implicit tagging is not supported"); }
1541 break;
1542
1543 case 5:
1544 #line 242 "parse.y"
1545 { error_message("automatic tagging is not supported"); }
1546 break;
1547
1548 case 7:
1549 #line 247 "parse.y"
1550 { error_message("no extensibility options supported"); }
1551 break;
1552
1553 case 17:
1554 #line 268 "parse.y"
1555 {
1556 struct string_list *sl;
1557 for(sl = (yyvsp[-3].sl); sl != NULL; sl = sl->next) {
1558 Symbol *s = addsym(sl->string);
1559 s->stype = Stype;
1560 }
1561 add_import((yyvsp[-1].name));
1562 }
1563 break;
1564
1565 case 22:
1566 #line 287 "parse.y"
1567 {
1568 (yyval.sl) = emalloc(sizeof(*(yyval.sl)));
1569 (yyval.sl)->string = (yyvsp[-2].name);
1570 (yyval.sl)->next = (yyvsp[0].sl);
1571 }
1572 break;
1573
1574 case 23:
1575 #line 293 "parse.y"
1576 {
1577 (yyval.sl) = emalloc(sizeof(*(yyval.sl)));
1578 (yyval.sl)->string = (yyvsp[0].name);
1579 (yyval.sl)->next = NULL;
1580 }
1581 break;
1582
1583 case 24:
1584 #line 301 "parse.y"
1585 {
1586 Symbol *s = addsym ((yyvsp[-2].name));
1587 s->stype = Stype;
1588 s->type = (yyvsp[0].type);
1589 fix_labels(s);
1590 generate_type (s);
1591 }
1592 break;
1593
1594 case 42:
1595 #line 332 "parse.y"
1596 {
1597 (yyval.type) = new_tag(ASN1_C_UNIV, UT_Boolean,
1598 TE_EXPLICIT, new_type(TBoolean));
1599 }
1600 break;
1601
1602 case 43:
1603 #line 339 "parse.y"
1604 {
1605 if((yyvsp[-3].value)->type != integervalue ||
1606 (yyvsp[-1].value)->type != integervalue)
1607 error_message("Non-integer value used in range");
1608 (yyval.range).min = (yyvsp[-3].value)->u.integervalue;
1609 (yyval.range).max = (yyvsp[-1].value)->u.integervalue;
1610 }
1611 break;
1612
1613 case 44:
1614 #line 349 "parse.y"
1615 {
1616 (yyval.type) = new_tag(ASN1_C_UNIV, UT_Integer,
1617 TE_EXPLICIT, new_type(TInteger));
1618 }
1619 break;
1620
1621 case 45:
1622 #line 354 "parse.y"
1623 {
1624 (yyval.type) = new_type(TInteger);
1625 (yyval.type)->range = emalloc(sizeof(*(yyval.type)->range));
1626 *((yyval.type)->range) = (yyvsp[0].range);
1627 (yyval.type) = new_tag(ASN1_C_UNIV, UT_Integer, TE_EXPLICIT, (yyval.type));
1628 }
1629 break;
1630
1631 case 46:
1632 #line 361 "parse.y"
1633 {
1634 (yyval.type) = new_type(TInteger);
1635 (yyval.type)->members = (yyvsp[-1].members);
1636 (yyval.type) = new_tag(ASN1_C_UNIV, UT_Integer, TE_EXPLICIT, (yyval.type));
1637 }
1638 break;
1639
1640 case 47:
1641 #line 369 "parse.y"
1642 {
1643 (yyval.members) = emalloc(sizeof(*(yyval.members)));
1644 ASN1_TAILQ_INIT((yyval.members));
1645 ASN1_TAILQ_INSERT_HEAD((yyval.members), (yyvsp[0].member), members);
1646 }
1647 break;
1648
1649 case 48:
1650 #line 375 "parse.y"
1651 {
1652 ASN1_TAILQ_INSERT_TAIL((yyvsp[-2].members), (yyvsp[0].member), members);
1653 (yyval.members) = (yyvsp[-2].members);
1654 }
1655 break;
1656
1657 case 49:
1658 #line 380 "parse.y"
1659 { (yyval.members) = (yyvsp[-2].members); }
1660 break;
1661
1662 case 50:
1663 #line 384 "parse.y"
1664 {
1665 (yyval.member) = emalloc(sizeof(*(yyval.member)));
1666 (yyval.member)->name = (yyvsp[-3].name);
1667 (yyval.member)->gen_name = estrdup((yyvsp[-3].name));
1668 output_name ((yyval.member)->gen_name);
1669 (yyval.member)->val = (yyvsp[-1].constant);
1670 (yyval.member)->optional = 0;
1671 (yyval.member)->ellipsis = 0;
1672 (yyval.member)->type = NULL;
1673 }
1674 break;
1675
1676 case 51:
1677 #line 397 "parse.y"
1678 {
1679 (yyval.type) = new_type(TInteger);
1680 (yyval.type)->members = (yyvsp[-1].members);
1681 (yyval.type) = new_tag(ASN1_C_UNIV, UT_Enumerated, TE_EXPLICIT, (yyval.type));
1682 }
1683 break;
1684
1685 case 53:
1686 #line 408 "parse.y"
1687 {
1688 (yyval.type) = new_type(TBitString);
1689 (yyval.type)->members = emalloc(sizeof(*(yyval.type)->members));
1690 ASN1_TAILQ_INIT((yyval.type)->members);
1691 (yyval.type) = new_tag(ASN1_C_UNIV, UT_BitString, TE_EXPLICIT, (yyval.type));
1692 }
1693 break;
1694
1695 case 54:
1696 #line 415 "parse.y"
1697 {
1698 (yyval.type) = new_type(TBitString);
1699 (yyval.type)->members = (yyvsp[-1].members);
1700 (yyval.type) = new_tag(ASN1_C_UNIV, UT_BitString, TE_EXPLICIT, (yyval.type));
1701 }
1702 break;
1703
1704 case 55:
1705 #line 423 "parse.y"
1706 {
1707 (yyval.type) = new_tag(ASN1_C_UNIV, UT_OID,
1708 TE_EXPLICIT, new_type(TOID));
1709 }
1710 break;
1711
1712 case 56:
1713 #line 429 "parse.y"
1714 {
1715 (yyval.type) = new_tag(ASN1_C_UNIV, UT_OctetString,
1716 TE_EXPLICIT, new_type(TOctetString));
1717 }
1718 break;
1719
1720 case 57:
1721 #line 436 "parse.y"
1722 {
1723 (yyval.type) = new_tag(ASN1_C_UNIV, UT_Null,
1724 TE_EXPLICIT, new_type(TNull));
1725 }
1726 break;
1727
1728 case 58:
1729 #line 443 "parse.y"
1730 {
1731 (yyval.type) = new_type(TSequence);
1732 (yyval.type)->members = (yyvsp[-1].members);
1733 (yyval.type) = new_tag(ASN1_C_UNIV, UT_Sequence, TE_EXPLICIT, (yyval.type));
1734 }
1735 break;
1736
1737 case 59:
1738 #line 449 "parse.y"
1739 {
1740 (yyval.type) = new_type(TSequence);
1741 (yyval.type)->members = NULL;
1742 (yyval.type) = new_tag(ASN1_C_UNIV, UT_Sequence, TE_EXPLICIT, (yyval.type));
1743 }
1744 break;
1745
1746 case 60:
1747 #line 457 "parse.y"
1748 {
1749 (yyval.type) = new_type(TSequenceOf);
1750 (yyval.type)->subtype = (yyvsp[0].type);
1751 (yyval.type) = new_tag(ASN1_C_UNIV, UT_Sequence, TE_EXPLICIT, (yyval.type));
1752 }
1753 break;
1754
1755 case 61:
1756 #line 465 "parse.y"
1757 {
1758 (yyval.type) = new_type(TSet);
1759 (yyval.type)->members = (yyvsp[-1].members);
1760 (yyval.type) = new_tag(ASN1_C_UNIV, UT_Set, TE_EXPLICIT, (yyval.type));
1761 }
1762 break;
1763
1764 case 62:
1765 #line 471 "parse.y"
1766 {
1767 (yyval.type) = new_type(TSet);
1768 (yyval.type)->members = NULL;
1769 (yyval.type) = new_tag(ASN1_C_UNIV, UT_Set, TE_EXPLICIT, (yyval.type));
1770 }
1771 break;
1772
1773 case 63:
1774 #line 479 "parse.y"
1775 {
1776 (yyval.type) = new_type(TSetOf);
1777 (yyval.type)->subtype = (yyvsp[0].type);
1778 (yyval.type) = new_tag(ASN1_C_UNIV, UT_Set, TE_EXPLICIT, (yyval.type));
1779 }
1780 break;
1781
1782 case 64:
1783 #line 487 "parse.y"
1784 {
1785 (yyval.type) = new_type(TChoice);
1786 (yyval.type)->members = (yyvsp[-1].members);
1787 }
1788 break;
1789
1790 case 67:
1791 #line 498 "parse.y"
1792 {
1793 Symbol *s = addsym((yyvsp[0].name));
1794 (yyval.type) = new_type(TType);
1795 if(s->stype != Stype && s->stype != SUndefined)
1796 error_message ("%s is not a type\n", (yyvsp[0].name));
1797 else
1798 (yyval.type)->symbol = s;
1799 }
1800 break;
1801
1802 case 68:
1803 #line 509 "parse.y"
1804 {
1805 (yyval.type) = new_tag(ASN1_C_UNIV, UT_GeneralizedTime,
1806 TE_EXPLICIT, new_type(TGeneralizedTime));
1807 }
1808 break;
1809
1810 case 69:
1811 #line 514 "parse.y"
1812 {
1813 (yyval.type) = new_tag(ASN1_C_UNIV, UT_UTCTime,
1814 TE_EXPLICIT, new_type(TUTCTime));
1815 }
1816 break;
1817
1818 case 70:
1819 #line 521 "parse.y"
1820 {
1821 /* if (Constraint.type == contentConstrant) {
1822 assert(Constraint.u.constraint.type == octetstring|bitstring-w/o-NamedBitList); // remember to check type reference too
1823 if (Constraint.u.constraint.type) {
1824 assert((Constraint.u.constraint.type.length % 8) == 0);
1825 }
1826 }
1827 if (Constraint.u.constraint.encoding) {
1828 type == der-oid|ber-oid
1829 }
1830 */
1831 }
1832 break;
1833
1834 case 71:
1835 #line 537 "parse.y"
1836 {
1837 (yyval.constraint_spec) = (yyvsp[-1].constraint_spec);
1838 }
1839 break;
1840
1841 case 75:
1842 #line 550 "parse.y"
1843 {
1844 (yyval.constraint_spec) = new_constraint_spec(CT_CONTENTS);
1845 (yyval.constraint_spec)->u.content.type = (yyvsp[0].type);
1846 (yyval.constraint_spec)->u.content.encoding = NULL;
1847 }
1848 break;
1849
1850 case 76:
1851 #line 556 "parse.y"
1852 {
1853 if ((yyvsp[0].value)->type != objectidentifiervalue)
1854 error_message("Non-OID used in ENCODED BY constraint");
1855 (yyval.constraint_spec) = new_constraint_spec(CT_CONTENTS);
1856 (yyval.constraint_spec)->u.content.type = NULL;
1857 (yyval.constraint_spec)->u.content.encoding = (yyvsp[0].value);
1858 }
1859 break;
1860
1861 case 77:
1862 #line 564 "parse.y"
1863 {
1864 if ((yyvsp[0].value)->type != objectidentifiervalue)
1865 error_message("Non-OID used in ENCODED BY constraint");
1866 (yyval.constraint_spec) = new_constraint_spec(CT_CONTENTS);
1867 (yyval.constraint_spec)->u.content.type = (yyvsp[-3].type);
1868 (yyval.constraint_spec)->u.content.encoding = (yyvsp[0].value);
1869 }
1870 break;
1871
1872 case 78:
1873 #line 574 "parse.y"
1874 {
1875 (yyval.constraint_spec) = new_constraint_spec(CT_USER);
1876 }
1877 break;
1878
1879 case 79:
1880 #line 580 "parse.y"
1881 {
1882 (yyval.type) = new_type(TTag);
1883 (yyval.type)->tag = (yyvsp[-2].tag);
1884 (yyval.type)->tag.tagenv = (yyvsp[-1].constant);
1885 if((yyvsp[0].type)->type == TTag && (yyvsp[-1].constant) == TE_IMPLICIT) {
1886 (yyval.type)->subtype = (yyvsp[0].type)->subtype;
1887 free((yyvsp[0].type));
1888 } else
1889 (yyval.type)->subtype = (yyvsp[0].type);
1890 }
1891 break;
1892
1893 case 80:
1894 #line 593 "parse.y"
1895 {
1896 (yyval.tag).tagclass = (yyvsp[-2].constant);
1897 (yyval.tag).tagvalue = (yyvsp[-1].constant);
1898 (yyval.tag).tagenv = TE_EXPLICIT;
1899 }
1900 break;
1901
1902 case 81:
1903 #line 601 "parse.y"
1904 {
1905 (yyval.constant) = ASN1_C_CONTEXT;
1906 }
1907 break;
1908
1909 case 82:
1910 #line 605 "parse.y"
1911 {
1912 (yyval.constant) = ASN1_C_UNIV;
1913 }
1914 break;
1915
1916 case 83:
1917 #line 609 "parse.y"
1918 {
1919 (yyval.constant) = ASN1_C_APPL;
1920 }
1921 break;
1922
1923 case 84:
1924 #line 613 "parse.y"
1925 {
1926 (yyval.constant) = ASN1_C_PRIVATE;
1927 }
1928 break;
1929
1930 case 85:
1931 #line 619 "parse.y"
1932 {
1933 (yyval.constant) = TE_EXPLICIT;
1934 }
1935 break;
1936
1937 case 86:
1938 #line 623 "parse.y"
1939 {
1940 (yyval.constant) = TE_EXPLICIT;
1941 }
1942 break;
1943
1944 case 87:
1945 #line 627 "parse.y"
1946 {
1947 (yyval.constant) = TE_IMPLICIT;
1948 }
1949 break;
1950
1951 case 88:
1952 #line 634 "parse.y"
1953 {
1954 Symbol *s;
1955 s = addsym ((yyvsp[-3].name));
1956
1957 s->stype = SValue;
1958 s->value = (yyvsp[0].value);
1959 generate_constant (s);
1960 }
1961 break;
1962
1963 case 90:
1964 #line 648 "parse.y"
1965 {
1966 (yyval.type) = new_tag(ASN1_C_UNIV, UT_GeneralString,
1967 TE_EXPLICIT, new_type(TGeneralString));
1968 }
1969 break;
1970
1971 case 91:
1972 #line 653 "parse.y"
1973 {
1974 (yyval.type) = new_tag(ASN1_C_UNIV, UT_UTF8String,
1975 TE_EXPLICIT, new_type(TUTF8String));
1976 }
1977 break;
1978
1979 case 92:
1980 #line 658 "parse.y"
1981 {
1982 (yyval.type) = new_tag(ASN1_C_UNIV, UT_PrintableString,
1983 TE_EXPLICIT, new_type(TPrintableString));
1984 }
1985 break;
1986
1987 case 93:
1988 #line 663 "parse.y"
1989 {
1990 (yyval.type) = new_tag(ASN1_C_UNIV, UT_IA5String,
1991 TE_EXPLICIT, new_type(TIA5String));
1992 }
1993 break;
1994
1995 case 94:
1996 #line 668 "parse.y"
1997 {
1998 (yyval.type) = new_tag(ASN1_C_UNIV, UT_BMPString,
1999 TE_EXPLICIT, new_type(TBMPString));
2000 }
2001 break;
2002
2003 case 95:
2004 #line 673 "parse.y"
2005 {
2006 (yyval.type) = new_tag(ASN1_C_UNIV, UT_UniversalString,
2007 TE_EXPLICIT, new_type(TUniversalString));
2008 }
2009 break;
2010
2011 case 96:
2012 #line 681 "parse.y"
2013 {
2014 (yyval.members) = emalloc(sizeof(*(yyval.members)));
2015 ASN1_TAILQ_INIT((yyval.members));
2016 ASN1_TAILQ_INSERT_HEAD((yyval.members), (yyvsp[0].member), members);
2017 }
2018 break;
2019
2020 case 97:
2021 #line 687 "parse.y"
2022 {
2023 ASN1_TAILQ_INSERT_TAIL((yyvsp[-2].members), (yyvsp[0].member), members);
2024 (yyval.members) = (yyvsp[-2].members);
2025 }
2026 break;
2027
2028 case 98:
2029 #line 692 "parse.y"
2030 {
2031 struct member *m = ecalloc(1, sizeof(*m));
2032 m->name = estrdup("...");
2033 m->gen_name = estrdup("asn1_ellipsis");
2034 m->ellipsis = 1;
2035 ASN1_TAILQ_INSERT_TAIL((yyvsp[-2].members), m, members);
2036 (yyval.members) = (yyvsp[-2].members);
2037 }
2038 break;
2039
2040 case 99:
2041 #line 703 "parse.y"
2042 {
2043 (yyval.member) = emalloc(sizeof(*(yyval.member)));
2044 (yyval.member)->name = (yyvsp[-1].name);
2045 (yyval.member)->gen_name = estrdup((yyvsp[-1].name));
2046 output_name ((yyval.member)->gen_name);
2047 (yyval.member)->type = (yyvsp[0].type);
2048 (yyval.member)->ellipsis = 0;
2049 }
2050 break;
2051
2052 case 100:
2053 #line 714 "parse.y"
2054 {
2055 (yyval.member) = (yyvsp[0].member);
2056 (yyval.member)->optional = 0;
2057 (yyval.member)->defval = NULL;
2058 }
2059 break;
2060
2061 case 101:
2062 #line 720 "parse.y"
2063 {
2064 (yyval.member) = (yyvsp[-1].member);
2065 (yyval.member)->optional = 1;
2066 (yyval.member)->defval = NULL;
2067 }
2068 break;
2069
2070 case 102:
2071 #line 726 "parse.y"
2072 {
2073 (yyval.member) = (yyvsp[-2].member);
2074 (yyval.member)->optional = 0;
2075 (yyval.member)->defval = (yyvsp[0].value);
2076 }
2077 break;
2078
2079 case 103:
2080 #line 734 "parse.y"
2081 {
2082 (yyval.members) = emalloc(sizeof(*(yyval.members)));
2083 ASN1_TAILQ_INIT((yyval.members));
2084 ASN1_TAILQ_INSERT_HEAD((yyval.members), (yyvsp[0].member), members);
2085 }
2086 break;
2087
2088 case 104:
2089 #line 740 "parse.y"
2090 {
2091 ASN1_TAILQ_INSERT_TAIL((yyvsp[-2].members), (yyvsp[0].member), members);
2092 (yyval.members) = (yyvsp[-2].members);
2093 }
2094 break;
2095
2096 case 105:
2097 #line 747 "parse.y"
2098 {
2099 (yyval.member) = emalloc(sizeof(*(yyval.member)));
2100 (yyval.member)->name = (yyvsp[-3].name);
2101 (yyval.member)->gen_name = estrdup((yyvsp[-3].name));
2102 output_name ((yyval.member)->gen_name);
2103 (yyval.member)->val = (yyvsp[-1].constant);
2104 (yyval.member)->optional = 0;
2105 (yyval.member)->ellipsis = 0;
2106 (yyval.member)->type = NULL;
2107 }
2108 break;
2109
2110 case 107:
2111 #line 760 "parse.y"
2112 { (yyval.objid) = NULL; }
2113 break;
2114
2115 case 108:
2116 #line 764 "parse.y"
2117 {
2118 (yyval.objid) = (yyvsp[-1].objid);
2119 }
2120 break;
2121
2122 case 109:
2123 #line 770 "parse.y"
2124 {
2125 (yyval.objid) = NULL;
2126 }
2127 break;
2128
2129 case 110:
2130 #line 774 "parse.y"
2131 {
2132 if ((yyvsp[0].objid)) {
2133 (yyval.objid) = (yyvsp[0].objid);
2134 add_oid_to_tail((yyvsp[0].objid), (yyvsp[-1].objid));
2135 } else {
2136 (yyval.objid) = (yyvsp[-1].objid);
2137 }
2138 }
2139 break;
2140
2141 case 111:
2142 #line 785 "parse.y"
2143 {
2144 (yyval.objid) = new_objid((yyvsp[-3].name), (yyvsp[-1].constant));
2145 }
2146 break;
2147
2148 case 112:
2149 #line 789 "parse.y"
2150 {
2151 Symbol *s = addsym((yyvsp[0].name));
2152 if(s->stype != SValue ||
2153 s->value->type != objectidentifiervalue) {
2154 error_message("%s is not an object identifier\n",
2155 s->name);
2156 exit(1);
2157 }
2158 (yyval.objid) = s->value->u.objectidentifiervalue;
2159 }
2160 break;
2161
2162 case 113:
2163 #line 800 "parse.y"
2164 {
2165 (yyval.objid) = new_objid(NULL, (yyvsp[0].constant));
2166 }
2167 break;
2168
2169 case 123:
2170 #line 823 "parse.y"
2171 {
2172 Symbol *s = addsym((yyvsp[0].name));
2173 if(s->stype != SValue)
2174 error_message ("%s is not a value\n",
2175 s->name);
2176 else
2177 (yyval.value) = s->value;
2178 }
2179 break;
2180
2181 case 124:
2182 #line 834 "parse.y"
2183 {
2184 (yyval.value) = emalloc(sizeof(*(yyval.value)));
2185 (yyval.value)->type = stringvalue;
2186 (yyval.value)->u.stringvalue = (yyvsp[0].name);
2187 }
2188 break;
2189
2190 case 125:
2191 #line 842 "parse.y"
2192 {
2193 (yyval.value) = emalloc(sizeof(*(yyval.value)));
2194 (yyval.value)->type = booleanvalue;
2195 (yyval.value)->u.booleanvalue = 0;
2196 }
2197 break;
2198
2199 case 126:
2200 #line 848 "parse.y"
2201 {
2202 (yyval.value) = emalloc(sizeof(*(yyval.value)));
2203 (yyval.value)->type = booleanvalue;
2204 (yyval.value)->u.booleanvalue = 0;
2205 }
2206 break;
2207
2208 case 127:
2209 #line 856 "parse.y"
2210 {
2211 (yyval.value) = emalloc(sizeof(*(yyval.value)));
2212 (yyval.value)->type = integervalue;
2213 (yyval.value)->u.integervalue = (yyvsp[0].constant);
2214 }
2215 break;
2216
2217 case 129:
2218 #line 867 "parse.y"
2219 {
2220 }
2221 break;
2222
2223 case 130:
2224 #line 872 "parse.y"
2225 {
2226 (yyval.value) = emalloc(sizeof(*(yyval.value)));
2227 (yyval.value)->type = objectidentifiervalue;
2228 (yyval.value)->u.objectidentifiervalue = (yyvsp[0].objid);
2229 }
2230 break;
2231
2232
2233 default: break;
2234 }
2235
2236 /* Line 1126 of yacc.c. */
2237 #line 2238 "parse.c"
2238
2239 yyvsp -= yylen;
2240 yyssp -= yylen;
2241
2242
2243 YY_STACK_PRINT (yyss, yyssp);
2244
2245 *++yyvsp = yyval;
2246
2247
2248 /* Now `shift' the result of the reduction. Determine what state
2249 that goes to, based on the state we popped back to and the rule
2250 number reduced by. */
2251
2252 yyn = yyr1[yyn];
2253
2254 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
2255 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
2256 yystate = yytable[yystate];
2257 else
2258 yystate = yydefgoto[yyn - YYNTOKENS];
2259
2260 goto yynewstate;
2261
2262
2263 /*------------------------------------.
2264 | yyerrlab -- here on detecting error |
2265 `------------------------------------*/
2266 yyerrlab:
2267 /* If not already recovering from an error, report this error. */
2268 if (!yyerrstatus)
2269 {
2270 ++yynerrs;
2271 #if YYERROR_VERBOSE
2272 yyn = yypact[yystate];
2273
2274 if (YYPACT_NINF < yyn && yyn < YYLAST)
2275 {
2276 int yytype = YYTRANSLATE (yychar);
2277 YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]);
2278 YYSIZE_T yysize = yysize0;
2279 YYSIZE_T yysize1;
2280 int yysize_overflow = 0;
2281 char *yymsg = 0;
2282 # define YYERROR_VERBOSE_ARGS_MAXIMUM 5
2283 char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
2284 int yyx;
2285
2286 #if 0
2287 /* This is so xgettext sees the translatable formats that are
2288 constructed on the fly. */
2289 YY_("syntax error, unexpected %s");
2290 YY_("syntax error, unexpected %s, expecting %s");
2291 YY_("syntax error, unexpected %s, expecting %s or %s");
2292 YY_("syntax error, unexpected %s, expecting %s or %s or %s");
2293 YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s");
2294 #endif
2295 char *yyfmt;
2296 char const *yyf;
2297 static char const yyunexpected[] = "syntax error, unexpected %s";
2298 static char const yyexpecting[] = ", expecting %s";
2299 static char const yyor[] = " or %s";
2300 char yyformat[sizeof yyunexpected
2301 + sizeof yyexpecting - 1
2302 + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2)
2303 * (sizeof yyor - 1))];
2304 char const *yyprefix = yyexpecting;
2305
2306 /* Start YYX at -YYN if negative to avoid negative indexes in
2307 YYCHECK. */
2308 int yyxbegin = yyn < 0 ? -yyn : 0;
2309
2310 /* Stay within bounds of both yycheck and yytname. */
2311 int yychecklim = YYLAST - yyn;
2312 int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
2313 int yycount = 1;
2314
2315 yyarg[0] = yytname[yytype];
2316 yyfmt = yystpcpy (yyformat, yyunexpected);
2317
2318 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
2319 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
2320 {
2321 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
2322 {
2323 yycount = 1;
2324 yysize = yysize0;
2325 yyformat[sizeof yyunexpected - 1] = '\0';
2326 break;
2327 }
2328 yyarg[yycount++] = yytname[yyx];
2329 yysize1 = yysize + yytnamerr (0, yytname[yyx]);
2330 yysize_overflow |= yysize1 < yysize;
2331 yysize = yysize1;
2332 yyfmt = yystpcpy (yyfmt, yyprefix);
2333 yyprefix = yyor;
2334 }
2335
2336 yyf = YY_(yyformat);
2337 yysize1 = yysize + yystrlen (yyf);
2338 yysize_overflow |= yysize1 < yysize;
2339 yysize = yysize1;
2340
2341 if (!yysize_overflow && yysize <= YYSTACK_ALLOC_MAXIMUM)
2342 yymsg = (char *) YYSTACK_ALLOC (yysize);
2343 if (yymsg)
2344 {
2345 /* Avoid sprintf, as that infringes on the user's name space.
2346 Don't have undefined behavior even if the translation
2347 produced a string with the wrong number of "%s"s. */
2348 char *yyp = yymsg;
2349 int yyi = 0;
2350 while ((*yyp = *yyf))
2351 {
2352 if (*yyp == '%' && yyf[1] == 's' && yyi < yycount)
2353 {
2354 yyp += yytnamerr (yyp, yyarg[yyi++]);
2355 yyf += 2;
2356 }
2357 else
2358 {
2359 yyp++;
2360 yyf++;
2361 }
2362 }
2363 yyerror (yymsg);
2364 YYSTACK_FREE (yymsg);
2365 }
2366 else
2367 {
2368 yyerror (YY_("syntax error"));
2369 goto yyexhaustedlab;
2370 }
2371 }
2372 else
2373 #endif /* YYERROR_VERBOSE */
2374 yyerror (YY_("syntax error"));
2375 }
2376
2377
2378
2379 if (yyerrstatus == 3)
2380 {
2381 /* If just tried and failed to reuse look-ahead token after an
2382 error, discard it. */
2383
2384 if (yychar <= YYEOF)
2385 {
2386 /* Return failure if at end of input. */
2387 if (yychar == YYEOF)
2388 YYABORT;
2389 }
2390 else
2391 {
2392 yydestruct ("Error: discarding", yytoken, &yylval);
2393 yychar = YYEMPTY;
2394 }
2395 }
2396
2397 /* Else will try to reuse look-ahead token after shifting the error
2398 token. */
2399 goto yyerrlab1;
2400
2401
2402 /*---------------------------------------------------.
2403 | yyerrorlab -- error raised explicitly by YYERROR. |
2404 `---------------------------------------------------*/
2405 yyerrorlab:
2406
2407 /* Pacify compilers like GCC when the user code never invokes
2408 YYERROR and the label yyerrorlab therefore never appears in user
2409 code. */
2410 if (0)
2411 goto yyerrorlab;
2412
2413 yyvsp -= yylen;
2414 yyssp -= yylen;
2415 yystate = *yyssp;
2416 goto yyerrlab1;
2417
2418
2419 /*-------------------------------------------------------------.
2420 | yyerrlab1 -- common code for both syntax error and YYERROR. |
2421 `-------------------------------------------------------------*/
2422 yyerrlab1:
2423 yyerrstatus = 3; /* Each real token shifted decrements this. */
2424
2425 for (;;)
2426 {
2427 yyn = yypact[yystate];
2428 if (yyn != YYPACT_NINF)
2429 {
2430 yyn += YYTERROR;
2431 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
2432 {
2433 yyn = yytable[yyn];
2434 if (0 < yyn)
2435 break;
2436 }
2437 }
2438
2439 /* Pop the current state because it cannot handle the error token. */
2440 if (yyssp == yyss)
2441 YYABORT;
2442
2443
2444 yydestruct ("Error: popping", yystos[yystate], yyvsp);
2445 YYPOPSTACK;
2446 yystate = *yyssp;
2447 YY_STACK_PRINT (yyss, yyssp);
2448 }
2449
2450 if (yyn == YYFINAL)
2451 YYACCEPT;
2452
2453 *++yyvsp = yylval;
2454
2455
2456 /* Shift the error token. */
2457 YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
2458
2459 yystate = yyn;
2460 goto yynewstate;
2461
2462
2463 /*-------------------------------------.
2464 | yyacceptlab -- YYACCEPT comes here. |
2465 `-------------------------------------*/
2466 yyacceptlab:
2467 yyresult = 0;
2468 goto yyreturn;
2469
2470 /*-----------------------------------.
2471 | yyabortlab -- YYABORT comes here. |
2472 `-----------------------------------*/
2473 yyabortlab:
2474 yyresult = 1;
2475 goto yyreturn;
2476
2477 #ifndef yyoverflow
2478 /*-------------------------------------------------.
2479 | yyexhaustedlab -- memory exhaustion comes here. |
2480 `-------------------------------------------------*/
2481 yyexhaustedlab:
2482 yyerror (YY_("memory exhausted"));
2483 yyresult = 2;
2484 /* Fall through. */
2485 #endif
2486
2487 yyreturn:
2488 if (yychar != YYEOF && yychar != YYEMPTY)
2489 yydestruct ("Cleanup: discarding lookahead",
2490 yytoken, &yylval);
2491 while (yyssp != yyss)
2492 {
2493 yydestruct ("Cleanup: popping",
2494 yystos[*yyssp], yyvsp);
2495 YYPOPSTACK;
2496 }
2497 #ifndef yyoverflow
2498 if (yyss != yyssa)
2499 YYSTACK_FREE (yyss);
2500 #endif
2501 return yyresult;
2502 }
2503
2504
2505 #line 879 "parse.y"
2506
2507
2508 void
yyerror(const char * s)2509 yyerror (const char *s)
2510 {
2511 error_message ("%s\n", s);
2512 }
2513
2514 static Type *
new_tag(int tagclass,int tagvalue,int tagenv,Type * oldtype)2515 new_tag(int tagclass, int tagvalue, int tagenv, Type *oldtype)
2516 {
2517 Type *t;
2518 if(oldtype->type == TTag && oldtype->tag.tagenv == TE_IMPLICIT) {
2519 t = oldtype;
2520 oldtype = oldtype->subtype; /* XXX */
2521 } else
2522 t = new_type (TTag);
2523
2524 t->tag.tagclass = tagclass;
2525 t->tag.tagvalue = tagvalue;
2526 t->tag.tagenv = tagenv;
2527 t->subtype = oldtype;
2528 return t;
2529 }
2530
2531 static struct objid *
new_objid(const char * label,int value)2532 new_objid(const char *label, int value)
2533 {
2534 struct objid *s;
2535 s = emalloc(sizeof(*s));
2536 s->label = label;
2537 s->value = value;
2538 s->next = NULL;
2539 return s;
2540 }
2541
2542 static void
add_oid_to_tail(struct objid * head,struct objid * tail)2543 add_oid_to_tail(struct objid *head, struct objid *tail)
2544 {
2545 struct objid *o;
2546 o = head;
2547 while (o->next)
2548 o = o->next;
2549 o->next = tail;
2550 }
2551
2552 static Type *
new_type(Typetype tt)2553 new_type (Typetype tt)
2554 {
2555 Type *t = ecalloc(1, sizeof(*t));
2556 t->type = tt;
2557 return t;
2558 }
2559
2560 static struct constraint_spec *
new_constraint_spec(enum ctype ct)2561 new_constraint_spec(enum ctype ct)
2562 {
2563 struct constraint_spec *c = ecalloc(1, sizeof(*c));
2564 c->ctype = ct;
2565 return c;
2566 }
2567
2568 static void fix_labels2(Type *t, const char *prefix);
fix_labels1(struct memhead * members,const char * prefix)2569 static void fix_labels1(struct memhead *members, const char *prefix)
2570 {
2571 Member *m;
2572
2573 if(members == NULL)
2574 return;
2575 ASN1_TAILQ_FOREACH(m, members, members) {
2576 asprintf(&m->label, "%s_%s", prefix, m->gen_name);
2577 if (m->label == NULL)
2578 errx(1, "malloc");
2579 if(m->type != NULL)
2580 fix_labels2(m->type, m->label);
2581 }
2582 }
2583
fix_labels2(Type * t,const char * prefix)2584 static void fix_labels2(Type *t, const char *prefix)
2585 {
2586 for(; t; t = t->subtype)
2587 fix_labels1(t->members, prefix);
2588 }
2589
2590 static void
fix_labels(Symbol * s)2591 fix_labels(Symbol *s)
2592 {
2593 char *p;
2594 asprintf(&p, "choice_%s", s->gen_name);
2595 if (p == NULL)
2596 errx(1, "malloc");
2597 fix_labels2(s->type, p);
2598 free(p);
2599 }
2600
2601