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