1 /* $NetBSD: xebec.c,v 1.11 2007/01/18 12:43:38 cbiere Exp $ */
4 __RCSID("$NetBSD: xebec.c,v 1.11 2007/01/18 12:43:38 cbiere Exp $");
9 #define E_TABLE "xebec.e"
18 extern FILE *eventfile_h
, *actfile
;
21 llaction(int lln
,LLtoken
*token
)
23 struct llattr
*llattr
;
25 llattr
= &llattrdesc
[lldescindex
-1];
33 if(strlen(llattr
->llabase
[3].ID
.address
) > 50 ) {
35 "Protocol name may not exceed 50 chars in length.\n");
38 strcpy(protocol
, llattr
->llabase
[3].ID
.address
);
45 llattr
->llabase
[7].pcb
.isevent
= 0;
51 fprintf(actfile
, "\ntypedef %s %s%s;\n",
52 llattr
->llabase
[7].pcb
.address
,protocol
, PCBNAME
);
53 llattr
->llabase
[8].syn
.type
= PCB_SYN
;
58 llattr
->llabase
[11].part
.type
= (unsigned char) STATESET
;
62 end_states(eventfile_h
);
66 llattr
->llabase
[14].pcb
.isevent
= 1;
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
;
80 llattr
->llabase
[16].part
.type
= (unsigned char)EVENTSET
;
91 putdriver(actfile
, 9);
96 if(llattr
->llabase
[0].pcb
.isevent
) {
98 "Event is a list of objects enclosed by \"{}\"\n");
101 fprintf(eventfile_h
, "struct ");
106 llattr
->llabase
[0].pcb
.address
= llattr
->llabase
[2].ACTION
.address
;
110 if( ! llattr
->llabase
[0].pcb
.isevent
) {
112 "Pcb requires a type or structure definition.\"{}\"\n");
115 llattr
->llabase
[0].pcb
.address
= llattr
->llabase
[1].ACTION
.address
;
120 llattr
->llabase
[0].pcb
.address
= llattr
->llabase
[1].ID
.address
;
124 synonyms
[llattr
->llabase
[0].syn
.type
] = stash( llattr
->llabase
[2].ID
.address
);
128 includecode(actfile
, llattr
->llabase
[2].ACTION
.address
);
133 llattr
->llabase
[2].partrest
.address
= llattr
->llabase
[1].ID
.address
;
134 llattr
->llabase
[2].partrest
.type
= llattr
->llabase
[0].part
.type
;
139 llattr
->llabase
[3].parttail
.type
= llattr
->llabase
[0].part
.type
;
143 llattr
->llabase
[1].part
.type
= llattr
->llabase
[0].parttail
.type
;
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
);
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;
160 llattr
->llabase
[3].setstruct
.object
= llattr
->llabase
[2].setdef
.object
;
165 defineitem(llattr
->llabase
[0].partrest
.type
,
166 llattr
->llabase
[0].partrest
.address
, llattr
->llabase
[1].ACTION
.address
);
172 defineitem(llattr
->llabase
[0].partrest
.type
, llattr
->llabase
[0].partrest
.address
, (char *)0);
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
;
186 "struct %s %s%s;\n\n", llattr
->llabase
[1].ACTION
.address
,
187 EV_PREFIX
, llattr
->llabase
[0].setstruct
.object
->obj_name
);
194 llattr
->llabase
[2].setlist
.setnum
=
195 defineset(llattr
->llabase
[0].setdef
.type
, llattr
->llabase
[0].setdef
.address
, llattr
->llabase
[0].setdef
.keep
);
200 llattr
->llabase
[0].setdef
.object
= llattr
->llabase
[2].setlist
.setnum
;
205 member(llattr
->llabase
[0].setlist
.setnum
, llattr
->llabase
[1].ID
.address
);
206 llattr
->llabase
[2].setlisttail
.setnum
= llattr
->llabase
[0].setlist
.setnum
;
211 llattr
->llabase
[2].setlist
.setnum
= llattr
->llabase
[0].setlisttail
.setnum
;
220 CurrentEvent
/* GAG! */ = llattr
->llabase
[6].event
.object
;
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
;
234 llattr
->llabase
[0].predicatepart
.string
= stash ( llattr
->llabase
[1].PREDICATE
.address
);
240 llattr
->llabase
[0].predicatepart
.string
= (char *)0;
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
),
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
);
260 statetable(llattr
->llabase
[0].actionpart
.string
, llattr
->llabase
[0].actionpart
.oldstate
, llattr
->llabase
[0].actionpart
.newstate
,
261 0, CurrentEvent
); /* KLUDGE - remove this */
263 dump_trans( llattr
->llabase
[0].actionpart
.string
, llattr
->llabase
[0].actionpart
.oldstate
,
264 llattr
->llabase
[0].actionpart
.newstate
,
265 "NULLACTION", CurrentEvent
);
272 llattr
->llabase
[0].oldstate
.object
= Lookup(STATESET
, llattr
->llabase
[1].ID
.address
);
278 llattr
->llabase
[1].setdef
.address
= (char *)0;
279 llattr
->llabase
[1].setdef
.type
= (unsigned char)STATESET
;
280 llattr
->llabase
[1].setdef
.keep
= 0;
286 llattr
->llabase
[0].oldstate
.object
= llattr
->llabase
[1].setdef
.object
;
292 llattr
->llabase
[0].newstate
.object
= Lookup(STATESET
, llattr
->llabase
[1].ID
.address
);
298 extern struct Object
*SameState
;
300 llattr
->llabase
[0].newstate
.object
= SameState
;
306 llattr
->llabase
[0].event
.object
= Lookup(EVENTSET
, llattr
->llabase
[1].ID
.address
);
312 llattr
->llabase
[1].setdef
.address
= (char *)0;
313 llattr
->llabase
[1].setdef
.type
= (unsigned char)EVENTSET
;
314 llattr
->llabase
[1].setdef
.keep
= 0;
320 llattr
->llabase
[0].event
.object
= llattr
->llabase
[1].setdef
.object
;
325 char *llstrings
[] = {
375 short llinfinite
= 10000;
376 short llproductions
[] = {
388 30, -30, 31, -29, 10,
395 17, 38, -40, 37, -39, 34, 35, 10, 10, 9, -38, 36,
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,
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 },
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,