heimdal: Re-run lexyacc.sh
[ab/samba.git/.git] / source4 / heimdal / lib / asn1 / asn1parse.c
1 #ifndef lint
2 static const char yysccsid[] = "@(#)yaccpar     1.9 (Berkeley) 02/21/93";
3 #endif
4
5 #define YYBYACC 1
6 #define YYMAJOR 1
7 #define YYMINOR 9
8 #define YYPATCH 20101229
9
10 #define YYEMPTY        (-1)
11 #define yyclearin      (yychar = YYEMPTY)
12 #define yyerrok        (yyerrflag = 0)
13 #define YYRECOVERING() (yyerrflag != 0)
14
15 #define YYPREFIX "yy"
16
17 #define YYPURE 0
18
19 #line 39 "asn1parse.c"
20
21 #include <config.h>
22
23 #include <stdio.h>
24 #include <stdlib.h>
25 #include <string.h>
26 #include "symbol.h"
27 #include "lex.h"
28 #include "gen_locl.h"
29 #include "der.h"
30
31 RCSID("$Id$");
32
33 static Type *new_type (Typetype t);
34 static struct constraint_spec *new_constraint_spec(enum ctype);
35 static Type *new_tag(int tagclass, int tagvalue, int tagenv, Type *oldtype);
36 void yyerror (const char *);
37 static struct objid *new_objid(const char *label, int value);
38 static void add_oid_to_tail(struct objid *, struct objid *);
39 static void fix_labels(Symbol *s);
40
41 struct string_list {
42     char *string;
43     struct string_list *next;
44 };
45
46 /* Declarations for Bison */
47 #define YYMALLOC malloc
48 #define YYFREE   free
49
50 #line 71 "asn1parse.c"
51 #ifdef YYSTYPE
52 #undef  YYSTYPE_IS_DECLARED
53 #define YYSTYPE_IS_DECLARED 1
54 #endif
55 #ifndef YYSTYPE_IS_DECLARED
56 #define YYSTYPE_IS_DECLARED 1
57 typedef union {
58     int constant;
59     struct value *value;
60     struct range *range;
61     char *name;
62     Type *type;
63     Member *member;
64     struct objid *objid;
65     char *defval;
66     struct string_list *sl;
67     struct tagtype tag;
68     struct memhead *members;
69     struct constraint_spec *constraint_spec;
70 } YYSTYPE;
71 #endif /* !YYSTYPE_IS_DECLARED */
72 #line 72 "asn1parse.c"
73 /* compatibility with bison */
74 #ifdef YYPARSE_PARAM
75 /* compatibility with FreeBSD */
76 # ifdef YYPARSE_PARAM_TYPE
77 #  define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM)
78 # else
79 #  define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM)
80 # endif
81 #else
82 # define YYPARSE_DECL() yyparse(void)
83 #endif
84
85 /* Parameters sent to lex. */
86 #ifdef YYLEX_PARAM
87 # define YYLEX_DECL() yylex(void *YYLEX_PARAM)
88 # define YYLEX yylex(YYLEX_PARAM)
89 #else
90 # define YYLEX_DECL() yylex(void)
91 # define YYLEX yylex()
92 #endif
93
94 /* Parameters sent to yyerror. */
95 #define YYERROR_DECL() yyerror(const char *s)
96 #define YYERROR_CALL(msg) yyerror(msg)
97
98 extern int YYPARSE_DECL();
99
100 #define kw_ABSENT 257
101 #define kw_ABSTRACT_SYNTAX 258
102 #define kw_ALL 259
103 #define kw_APPLICATION 260
104 #define kw_AUTOMATIC 261
105 #define kw_BEGIN 262
106 #define kw_BIT 263
107 #define kw_BMPString 264
108 #define kw_BOOLEAN 265
109 #define kw_BY 266
110 #define kw_CHARACTER 267
111 #define kw_CHOICE 268
112 #define kw_CLASS 269
113 #define kw_COMPONENT 270
114 #define kw_COMPONENTS 271
115 #define kw_CONSTRAINED 272
116 #define kw_CONTAINING 273
117 #define kw_DEFAULT 274
118 #define kw_DEFINITIONS 275
119 #define kw_EMBEDDED 276
120 #define kw_ENCODED 277
121 #define kw_END 278
122 #define kw_ENUMERATED 279
123 #define kw_EXCEPT 280
124 #define kw_EXPLICIT 281
125 #define kw_EXPORTS 282
126 #define kw_EXTENSIBILITY 283
127 #define kw_EXTERNAL 284
128 #define kw_FALSE 285
129 #define kw_FROM 286
130 #define kw_GeneralString 287
131 #define kw_GeneralizedTime 288
132 #define kw_GraphicString 289
133 #define kw_IA5String 290
134 #define kw_IDENTIFIER 291
135 #define kw_IMPLICIT 292
136 #define kw_IMPLIED 293
137 #define kw_IMPORTS 294
138 #define kw_INCLUDES 295
139 #define kw_INSTANCE 296
140 #define kw_INTEGER 297
141 #define kw_INTERSECTION 298
142 #define kw_ISO646String 299
143 #define kw_MAX 300
144 #define kw_MIN 301
145 #define kw_MINUS_INFINITY 302
146 #define kw_NULL 303
147 #define kw_NumericString 304
148 #define kw_OBJECT 305
149 #define kw_OCTET 306
150 #define kw_OF 307
151 #define kw_OPTIONAL 308
152 #define kw_ObjectDescriptor 309
153 #define kw_PATTERN 310
154 #define kw_PDV 311
155 #define kw_PLUS_INFINITY 312
156 #define kw_PRESENT 313
157 #define kw_PRIVATE 314
158 #define kw_PrintableString 315
159 #define kw_REAL 316
160 #define kw_RELATIVE_OID 317
161 #define kw_SEQUENCE 318
162 #define kw_SET 319
163 #define kw_SIZE 320
164 #define kw_STRING 321
165 #define kw_SYNTAX 322
166 #define kw_T61String 323
167 #define kw_TAGS 324
168 #define kw_TRUE 325
169 #define kw_TYPE_IDENTIFIER 326
170 #define kw_TeletexString 327
171 #define kw_UNION 328
172 #define kw_UNIQUE 329
173 #define kw_UNIVERSAL 330
174 #define kw_UTCTime 331
175 #define kw_UTF8String 332
176 #define kw_UniversalString 333
177 #define kw_VideotexString 334
178 #define kw_VisibleString 335
179 #define kw_WITH 336
180 #define RANGE 337
181 #define EEQUAL 338
182 #define ELLIPSIS 339
183 #define IDENTIFIER 340
184 #define referencename 341
185 #define STRING 342
186 #define NUMBER 343
187 #define YYERRCODE 256
188 static const short yylhs[] = {                           -1,
189     0,   56,   56,   56,   56,   57,   57,   58,   58,   60,
190    60,   62,   62,   63,   63,   64,   59,   59,   59,   61,
191    61,   65,   65,   50,   50,   66,   14,   14,   14,   15,
192    15,   15,   15,   15,   15,   15,   15,   15,   15,   15,
193    15,   15,   15,   17,   48,   48,   48,   48,   21,   21,
194    21,   43,   43,   43,   38,   20,   41,   16,   16,   32,
195    23,   22,   49,   49,   24,   24,   25,   26,   26,   27,
196    18,   29,   29,   30,   31,   31,   19,   51,   52,   53,
197    53,   54,   54,   54,   55,   28,   35,    2,    2,    2,
198     2,    3,    3,    3,   67,   33,   34,   34,   34,   34,
199    34,   34,   34,   34,   40,   40,   40,   39,   36,   36,
200    36,   42,   42,   37,   47,   47,   44,   45,   45,   46,
201    46,   46,    4,    4,    5,    5,    5,    5,    5,   12,
202    11,   13,    9,    7,    7,    6,    1,   10,    8,
203 };
204 static const short yylen[] = {                            2,
205     9,    2,    2,    2,    0,    2,    0,    3,    0,    3,
206     0,    1,    0,    1,    2,    4,    3,    2,    0,    1,
207     2,    1,    1,    3,    1,    3,    1,    1,    1,    1,
208     1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
209     1,    1,    1,    1,    5,    5,    5,    3,    1,    2,
210     4,    1,    3,    3,    4,    4,    1,    2,    5,    2,
211     3,    1,    0,    2,    4,    3,    4,    4,    3,    3,
212     4,    1,    1,    1,    1,    1,    2,    3,    1,    1,
213     1,    2,    3,    5,    4,    3,    4,    0,    1,    1,
214     1,    0,    1,    1,    4,    1,    1,    1,    1,    1,
215     1,    1,    1,    1,    1,    3,    3,    2,    1,    2,
216     3,    1,    3,    4,    1,    0,    3,    0,    2,    4,
217     1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
218     1,    1,    1,    1,    1,    1,    1,    1,    1,
219 };
220 static const short yydefred[] = {                         0,
221     0,    0,    0,  115,    0,    0,  122,    0,    0,    0,
222     0,  117,  119,    0,    0,    0,    0,    0,    4,    2,
223     3,    0,    0,  120,    6,    0,    0,    0,    0,    0,
224    18,    0,    0,    1,    0,    0,    0,   17,    0,    0,
225     0,   14,    0,    8,    0,   22,   23,   24,    0,   10,
226    15,    0,  103,   44,    0,    0,   97,   75,  102,    0,
227    62,    0,    0,  100,    0,    0,   98,   76,   99,  104,
228   101,    0,   74,    0,    0,   27,   30,   31,   33,   29,
229    34,   35,   36,   38,   39,   40,   41,   42,   43,   28,
230    72,   73,   37,   32,   96,    0,   21,    0,    0,    0,
231     0,    0,    0,   50,   60,    0,    0,    0,    0,    0,
232     0,    0,   90,   91,   89,    0,    0,    0,   77,   93,
233    94,    0,   16,    0,    0,  105,    0,    0,    0,   52,
234     0,    0,  135,    0,  138,  134,  132,  133,  137,  136,
235     0,  123,  127,  125,  128,  126,  129,  130,  124,  131,
236   139,    0,   61,   64,   66,    0,    0,    0,   69,    0,
237     0,   95,    0,    0,    0,    0,   79,   80,   81,    0,
238     0,  112,    0,    0,    0,  110,    0,   71,    0,   56,
239     0,    0,    0,   48,   51,   65,    0,   68,   87,    0,
240     0,    0,   78,    0,    0,   59,  111,  107,  106,    0,
241    54,   53,    0,    0,    0,    0,    0,   83,    0,  113,
242    55,   47,   46,   45,   85,    0,  114,   84,
243 };
244 static const short yydgoto[] = {                          2,
245   140,  116,  122,  141,  142,  143,  144,  145,  146,  147,
246   148,  149,  150,   75,   76,   77,   78,   79,   80,   81,
247    82,   83,   84,   85,   86,   87,   88,   89,   90,   91,
248    92,   93,   94,   95,   96,  126,  172,  130,  127,  128,
249   131,  173,  132,  151,    8,    9,    5,  104,  109,   39,
250   119,  166,  167,  168,  169,   17,   23,   29,   30,   36,
251    44,   40,   41,   42,   45,   46,   47,
252 };
253 static const short yysindex[] = {                      -295,
254   -74,    0, -289,    0, -216,   23,    0,  -61, -289, -221,
255  -277,    0,    0, -259, -257, -256, -214,   31,    0,    0,
256     0, -220, -264,    0,    0, -187, -206, -232, -201, -213,
257     0,   34,   25,    0, -258, -251, -258,    0, -188,   40,
258  -258,    0,   63,    0, -251,    0,    0,    0, -239,    0,
259     0, -218,    0,    0,  -19,  -17,    0,    0,    0,  -12,
260     0, -184, -212,    0, -106, -111,    0,    0,    0,    0,
261     0,  112,    0, -228,  -37,    0,    0,    0,    0,    0,
262     0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
263     0,    0,    0,    0,    0, -242,    0,  -74,  -10, -223,
264  -215, -116, -215,    0,    0, -198,   87, -105, -179,  112,
265  -100,   89,    0,    0,    0, -211,   -4, -225,    0,    0,
266     0,  112,    0, -210,  112,    0, -238,  -13,   91,    0,
267     9,   92,    0, -202,    0,    0,    0,    0,    0,    0,
268   -33,    0,    0,    0,    0,    0,    0,    0,    0,    0,
269     0,  -11,    0,    0,    0,   -9,  112,   89,    0,   -7,
270    44,    0, -128,  112, -127,   99,    0,    0,    0,   89,
271   101,    0,   -2,   89,   -4,    0, -283,    0, -200,    0,
272  -278,   -4,   -8,    0,    0,    0,   89,    0,    0,   19,
273   -27,   -4,    0, -199, -210,    0,    0,    0,    0,  104,
274     0,    0,  105,  106,  107,   24, -115,    0,  109,    0,
275     0,    0,    0,    0,    0,   -4,    0,    0,
276 };
277 static const short yyrindex[] = {                         0,
278  -123,    0,   28,    0,    0, -110,    0,    0,   28, -245,
279     0,    0,    0,    0,    0,    0, -183,    0,    0,    0,
280     0,    0,    0,    0,    0,    0, -248,    0,    0, -182,
281     0,  -41,    0,    0,   97,    0,    0,    0,    0,    0,
282    98,    0,    0,    0, -119,    0,    0,    0,    0,    0,
283     0,    0,    0,    0,    0,    0,    0,    0,    0,  -30,
284     0,    0,    0,    0, -147,    0,    0,    0,    0,    0,
285     0,    0,    0, -181,    0,    0,    0,    0,    0,    0,
286     0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
287     0,    0,    0,    0,    0,  169,    0,  -49,  -40,    0,
288     0,    0,    0,    0,    0,  -35,    0,    0,    0,    0,
289     0, -244,    0,    0,    0,    0,    0,    0,    0,    0,
290     0,    0,    0,    0,    0,    0,   -1,    0,    0,    0,
291     0,   36,    0,    0,    0,    0,    0,    0,    0,    0,
292     0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
293     0,    0,    0,    0,    0,    0,    0,  -25,    0,    0,
294     0,    0,    0,    0,    0,    0,    0,    0,    0,  -20,
295     0,    0,    0,  -42,    0,    0,    0,    0,    0,    0,
296     0,    0,    0,    0,    0,    0,  -15,    0,    0,    0,
297   122,    0,    0,    0,    0,    0,    0,    0,    0,    0,
298     0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
299     0,    0,    0,    0,    0,    0,    0,    0,
300 };
301 static const short yygindex[] = {                         0,
302   -14,    0,    0,  -95,    0,    0,    0,    0,    0,    0,
303     0,    0,    0,  -31,    0,    0,    0,    0,    0,    0,
304     0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
305     0,    0,    0,    0,    0,   -6,  -29,   -5,    0,  -53,
306     0,    0,   61,   22,  158,    0,   70,   65,   64,   16,
307     0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
308   128,    0,    0,  133,    0,    0,    0,
309 };
310 #define YYTABLESIZE 509
311 static const short yytable[] = {                         58,
312    58,  108,  118,   58,   63,   63,    3,  184,   63,  116,
313    49,  111,  118,   49,  121,   70,  108,   25,   70,  155,
314    86,  162,    4,   86,  159,   67,   31,  102,   67,    9,
315   177,  113,  181,   26,  177,  175,  177,    5,  120,   14,
316   112,  195,  109,   33,    1,   19,  163,  164,    3,  121,
317     6,  165,   48,    7,  156,  198,  125,  160,   10,   15,
318   201,  129,   11,   12,   19,   18,   20,   21,   22,  176,
319    16,   24,   25,   26,   27,   28,   34,   37,  158,  197,
320    35,   32,  108,   38,   58,  114,  203,  205,   43,   63,
321   170,   19,    5,  174,   49,   26,  208,   49,   50,   70,
322    98,  115,   99,  100,   86,  101,  105,   32,  106,   67,
323   103,  178,  124,  185,    3,  186,  125,  188,    3,    4,
324   218,  107,  196,  109,  129,  187,  102,  157,  118,  171,
325   179,  161,  191,  180,  182,  181,  189,  190,  192,  193,
326   194,  206,  139,  209,  211,  212,  213,  214,  215,  217,
327   216,  116,  118,   74,    7,   13,   12,   11,   20,   63,
328    57,   88,   82,  152,  200,  210,   13,  123,  133,  153,
329   199,  154,   97,   51,    0,  202,    0,    0,    0,    0,
330     0,    0,    0,    0,  134,    0,  135,    0,    0,    0,
331     0,    0,    0,    0,    0,  110,    0,    0,    0,    0,
332     0,    0,   74,    0,    0,    0,    0,    0,  136,    0,
333     0,    0,    0,  107,    0,    0,    0,    0,    0,    0,
334     0,    0,    0,  137,    0,  138,  139,    0,    0,  121,
335     0,  108,  121,   58,  125,    0,   58,   58,   63,  125,
336     0,   63,   63,   49,   25,    0,   49,   49,   70,  207,
337     0,   70,   70,   86,    0,    0,   86,   86,   67,   92,
338     0,   67,   67,    0,    0,  108,    0,   58,    0,    0,
339     0,    0,   63,    0,    0,    0,  133,   49,    0,    0,
340   133,    0,   70,    0,    0,    0,    0,   86,    0,    0,
341   116,  204,   67,    0,  135,    0,    0,   58,  135,   58,
342   117,    0,   63,  183,   63,    0,    0,   49,    0,   49,
343     0,    0,   70,    0,   70,    0,  136,   86,    0,   86,
344   136,    0,   67,    0,   67,   52,   53,   54,    0,    0,
345    55,  137,    0,  138,  139,  137,    0,  138,  139,    0,
346     0,   56,    0,    0,    0,    0,    0,    0,    0,   57,
347    58,    0,   59,    0,    0,    0,    0,    0,    0,   60,
348     0,    0,    0,    0,    0,   61,    0,   62,   63,    0,
349     0,    0,    0,    0,   52,   53,   54,   64,    0,   55,
350    65,   66,    0,    0,    0,    0,    0,    0,    0,   67,
351    56,    0,    0,   68,   69,   70,    0,   71,   57,   58,
352    72,   59,   73,    0,    0,    0,    0,    0,   60,    0,
353     0,    0,    0,    0,   61,    0,   62,   63,    0,    0,
354     0,    0,    0,    0,    0,    0,   64,    0,    0,   65,
355    66,   92,   92,   92,    0,    0,   92,    0,   67,    0,
356     0,    0,   68,   69,   70,    0,   71,   92,    0,    0,
357     0,   73,    0,    0,    0,   92,   92,    0,   92,    0,
358     0,    0,    0,    0,    0,   92,    0,    0,    0,    0,
359     0,   92,    0,   92,   92,    0,    0,    0,    0,    0,
360     0,    0,    0,   92,    0,    0,   92,   92,    0,    0,
361     0,    0,    0,    0,    0,   92,    0,    0,    0,   92,
362    92,   92,    0,   92,    0,    0,    0,    0,   92,
363 };
364 static const short yycheck[] = {                         40,
365    41,   44,   40,   44,   40,   41,  123,   41,   44,   59,
366    41,  123,   40,   44,  125,   41,  123,   59,   44,  125,
367    41,  117,    1,   44,  125,   41,  259,   40,   44,  278,
368    44,  260,   44,  278,   44,  274,   44,  283,  281,  261,
369    72,   44,   44,   28,  340,  294,  272,  273,  123,  292,
370   340,  277,   37,  343,  108,  339,  340,  111,  275,  281,
371   339,  340,   40,  125,  324,  343,  324,  324,  283,  308,
372   292,   41,  293,  338,  262,  282,  278,   44,  110,  175,
373   294,  340,  125,   59,  125,  314,  182,  183,  340,  125,
374   122,  340,  338,  125,  125,  340,  192,  286,   59,  125,
375   340,  330,  321,  123,  125,  123,  291,  340,  321,  125,
376   123,  125,  123,  125,  123,  125,  340,  125,  123,   98,
377   216,  320,  125,  125,  340,  157,   40,  307,   40,  340,
378    40,  343,  164,  125,  337,   44,   93,  266,  266,   41,
379    40,  123,  343,  343,   41,   41,   41,   41,  125,   41,
380   266,  275,  125,   91,  338,   59,   59,  340,  278,  307,
381   125,  343,   41,  103,  179,  195,    9,   98,  285,  106,
382   177,  107,   45,   41,   -1,  181,   -1,   -1,   -1,   -1,
383    -1,   -1,   -1,   -1,  301,   -1,  303,   -1,   -1,   -1,
384    -1,   -1,   -1,   -1,   -1,  307,   -1,   -1,   -1,   -1,
385    -1,   -1,   91,   -1,   -1,   -1,   -1,   -1,  325,   -1,
386    -1,   -1,   -1,  320,   -1,   -1,   -1,   -1,   -1,   -1,
387    -1,   -1,   -1,  340,   -1,  342,  343,   -1,   -1,  340,
388    -1,  274,  343,  274,  340,   -1,  277,  278,  274,  340,
389    -1,  277,  278,  274,  286,   -1,  277,  278,  274,  277,
390    -1,  277,  278,  274,   -1,   -1,  277,  278,  274,   91,
391    -1,  277,  278,   -1,   -1,  308,   -1,  308,   -1,   -1,
392    -1,   -1,  308,   -1,   -1,   -1,  285,  308,   -1,   -1,
393   285,   -1,  308,   -1,   -1,   -1,   -1,  308,   -1,   -1,
394   340,  300,  308,   -1,  303,   -1,   -1,  338,  303,  340,
395   338,   -1,  338,  337,  340,   -1,   -1,  338,   -1,  340,
396    -1,   -1,  338,   -1,  340,   -1,  325,  338,   -1,  340,
397   325,   -1,  338,   -1,  340,  263,  264,  265,   -1,   -1,
398   268,  340,   -1,  342,  343,  340,   -1,  342,  343,   -1,
399    -1,  279,   -1,   -1,   -1,   -1,   -1,   -1,   -1,  287,
400   288,   -1,  290,   -1,   -1,   -1,   -1,   -1,   -1,  297,
401    -1,   -1,   -1,   -1,   -1,  303,   -1,  305,  306,   -1,
402    -1,   -1,   -1,   -1,  263,  264,  265,  315,   -1,  268,
403   318,  319,   -1,   -1,   -1,   -1,   -1,   -1,   -1,  327,
404   279,   -1,   -1,  331,  332,  333,   -1,  335,  287,  288,
405   338,  290,  340,   -1,   -1,   -1,   -1,   -1,  297,   -1,
406    -1,   -1,   -1,   -1,  303,   -1,  305,  306,   -1,   -1,
407    -1,   -1,   -1,   -1,   -1,   -1,  315,   -1,   -1,  318,
408   319,  263,  264,  265,   -1,   -1,  268,   -1,  327,   -1,
409    -1,   -1,  331,  332,  333,   -1,  335,  279,   -1,   -1,
410    -1,  340,   -1,   -1,   -1,  287,  288,   -1,  290,   -1,
411    -1,   -1,   -1,   -1,   -1,  297,   -1,   -1,   -1,   -1,
412    -1,  303,   -1,  305,  306,   -1,   -1,   -1,   -1,   -1,
413    -1,   -1,   -1,  315,   -1,   -1,  318,  319,   -1,   -1,
414    -1,   -1,   -1,   -1,   -1,  327,   -1,   -1,   -1,  331,
415   332,  333,   -1,  335,   -1,   -1,   -1,   -1,  340,
416 };
417 #define YYFINAL 2
418 #ifndef YYDEBUG
419 #define YYDEBUG 0
420 #endif
421 #define YYMAXTOKEN 343
422 #if YYDEBUG
423 static const char *yyname[] = {
424
425 "end-of-file",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
426 0,0,0,0,0,0,"'('","')'",0,0,"','",0,0,0,0,0,0,0,0,0,0,0,0,0,0,"';'",0,0,0,0,0,0,
427 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"'['",0,"']'",0,0,0,0,0,0,0,0,
428 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"'{'",0,"'}'",0,0,0,0,0,0,0,0,0,0,0,0,
429 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
430 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
431 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
432 "kw_ABSENT","kw_ABSTRACT_SYNTAX","kw_ALL","kw_APPLICATION","kw_AUTOMATIC",
433 "kw_BEGIN","kw_BIT","kw_BMPString","kw_BOOLEAN","kw_BY","kw_CHARACTER",
434 "kw_CHOICE","kw_CLASS","kw_COMPONENT","kw_COMPONENTS","kw_CONSTRAINED",
435 "kw_CONTAINING","kw_DEFAULT","kw_DEFINITIONS","kw_EMBEDDED","kw_ENCODED",
436 "kw_END","kw_ENUMERATED","kw_EXCEPT","kw_EXPLICIT","kw_EXPORTS",
437 "kw_EXTENSIBILITY","kw_EXTERNAL","kw_FALSE","kw_FROM","kw_GeneralString",
438 "kw_GeneralizedTime","kw_GraphicString","kw_IA5String","kw_IDENTIFIER",
439 "kw_IMPLICIT","kw_IMPLIED","kw_IMPORTS","kw_INCLUDES","kw_INSTANCE",
440 "kw_INTEGER","kw_INTERSECTION","kw_ISO646String","kw_MAX","kw_MIN",
441 "kw_MINUS_INFINITY","kw_NULL","kw_NumericString","kw_OBJECT","kw_OCTET","kw_OF",
442 "kw_OPTIONAL","kw_ObjectDescriptor","kw_PATTERN","kw_PDV","kw_PLUS_INFINITY",
443 "kw_PRESENT","kw_PRIVATE","kw_PrintableString","kw_REAL","kw_RELATIVE_OID",
444 "kw_SEQUENCE","kw_SET","kw_SIZE","kw_STRING","kw_SYNTAX","kw_T61String",
445 "kw_TAGS","kw_TRUE","kw_TYPE_IDENTIFIER","kw_TeletexString","kw_UNION",
446 "kw_UNIQUE","kw_UNIVERSAL","kw_UTCTime","kw_UTF8String","kw_UniversalString",
447 "kw_VideotexString","kw_VisibleString","kw_WITH","RANGE","EEQUAL","ELLIPSIS",
448 "IDENTIFIER","referencename","STRING","NUMBER",
449 };
450 static const char *yyrule[] = {
451 "$accept : ModuleDefinition",
452 "ModuleDefinition : IDENTIFIER objid_opt kw_DEFINITIONS TagDefault ExtensionDefault EEQUAL kw_BEGIN ModuleBody kw_END",
453 "TagDefault : kw_EXPLICIT kw_TAGS",
454 "TagDefault : kw_IMPLICIT kw_TAGS",
455 "TagDefault : kw_AUTOMATIC kw_TAGS",
456 "TagDefault :",
457 "ExtensionDefault : kw_EXTENSIBILITY kw_IMPLIED",
458 "ExtensionDefault :",
459 "ModuleBody : Exports Imports AssignmentList",
460 "ModuleBody :",
461 "Imports : kw_IMPORTS SymbolsImported ';'",
462 "Imports :",
463 "SymbolsImported : SymbolsFromModuleList",
464 "SymbolsImported :",
465 "SymbolsFromModuleList : SymbolsFromModule",
466 "SymbolsFromModuleList : SymbolsFromModuleList SymbolsFromModule",
467 "SymbolsFromModule : referencenames kw_FROM IDENTIFIER objid_opt",
468 "Exports : kw_EXPORTS referencenames ';'",
469 "Exports : kw_EXPORTS kw_ALL",
470 "Exports :",
471 "AssignmentList : Assignment",
472 "AssignmentList : Assignment AssignmentList",
473 "Assignment : TypeAssignment",
474 "Assignment : ValueAssignment",
475 "referencenames : IDENTIFIER ',' referencenames",
476 "referencenames : IDENTIFIER",
477 "TypeAssignment : IDENTIFIER EEQUAL Type",
478 "Type : BuiltinType",
479 "Type : ReferencedType",
480 "Type : ConstrainedType",
481 "BuiltinType : BitStringType",
482 "BuiltinType : BooleanType",
483 "BuiltinType : CharacterStringType",
484 "BuiltinType : ChoiceType",
485 "BuiltinType : EnumeratedType",
486 "BuiltinType : IntegerType",
487 "BuiltinType : NullType",
488 "BuiltinType : ObjectIdentifierType",
489 "BuiltinType : OctetStringType",
490 "BuiltinType : SequenceType",
491 "BuiltinType : SequenceOfType",
492 "BuiltinType : SetType",
493 "BuiltinType : SetOfType",
494 "BuiltinType : TaggedType",
495 "BooleanType : kw_BOOLEAN",
496 "range : '(' Value RANGE Value ')'",
497 "range : '(' Value RANGE kw_MAX ')'",
498 "range : '(' kw_MIN RANGE Value ')'",
499 "range : '(' Value ')'",
500 "IntegerType : kw_INTEGER",
501 "IntegerType : kw_INTEGER range",
502 "IntegerType : kw_INTEGER '{' NamedNumberList '}'",
503 "NamedNumberList : NamedNumber",
504 "NamedNumberList : NamedNumberList ',' NamedNumber",
505 "NamedNumberList : NamedNumberList ',' ELLIPSIS",
506 "NamedNumber : IDENTIFIER '(' SignedNumber ')'",
507 "EnumeratedType : kw_ENUMERATED '{' Enumerations '}'",
508 "Enumerations : NamedNumberList",
509 "BitStringType : kw_BIT kw_STRING",
510 "BitStringType : kw_BIT kw_STRING '{' NamedBitList '}'",
511 "ObjectIdentifierType : kw_OBJECT kw_IDENTIFIER",
512 "OctetStringType : kw_OCTET kw_STRING size",
513 "NullType : kw_NULL",
514 "size :",
515 "size : kw_SIZE range",
516 "SequenceType : kw_SEQUENCE '{' ComponentTypeList '}'",
517 "SequenceType : kw_SEQUENCE '{' '}'",
518 "SequenceOfType : kw_SEQUENCE size kw_OF Type",
519 "SetType : kw_SET '{' ComponentTypeList '}'",
520 "SetType : kw_SET '{' '}'",
521 "SetOfType : kw_SET kw_OF Type",
522 "ChoiceType : kw_CHOICE '{' ComponentTypeList '}'",
523 "ReferencedType : DefinedType",
524 "ReferencedType : UsefulType",
525 "DefinedType : IDENTIFIER",
526 "UsefulType : kw_GeneralizedTime",
527 "UsefulType : kw_UTCTime",
528 "ConstrainedType : Type Constraint",
529 "Constraint : '(' ConstraintSpec ')'",
530 "ConstraintSpec : GeneralConstraint",
531 "GeneralConstraint : ContentsConstraint",
532 "GeneralConstraint : UserDefinedConstraint",
533 "ContentsConstraint : kw_CONTAINING Type",
534 "ContentsConstraint : kw_ENCODED kw_BY Value",
535 "ContentsConstraint : kw_CONTAINING Type kw_ENCODED kw_BY Value",
536 "UserDefinedConstraint : kw_CONSTRAINED kw_BY '{' '}'",
537 "TaggedType : Tag tagenv Type",
538 "Tag : '[' Class NUMBER ']'",
539 "Class :",
540 "Class : kw_UNIVERSAL",
541 "Class : kw_APPLICATION",
542 "Class : kw_PRIVATE",
543 "tagenv :",
544 "tagenv : kw_EXPLICIT",
545 "tagenv : kw_IMPLICIT",
546 "ValueAssignment : IDENTIFIER Type EEQUAL Value",
547 "CharacterStringType : RestrictedCharactedStringType",
548 "RestrictedCharactedStringType : kw_GeneralString",
549 "RestrictedCharactedStringType : kw_TeletexString",
550 "RestrictedCharactedStringType : kw_UTF8String",
551 "RestrictedCharactedStringType : kw_PrintableString",
552 "RestrictedCharactedStringType : kw_VisibleString",
553 "RestrictedCharactedStringType : kw_IA5String",
554 "RestrictedCharactedStringType : kw_BMPString",
555 "RestrictedCharactedStringType : kw_UniversalString",
556 "ComponentTypeList : ComponentType",
557 "ComponentTypeList : ComponentTypeList ',' ComponentType",
558 "ComponentTypeList : ComponentTypeList ',' ELLIPSIS",
559 "NamedType : IDENTIFIER Type",
560 "ComponentType : NamedType",
561 "ComponentType : NamedType kw_OPTIONAL",
562 "ComponentType : NamedType kw_DEFAULT Value",
563 "NamedBitList : NamedBit",
564 "NamedBitList : NamedBitList ',' NamedBit",
565 "NamedBit : IDENTIFIER '(' NUMBER ')'",
566 "objid_opt : objid",
567 "objid_opt :",
568 "objid : '{' objid_list '}'",
569 "objid_list :",
570 "objid_list : objid_element objid_list",
571 "objid_element : IDENTIFIER '(' NUMBER ')'",
572 "objid_element : IDENTIFIER",
573 "objid_element : NUMBER",
574 "Value : BuiltinValue",
575 "Value : ReferencedValue",
576 "BuiltinValue : BooleanValue",
577 "BuiltinValue : CharacterStringValue",
578 "BuiltinValue : IntegerValue",
579 "BuiltinValue : ObjectIdentifierValue",
580 "BuiltinValue : NullValue",
581 "ReferencedValue : DefinedValue",
582 "DefinedValue : Valuereference",
583 "Valuereference : IDENTIFIER",
584 "CharacterStringValue : STRING",
585 "BooleanValue : kw_TRUE",
586 "BooleanValue : kw_FALSE",
587 "IntegerValue : SignedNumber",
588 "SignedNumber : NUMBER",
589 "NullValue : kw_NULL",
590 "ObjectIdentifierValue : objid",
591
592 };
593 #endif
594 /* define the initial stack-sizes */
595 #ifdef YYSTACKSIZE
596 #undef YYMAXDEPTH
597 #define YYMAXDEPTH  YYSTACKSIZE
598 #else
599 #ifdef YYMAXDEPTH
600 #define YYSTACKSIZE YYMAXDEPTH
601 #else
602 #define YYSTACKSIZE 500
603 #define YYMAXDEPTH  500
604 #endif
605 #endif
606
607 #define YYINITSTACKSIZE 500
608
609 int      yydebug;
610 int      yynerrs;
611
612 typedef struct {
613     unsigned stacksize;
614     short    *s_base;
615     short    *s_mark;
616     short    *s_last;
617     YYSTYPE  *l_base;
618     YYSTYPE  *l_mark;
619 } YYSTACKDATA;
620 int      yyerrflag;
621 int      yychar;
622 YYSTYPE  yyval;
623 YYSTYPE  yylval;
624
625 /* variables for the parser stack */
626 static YYSTACKDATA yystack;
627 #line 945 "asn1parse.c"
628
629 void
630 yyerror (const char *s)
631 {
632      lex_error_message ("%s\n", s);
633 }
634
635 static Type *
636 new_tag(int tagclass, int tagvalue, int tagenv, Type *oldtype)
637 {
638     Type *t;
639     if(oldtype->type == TTag && oldtype->tag.tagenv == TE_IMPLICIT) {
640         t = oldtype;
641         oldtype = oldtype->subtype; /* XXX */
642     } else
643         t = new_type (TTag);
644
645     t->tag.tagclass = tagclass;
646     t->tag.tagvalue = tagvalue;
647     t->tag.tagenv = tagenv;
648     t->subtype = oldtype;
649     return t;
650 }
651
652 static struct objid *
653 new_objid(const char *label, int value)
654 {
655     struct objid *s;
656     s = emalloc(sizeof(*s));
657     s->label = label;
658     s->value = value;
659     s->next = NULL;
660     return s;
661 }
662
663 static void
664 add_oid_to_tail(struct objid *head, struct objid *tail)
665 {
666     struct objid *o;
667     o = head;
668     while (o->next)
669         o = o->next;
670     o->next = tail;
671 }
672
673 static Type *
674 new_type (Typetype tt)
675 {
676     Type *t = ecalloc(1, sizeof(*t));
677     t->type = tt;
678     return t;
679 }
680
681 static struct constraint_spec *
682 new_constraint_spec(enum ctype ct)
683 {
684     struct constraint_spec *c = ecalloc(1, sizeof(*c));
685     c->ctype = ct;
686     return c;
687 }
688
689 static void fix_labels2(Type *t, const char *prefix);
690 static void fix_labels1(struct memhead *members, const char *prefix)
691 {
692     Member *m;
693
694     if(members == NULL)
695         return;
696     ASN1_TAILQ_FOREACH(m, members, members) {
697         if (asprintf(&m->label, "%s_%s", prefix, m->gen_name) < 0)
698             errx(1, "malloc");
699         if (m->label == NULL)
700             errx(1, "malloc");
701         if(m->type != NULL)
702             fix_labels2(m->type, m->label);
703     }
704 }
705
706 static void fix_labels2(Type *t, const char *prefix)
707 {
708     for(; t; t = t->subtype)
709         fix_labels1(t->members, prefix);
710 }
711
712 static void
713 fix_labels(Symbol *s)
714 {
715     char *p = NULL;
716     if (asprintf(&p, "choice_%s", s->gen_name) < 0 || p == NULL)
717         errx(1, "malloc");
718     fix_labels2(s->type, p);
719     free(p);
720 }
721 #line 721 "asn1parse.c"
722
723 #if YYDEBUG
724 #include <stdio.h>              /* needed for printf */
725 #endif
726
727 #include <stdlib.h>     /* needed for malloc, etc */
728 #include <string.h>     /* needed for memset */
729
730 /* allocate initial stack or double stack size, up to YYMAXDEPTH */
731 static int yygrowstack(YYSTACKDATA *data)
732 {
733     int i;
734     unsigned newsize;
735     short *newss;
736     YYSTYPE *newvs;
737
738     if ((newsize = data->stacksize) == 0)
739         newsize = YYINITSTACKSIZE;
740     else if (newsize >= YYMAXDEPTH)
741         return -1;
742     else if ((newsize *= 2) > YYMAXDEPTH)
743         newsize = YYMAXDEPTH;
744
745     i = data->s_mark - data->s_base;
746     newss = (short *)realloc(data->s_base, newsize * sizeof(*newss));
747     if (newss == 0)
748         return -1;
749
750     data->s_base = newss;
751     data->s_mark = newss + i;
752
753     newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs));
754     if (newvs == 0)
755         return -1;
756
757     data->l_base = newvs;
758     data->l_mark = newvs + i;
759
760     data->stacksize = newsize;
761     data->s_last = data->s_base + newsize - 1;
762     return 0;
763 }
764
765 #if YYPURE || defined(YY_NO_LEAKS)
766 static void yyfreestack(YYSTACKDATA *data)
767 {
768     free(data->s_base);
769     free(data->l_base);
770     memset(data, 0, sizeof(*data));
771 }
772 #else
773 #define yyfreestack(data) /* nothing */
774 #endif
775
776 #define YYABORT  goto yyabort
777 #define YYREJECT goto yyabort
778 #define YYACCEPT goto yyaccept
779 #define YYERROR  goto yyerrlab
780
781 int
782 YYPARSE_DECL()
783 {
784     int yym, yyn, yystate;
785 #if YYDEBUG
786     const char *yys;
787
788     if ((yys = getenv("YYDEBUG")) != 0)
789     {
790         yyn = *yys;
791         if (yyn >= '0' && yyn <= '9')
792             yydebug = yyn - '0';
793     }
794 #endif
795
796     yynerrs = 0;
797     yyerrflag = 0;
798     yychar = YYEMPTY;
799     yystate = 0;
800
801 #if YYPURE
802     memset(&yystack, 0, sizeof(yystack));
803 #endif
804
805     if (yystack.s_base == NULL && yygrowstack(&yystack)) goto yyoverflow;
806     yystack.s_mark = yystack.s_base;
807     yystack.l_mark = yystack.l_base;
808     yystate = 0;
809     *yystack.s_mark = 0;
810
811 yyloop:
812     if ((yyn = yydefred[yystate]) != 0) goto yyreduce;
813     if (yychar < 0)
814     {
815         if ((yychar = YYLEX) < 0) yychar = 0;
816 #if YYDEBUG
817         if (yydebug)
818         {
819             yys = 0;
820             if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
821             if (!yys) yys = "illegal-symbol";
822             printf("%sdebug: state %d, reading %d (%s)\n",
823                     YYPREFIX, yystate, yychar, yys);
824         }
825 #endif
826     }
827     if ((yyn = yysindex[yystate]) && (yyn += yychar) >= 0 &&
828             yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
829     {
830 #if YYDEBUG
831         if (yydebug)
832             printf("%sdebug: state %d, shifting to state %d\n",
833                     YYPREFIX, yystate, yytable[yyn]);
834 #endif
835         if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack))
836         {
837             goto yyoverflow;
838         }
839         yystate = yytable[yyn];
840         *++yystack.s_mark = yytable[yyn];
841         *++yystack.l_mark = yylval;
842         yychar = YYEMPTY;
843         if (yyerrflag > 0)  --yyerrflag;
844         goto yyloop;
845     }
846     if ((yyn = yyrindex[yystate]) && (yyn += yychar) >= 0 &&
847             yyn <= YYTABLESIZE && yycheck[yyn] == yychar)
848     {
849         yyn = yytable[yyn];
850         goto yyreduce;
851     }
852     if (yyerrflag) goto yyinrecovery;
853
854     yyerror("syntax error");
855
856     goto yyerrlab;
857
858 yyerrlab:
859     ++yynerrs;
860
861 yyinrecovery:
862     if (yyerrflag < 3)
863     {
864         yyerrflag = 3;
865         for (;;)
866         {
867             if ((yyn = yysindex[*yystack.s_mark]) && (yyn += YYERRCODE) >= 0 &&
868                     yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE)
869             {
870 #if YYDEBUG
871                 if (yydebug)
872                     printf("%sdebug: state %d, error recovery shifting\
873  to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]);
874 #endif
875                 if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack))
876                 {
877                     goto yyoverflow;
878                 }
879                 yystate = yytable[yyn];
880                 *++yystack.s_mark = yytable[yyn];
881                 *++yystack.l_mark = yylval;
882                 goto yyloop;
883             }
884             else
885             {
886 #if YYDEBUG
887                 if (yydebug)
888                     printf("%sdebug: error recovery discarding state %d\n",
889                             YYPREFIX, *yystack.s_mark);
890 #endif
891                 if (yystack.s_mark <= yystack.s_base) goto yyabort;
892                 --yystack.s_mark;
893                 --yystack.l_mark;
894             }
895         }
896     }
897     else
898     {
899         if (yychar == 0) goto yyabort;
900 #if YYDEBUG
901         if (yydebug)
902         {
903             yys = 0;
904             if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
905             if (!yys) yys = "illegal-symbol";
906             printf("%sdebug: state %d, error recovery discards token %d (%s)\n",
907                     YYPREFIX, yystate, yychar, yys);
908         }
909 #endif
910         yychar = YYEMPTY;
911         goto yyloop;
912     }
913
914 yyreduce:
915 #if YYDEBUG
916     if (yydebug)
917         printf("%sdebug: state %d, reducing by rule %d (%s)\n",
918                 YYPREFIX, yystate, yyn, yyrule[yyn]);
919 #endif
920     yym = yylen[yyn];
921     if (yym)
922         yyval = yystack.l_mark[1-yym];
923     else
924         memset(&yyval, 0, sizeof yyval);
925     switch (yyn)
926     {
927 case 1:
928 #line 241 "asn1parse.c"
929         {
930                         checkundefined();
931                 }
932 break;
933 case 3:
934 #line 248 "asn1parse.c"
935         { lex_error_message("implicit tagging is not supported"); }
936 break;
937 case 4:
938 #line 250 "asn1parse.c"
939         { lex_error_message("automatic tagging is not supported"); }
940 break;
941 case 6:
942 #line 255 "asn1parse.c"
943         { lex_error_message("no extensibility options supported"); }
944 break;
945 case 16:
946 #line 276 "asn1parse.c"
947         {
948                     struct string_list *sl;
949                     for(sl = yystack.l_mark[-3].sl; sl != NULL; sl = sl->next) {
950                         Symbol *s = addsym(sl->string);
951                         s->stype = Stype;
952                         gen_template_import(s);
953                     }
954                     add_import(yystack.l_mark[-1].name);
955                 }
956 break;
957 case 17:
958 #line 288 "asn1parse.c"
959         {
960                     struct string_list *sl;
961                     for(sl = yystack.l_mark[-1].sl; sl != NULL; sl = sl->next)
962                         add_export(sl->string);
963                 }
964 break;
965 case 24:
966 #line 306 "asn1parse.c"
967         {
968                     yyval.sl = emalloc(sizeof(*yyval.sl));
969                     yyval.sl->string = yystack.l_mark[-2].name;
970                     yyval.sl->next = yystack.l_mark[0].sl;
971                 }
972 break;
973 case 25:
974 #line 312 "asn1parse.c"
975         {
976                     yyval.sl = emalloc(sizeof(*yyval.sl));
977                     yyval.sl->string = yystack.l_mark[0].name;
978                     yyval.sl->next = NULL;
979                 }
980 break;
981 case 26:
982 #line 320 "asn1parse.c"
983         {
984                     Symbol *s = addsym (yystack.l_mark[-2].name);
985                     s->stype = Stype;
986                     s->type = yystack.l_mark[0].type;
987                     fix_labels(s);
988                     generate_type (s);
989                 }
990 break;
991 case 44:
992 #line 351 "asn1parse.c"
993         {
994                         yyval.type = new_tag(ASN1_C_UNIV, UT_Boolean,
995                                      TE_EXPLICIT, new_type(TBoolean));
996                 }
997 break;
998 case 45:
999 #line 358 "asn1parse.c"
1000         {
1001                     if(yystack.l_mark[-3].value->type != integervalue)
1002                         lex_error_message("Non-integer used in first part of range");
1003                     if(yystack.l_mark[-3].value->type != integervalue)
1004                         lex_error_message("Non-integer in second part of range");
1005                     yyval.range = ecalloc(1, sizeof(*yyval.range));
1006                     yyval.range->min = yystack.l_mark[-3].value->u.integervalue;
1007                     yyval.range->max = yystack.l_mark[-1].value->u.integervalue;
1008                 }
1009 break;
1010 case 46:
1011 #line 368 "asn1parse.c"
1012         {
1013                     if(yystack.l_mark[-3].value->type != integervalue)
1014                         lex_error_message("Non-integer in first part of range");
1015                     yyval.range = ecalloc(1, sizeof(*yyval.range));
1016                     yyval.range->min = yystack.l_mark[-3].value->u.integervalue;
1017                     yyval.range->max = yystack.l_mark[-3].value->u.integervalue - 1;
1018                 }
1019 break;
1020 case 47:
1021 #line 376 "asn1parse.c"
1022         {
1023                     if(yystack.l_mark[-1].value->type != integervalue)
1024                         lex_error_message("Non-integer in second part of range");
1025                     yyval.range = ecalloc(1, sizeof(*yyval.range));
1026                     yyval.range->min = yystack.l_mark[-1].value->u.integervalue + 2;
1027                     yyval.range->max = yystack.l_mark[-1].value->u.integervalue;
1028                 }
1029 break;
1030 case 48:
1031 #line 384 "asn1parse.c"
1032         {
1033                     if(yystack.l_mark[-1].value->type != integervalue)
1034                         lex_error_message("Non-integer used in limit");
1035                     yyval.range = ecalloc(1, sizeof(*yyval.range));
1036                     yyval.range->min = yystack.l_mark[-1].value->u.integervalue;
1037                     yyval.range->max = yystack.l_mark[-1].value->u.integervalue;
1038                 }
1039 break;
1040 case 49:
1041 #line 395 "asn1parse.c"
1042         {
1043                         yyval.type = new_tag(ASN1_C_UNIV, UT_Integer,
1044                                      TE_EXPLICIT, new_type(TInteger));
1045                 }
1046 break;
1047 case 50:
1048 #line 400 "asn1parse.c"
1049         {
1050                         yyval.type = new_type(TInteger);
1051                         yyval.type->range = yystack.l_mark[0].range;
1052                         yyval.type = new_tag(ASN1_C_UNIV, UT_Integer, TE_EXPLICIT, yyval.type);
1053                 }
1054 break;
1055 case 51:
1056 #line 406 "asn1parse.c"
1057         {
1058                   yyval.type = new_type(TInteger);
1059                   yyval.type->members = yystack.l_mark[-1].members;
1060                   yyval.type = new_tag(ASN1_C_UNIV, UT_Integer, TE_EXPLICIT, yyval.type);
1061                 }
1062 break;
1063 case 52:
1064 #line 414 "asn1parse.c"
1065         {
1066                         yyval.members = emalloc(sizeof(*yyval.members));
1067                         ASN1_TAILQ_INIT(yyval.members);
1068                         ASN1_TAILQ_INSERT_HEAD(yyval.members, yystack.l_mark[0].member, members);
1069                 }
1070 break;
1071 case 53:
1072 #line 420 "asn1parse.c"
1073         {
1074                         ASN1_TAILQ_INSERT_TAIL(yystack.l_mark[-2].members, yystack.l_mark[0].member, members);
1075                         yyval.members = yystack.l_mark[-2].members;
1076                 }
1077 break;
1078 case 54:
1079 #line 425 "asn1parse.c"
1080         { yyval.members = yystack.l_mark[-2].members; }
1081 break;
1082 case 55:
1083 #line 429 "asn1parse.c"
1084         {
1085                         yyval.member = emalloc(sizeof(*yyval.member));
1086                         yyval.member->name = yystack.l_mark[-3].name;
1087                         yyval.member->gen_name = estrdup(yystack.l_mark[-3].name);
1088                         output_name (yyval.member->gen_name);
1089                         yyval.member->val = yystack.l_mark[-1].constant;
1090                         yyval.member->optional = 0;
1091                         yyval.member->ellipsis = 0;
1092                         yyval.member->type = NULL;
1093                 }
1094 break;
1095 case 56:
1096 #line 442 "asn1parse.c"
1097         {
1098                   yyval.type = new_type(TInteger);
1099                   yyval.type->members = yystack.l_mark[-1].members;
1100                   yyval.type = new_tag(ASN1_C_UNIV, UT_Enumerated, TE_EXPLICIT, yyval.type);
1101                 }
1102 break;
1103 case 58:
1104 #line 453 "asn1parse.c"
1105         {
1106                   yyval.type = new_type(TBitString);
1107                   yyval.type->members = emalloc(sizeof(*yyval.type->members));
1108                   ASN1_TAILQ_INIT(yyval.type->members);
1109                   yyval.type = new_tag(ASN1_C_UNIV, UT_BitString, TE_EXPLICIT, yyval.type);
1110                 }
1111 break;
1112 case 59:
1113 #line 460 "asn1parse.c"
1114         {
1115                   yyval.type = new_type(TBitString);
1116                   yyval.type->members = yystack.l_mark[-1].members;
1117                   yyval.type = new_tag(ASN1_C_UNIV, UT_BitString, TE_EXPLICIT, yyval.type);
1118                 }
1119 break;
1120 case 60:
1121 #line 468 "asn1parse.c"
1122         {
1123                         yyval.type = new_tag(ASN1_C_UNIV, UT_OID,
1124                                      TE_EXPLICIT, new_type(TOID));
1125                 }
1126 break;
1127 case 61:
1128 #line 474 "asn1parse.c"
1129         {
1130                     Type *t = new_type(TOctetString);
1131                     t->range = yystack.l_mark[0].range;
1132                     yyval.type = new_tag(ASN1_C_UNIV, UT_OctetString,
1133                                  TE_EXPLICIT, t);
1134                 }
1135 break;
1136 case 62:
1137 #line 483 "asn1parse.c"
1138         {
1139                         yyval.type = new_tag(ASN1_C_UNIV, UT_Null,
1140                                      TE_EXPLICIT, new_type(TNull));
1141                 }
1142 break;
1143 case 63:
1144 #line 490 "asn1parse.c"
1145         { yyval.range = NULL; }
1146 break;
1147 case 64:
1148 #line 492 "asn1parse.c"
1149         { yyval.range = yystack.l_mark[0].range; }
1150 break;
1151 case 65:
1152 #line 497 "asn1parse.c"
1153         {
1154                   yyval.type = new_type(TSequence);
1155                   yyval.type->members = yystack.l_mark[-1].members;
1156                   yyval.type = new_tag(ASN1_C_UNIV, UT_Sequence, TE_EXPLICIT, yyval.type);
1157                 }
1158 break;
1159 case 66:
1160 #line 503 "asn1parse.c"
1161         {
1162                   yyval.type = new_type(TSequence);
1163                   yyval.type->members = NULL;
1164                   yyval.type = new_tag(ASN1_C_UNIV, UT_Sequence, TE_EXPLICIT, yyval.type);
1165                 }
1166 break;
1167 case 67:
1168 #line 511 "asn1parse.c"
1169         {
1170                   yyval.type = new_type(TSequenceOf);
1171                   yyval.type->range = yystack.l_mark[-2].range;
1172                   yyval.type->subtype = yystack.l_mark[0].type;
1173                   yyval.type = new_tag(ASN1_C_UNIV, UT_Sequence, TE_EXPLICIT, yyval.type);
1174                 }
1175 break;
1176 case 68:
1177 #line 520 "asn1parse.c"
1178         {
1179                   yyval.type = new_type(TSet);
1180                   yyval.type->members = yystack.l_mark[-1].members;
1181                   yyval.type = new_tag(ASN1_C_UNIV, UT_Set, TE_EXPLICIT, yyval.type);
1182                 }
1183 break;
1184 case 69:
1185 #line 526 "asn1parse.c"
1186         {
1187                   yyval.type = new_type(TSet);
1188                   yyval.type->members = NULL;
1189                   yyval.type = new_tag(ASN1_C_UNIV, UT_Set, TE_EXPLICIT, yyval.type);
1190                 }
1191 break;
1192 case 70:
1193 #line 534 "asn1parse.c"
1194         {
1195                   yyval.type = new_type(TSetOf);
1196                   yyval.type->subtype = yystack.l_mark[0].type;
1197                   yyval.type = new_tag(ASN1_C_UNIV, UT_Set, TE_EXPLICIT, yyval.type);
1198                 }
1199 break;
1200 case 71:
1201 #line 542 "asn1parse.c"
1202         {
1203                   yyval.type = new_type(TChoice);
1204                   yyval.type->members = yystack.l_mark[-1].members;
1205                 }
1206 break;
1207 case 74:
1208 #line 553 "asn1parse.c"
1209         {
1210                   Symbol *s = addsym(yystack.l_mark[0].name);
1211                   yyval.type = new_type(TType);
1212                   if(s->stype != Stype && s->stype != SUndefined)
1213                     lex_error_message ("%s is not a type\n", yystack.l_mark[0].name);
1214                   else
1215                     yyval.type->symbol = s;
1216                 }
1217 break;
1218 case 75:
1219 #line 564 "asn1parse.c"
1220         {
1221                         yyval.type = new_tag(ASN1_C_UNIV, UT_GeneralizedTime,
1222                                      TE_EXPLICIT, new_type(TGeneralizedTime));
1223                 }
1224 break;
1225 case 76:
1226 #line 569 "asn1parse.c"
1227         {
1228                         yyval.type = new_tag(ASN1_C_UNIV, UT_UTCTime,
1229                                      TE_EXPLICIT, new_type(TUTCTime));
1230                 }
1231 break;
1232 case 77:
1233 #line 576 "asn1parse.c"
1234         {
1235                     /* if (Constraint.type == contentConstrant) {
1236                        assert(Constraint.u.constraint.type == octetstring|bitstring-w/o-NamedBitList); // remember to check type reference too
1237                        if (Constraint.u.constraint.type) {
1238                          assert((Constraint.u.constraint.type.length % 8) == 0);
1239                        }
1240                       }
1241                       if (Constraint.u.constraint.encoding) {
1242                         type == der-oid|ber-oid
1243                       }
1244                     */
1245                 }
1246 break;
1247 case 78:
1248 #line 592 "asn1parse.c"
1249         {
1250                     yyval.constraint_spec = yystack.l_mark[-1].constraint_spec;
1251                 }
1252 break;
1253 case 82:
1254 #line 605 "asn1parse.c"
1255         {
1256                     yyval.constraint_spec = new_constraint_spec(CT_CONTENTS);
1257                     yyval.constraint_spec->u.content.type = yystack.l_mark[0].type;
1258                     yyval.constraint_spec->u.content.encoding = NULL;
1259                 }
1260 break;
1261 case 83:
1262 #line 611 "asn1parse.c"
1263         {
1264                     if (yystack.l_mark[0].value->type != objectidentifiervalue)
1265                         lex_error_message("Non-OID used in ENCODED BY constraint");
1266                     yyval.constraint_spec = new_constraint_spec(CT_CONTENTS);
1267                     yyval.constraint_spec->u.content.type = NULL;
1268                     yyval.constraint_spec->u.content.encoding = yystack.l_mark[0].value;
1269                 }
1270 break;
1271 case 84:
1272 #line 619 "asn1parse.c"
1273         {
1274                     if (yystack.l_mark[0].value->type != objectidentifiervalue)
1275                         lex_error_message("Non-OID used in ENCODED BY constraint");
1276                     yyval.constraint_spec = new_constraint_spec(CT_CONTENTS);
1277                     yyval.constraint_spec->u.content.type = yystack.l_mark[-3].type;
1278                     yyval.constraint_spec->u.content.encoding = yystack.l_mark[0].value;
1279                 }
1280 break;
1281 case 85:
1282 #line 629 "asn1parse.c"
1283         {
1284                     yyval.constraint_spec = new_constraint_spec(CT_USER);
1285                 }
1286 break;
1287 case 86:
1288 #line 635 "asn1parse.c"
1289         {
1290                         yyval.type = new_type(TTag);
1291                         yyval.type->tag = yystack.l_mark[-2].tag;
1292                         yyval.type->tag.tagenv = yystack.l_mark[-1].constant;
1293                         if(yystack.l_mark[0].type->type == TTag && yystack.l_mark[-1].constant == TE_IMPLICIT) {
1294                                 yyval.type->subtype = yystack.l_mark[0].type->subtype;
1295                                 free(yystack.l_mark[0].type);
1296                         } else
1297                                 yyval.type->subtype = yystack.l_mark[0].type;
1298                 }
1299 break;
1300 case 87:
1301 #line 648 "asn1parse.c"
1302         {
1303                         yyval.tag.tagclass = yystack.l_mark[-2].constant;
1304                         yyval.tag.tagvalue = yystack.l_mark[-1].constant;
1305                         yyval.tag.tagenv = TE_EXPLICIT;
1306                 }
1307 break;
1308 case 88:
1309 #line 656 "asn1parse.c"
1310         {
1311                         yyval.constant = ASN1_C_CONTEXT;
1312                 }
1313 break;
1314 case 89:
1315 #line 660 "asn1parse.c"
1316         {
1317                         yyval.constant = ASN1_C_UNIV;
1318                 }
1319 break;
1320 case 90:
1321 #line 664 "asn1parse.c"
1322         {
1323                         yyval.constant = ASN1_C_APPL;
1324                 }
1325 break;
1326 case 91:
1327 #line 668 "asn1parse.c"
1328         {
1329                         yyval.constant = ASN1_C_PRIVATE;
1330                 }
1331 break;
1332 case 92:
1333 #line 674 "asn1parse.c"
1334         {
1335                         yyval.constant = TE_EXPLICIT;
1336                 }
1337 break;
1338 case 93:
1339 #line 678 "asn1parse.c"
1340         {
1341                         yyval.constant = TE_EXPLICIT;
1342                 }
1343 break;
1344 case 94:
1345 #line 682 "asn1parse.c"
1346         {
1347                         yyval.constant = TE_IMPLICIT;
1348                 }
1349 break;
1350 case 95:
1351 #line 689 "asn1parse.c"
1352         {
1353                         Symbol *s;
1354                         s = addsym (yystack.l_mark[-3].name);
1355
1356                         s->stype = SValue;
1357                         s->value = yystack.l_mark[0].value;
1358                         generate_constant (s);
1359                 }
1360 break;
1361 case 97:
1362 #line 703 "asn1parse.c"
1363         {
1364                         yyval.type = new_tag(ASN1_C_UNIV, UT_GeneralString,
1365                                      TE_EXPLICIT, new_type(TGeneralString));
1366                 }
1367 break;
1368 case 98:
1369 #line 708 "asn1parse.c"
1370         {
1371                         yyval.type = new_tag(ASN1_C_UNIV, UT_TeletexString,
1372                                      TE_EXPLICIT, new_type(TTeletexString));
1373                 }
1374 break;
1375 case 99:
1376 #line 713 "asn1parse.c"
1377         {
1378                         yyval.type = new_tag(ASN1_C_UNIV, UT_UTF8String,
1379                                      TE_EXPLICIT, new_type(TUTF8String));
1380                 }
1381 break;
1382 case 100:
1383 #line 718 "asn1parse.c"
1384         {
1385                         yyval.type = new_tag(ASN1_C_UNIV, UT_PrintableString,
1386                                      TE_EXPLICIT, new_type(TPrintableString));
1387                 }
1388 break;
1389 case 101:
1390 #line 723 "asn1parse.c"
1391         {
1392                         yyval.type = new_tag(ASN1_C_UNIV, UT_VisibleString,
1393                                      TE_EXPLICIT, new_type(TVisibleString));
1394                 }
1395 break;
1396 case 102:
1397 #line 728 "asn1parse.c"
1398         {
1399                         yyval.type = new_tag(ASN1_C_UNIV, UT_IA5String,
1400                                      TE_EXPLICIT, new_type(TIA5String));
1401                 }
1402 break;
1403 case 103:
1404 #line 733 "asn1parse.c"
1405         {
1406                         yyval.type = new_tag(ASN1_C_UNIV, UT_BMPString,
1407                                      TE_EXPLICIT, new_type(TBMPString));
1408                 }
1409 break;
1410 case 104:
1411 #line 738 "asn1parse.c"
1412         {
1413                         yyval.type = new_tag(ASN1_C_UNIV, UT_UniversalString,
1414                                      TE_EXPLICIT, new_type(TUniversalString));
1415                 }
1416 break;
1417 case 105:
1418 #line 746 "asn1parse.c"
1419         {
1420                         yyval.members = emalloc(sizeof(*yyval.members));
1421                         ASN1_TAILQ_INIT(yyval.members);
1422                         ASN1_TAILQ_INSERT_HEAD(yyval.members, yystack.l_mark[0].member, members);
1423                 }
1424 break;
1425 case 106:
1426 #line 752 "asn1parse.c"
1427         {
1428                         ASN1_TAILQ_INSERT_TAIL(yystack.l_mark[-2].members, yystack.l_mark[0].member, members);
1429                         yyval.members = yystack.l_mark[-2].members;
1430                 }
1431 break;
1432 case 107:
1433 #line 757 "asn1parse.c"
1434         {
1435                         struct member *m = ecalloc(1, sizeof(*m));
1436                         m->name = estrdup("...");
1437                         m->gen_name = estrdup("asn1_ellipsis");
1438                         m->ellipsis = 1;
1439                         ASN1_TAILQ_INSERT_TAIL(yystack.l_mark[-2].members, m, members);
1440                         yyval.members = yystack.l_mark[-2].members;
1441                 }
1442 break;
1443 case 108:
1444 #line 768 "asn1parse.c"
1445         {
1446                   yyval.member = emalloc(sizeof(*yyval.member));
1447                   yyval.member->name = yystack.l_mark[-1].name;
1448                   yyval.member->gen_name = estrdup(yystack.l_mark[-1].name);
1449                   output_name (yyval.member->gen_name);
1450                   yyval.member->type = yystack.l_mark[0].type;
1451                   yyval.member->ellipsis = 0;
1452                 }
1453 break;
1454 case 109:
1455 #line 779 "asn1parse.c"
1456         {
1457                         yyval.member = yystack.l_mark[0].member;
1458                         yyval.member->optional = 0;
1459                         yyval.member->defval = NULL;
1460                 }
1461 break;
1462 case 110:
1463 #line 785 "asn1parse.c"
1464         {
1465                         yyval.member = yystack.l_mark[-1].member;
1466                         yyval.member->optional = 1;
1467                         yyval.member->defval = NULL;
1468                 }
1469 break;
1470 case 111:
1471 #line 791 "asn1parse.c"
1472         {
1473                         yyval.member = yystack.l_mark[-2].member;
1474                         yyval.member->optional = 0;
1475                         yyval.member->defval = yystack.l_mark[0].value;
1476                 }
1477 break;
1478 case 112:
1479 #line 799 "asn1parse.c"
1480         {
1481                         yyval.members = emalloc(sizeof(*yyval.members));
1482                         ASN1_TAILQ_INIT(yyval.members);
1483                         ASN1_TAILQ_INSERT_HEAD(yyval.members, yystack.l_mark[0].member, members);
1484                 }
1485 break;
1486 case 113:
1487 #line 805 "asn1parse.c"
1488         {
1489                         ASN1_TAILQ_INSERT_TAIL(yystack.l_mark[-2].members, yystack.l_mark[0].member, members);
1490                         yyval.members = yystack.l_mark[-2].members;
1491                 }
1492 break;
1493 case 114:
1494 #line 812 "asn1parse.c"
1495         {
1496                   yyval.member = emalloc(sizeof(*yyval.member));
1497                   yyval.member->name = yystack.l_mark[-3].name;
1498                   yyval.member->gen_name = estrdup(yystack.l_mark[-3].name);
1499                   output_name (yyval.member->gen_name);
1500                   yyval.member->val = yystack.l_mark[-1].constant;
1501                   yyval.member->optional = 0;
1502                   yyval.member->ellipsis = 0;
1503                   yyval.member->type = NULL;
1504                 }
1505 break;
1506 case 116:
1507 #line 825 "asn1parse.c"
1508         { yyval.objid = NULL; }
1509 break;
1510 case 117:
1511 #line 829 "asn1parse.c"
1512         {
1513                         yyval.objid = yystack.l_mark[-1].objid;
1514                 }
1515 break;
1516 case 118:
1517 #line 835 "asn1parse.c"
1518         {
1519                         yyval.objid = NULL;
1520                 }
1521 break;
1522 case 119:
1523 #line 839 "asn1parse.c"
1524         {
1525                         if (yystack.l_mark[0].objid) {
1526                                 yyval.objid = yystack.l_mark[0].objid;
1527                                 add_oid_to_tail(yystack.l_mark[0].objid, yystack.l_mark[-1].objid);
1528                         } else {
1529                                 yyval.objid = yystack.l_mark[-1].objid;
1530                         }
1531                 }
1532 break;
1533 case 120:
1534 #line 850 "asn1parse.c"
1535         {
1536                         yyval.objid = new_objid(yystack.l_mark[-3].name, yystack.l_mark[-1].constant);
1537                 }
1538 break;
1539 case 121:
1540 #line 854 "asn1parse.c"
1541         {
1542                     Symbol *s = addsym(yystack.l_mark[0].name);
1543                     if(s->stype != SValue ||
1544                        s->value->type != objectidentifiervalue) {
1545                         lex_error_message("%s is not an object identifier\n",
1546                                       s->name);
1547                         exit(1);
1548                     }
1549                     yyval.objid = s->value->u.objectidentifiervalue;
1550                 }
1551 break;
1552 case 122:
1553 #line 865 "asn1parse.c"
1554         {
1555                     yyval.objid = new_objid(NULL, yystack.l_mark[0].constant);
1556                 }
1557 break;
1558 case 132:
1559 #line 888 "asn1parse.c"
1560         {
1561                         Symbol *s = addsym(yystack.l_mark[0].name);
1562                         if(s->stype != SValue)
1563                                 lex_error_message ("%s is not a value\n",
1564                                                 s->name);
1565                         else
1566                                 yyval.value = s->value;
1567                 }
1568 break;
1569 case 133:
1570 #line 899 "asn1parse.c"
1571         {
1572                         yyval.value = emalloc(sizeof(*yyval.value));
1573                         yyval.value->type = stringvalue;
1574                         yyval.value->u.stringvalue = yystack.l_mark[0].name;
1575                 }
1576 break;
1577 case 134:
1578 #line 907 "asn1parse.c"
1579         {
1580                         yyval.value = emalloc(sizeof(*yyval.value));
1581                         yyval.value->type = booleanvalue;
1582                         yyval.value->u.booleanvalue = 0;
1583                 }
1584 break;
1585 case 135:
1586 #line 913 "asn1parse.c"
1587         {
1588                         yyval.value = emalloc(sizeof(*yyval.value));
1589                         yyval.value->type = booleanvalue;
1590                         yyval.value->u.booleanvalue = 0;
1591                 }
1592 break;
1593 case 136:
1594 #line 921 "asn1parse.c"
1595         {
1596                         yyval.value = emalloc(sizeof(*yyval.value));
1597                         yyval.value->type = integervalue;
1598                         yyval.value->u.integervalue = yystack.l_mark[0].constant;
1599                 }
1600 break;
1601 case 138:
1602 #line 932 "asn1parse.c"
1603         {
1604                 }
1605 break;
1606 case 139:
1607 #line 937 "asn1parse.c"
1608         {
1609                         yyval.value = emalloc(sizeof(*yyval.value));
1610                         yyval.value->type = objectidentifiervalue;
1611                         yyval.value->u.objectidentifiervalue = yystack.l_mark[0].objid;
1612                 }
1613 break;
1614 #line 1614 "asn1parse.c"
1615     }
1616     yystack.s_mark -= yym;
1617     yystate = *yystack.s_mark;
1618     yystack.l_mark -= yym;
1619     yym = yylhs[yyn];
1620     if (yystate == 0 && yym == 0)
1621     {
1622 #if YYDEBUG
1623         if (yydebug)
1624             printf("%sdebug: after reduction, shifting from state 0 to\
1625  state %d\n", YYPREFIX, YYFINAL);
1626 #endif
1627         yystate = YYFINAL;
1628         *++yystack.s_mark = YYFINAL;
1629         *++yystack.l_mark = yyval;
1630         if (yychar < 0)
1631         {
1632             if ((yychar = YYLEX) < 0) yychar = 0;
1633 #if YYDEBUG
1634             if (yydebug)
1635             {
1636                 yys = 0;
1637                 if (yychar <= YYMAXTOKEN) yys = yyname[yychar];
1638                 if (!yys) yys = "illegal-symbol";
1639                 printf("%sdebug: state %d, reading %d (%s)\n",
1640                         YYPREFIX, YYFINAL, yychar, yys);
1641             }
1642 #endif
1643         }
1644         if (yychar == 0) goto yyaccept;
1645         goto yyloop;
1646     }
1647     if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 &&
1648             yyn <= YYTABLESIZE && yycheck[yyn] == yystate)
1649         yystate = yytable[yyn];
1650     else
1651         yystate = yydgoto[yym];
1652 #if YYDEBUG
1653     if (yydebug)
1654         printf("%sdebug: after reduction, shifting from state %d \
1655 to state %d\n", YYPREFIX, *yystack.s_mark, yystate);
1656 #endif
1657     if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack))
1658     {
1659         goto yyoverflow;
1660     }
1661     *++yystack.s_mark = (short) yystate;
1662     *++yystack.l_mark = yyval;
1663     goto yyloop;
1664
1665 yyoverflow:
1666     yyerror("yacc stack overflow");
1667
1668 yyabort:
1669     yyfreestack(&yystack);
1670     return (1);
1671
1672 yyaccept:
1673     yyfreestack(&yystack);
1674     return (0);
1675 }