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