/*grammar.c v3.32*/ /*printf("This minigrammar will generate nothing more than tense, aspect, voice, a verb, a complement of the verb, a complement of the verbal complement, and a complement of that. It also includes the tense operator, the aspect operator, and the voice operator. This is a statement of the grammar. A later statement will spell out the operators after lexical items have been enterred. This has not been programmed into the grammar yet. There is one NP loop, but currently no more. Each head is optionally intransitive depending on the choice of the user. dr. d.\n\n\n"; */ #include #include #include #include #include void strcatleft(char *dest, char *source) { char temp[256]; strcpy(temp,source); strcat(temp,dest); strcpy(dest,temp); } void initialize(void) { /* #if macintosh SIOUXSettings.setupmenus=FALSE; SIOUXSettings.autocloseonquit=TRUE; SIOUXSettings.asktosaveonclose=FALSE; SIOUXSettings.showstatusline=FALSE; #endif */ } //void isa_head (char *head) void isa_head(void) #define head (verb || noun || det || P || A || adv || def) #define operator (det) { // char *verb, *det, *P, *comp, *A, *noun1, *det1, *adv; } int main(void) { char lba[256] = "[A ]"; char verb[256]; char noun[256]; char det[256]; // char dem[256]; char P[256]; //char comp[256]; //char A[256]; char noun1[256]; char det1[256]; char adv[256]; // char advv[256]; char past_table[2][6] = {"-Past","+Past"}; char prog_table[2][6] = {"-Prog","+Prog"}; char passive_table[2][6] = {"-Pass","+Pass"}; char def_table[2][6] = {"-Def","+Def"}; char dem_table[2][6] = {"-Dem","+Dem"}; int past; //0 = [-Past]; 1= [+Past] int prog; //0 = [-Prog; 1= [+Prog] int pass; //0 = [-Pass]; 1= [+Pass] int def; //0 = [-Def]; 1 = [+Def] int dem; //0 = [-Dem]; 1 = [+Dem] char ans; char s[256]; char p[256]; char v[256]; char d[256]; char dm[256]; initialize(); printf("This minigrammar will generate nothing more than a verb,"); printf("a complement of the verb, a complement of the verbal complement, "); printf("and a complement of that. It also includes the tense operator and the progressive "); printf("aspect operator. This is a statement of the grammar. A later statement will"); printf("spell out the operators after lexical items have been enterred. This"); printf("has not been programmed into the grammar yet. There is one NP loop, but currently no more."); printf("Each head is optionally intransitive depending on the choice of the user. dr. d."); printf("Each operator has a binary value. Many minus value operators are phonetically null.\n\n"); strcpy(verb,"Main Verb"); strcatleft(verb,"[V "); strcat(verb," ]"); printf("%s\n\n",verb); /*strcpy(noun,""); */ { strcpy(s,""); while((strcmp(s,past_table[0])!=0)&&(strcmp(s,past_table[1])!=0)) { printf("Select a feature of tense. If you want the past tense , type in '+Past'; otherwise type in '-Past' for the present tense: \n\n"); cin>>s; //scanf("%s\n\n",s); } if(strcmp(s,past_table[0])==0) past=0; else past=1; printf("[T %s] is the tense operator.\n\n", past_table[past]); } { strcpy(p,""); while((strcmp(p,prog_table[0])!=0)&&(strcmp(p,prog_table[1])!=0)) { printf("Select a feature of aspect. If you want the progressive aspect , type in '+Prog'; otherwise type in '-Prog' for the non-progressive aspect. Note, we do not consider the perfect to be aspect: \n"); cin>>p; } if(strcmp(p,prog_table[0])==0) prog=0; else prog=1; printf("[Asp %s] is the aspect operator.\n\n", prog_table[prog]); printf("[T %s [Asp %s]] is the tense operator plus the progressive operator.\n\n", prog_table[prog], past_table[past]); } { strcpy(v,""); while((strcmp(v,passive_table[0])!=0)&&(strcmp(v,passive_table[1])!=0)) { cout << "Select a feature of voice. If you want the passive voice, type in '+Pass'. Otherwise type in '-Pass' for the active voice: \n\n"; cin>>v; } if(strcmp(v,passive_table[0])==0) pass=0; else pass=1; printf("[Vce %s] is the voice operator.\n\n", passive_table[pass]); printf("[T %s [Asp %s [Vce %s]]] is the tense operator plus the aspect operator plus the voice operator.\n\n", prog_table[prog], past_table[past], passive_table[pass]); } { printf("Enter a verb.\n\n"); //cout <<"Enter a verb" <> verb; cout << "[V " <> ans; if (ans == 'N' || ans == 'n') goto vp; else cout <<"Type in the adverb:\n\n"; cin >> adv; cout << "[A " <> ans; if (ans == 'N' || ans == 'n' ) { cout << "[TP [T "<>d; } if(strcmp(d,def_table[0])==0) def=0; else def=1; printf("[D %s]\n\n", def_table[def]); } { strcpy(dm,""); while((strcmp(dm,dem_table[0])!=0)&&(strcmp(dm,dem_table[1])!=0)) { printf("Select a demonstrative feature. If you want a demonstrative, type in '+Dem'; otherwise type in '-Dem' for no demonstrative. \n\n"); cin>>dm; } if(strcmp(dm,dem_table[0])==0) dem=0; else dem=1; printf("[D %s , %s]\n\n", def_table[def], dem_table[dem]); } { cout << "Determine the head of the complement and type it in: \n\n"; cin >> noun; cout << "[N " <> ans; if (ans == 'N' || ans == 'n' ) { cout << "[VP [V " <> P; cout << "[P " <> ans; if (ans == 'N' || ans == 'n') { cout << "[PP [P " << P << " ]] is an intransitive preposition.\n\n"; cout << "[TP [T " <> noun1; cout << "[N " << noun1 << " ] is a noun."<> ans; if (ans == 'N' || ans == 'n') { cout << "[NP [NP "<> det1; cout << "[NP [D "<