Annotation of 43BSDReno/sys/netiso/xebec/xebec.bnf, revision 1.1.1.1

1.1       root        1: {
                      2: #include "main.h"
                      3: #include "sets.h"
                      4: #include <stdio.h> 
                      5: 
                      6: extern FILE *eventfile_h, *actfile; 
                      7: }
                      8: 
                      9: *fmq
                     10: 
                     11:        novocab
                     12:        nobnf
                     13:        nofirst
                     14:        nofollow
                     15:        noparsetable
                     16:        noerrortables
                     17:        nos
                     18:        noe
                     19: 
                     20: *terminals
                     21: 
                     22: ID                     0       0       { char *address; }
                     23: STRUCT         0       0
                     24: SYNONYM                0       0
                     25: PREDICATE              0       0       { char *address; }
                     26: ACTION         0       0       { char *address; }
                     27: /*
                     28: FSTRING                0       0       { char *address; }
                     29: */
                     30: PROTOCOL       0       0       
                     31: LBRACK         0       0
                     32: RBRACK         0       0
                     33: LANGLE         0       0
                     34: EQUAL          0       0
                     35: COMMA          0       0
                     36: STAR           0       0
                     37: EVENTS         0       0
                     38: TRANSITIONS    0       0
                     39: INCLUDE                0       0
                     40: STATES         0       0
                     41: SEMI           0       0
                     42: PCB                    0       0               { char *address; }
                     43: DEFAULT                0       0
                     44: NULLACTION     0       0
                     45: SAME           0       0
                     46: 
                     47: *nonterminals
                     48: 
                     49: pcb                            { char *address; int isevent; }
                     50: syn                            { int type; }
                     51: setlist                        { struct Object *setnum; }
                     52: setlisttail            { struct Object *setnum; }
                     53: part                   { unsigned char type; }
                     54: parttail               { unsigned char type; }
                     55: partrest               { unsigned char type; char *address; }
                     56: setstruct              { struct Object *object; }
                     57: setdef                 { unsigned char type,keep; char *address; struct Object *object; }
                     58: translist              
                     59: transition     
                     60: event                  { struct Object *object;  }
                     61: oldstate               {       struct Object *object;  }
                     62: newstate               {       struct Object *object;  }
                     63: predicatepart  {       char *string; }
                     64: actionpart             {       char *string; struct Object *oldstate; struct Object *newstate; }
                     65: 
                     66: *productions
                     67: 
                     68: program        ::= 
                     69:                                STAR PROTOCOL ID 
                     70:                                {       
                     71:                                        if(strlen($ID.address) > 50 ) {
                     72:                                                fprintf(stderr, 
                     73:                                                "Protocol name may not exceed 50 chars in length.\n"); 
                     74:                                                Exit(-1);
                     75:                                        }
                     76:                                        strcpy(protocol, $ID.address); 
                     77:                                        openfiles(protocol); 
                     78:                                }
                     79:                                STAR includelist
                     80:                                PCB  
                     81:                                { 
                     82:                                        $$pcb.isevent = 0; 
                     83:                                }
                     84:                                pcb 
                     85:                                {
                     86:                                  fprintf(actfile, "\ntypedef %s %s%s;\n",
                     87:                                                          $pcb[7].address,protocol, PCBNAME); 
                     88:                                  $$syn.type = PCB_SYN;
                     89:                                } 
                     90:                                syn 
                     91:                                STAR STATES { $$part.type = (unsigned char) STATESET; } part
                     92:                                STAR { end_states(eventfile_h); } EVENTS 
                     93:                                { $$pcb.isevent = 1; }
                     94:                                pcb 
                     95:                                {
                     96:                                        fprintf(eventfile_h, "\t"); /* fmq gags on single chars */
                     97:                                        includecode(eventfile_h, $pcb[14].address);
                     98:                                        fprintf(eventfile_h, "\n"); /* fmq gags on single chars */
                     99:                                        $$syn.type = EVENT_SYN;
                    100:                                }
                    101:                                syn 
                    102:                                { 
                    103:                                        $$part.type = (unsigned char)EVENTSET; 
                    104:                                } 
                    105:                                part 
                    106:                                STAR { end_events(); } 
                    107:                                TRANSITIONS 
                    108:                                { 
                    109:                                        putincludes();
                    110:                                        putdriver(actfile, 9);
                    111:                                } 
                    112:                                translist
                    113: ;
                    114: pcb    ::=  STRUCT  
                    115:                         {      if($pcb.isevent)  {
                    116:                                        fprintf(stderr, 
                    117:                                        "Event is a list of objects enclosed by \"{}\"\n");
                    118:                                        Exit(-1);
                    119:                                }
                    120:                          fprintf(eventfile_h, "struct "); 
                    121:                        }
                    122:                         ACTION { $pcb.address = $ACTION.address; }
                    123:                         optsemi
                    124:                ::=      ACTION 
                    125:                        {       if( ! $pcb.isevent)  {
                    126:                                        fprintf(stderr, 
                    127:                                        "Pcb requires a type or structure definition.\"{}\"\n");
                    128:                                        Exit(-1);
                    129:                                }
                    130:                           $pcb.address = $ACTION.address; 
                    131:                        }
                    132:                         optsemi
                    133:                ::=  ID {  $pcb.address = $ID.address; } optsemi
                    134: ;
                    135: 
                    136: syn ::= SYNONYM ID { synonyms[$syn.type] = stash( $ID.address ); }
                    137:                ::= 
                    138: ;
                    139: 
                    140: optsemi ::= SEMI 
                    141:                ::= 
                    142: ;
                    143: includelist ::= INCLUDE ACTION { includecode(actfile, $ACTION.address);} STAR
                    144:                        ::=
                    145: ;
                    146: part ::= ID 
                    147:                { 
                    148:                        $$partrest.address = $ID.address;
                    149:                        $$partrest.type = $part.type; 
                    150:                }
                    151:                partrest  
                    152:                { $$parttail.type = $part.type; } 
                    153:                parttail
                    154: ;
                    155: parttail ::= { $$part.type = $parttail.type; } part 
                    156:                ::=  
                    157: ;
                    158: partrest ::=  EQUAL 
                    159:                        { 
                    160:                          if(  lookup( $partrest.type, $partrest.address ) ) {
                    161:                                fprintf(stderr, "bnf:trying to redefine obj type 0x%x, adr %s\n",
                    162:                                        $partrest.type, $partrest.address);
                    163:                                Exit(-1);
                    164:                          } 
                    165:                          $$setdef.type = $partrest.type;
                    166:                          $$setdef.address = stash( $partrest.address );
                    167:                          $$setdef.keep = 1;
                    168:                        } setdef { $$setstruct.object = $setdef.object; } setstruct
                    169: 
                    170:        ::=  ACTION 
                    171:                { 
                    172:                 defineitem($partrest.type, 
                    173:                                        $partrest.address, $ACTION.address); 
                    174:                }
                    175: 
                    176:        ::= { 
                    177:                        defineitem($partrest.type, $partrest.address, (char *)0);
                    178:                }
                    179: ;
                    180: 
                    181: setstruct ::= ACTION 
                    182:                        {
                    183:                                if($setstruct.object)  {
                    184:                                        /* WHEN COULD THIS BE FALSE?? 
                    185:                                         * isn't it supposed to be setstruct.object???
                    186:                                         * (it used to be $ACTION.address)
                    187:                                         */
                    188: 
                    189:                                        $setstruct.object->obj_struc = $ACTION.address;
                    190:                                        fprintf(eventfile_h, 
                    191:                                                "struct %s %s%s;\n\n", $ACTION.address, 
                    192:                                                EV_PREFIX,  $setstruct.object->obj_name);
                    193:                                }
                    194:                        }
                    195:                ::=
                    196: ;
                    197: 
                    198: setdef ::= LBRACK 
                    199:                { 
                    200:                        $$setlist.setnum = 
                    201:                        defineset($setdef.type, $setdef.address, $setdef.keep); 
                    202:                } setlist RBRACK { $setdef.object = $setlist.setnum; }
                    203: ;
                    204: 
                    205: setlist ::= ID 
                    206:        { 
                    207:                member($setlist.setnum, $ID.address); 
                    208:                                $$setlisttail.setnum = $setlist.setnum; 
                    209:        } setlisttail 
                    210: ;
                    211: 
                    212: setlisttail ::= COMMA { $$setlist.setnum = $setlisttail.setnum; } setlist
                    213:                ::=
                    214: ;
                    215: translist              ::=      transition  translisttail 
                    216: ;
                    217: translisttail  ::= translist
                    218:        ::=     
                    219: ;
                    220: transition ::=  newstate { transno ++; } LANGLE EQUAL EQUAL oldstate  
                    221:        event 
                    222:        { 
                    223:                CurrentEvent /* GAG! */ = $event.object; 
                    224:         }
                    225:        predicatepart
                    226:        { 
                    227:                $$actionpart.string = $predicatepart.string; 
                    228:                $$actionpart.newstate = $newstate.object; 
                    229:                $$actionpart.oldstate = $oldstate.object;
                    230:        }
                    231:        actionpart
                    232:        SEMI
                    233: ;
                    234: 
                    235: predicatepart ::= PREDICATE
                    236:        { 
                    237:                 $predicatepart.string = stash ( $PREDICATE.address );
                    238:        }
                    239:        ::= DEFAULT
                    240:        { 
                    241:                $predicatepart.string = (char *)0;
                    242:        }
                    243: ;
                    244: 
                    245: actionpart ::=  
                    246:        ACTION
                    247:        {
                    248:          statetable( $actionpart.string, $actionpart.oldstate, 
                    249:                                        $actionpart.newstate,
                    250:                                        acttable(actfile, $ACTION.address ), 
                    251:                                        CurrentEvent ); 
                    252:          if( print_trans ) {
                    253:                dump_trans( $actionpart.string, $actionpart.oldstate, 
                    254:                                        $actionpart.newstate,
                    255:                                        $ACTION.address, CurrentEvent ); 
                    256:          }
                    257:        }
                    258:        ::= NULLACTION
                    259:        {
                    260:          statetable($actionpart.string, $actionpart.oldstate, $actionpart.newstate,
                    261:                                  0, CurrentEvent ); /* KLUDGE - remove this */
                    262:          if( print_trans ) {
                    263:                dump_trans( $actionpart.string, $actionpart.oldstate, 
                    264:                                        $actionpart.newstate,
                    265:                                        "NULLACTION", CurrentEvent ); 
                    266:          }
                    267:        }
                    268: ;
                    269: 
                    270: oldstate ::= ID 
                    271:        {       
                    272:                $oldstate.object = Lookup(STATESET, $ID.address);
                    273:        }
                    274:        ::= {
                    275:                        $$setdef.address = (char *)0;
                    276:                        $$setdef.type = (unsigned char)STATESET; 
                    277:                        $$setdef.keep = 0;
                    278:                }
                    279:                setdef 
                    280:                { 
                    281:                        $oldstate.object = $setdef.object; 
                    282:                }
                    283: ;
                    284: 
                    285: newstate ::= ID 
                    286:        { 
                    287:                $newstate.object = Lookup(STATESET, $ID.address); 
                    288:        }
                    289: ;
                    290: 
                    291: newstate ::= SAME 
                    292:        { 
                    293:                extern struct Object *SameState;
                    294: 
                    295:                $newstate.object = SameState;
                    296:        }
                    297: ;
                    298: 
                    299: event ::= ID 
                    300:                {
                    301:                        $event.object = Lookup(EVENTSET, $ID.address); 
                    302:                }
                    303:        ::= 
                    304:                {
                    305:                        $$setdef.address = (char *)0;
                    306:                        $$setdef.type = (unsigned char)EVENTSET; 
                    307:                        $$setdef.keep = 0;
                    308:                }
                    309:                setdef 
                    310:                { 
                    311:                        $event.object = $setdef.object; 
                    312:                }
                    313: ;
                    314: 
                    315: *end

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.