/*grammar.c v4.2*/ /*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 strclear(char *s) { strcpy(s,""); }*/ 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 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"}; char prox_table[2][6] = {"-Prox","+Prox"}; char def_table1[2][6] = {"-Def","+Def"}; char dem_table1[2][6] = {"-Dem","+Dem"}; char prox_table1[2][6] = {"-Prox","+Prox"}; 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] int prox; //0 = [-Prox]; 1 = [+Prox] int def1; //0 = [-Def]; 1 = [+Def] int dem1; //0 = [-Dem]; 1 = [+Dem] int prox1; //0 = [-Prox]; 1 = [+Prox] char ans; char s[256]; char p[256]; char v[256]; char d[256]; char dm[256]; char pr[256]; char d1[256]; char dm1[256]; char pr1[256]; /*int i; i=0; do { i++; printf("%d\n",i); } while (i<5);*/ 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"); printf("At this time indefinite mass nouns will return 'a' for the determiner. We will fix this at a later date. "); strcpy(verb,"Main Verb"); strcatleft(verb,"[V "); strcat(verb," ]"); printf("%s\n\n",verb); /*strcpy(noun,""); */ strcpy(P,""); { 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"); 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"); scanf(" %s \n\n",p); //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", past_table[past], prog_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]); //goto np3; //demonstrative for main noun if(def==1) { strcpy(dm,""); while((strcmp(dm,dem_table[0])!=0)&&(strcmp(dm,dem_table[1])!=0)) { printf("Select a demonstrative feature--you want a demonstrative, type in '+Dem'; otherwise type in '-Dem' for no demonstrative. \n\n"); //scanf(" %s \n\n",dm); cin>>dm;//"\n\n"; } if(strcmp(dm,dem_table[0])==0) dem=0; else dem=1; printf("[D %s , %s]\n\n", d, dem_table[dem]); if(dem==1) { strcpy(pr,""); while((strcmp(pr,prox_table[0])!=0)&&(strcmp(pr,prox_table[1])!=0)) { printf("Select a proximal feature (closeness). If you want proximal, type in '+Prox'; otherwise type in '-Prox' for non-proximal. \n\n"); cin>>pr; } if(strcmp(pr,prox_table[0])==0) prox=0; else prox=1; printf("[D %s , %s, %s ]\n\n", def_table[def], dem_table[dem], prox_table[prox]); } else printf("[D %s , %s, %s ]\n\n", def_table[def], dem_table[dem], prox_table[prox]); goto np3; } else //printf("Sorry, for technical reasons, I cannot take you to the complement. Try a fuller derivation with a demonstrative."); goto np3; } np3:; { cout << "Determine the head of the complement and type it in: \n\n"; cin >> noun; cout << "[N " <> ans; if (ans == 'N' || ans == 'n' ) //printf( "[VP [V %s ] [NP [D %s , %s, %s ] [NP [N %s ]]]] is a verb phrase.\n\n", verb, def_table[def], dem_table[dem], prox_table[prox], noun); //printf( "[TP %s [AspP %s [VceP %s [VP [V %s ] [NP [D %s , %s, %s ] [NP [N %s ]]]] is a verb (tense) phrase.\n\n", past_table[past], prog_table[past], passive_table[pass], verb, def_table[def], dem_table[dem], prox_table[prox], noun); goto end; else { cout << "What is the head of the complement of '"<> P; cout << "[P " <> ans; if (ans == 'N' || ans == 'n') { cout << "[PP [P " << P << " ]] is an intransitive preposition.\n\n"; cout << "[TP [T " <>d1; } if(strcmp(d1,def_table1[0])==0) def1=0; else def1=1; printf("[D %s]\n\n", def_table1[def]); //goto np3; //demonstrative for embedded noun if(def==1) { strcpy(dm1,""); while((strcmp(dm1,dem_table1[0])!=0)&&(strcmp(dm1,dem_table1[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>>dm1;//"\n\n"; } if(strcmp(dm1,dem_table1[0])==0) dem1=0; else dem1=1; printf("[D %s , %s]\n\n", def_table1[def], dem_table1[dem]); if(dem==1) { strcpy(pr1,""); scanf(" %s \n\n",pr1); //cout<>pr1; scanf(" %s \n\n", pr1); printf(" %s \n\n", pr1); } if(strcmp(pr1,prox_table1[0])==0) prox1=0; else prox1=1; printf("[D %s , %s, %s ] is the determiner.\n\n", d1, dem_table1[dem], prox_table1[prox]); goto np4; } else np4:; { printf("Please enter the head of the complement of '%s' here.\n\n",P); //cout << "Please enter the head of the complement of '"<> noun1; printf("[N %s ] is a noun.\n\n",noun1); //cout << "[N " << noun1 << " ] is a noun."<