1 /* $NetBSD: xebec.bnf,v 1.5.22.1 2005/02/15 21:33:40 skrll Exp $ */
8 extern FILE *eventfile_h, *actfile;
24 ID
0 0 { char *address;
}
27 PREDICATE
0 0 { char *address;
}
28 ACTION
0 0 { char *address;
}
30 FSTRING 0 0 { char *address; }
44 PCB
0 0 { char *address;
}
51 pcb
{ char *address; int isevent;
}
53 setlist
{ struct Object *setnum;
}
54 setlisttail
{ struct Object *setnum;
}
55 part
{ unsigned char type;
}
56 parttail
{ unsigned char type;
}
57 partrest
{ unsigned char type; char *address;
}
58 setstruct
{ struct Object *object;
}
59 setdef
{ unsigned char type,keep; char *address; struct Object *object;
}
62 event
{ struct Object *object;
}
63 oldstate
{ struct Object *object;
}
64 newstate
{ struct Object *object;
}
65 predicatepart
{ char *string;
}
66 actionpart
{ char *string; struct Object *oldstate; struct Object *newstate;
}
73 if
(strlen
($ID
.address
) >
50 ) {
75 "Protocol name may not exceed 50 chars in length.\n");
78 strcpy
(protocol, $ID
.address
);
88 fprintf
(actfile,
"\ntypedef %s %s%s;\n",
89 $pcb
[7].address,protocol, PCBNAME
);
93 STAR STATES
{ $$part
.type
= (unsigned char
) STATESET;
} part
94 STAR
{ end_states
(eventfile_h
);
} EVENTS
95 { $$pcb
.isevent
= 1;
}
98 fprintf
(eventfile_h,
"\t");
/* fmq gags on single chars */
99 includecode
(eventfile_h, $pcb
[14].address
);
100 fprintf
(eventfile_h,
"\n");
/* fmq gags on single chars */
101 $$syn
.type
= EVENT_SYN;
105 $$part
.type
= (unsigned char
)EVENTSET;
108 STAR
{ end_events
();
}
112 putdriver
(actfile,
9);
119 "Event is a list of objects enclosed by \"{}\"\n");
122 fprintf
(eventfile_h,
"struct ");
124 ACTION
{ $pcb
.address
= $ACTION
.address;
}
127 { if
( ! $pcb
.isevent
) {
129 "Pcb requires a type or structure definition.\"{}\"\n");
132 $pcb
.address
= $ACTION
.address;
135 ::= ID
{ $pcb
.address
= $ID
.address;
} optsemi
138 syn ::= SYNONYM ID
{ synonyms
[$syn
.type
] = stash
( $ID
.address
);
}
145 includelist ::= INCLUDE ACTION
{ includecode
(actfile, $ACTION
.address
);
} STAR
150 $$partrest
.address
= $ID
.address;
151 $$partrest
.type
= $part
.type;
154 { $$parttail
.type
= $part
.type;
}
157 parttail ::= { $$part
.type
= $parttail
.type;
} part
162 if
( lookup
( $partrest
.type, $partrest
.address
) ) {
163 fprintf
(stderr,
"bnf:trying to redefine obj type 0x%x, adr %s\n",
164 $partrest
.type, $partrest
.address
);
167 $$setdef
.type
= $partrest
.type;
168 $$setdef
.address
= stash
( $partrest
.address
);
170 } setdef
{ $$setstruct
.object
= $setdef
.object;
} setstruct
174 defineitem
($partrest
.type,
175 $partrest
.address, $ACTION
.address
);
179 defineitem
($partrest
.type, $partrest
.address,
(char *
)0);
185 if
($setstruct
.object
) {
186 /* WHEN COULD THIS BE FALSE??
187 * isn't it supposed to be setstruct.object???
188 * (it used to be $ACTION.address)
191 $setstruct
.object->obj_struc
= $ACTION
.address;
193 "struct %s %s%s;\n\n", $ACTION
.address,
194 EV_PREFIX, $setstruct
.object->obj_name
);
203 defineset
($setdef
.type, $setdef
.address, $setdef
.keep
);
204 } setlist RBRACK
{ $setdef
.object
= $setlist
.setnum;
}
209 member
($setlist
.setnum, $ID
.address
);
210 $$setlisttail
.setnum
= $setlist
.setnum;
214 setlisttail ::= COMMA
{ $$setlist
.setnum
= $setlisttail
.setnum;
} setlist
217 translist ::= transition translisttail
219 translisttail ::= translist
222 transition ::= newstate
{ transno++;
} LANGLE EQUAL EQUAL oldstate
225 CurrentEvent
/* GAG! */ = $event
.object;
229 $$actionpart
.string
= $predicatepart
.string;
230 $$actionpart
.newstate
= $newstate
.object;
231 $$actionpart
.oldstate
= $oldstate
.object;
237 predicatepart ::= PREDICATE
239 $predicatepart
.string
= stash
( $PREDICATE
.address
);
243 $predicatepart
.string
= (char *
)0;
250 statetable
( $actionpart
.string, $actionpart
.oldstate,
251 $actionpart
.newstate,
252 acttable
(actfile, $ACTION
.address
),
255 dump_trans
( $actionpart
.string, $actionpart
.oldstate,
256 $actionpart
.newstate,
257 $ACTION
.address, CurrentEvent
);
262 statetable
($actionpart
.string, $actionpart
.oldstate, $actionpart
.newstate,
263 0, CurrentEvent
);
/* KLUDGE - remove this */
265 dump_trans
( $actionpart
.string, $actionpart
.oldstate,
266 $actionpart
.newstate,
267 "NULLACTION", CurrentEvent
);
274 $oldstate
.object
= Lookup
(STATESET, $ID
.address
);
277 $$setdef
.address
= (char *
)0;
278 $$setdef
.type
= (unsigned char
)STATESET;
283 $oldstate
.object
= $setdef
.object;
289 $newstate
.object
= Lookup
(STATESET, $ID
.address
);
295 extern struct Object *SameState;
297 $newstate
.object
= SameState;
303 $event
.object
= Lookup
(EVENTSET, $ID
.address
);
307 $$setdef
.address
= (char *
)0;
308 $$setdef
.type
= (unsigned char
)EVENTSET;
313 $event
.object
= $setdef
.object;