/*grammar.c v3.0*/ /*printf("This minigrammar will generate nothing more than a verb, a complement of the verb, a complement of the verbal complement, and a complement of that. It also includes the tense operator and the progressive aspect 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) { // char *verb, *det, *P, *comp, *A, *noun1, *det1,* adv, *lba, *advv, *past, *pres; } int main(void) { char lba[256] = "[A ]"; char verb[256]; char noun[256]; char det[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"}; int past; //0 = [-Past]; 1= [+Past] int prog; //0 = [-Prog; 1= [+Prog] int pass; //0 = [-Pass]; 1= [+Pass] char ans; char s[256]; char p[256]; char v[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",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"); cin>>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]\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)) { printf("Select a feature of voice. If you want the past tense, 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("[T %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"); cin >> verb; cout << "[V " <> ans; if (ans == 'N' || ans == 'n') goto vp; else cout <<"Type in the adverb:\n"; cin >> adv; cout << "[A " <> ans; if (ans == 'N' || ans == 'n' ) { cout << "[TP [T" <> noun; cout << "[N " <> ans; if (ans == 'N' || ans == 'n' ) { cout << "[NP [N "<< noun << "]] is a noun phrase.\n"; goto np2; } else { cout << "Enter the determiner." <> det; cout << "[D "<> 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"; goto end; } else //goto np; //embedded NP { cout << "Please enter the head of the complement of '"<> noun1; cout << "[N " << noun1 << " ] is a noun."<> ans; if (ans == 'N' || ans == 'n') { cout << "[NP [NP "<> det1; cout << "[NP [D "<