Expand PMF_FN_* macros.
[netbsd-mini2440.git] / sys / netiso / xebec / xebec.c
blob12c9a1f9bf612320ca66de3ea24ca85a1508bf24
1 /* $NetBSD: xebec.c,v 1.11 2007/01/18 12:43:38 cbiere Exp $ */
3 #include <sys/cdefs.h>
4 __RCSID("$NetBSD: xebec.c,v 1.11 2007/01/18 12:43:38 cbiere Exp $");
6 #include "xebec.h"
7 #include "llparse.h"
8 #ifndef E_TABLE
9 #define E_TABLE "xebec.e"
10 #endif /* !E_TABLE */
12 #include "main.h"
13 #include "sets.h"
14 #include "procs.h"
15 #include <stdio.h>
16 #include <string.h>
18 extern FILE *eventfile_h, *actfile;
20 void
21 llaction(int lln,LLtoken *token)
23 struct llattr *llattr;
24 (void) token;
25 llattr = &llattrdesc[lldescindex-1];
26 switch(lln) {
27 case 1:
28 llfinprod();
29 break;
31 case 10: {
33 if(strlen(llattr->llabase[3].ID.address) > 50 ) {
34 fprintf(stderr,
35 "Protocol name may not exceed 50 chars in length.\n");
36 Exit(-1);
38 strcpy(protocol, llattr->llabase[3].ID.address);
39 openfiles(protocol);
41 } break;
43 case 11: {
45 llattr->llabase[7].pcb.isevent = 0;
47 } break;
49 case 12: {
51 fprintf(actfile, "\ntypedef %s %s%s;\n",
52 llattr->llabase[7].pcb.address,protocol, PCBNAME);
53 llattr->llabase[8].syn.type = PCB_SYN;
55 } break;
57 case 13: {
58 llattr->llabase[11].part.type = (unsigned char) STATESET;
59 } break;
61 case 14: {
62 end_states(eventfile_h);
63 } break;
65 case 15: {
66 llattr->llabase[14].pcb.isevent = 1;
67 } break;
69 case 16: {
71 fprintf(eventfile_h, "\t"); /* fmq gags on single chars */
72 includecode(eventfile_h, llattr->llabase[14].pcb.address);
73 fprintf(eventfile_h, "\n"); /* fmq gags on single chars */
74 llattr->llabase[15].syn.type = EVENT_SYN;
76 } break;
78 case 17: {
80 llattr->llabase[16].part.type = (unsigned char)EVENTSET;
82 } break;
84 case 18: {
85 end_events();
86 } break;
88 case 19: {
90 putincludes();
91 putdriver(actfile, 9);
93 } break;
95 case 20: {
96 if(llattr->llabase[0].pcb.isevent) {
97 fprintf(stderr,
98 "Event is a list of objects enclosed by \"{}\"\n");
99 Exit(-1);
101 fprintf(eventfile_h, "struct ");
103 } break;
105 case 21: {
106 llattr->llabase[0].pcb.address = llattr->llabase[2].ACTION.address;
107 } break;
109 case 22: {
110 if( ! llattr->llabase[0].pcb.isevent) {
111 fprintf(stderr,
112 "Pcb requires a type or structure definition.\"{}\"\n");
113 Exit(-1);
115 llattr->llabase[0].pcb.address = llattr->llabase[1].ACTION.address;
117 } break;
119 case 23: {
120 llattr->llabase[0].pcb.address = llattr->llabase[1].ID.address;
121 } break;
123 case 24: {
124 synonyms[llattr->llabase[0].syn.type] = stash( llattr->llabase[2].ID.address );
125 } break;
127 case 25: {
128 includecode(actfile, llattr->llabase[2].ACTION.address);
129 } break;
131 case 26: {
133 llattr->llabase[2].partrest.address = llattr->llabase[1].ID.address;
134 llattr->llabase[2].partrest.type = llattr->llabase[0].part.type;
136 } break;
138 case 27: {
139 llattr->llabase[3].parttail.type = llattr->llabase[0].part.type;
140 } break;
142 case 28: {
143 llattr->llabase[1].part.type = llattr->llabase[0].parttail.type;
144 } break;
146 case 29: {
148 if( lookup( llattr->llabase[0].partrest.type, llattr->llabase[0].partrest.address ) ) {
149 fprintf(stderr, "bnf:trying to redefine obj type 0x%x, adr %s\n",
150 llattr->llabase[0].partrest.type, llattr->llabase[0].partrest.address);
151 Exit(-1);
153 llattr->llabase[2].setdef.type = llattr->llabase[0].partrest.type;
154 llattr->llabase[2].setdef.address = stash( llattr->llabase[0].partrest.address );
155 llattr->llabase[2].setdef.keep = 1;
157 } break;
159 case 30: {
160 llattr->llabase[3].setstruct.object = llattr->llabase[2].setdef.object;
161 } break;
163 case 31: {
165 defineitem(llattr->llabase[0].partrest.type,
166 llattr->llabase[0].partrest.address, llattr->llabase[1].ACTION.address);
168 } break;
170 case 32: {
172 defineitem(llattr->llabase[0].partrest.type, llattr->llabase[0].partrest.address, (char *)0);
174 } break;
176 case 33: {
178 if(llattr->llabase[0].setstruct.object) {
179 /* WHEN COULD THIS BE FALSE??
180 * isn't it supposed to be setstruct.object???
181 * (it used to be $ACTION.address)
184 llattr->llabase[0].setstruct.object->obj_struc = llattr->llabase[1].ACTION.address;
185 fprintf(eventfile_h,
186 "struct %s %s%s;\n\n", llattr->llabase[1].ACTION.address,
187 EV_PREFIX, llattr->llabase[0].setstruct.object->obj_name);
190 } break;
192 case 34: {
194 llattr->llabase[2].setlist.setnum =
195 defineset(llattr->llabase[0].setdef.type, llattr->llabase[0].setdef.address, llattr->llabase[0].setdef.keep);
197 } break;
199 case 35: {
200 llattr->llabase[0].setdef.object = llattr->llabase[2].setlist.setnum;
201 } break;
203 case 36: {
205 member(llattr->llabase[0].setlist.setnum, llattr->llabase[1].ID.address);
206 llattr->llabase[2].setlisttail.setnum = llattr->llabase[0].setlist.setnum;
208 } break;
210 case 37: {
211 llattr->llabase[2].setlist.setnum = llattr->llabase[0].setlisttail.setnum;
212 } break;
214 case 38: {
215 transno++;
216 } break;
218 case 39: {
220 CurrentEvent /* GAG! */ = llattr->llabase[6].event.object;
222 } break;
224 case 40: {
226 llattr->llabase[8].actionpart.string = llattr->llabase[7].predicatepart.string;
227 llattr->llabase[8].actionpart.newstate = llattr->llabase[1].newstate.object;
228 llattr->llabase[8].actionpart.oldstate = llattr->llabase[5].oldstate.object;
230 } break;
232 case 41: {
234 llattr->llabase[0].predicatepart.string = stash ( llattr->llabase[1].PREDICATE.address );
236 } break;
238 case 42: {
240 llattr->llabase[0].predicatepart.string = (char *)0;
242 } break;
244 case 43: {
246 statetable( llattr->llabase[0].actionpart.string, llattr->llabase[0].actionpart.oldstate,
247 llattr->llabase[0].actionpart.newstate,
248 acttable(actfile, llattr->llabase[1].ACTION.address ),
249 CurrentEvent );
250 if( print_trans ) {
251 dump_trans( llattr->llabase[0].actionpart.string, llattr->llabase[0].actionpart.oldstate,
252 llattr->llabase[0].actionpart.newstate,
253 llattr->llabase[1].ACTION.address, CurrentEvent );
256 } break;
258 case 44: {
260 statetable(llattr->llabase[0].actionpart.string, llattr->llabase[0].actionpart.oldstate, llattr->llabase[0].actionpart.newstate,
261 0, CurrentEvent ); /* KLUDGE - remove this */
262 if( print_trans ) {
263 dump_trans( llattr->llabase[0].actionpart.string, llattr->llabase[0].actionpart.oldstate,
264 llattr->llabase[0].actionpart.newstate,
265 "NULLACTION", CurrentEvent );
268 } break;
270 case 45: {
272 llattr->llabase[0].oldstate.object = Lookup(STATESET, llattr->llabase[1].ID.address);
274 } break;
276 case 46: {
278 llattr->llabase[1].setdef.address = (char *)0;
279 llattr->llabase[1].setdef.type = (unsigned char)STATESET;
280 llattr->llabase[1].setdef.keep = 0;
282 } break;
284 case 47: {
286 llattr->llabase[0].oldstate.object = llattr->llabase[1].setdef.object;
288 } break;
290 case 48: {
292 llattr->llabase[0].newstate.object = Lookup(STATESET, llattr->llabase[1].ID.address);
294 } break;
296 case 49: {
298 extern struct Object *SameState;
300 llattr->llabase[0].newstate.object = SameState;
302 } break;
304 case 50: {
306 llattr->llabase[0].event.object = Lookup(EVENTSET, llattr->llabase[1].ID.address);
308 } break;
310 case 51: {
312 llattr->llabase[1].setdef.address = (char *)0;
313 llattr->llabase[1].setdef.type = (unsigned char)EVENTSET;
314 llattr->llabase[1].setdef.keep = 0;
316 } break;
318 case 52: {
320 llattr->llabase[0].event.object = llattr->llabase[1].setdef.object;
322 } break;
325 char *llstrings[] = {
326 "<null>",
327 "ID",
328 "STRUCT",
329 "SYNONYM",
330 "PREDICATE",
331 "ACTION",
332 "PROTOCOL",
333 "LBRACK",
334 "RBRACK",
335 "LANGLE",
336 "EQUAL",
337 "COMMA",
338 "STAR",
339 "EVENTS",
340 "TRANSITIONS",
341 "INCLUDE",
342 "STATES",
343 "SEMI",
344 "PCB",
345 "DEFAULT",
346 "NULLACTION",
347 "SAME",
348 "ENDMARKER",
349 "pcb",
350 "syn",
351 "setlist",
352 "setlisttail",
353 "part",
354 "parttail",
355 "partrest",
356 "setstruct",
357 "setdef",
358 "translist",
359 "transition",
360 "event",
361 "oldstate",
362 "newstate",
363 "predicatepart",
364 "actionpart",
365 "program",
366 "includelist",
367 "optsemi",
368 "translisttail",
369 "$goal$",
370 (char *) 0
372 short llnterms = 23;
373 short llnsyms = 44;
374 short llnprods = 38;
375 short llinfinite = 10000;
376 short llproductions[] = {
377 41, -21, 5, -20, 2,
378 41, -22, 5,
379 41, -23, 1,
380 -24, 1, 3,
382 26, -36, 1,
383 25, -37, 11,
385 28, -27, 29, -26, 1,
386 27, -28,
388 30, -30, 31, -29, 10,
389 -31, 5,
390 -32,
391 -33, 5,
393 -35, 8, 25, -34, 7,
394 42, 33,
395 17, 38, -40, 37, -39, 34, 35, 10, 10, 9, -38, 36,
396 -50, 1,
397 -52, 31, -51,
398 -45, 1,
399 -47, 31, -46,
400 -48, 1,
401 -49, 21,
402 -41, 4,
403 -42, 19,
404 -43, 5,
405 -44, 20,
406 32, -19, 14, -18, 12, 27, -17, 24, -16, 23, -15, 13, -14, 12, 27, -13, 16, 12, 24, -12, 23, -11, 18, 40, 12, -10, 1, 6, 12,
407 12, -25, 5, 15,
413 22, 39,
416 struct llprodindex llprodindex[] = {
417 { 0, 0, 0 }, { 0, 5, 19 }, { 5, 3, 3 }, { 8, 3, 2 },
418 { 11, 3, 2 }, { 14, 0, 2 }, { 14, 3, 0 }, { 17, 3, 1 },
419 { 20, 0, 0 }, { 20, 5, 3 }, { 25, 2, 0 }, { 27, 0, 3 },
420 { 27, 5, 1 }, { 32, 2, 0 }, { 34, 1, 3 }, { 35, 2, 1 },
421 { 37, 0, 0 }, { 37, 5, 1 }, { 42, 2, 0 }, { 44, 12, 3 },
422 { 56, 2, 2 }, { 58, 3, 2 }, { 61, 2, 0 }, { 63, 3, 2 },
423 { 66, 2, 1 }, { 68, 2, 0 }, { 70, 2, 9 }, { 72, 2, 1 },
424 { 74, 2, 1 }, { 76, 2, 1 }, { 78, 29, 1 }, { 107, 4, 1 },
425 { 111, 0, 1 }, { 111, 1, 1 }, { 112, 0, 1 }, { 112, 1, 1 },
426 { 113, 0, 1 }, { 113, 2, 2 }, { 0, 0, 0 }
428 short llepsilon[] = {
429 0, 0, 0, 0, 0, 1, 0, 0, 1, 0,
430 0, 1, 0, 0, 1, 0, 1, 0, 0, 0,
431 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
432 0, 0, 1, 0, 1, 0, 1, 0, 0
434 struct llparsetable llparsetable[] = {
435 { 1, 3 }, { 2, 1 }, { 5, 2 }, { 0, 23 }, { 1, 5 },
436 { 3, 4 }, { 12, 5 }, { 0, 24 }, { 1, 6 }, { 0, 25 },
437 { 8, 8 }, { 11, 7 }, { 0, 26 }, { 1, 9 }, { 0, 27 },
438 { 1, 10 }, { 12, 11 }, { 0, 28 }, { 1, 14 }, { 5, 13 },
439 { 10, 12 }, { 12, 14 }, { 0, 29 }, { 1, 16 }, { 5, 15 },
440 { 12, 16 }, { 0, 30 }, { 7, 17 }, { 0, 31 }, { 1, 18 },
441 { 21, 18 }, { 0, 32 }, { 1, 19 }, { 21, 19 }, { 0, 33 },
442 { 1, 20 }, { 7, 21 }, { 0, 34 }, { 1, 22 }, { 7, 23 },
443 { 0, 35 }, { 1, 24 }, { 21, 25 }, { 0, 36 }, { 4, 26 },
444 { 19, 27 }, { 0, 37 }, { 5, 28 }, { 20, 29 }, { 0, 38 },
445 { 12, 30 }, { 0, 39 }, { 15, 31 }, { 18, 32 }, { 0, 40 },
446 { 1, 34 }, { 3, 34 }, { 12, 34 }, { 17, 33 }, { 0, 41 },
447 { 1, 35 }, { 21, 35 }, { 22, 36 }, { 0, 42 }, { 12, 37 },
448 { 0, 43 }, { 0, 0 }
450 short llparseindex[] = {
451 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
452 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
453 0, 0, 0, 0, 4, 8, 10, 13, 15, 18,
454 23, 27, 29, 32, 35, 38, 41, 44, 47, 50,
455 52, 55, 60, 64, 0