1: # include "../mcons.h"
   2: struct  {
   3:         int cl[NUMC];
   4:     }tab[NUMS];
   5: char    state[NUMS][SIZS];
   6: char    class[NUMC][SIZC];
   7: char    act[NUMA][SIZA];
   8: char    def[NUMS][SIZA];
   9: char    temp[SIZA];
  10: 
  11: char    *st[NUMS];
  12: char    *df[NUMS];
  13: char    *cl[NUMC];
  14: char    *ac[NUMA];
  15: 
  16: int t1;
  17: int t2;
  18: 
  19: 
  20: main(argc,argv) char    **argv;
  21: {
  22: 
  23:     extern  fin;
  24:     char    fl,nlfl,c,bfl,fo,brk;
  25:     int cs,ca,cc,i,j,cd;
  26: 
  27:     if(argc != 3) {
  28:         printf("Usage: mtab input output\n");
  29:         exit();
  30:     }
  31: 
  32:     if((fo = creat(argv[2],0644)) < 0) {
  33:         printf("Output file.\n");
  34:         exit();
  35:     }
  36:     if((fin = open(argv[1],0)) < 0) {
  37:         printf("Input file.\n");
  38:         exit();
  39:     }
  40: 
  41: 
  42: 
  43:     nlfl = 1;
  44:     i = -1;
  45:     while(brk = rword()) {
  46:         switch (brk) {
  47:             case '\n':
  48:                 if(nlfl) {
  49:                     move(temp,state[++i]);
  50:                     st[i] = &state[i];
  51:                 } else {
  52:                     move(temp,def[i]);
  53:                     df[i] = &def[i];
  54:                     nlfl = 1;
  55:                 }
  56:                 continue;
  57:             case ' ':
  58:                 if(nlfl) {
  59:                     move(temp,state[++i]);
  60:                     st[i] = &state[i];
  61:                     nlfl = 0;
  62:                 } else {
  63:                     error(7);
  64:                 }
  65:                 continue;
  66:         }
  67:     }
  68: 
  69: 
  70:     i = 128;
  71:     while(--i) {
  72:         class[i][0] = i;
  73:         class[i][1] = '\0';
  74:         cl[i] = &class[i];
  75:     }
  76:     cl[0] = &class[0];
  77: 
  78: 
  79:     bfl = nlfl = 0;
  80:     t1 = 0;
  81:     t2 = -1;
  82:     while(c = getchar()) {
  83: 
  84:         switch(c) {
  85: 
  86:             default:
  87:                 if(t1 >= NUMA)  error(4);
  88:                 bfl = nlfl = 0;
  89:                 act[t1][++t2<8?t2:7] = c;
  90:                 continue;
  91: 
  92:             case '\n':
  93:                 if(nlfl)    break;
  94:                 nlfl = 1;
  95: 
  96:             case ' ':
  97:                 if(bfl) continue;
  98:                 bfl = 1;
  99:                 act[t1][++t2<8?t2:7] = '\0';
 100:                 ac[t1] = &act[t1];
 101:                 t1++;
 102:                 t2 = -1;
 103:                 continue;
 104:         }
 105:     break;
 106:     }
 107:     if(c == '\0')   exit();
 108: 
 109:     i = -1;
 110:     while(++i < NUMS) {
 111:         if(df[i]) {
 112:             cd = find(ac,df[i],NUMA);
 113:             j = -1;
 114:             while(++j < NUMC)
 115:                 tab[i].cl[j] = cd;
 116:         }
 117:     }
 118: 
 119: 
 120:     fl = 0;
 121:     i = -1;
 122:     while(c = getchar()) {
 123: 
 124:         switch(c) {
 125: 
 126:             case '\\':
 127:                 temp[++i] = getchar();
 128:                 continue;
 129: 
 130:             case '\n':
 131:                 if(fl != 1) continue;
 132: 
 133:             default:
 134:                 temp[++i] = c;
 135:                 continue;
 136: 
 137:             case '/':
 138:                 temp[++i] = '\0';
 139:                 i = -1;
 140:                 switch(fl) {
 141:                     case 0:
 142:                         cs = find(st,temp,NUMS);
 143:                         fl = 1;
 144:                         continue;
 145: 
 146:                     case 1:
 147:                         cc = find(cl,temp,NUMC);
 148:                         fl = 2;
 149:                         continue;
 150: 
 151:                     default:
 152:                         error(1);
 153: 
 154:                 }
 155: 
 156:             case ';':
 157: 
 158:                 if(fl != 2) error(2);
 159: 
 160:                 temp[++i] = '\0';
 161:                 i = -1;
 162:                 ca = find(ac,temp,NUMA);
 163: 
 164: /*printf("%o %o %o\n",cs,cc,ca); /*DEBUG*/
 165:                 tab[cs].cl[cc] = ca;
 166: 
 167:                 fl = 0;
 168:                 continue;
 169: 
 170: 
 171:         }
 172:     }
 173: 
 174:     i = -1;
 175:     while(++i < NUMS)
 176:         write(fo,tab[i].cl,256);
 177: 
 178: }
 179: 
 180: error(a)
 181: {
 182: 
 183:     printf("Error %d\n",a);
 184:     exit();
 185: 
 186: }
 187: 
 188: find(a,b,c) char    (*a[])[];
 189:         char    b[];
 190:         int c;
 191: {
 192:     int i,j;
 193: 
 194: /*	printf("%s\n",b); /*DEBUG*/
 195:     i = -1;
 196:     while(++i < c) {
 197: /*	printf("	%s\n",a[i]); /*DEBUG*/
 198:         j = 0;
 199: /*	printf("b = %c\ta = %c\n",b[0],(*a[i])[0]); /*DEBUG*/
 200:         while(b[j] == (*a[i])[j]) {
 201:             if(b[j] == '\0')    goto found;
 202:             j++;
 203:         }
 204:     }
 205: found:
 206:     return(i);
 207: }
 208: 
 209: rword() {
 210: 
 211:     char    c;
 212:     int ct;
 213: 
 214:     ct = -1;
 215:     while(c = getchar()) {
 216:         switch(c) {
 217: 
 218:             default:
 219:                 temp[++ct] = c;
 220:                 continue;
 221: 
 222:             case '\n':
 223:                 if(ct == -1)    return('\0');
 224:             case ' ':
 225:                 temp[++ct] = '\0';
 226:                 return(c);
 227:         }
 228:     }
 229: }
 230: 
 231: move(a,b)   char    *a;
 232:         char    *b;
 233: {
 234:     while((*b++ = *a++) != '\0');
 235:     return;
 236: }

Defined functions

error defined in line 180; used 4 times
find defined in line 188; used 4 times
main defined in line 20; never used
move defined in line 231; used 3 times
rword defined in line 209; used 1 times
  • in line 45

Defined variables

ac defined in line 14; used 3 times
act defined in line 7; used 3 times
cl defined in line 13; used 7 times
class defined in line 6; used 4 times
def defined in line 8; used 2 times
df defined in line 12; used 3 times
st defined in line 11; used 3 times
state defined in line 5; used 4 times
t1 defined in line 16; used 7 times
t2 defined in line 17; used 6 times
temp defined in line 9; used 12 times
Last modified: 1975-05-14
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 1369
Valid CSS Valid XHTML 1.0 Strict