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