|
|
1.1 ! root 1: %{ ! 2: /* NOTICE-NOT TO BE DISCLOSED OUTSIDE BELL SYS EXCEPT UNDER WRITTEN AGRMT */ ! 3: /* Writer's Workbench version 2.0, January 1981 */ ! 4: #include <ctype.h> ! 5: int catch = 1; ! 6: int ct = 0; ! 7: int ret=0; ! 8: int linect = 0; ! 9: char name[50]; ! 10: int i; ! 11: char *p; ! 12: FILE *fopen(), *cat; ! 13: %} ! 14: %% ! 15: verb"\t"to\n search(); ! 16: art"\t"a\n cons(); ! 17: art"\t"an\n vowel(); ! 18: ^"."[0-9]+ linect = atoi(&yytext[1]); ! 19: ^".F ".* { ! 20: p = name; ! 21: for(i=3;i<yyleng;i++) ! 22: *p++ = yytext[i]; ! 23: } ! 24: . | ! 25: \n ; ! 26: %% ! 27: cons(){ ! 28: int c; ! 29: int f; ! 30: char *w1; ! 31: char w[100]; ! 32: w1 = w; ! 33: while((c=input()) != '\t')*w1++ = c; ! 34: if(strncmp("conj",w,4) == 0)return(ret); ! 35: if(strncmp("prep",w,4) == 0)return(ret); ! 36: if(strncmp("be",w,2) == 0)return(ret); ! 37: if(strncmp("verb",w,4) == 0)return(ret); ! 38: w1 = w; ! 39: while((f=input()) == ' '); ! 40: if(!isalpha(f))return(ret); ! 41: if(isupper(f))return(ret); ! 42: if(f == 'a'||f == 'e'||f =='i'||f =='o'||f == 'u'|| f == 'h'){ ! 43: *w1++ = f; ! 44: while((c=input()) != '\n'){ ! 45: if(!isalpha(c))break; ! 46: *w1++ = c; ! 47: } ! 48: if(w1 < &w[2])return(ret); ! 49: *w1 = '\0'; ! 50: if(f == 'h'){ ! 51: if(hexc(w)== 0)return(ret); ! 52: } else if(f == 'u'){ ! 53: if(uexc(w) == 1)return(ret); ! 54: } else if(f == 'e'){ ! 55: if(w[1] == 'u')return(ret); ! 56: } else if(f == 'o'){ ! 57: if(strncmp("one",w,3) == 0)return(ret); ! 58: if(strncmp("once",w,4) == 0)return(ret); ! 59: } ! 60: ret = 1; ! 61: if(++ct == 1)printf("Possible grammatical errors:\n"); ! 62: printf("\t\"a %s\" should be \"an %s\"",w,w); ! 63: printf(" after line %d file %s\n",linect,name); ! 64: } ! 65: return(ret); ! 66: } ! 67: vowel(){ ! 68: int c,f; ! 69: char *w1; ! 70: char w[100]; ! 71: w1 = w; ! 72: while((c=input()) != '\t')*w1++ = c; ! 73: if(strncmp("conj",w,4) == 0)return(ret); ! 74: if(strncmp("prep",w,4) == 0)return(ret); ! 75: if(strncmp("be",w,4) == 0)return(ret); ! 76: if(strncmp("verb",w,4) == 0)return(ret); ! 77: w1 = w; ! 78: while((f=input()) == ' '); ! 79: if(!isalpha(f))return(ret); ! 80: if(isupper(f))return(ret); ! 81: if(f != 'a' && f != 'i' ){ ! 82: *w1++ = f; ! 83: while((c=input()) != '\n'){ ! 84: if(!isalpha(c))break; ! 85: *w1++ = c; ! 86: } ! 87: if(w1 < &w[2])return(ret); ! 88: *w1 = '\0'; ! 89: if(f == 'h'){ ! 90: if(hexc(w))return(ret); ! 91: } ! 92: else if(f == 'u'){ ! 93: if(uexc(w) == 0)return(ret); ! 94: } else if(f == 'e'){ ! 95: if(w[1] != 'u')return(ret); ! 96: } else if(f == 'o' ){ ! 97: if( strncmp("one",w,3) != 0)return(ret); ! 98: if(strncmp("once",w,4) != 0)return(ret); ! 99: } ! 100: ret = 1; ! 101: if(++ct == 1)printf("Possible grammatical errors:\n"); ! 102: printf("\t\"an %s\" should be \"a %s\"",w,w); ! 103: printf(" after line %d file %s\n",linect,name); ! 104: } ! 105: return(ret); ! 106: } ! 107: search() ! 108: { ! 109: char *sv; ! 110: int c; ! 111: char *w1, *p1, *p2; ! 112: char words[100]; ! 113: char part1[10],part2[10]; ! 114: int f; ! 115: #ifdef SPCATCH ! 116: if(catch != 2){ ! 117: if((cat=fopen(SPCATCH,"a"))==NULL) catch=0; ! 118: else catch = 2; ! 119: } ! 120: #else ! 121: catch=0; ! 122: #endif ! 123: w1 = words; ! 124: f = 0; ! 125: more: ! 126: for(p1 = part1; (c= input())!= '\t';) ! 127: *p1++ = c; ! 128: while((c=input())!='\n') ! 129: *w1++ = c; ! 130: *w1++ = ' '; ! 131: if(strncmp(part1,"adv",3) != 0) ! 132: return(ret); ! 133: ! 134: while(1){ ! 135: for(p2=part2;(c=input())!='\t';) ! 136: *p2++ = c; ! 137: if(strncmp(part2,"verb",4) != 0) ! 138: break; ! 139: ! 140: sv = w1; ! 141: while((c=input())!='\n') ! 142: *w1++ = c; ! 143: if(strncmp(sv,"to",2) == 0 && w1 == sv+2)break; ! 144: *w1++ = ' '; ! 145: f = 1; ! 146: } ! 147: if(f == 0)return(ret); ! 148: *w1 = '\0'; ! 149: if(++ct==1)printf("Possible grammatical errors:\n\n"); ! 150: printf("\tsplit infinitive: \"to %s\"",words); ! 151: printf(" after line %d file %s\n",linect,name); ! 152: if(catch == 2){ ! 153: fprintf(cat,"%s\n",words); ! 154: } ! 155: ret=1; ! 156: return(ret); ! 157: } ! 158: hexc(w) ! 159: char *w; ! 160: { ! 161: if(strncmp(w,"heir",4) == 0)return(1); ! 162: if(strncmp(w,"herb",4) == 0)return(1); ! 163: if(strncmp(w,"hour",4) == 0)return(1); ! 164: if(strncmp(w,"honest",6) == 0)return(1); ! 165: if(strncmp(w,"hombre",6) == 0)return(1); ! 166: if(strncmp(w,"honor",4) == 0)return(1); ! 167: return(0); ! 168: } ! 169: uexc(w) ! 170: char *w; ! 171: { ! 172: int c1, c2; ! 173: if(strncmp(w,"uni",3) == 0){ ! 174: if(*(w+3) != 'm' && *(w+3) != 'n')return(1); ! 175: else return(0); ! 176: } ! 177: c1 = *(w+1); ! 178: if(c1 == 'b' || c1 == 'k')return(1); ! 179: c2 = *(w+2); ! 180: if(c1 == 'r' || c1 == 's'){ ! 181: if(c2== 'a' || c2 == 'e' || c2 == 'i' || c2 == 'o' || c2 == 'u') ! 182: return(1); ! 183: else return(0); ! 184: } ! 185: if(strncmp("unanim",w,6) == 0)return(1); ! 186: if(strncmp("unary",w,5) == 0)return(1); ! 187: if(c1 == 't' && c2 != 't')return(1); ! 188: return(0); ! 189: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.