Debian Codegraph @

terps/alan2/parse.c

raw symbols SCIP
1 /*----------------------------------------------------------------------*\
2
3 parse.c
4
5 Command line parser unit for Alan interpreter ARUN
6
7 \*----------------------------------------------------------------------*/
8
9 #include <stdio.h>
10 #include <ctype.h>
11
12 #include "types.h"
13
14 #ifdef USE_READLINE
15 #include "readline.h"
16 #endif
17
18 #include "main.h"
19 #include "inter.h"
20 #include "exe.h"
21 #include "term.h"
22 #include "debug.h"
23 #include "params.h"
24
25 #include "parse.h"
26
27 #ifdef GLK
28 #include "glkio.h"
29 #endif
30
31
32 #define LISTLEN 100
33
34
35 /* PUBLIC DATA */
36
37 int wrds[LISTLEN/2] = {EOF}; /* List of parsed words */
38 int wrdidx; /* and an index into it */
39
40 Boolean plural = FALSE;
41
42
43 /* Syntax Parameters */
44 int paramidx; /* Index in params */
45 ParamElem *params; /* List of params */
46 static ParamElem *pparams; /* Previous parameter list */
47 static ParamElem *mlst; /* Multiple objects list */
48 static ParamElem *pmlst; /* Previous multiple list */
49
50 /* Literals */
51 LitElem litValues[MAXPARAMS+1];
52 int litCount;
53
54 /* What did the user say? */
55 int vrbwrd; /* The word he used */
56 int vrbcode; /* The code for that verb */
57
58
59 /*----------------------------------------------------------------------*\
60
61 SCAN DATA & PROCEDURES
62
63 All procedures for getting a command and turning it into a list of
64 dictionary entries are placed here.
65
66 buf
67 unknown()
68 lookup()
69 token
70 agetline()
71 scan()
72
73 \*----------------------------------------------------------------------*/
74
75
76 /* PRIVATE DATA */
77
78 static char buf[LISTLEN+1]; /* The input buffer */
79 static char isobuf[LISTLEN+1]; /* The input buffer in ISO */
80
81
82 static Boolean eol = TRUE; /* Looking at End of line? Yes, initially */
83
84
85
86 #ifdef _PROTOTYPES_
87 static void unknown(
88 char token[]
89 )
90 #else
91 static void unknown(token)
92 char token[];
93 #endif
94 {
95 char *str = allocate((int)strlen(token)+4);
96
97 str[0] = '\'';
98 strcpy(&str[1], token);
99 strcat(str, "'?");
100 #if ISO == 0
101 fromIso(str, str);
102 #endif
103 output(str);
104 free(str);
105 eol = TRUE;
106 error(M_UNKNOWN_WORD);
107 }
108
109
110
111 static char *token;
112
113
114 #ifdef _PROTOTYPES_
115 static int lookup(
116 char wrd[]
117 )
118 #else
119 static int lookup(wrd)
120 char wrd[];
121 #endif
122 {
123 int i;
124
125 for (i = 0; !endOfTable(&dict[i]); i++) {
126 if (strcmp(wrd, (char *) addrTo(dict[i].wrd)) == 0)
127 return (i);
128 }
129 unknown(wrd);
130 return(EOF);
131 }
132
133
134 #ifdef _PROTOTYPES_
135 static int number(
136 char token[] /* IN - The string to convert to a number */
137 )
138 #else
139 static int number(token)
140 char token[]; /* IN - The string to convert to a number */
141 #endif
142 {
143 int i;
144
145 sscanf(token, "%d", &i);
146 return i;
147 }
148
149 #ifdef _PROTOTYPES_
150 static char *gettoken(
151 char *buf
152 )
153 #else
154 static char *gettoken(buf)
155 char *buf;
156 #endif
157 {
158 static char *marker;
159 static char oldch;
160
161 if (buf == NULL)
162 *marker = oldch;
163 else
164 marker = buf;
165 while (*marker != '\0' && isSpace(*marker) && *marker != '\n') marker++;
166 buf = marker;
167 if (isISOLetter(*marker))
168 while (*marker&&(isISOLetter(*marker)||isdigit(*marker)||*marker=='\'')) marker++;
169 else if (isdigit(*marker))
170 while (isdigit(*marker)) marker++;
171 else if (*marker == '\"') {
172 marker++;
173 while (*marker != '\"') marker++;
174 marker++;
175 } else if (*marker == '\0' || *marker == '\n')
176 return NULL;
177 else
178 marker++;
179 oldch = *marker;
180 *marker = '\0';
181 return buf;
182 }
183
184
185 #ifdef _PROTOTYPES_
186 static void agetline(void)
187 #else
188 static void agetline()
189 #endif
190 {
191 para();
192 do {
193 #if defined(HAVE_ANSI) || defined(GLK)
194 statusline();
195 #endif
196 printf("> ");
197 if (logflg)
198 fprintf(logfil, "> ");
199 #ifdef USE_READLINE
200 if (!readline(buf)) {
201 newline();
202 quit();
203 }
204 #else
205 if (fgets(buf, LISTLEN, stdin) == NULL) {
206 newline();
207 quit();
208 }
209 #endif
210 getPageSize();
211 anyOutput = FALSE;
212 if (logflg)
213 #ifndef __amiga__
214 fprintf(logfil, "%s\n", buf);
215 #else
216 fprintf(logfil, "%s", buf);
217 #endif
218 #if ISO == 0
219 toIso(isobuf, buf, NATIVECHARSET);
220 #else
221 strcpy(isobuf, buf);
222 #endif
223 token = gettoken(isobuf);
224 if (token != NULL && strcmp("debug", token) == 0 && header->debug) {
225 dbgflg = TRUE;
226 debug();
227 token = NULL;
228 }
229 } while (token == NULL);
230 eol = FALSE;
231 lin = 1;
232 }
233
234
235 #ifdef _PROTOTYPES_
236 static void scan(void)
237 #else
238 static void scan()
239 #endif
240 {
241 int i;
242 int w;
243 char *str;
244
245 agetline();
246 wrds[0] = 0;
247 for (i = 0; i < litCount; i++)
248 if (litValues[i].type == TYPSTR && litValues[i].value != 0)
249 free((char *) litValues[i].value);
250 i = 0;
251 litCount = 0;
252 do {
253 if (isISOLetter(token[0])) {
254 (void) stringLower(token);
255 w = lookup(token);
256 if (!isNoise(w))
257 wrds[i++] = w;
258 } else if (isdigit(token[0])) {
259 if (litCount > MAXPARAMS)
260 syserr("Too many parameters.");
261 wrds[i++] = dictsize+litCount; /* Word outside dictionary = literal */
262 litValues[litCount].type = TYPNUM;
263 litValues[litCount++].value = number(token);
264 } else if (token[0] == '\"') {
265 if (litCount > MAXPARAMS)
266 syserr("Too many parameters.");
267 wrds[i++] = dictsize+litCount; /* Word outside dictionary = literal */
268 litValues[litCount].type = TYPSTR;
269 /* Remove the string quotes while copying */
270 str = strdup(&token[1]);
271 str[strlen(token)-2] = '\0';
272 litValues[litCount++].value = (Aptr) str;
273 } else if (token[0] == ',') {
274 wrds[i++] = conjWord;
275 } else
276 unknown(token);
277 wrds[i] = EOF;
278 eol = (token = gettoken(NULL)) == NULL;
279 } while (!eol);
280 }
281
282
283
284 /*----------------------------------------------------------------------*\
285
286 PARSE DATA & PROCEDURES
287
288 All procedures and data for getting a command and parsing it
289
290 nonverb() - search for a non-verb command
291 buildall() - build a list of objects matching 'all'
292 unambig() - match an unambigous object reference
293 simple() - match a simple verb command
294 complex() - match a complex -"-
295 try() - to match a verb command
296 match() - find the verb class (not used currently) and 'try()'
297
298 \*---------------------------------------------------------------------- */
299
300 static int allLength; /* No. of objects matching 'all' */
301
302
303 #ifdef _PROTOTYPES_
304 static void nonverb(void)
305 #else
306 static void nonverb()
307 #endif
308 {
309 if (isDir(wrds[wrdidx])) {
310 wrdidx++;
311 if (wrds[wrdidx] != EOF && !isConj(wrds[wrdidx]))
312 error(M_WHAT);
313 else
314 go(dict[wrds[wrdidx-1]].code);
315 if (wrds[wrdidx] != EOF)
316 wrdidx++;
317 } else
318 error(M_WHAT);
319 }
320
321
322 #ifdef _PROTOTYPES_
323 static void buildall(
324 ParamElem list[]
325 )
326 #else
327 static void buildall(list)
328 ParamElem list[];
329 #endif
330 {
331 int o, i = 0;
332 Boolean found = FALSE;
333
334 for (o = OBJMIN; o <= OBJMAX; o++)
335 if (isHere(o)) {
336 found = TRUE;
337 list[i].code = o;
338 list[i++].firstWord = EOF;
339 }
340 if (!found)
341 error(M_WHAT_ALL);
342 else
343 list[i].code = EOF;
344 }
345
346
347 #ifdef _PROTOTYPES_
348 static void unambig(
349 ParamElem plst[]
350 )
351 #else
352 static void unambig(plst)
353 ParamElem plst[];
354 #endif
355 {
356 int i;
357 Boolean found = FALSE; /* Adjective or noun found ? */
358 static ParamElem *refs; /* Entities referenced by word */
359 static ParamElem *savlst; /* Saved list for backup at EOF */
360 int firstWord, lastWord; /* The words the player used */
361
362 if (refs == NULL)
363 refs = (ParamElem *)allocate((MAXENTITY+1)*sizeof(ParamElem));
364
365 if (savlst == NULL)
366 savlst = (ParamElem *)allocate((MAXENTITY+1)*sizeof(ParamElem));
367
368 if (isLiteral(wrds[wrdidx])) {
369 /* Transform the word into a reference to the literal value */
370 plst[0].code = wrds[wrdidx++]-dictsize+LITMIN;
371 plst[0].firstWord = EOF; /* No words used! */
372 plst[1].code = EOF;
373 return;
374 }
375
376 plst[0].code = EOF; /* Make empty */
377 if (isIt(wrds[wrdidx])) {
378 wrdidx++;
379 /* Use last object in previous command! */
380 for (i = lstlen(pparams)-1; i >= 0 && (pparams[i].code == 0 || pparams[i].code >= LITMIN); i--);
381 if (i < 0)
382 error(M_WHAT_IT);
383 if (!isHere(pparams[i].code)) {
384 params[0].code = pparams[i].code;
385 params[0].firstWord = EOF;
386 params[1].code = EOF;
387 error(M_NO_SUCH);
388 }
389 plst[0] = pparams[i];
390 plst[0].firstWord = EOF; /* No words used! */
391 plst[1].code = EOF;
392 return;
393 }
394
395 firstWord = wrdidx;
396 while (wrds[wrdidx] != EOF && isAdj(wrds[wrdidx])) {
397 /* If this word can be a noun and there is no noun following break loop */
398 if (isNoun(wrds[wrdidx]) && (wrds[wrdidx+1] == EOF || !isNoun(wrds[wrdidx+1])))
399 break;
400 cpyrefs(refs, (Aword *)addrTo(dict[wrds[wrdidx]].adjrefs));
401 lstcpy(savlst, plst); /* To save it for backtracking */
402 if (found)
403 isect(plst, refs);
404 else {
405 lstcpy(plst, refs);
406 found = TRUE;
407 }
408 wrdidx++;
409 }
410 if (wrds[wrdidx] != EOF) {
411 if (isNoun(wrds[wrdidx])) {
412 cpyrefs(refs, (Aword *)addrTo(dict[wrds[wrdidx]].nounrefs));
413 if (found)
414 isect(plst, refs);
415 else {
416 lstcpy(plst, refs);
417 found = TRUE;
418 }
419 wrdidx++;
420 } else
421 error(M_NOUN);
422 } else if (found) {
423 if (isNoun(wrds[wrdidx-1])) {
424 /* Perhaps the last word was also a noun? */
425 lstcpy(plst, savlst); /* Restore to before last adjective */
426 cpyrefs(refs, (Aword *)addrTo(dict[wrds[wrdidx-1]].nounrefs));
427 if (plst[0].code == EOF)
428 lstcpy(plst, refs);
429 else
430 isect(plst, refs);
431 } else
432 error(M_NOUN);
433 }
434 lastWord = wrdidx-1;
435
436 /* Allow remote objects, but resolve ambiguities by presence */
437 if (lstlen(plst) > 1) {
438 for (i=0; plst[i].code != EOF; i++)
439 if (!isHere(plst[i].code))
440 plst[i].code = 0;
441 compact(plst);
442 }
443
444 if (lstlen(plst) > 1 || (found && lstlen(plst) == 0)) {
445 params[0].code = 0; /* Just make it anything != EOF */
446 params[0].firstWord = firstWord; /* Remember words for errors below */
447 params[0].lastWord = lastWord;
448 params[1].code = EOF; /* But be sure to terminate */
449 if (lstlen(plst) > 1)
450 error(M_WHICH_ONE);
451 else if (found && lstlen(plst) == 0)
452 error(M_NO_SUCH);
453 } else {
454 plst[0].firstWord = firstWord;
455 plst[0].lastWord = lastWord;
456 }
457 }
458
459
460 #ifdef _PROTOTYPES_
461 static void simple(
462 ParamElem olst[]
463 )
464 #else
465 static void simple(olst)
466 ParamElem olst[];
467 #endif
468 {
469 static ParamElem *tlst = NULL;
470 int savidx = wrdidx;
471 Boolean savplur = FALSE;
472 int i;
473
474 if (tlst == NULL)
475 tlst = (ParamElem *) allocate(sizeof(ParamElem)*(MAXENTITY+1));
476 tlst[0].code = EOF;
477
478 for (;;) {
479 if (isThem(wrds[wrdidx])) {
480 plural = TRUE;
481 for (i = 0; pmlst[i].code != EOF; i++)
482 if (!isHere(pmlst[i].code))
483 pmlst[i].code = 0;
484 compact(pmlst);
485 if (lstlen(pmlst) == 0)
486 error(M_WHAT_THEM);
487 lstcpy(olst, pmlst);
488 olst[0].firstWord = EOF; /* No words used */
489 wrdidx++;
490 } else {
491 unambig(olst); /* Look for unambigous noun phrase */
492 if (lstlen(olst) == 0) { /* Failed! */
493 lstcpy(olst, tlst);
494 wrdidx = savidx;
495 plural = savplur;
496 return;
497 }
498 }
499 mrglst(tlst, olst);
500 if (wrds[wrdidx] != EOF
501 && (isConj(wrds[wrdidx]) &&
502 (isAdj(wrds[wrdidx+1]) || isNoun(wrds[wrdidx+1])))) {
503 /* More parameters in a conjunction separated list ? */
504 savplur = plural;
505 savidx = wrdidx;
506 wrdidx++;
507 plural = TRUE;
508 } else {
509 lstcpy(olst, tlst);
510 return;
511 }
512 }
513 }
514
515
516 /*----------------------------------------------------------------------
517
518 complex()
519
520 Above this procedure we can use the is* tests, but not below since
521 they work on words. Below all is converted to indices into the
522 entity tables. Particularly this goes for literals...
523
524 */
525 #ifdef _PROTOTYPES_
526 static void complex(
527 ParamElem olst[]
528 )
529 #else
530 static void complex(olst)
531 ParamElem olst[];
532 #endif
533 {
534 static ParamElem *alst = NULL;
535
536 if (alst == NULL)
537 alst = (ParamElem *) allocate((MAXENTITY+1)*sizeof(ParamElem));
538
539 if (isAll(wrds[wrdidx])) {
540 plural = TRUE;
541 buildall(alst); /* Build list of all objects */
542 wrdidx++;
543 if (wrds[wrdidx] != EOF && isBut(wrds[wrdidx])) {
544 wrdidx++;
545 simple(olst);
546 if (lstlen(olst) == 0)
547 error(M_AFTER_BUT);
548 sublst(alst, olst);
549 if (lstlen(alst) == 0)
550 error(M_NOT_MUCH);
551 }
552 lstcpy(olst, alst);
553 allLength = lstlen(olst);
554 } else
555 simple(olst); /* Look for simple noun group */
556 }
557
558
559 #ifdef _PROTOTYPES_
560 static Boolean claCheck(
561 ClaElem *cla /* IN - The cla elem to check */
562 )
563 #else
564 static Boolean claCheck(cla)
565 ClaElem *cla; /* IN - The cla elem to check */
566 #endif
567 {
568 Boolean ok = FALSE;
569
570 if ((cla->classes&(Aword)CLA_OBJ) != 0)
571 ok = ok || isObj(params[cla->code-1].code);
572 if ((cla->classes&(Aword)CLA_CNT) != 0)
573 ok = ok || isCnt(params[cla->code-1].code);
574 if ((cla->classes&(Aword)CLA_ACT) != 0)
575 ok = ok || isAct(params[cla->code-1].code);
576 if ((cla->classes&(Aword)CLA_NUM) != 0)
577 ok = ok || isNum(params[cla->code-1].code);
578 if ((cla->classes&(Aword)CLA_STR) != 0)
579 ok = ok || isStr(params[cla->code-1].code);
580 if ((cla->classes&(Aword)CLA_COBJ) != 0)
581 ok = ok || (isCnt(params[cla->code-1].code) && isObj(params[cla->code-1].code));
582 if ((cla->classes&(Aword)CLA_CACT) != 0)
583 ok = ok || (isCnt(params[cla->code-1].code) && isAct(params[cla->code-1].code));
584 return ok;
585 }
586
587
588 /*----------------------------------------------------------------------
589
590 resolve()
591
592 In case the syntax did not indicate omnipotent powers (allowed
593 access to remote object), we need to remove non-present parameters
594
595 */
596 static void resolve(ParamElem plst[])
597 {
598 int i;
599
600 if (allLength > 0) return; /* ALL has already done this */
601
602 /* Resolve ambiguities by presence */
603 for (i=0; plst[i].code != EOF; i++)
604 if (plst[i].code < LITMIN) /* Literals are always 'here' */
605 if (!isHere(plst[i].code)) {
606 params[0] = plst[i]; /* Copy error param as first one for message */
607 params[1].code = EOF; /* But be sure to terminate */
608 error(M_NO_SUCH);
609 }
610 }
611
612
613 #ifdef _PROTOTYPES_
614 static void try(
615 ParamElem mlst[] /* OUT - List of params allowed by multiple */
616 )
617 #else
618 static void try(mlst)
619 ParamElem mlst[]; /* OUT - List of params allowed by multiple */
620 #endif
621 {
622 ElmElem *elms; /* Pointer to element list */
623 StxElem *stx; /* Pointer to syntax list */
624 ClaElem *cla; /* Pointer to class definitions */
625 Boolean anyPlural = FALSE; /* Any parameter that was plural? */
626 int i, p;
627 static ParamElem *tlst = NULL; /* List of params found by complex() */
628 static Boolean *checked = NULL; /* Corresponding parameter checked? */
629
630 if (tlst == NULL) {
631 tlst = (ParamElem *) allocate((MAXENTITY+1)*sizeof(ParamElem));
632 checked = (Boolean *) allocate((MAXENTITY+1)*sizeof(Boolean));
633 }
634
635 for (stx = stxs; !endOfTable(stx); stx++)
636 if (stx->code == vrbcode)
637 break;
638 if (endOfTable(stx))
639 error(M_WHAT);
640
641 elms = (ElmElem *) addrTo(stx->elms);
642
643 while (TRUE) {
644 /* End of input? */
645 if (wrds[wrdidx] == EOF || isConj(wrds[wrdidx])) {
646 while (!endOfTable(elms) && elms->code != EOS)
647 elms++;
648 if (endOfTable(elms))
649 error(M_WHAT);
650 else
651 break;
652 } else {
653 /* A preposition? */
654 if (isPrep(wrds[wrdidx])) {
655 while (!endOfTable(elms) && elms->code != dict[wrds[wrdidx]].code)
656 elms++;
657 if (endOfTable(elms))
658 error(M_WHAT);
659 else
660 wrdidx++;
661 } else {
662 /* Must be a parameter! */
663 while (!endOfTable(elms) && elms->code != 0)
664 elms++;
665 if (endOfTable(elms))
666 error(M_WHAT);
667 /* Get it! */
668 plural = FALSE;
669 complex(tlst);
670 if (lstlen(tlst) == 0) /* No object!? */
671 error(M_WHAT);
672 if ((elms->flags & OMNIBIT) == 0) /* Omnipotent parameter? */
673 /* If its not an omnipotent parameter, resolve by presence */
674 resolve(tlst);
675 if (plural) {
676 if ((elms->flags & MULTIPLEBIT) == 0) /* Allowed multiple? */
677 error(M_MULTIPLE);
678 else {
679 /*
680 Mark this as the multiple position in which to insert
681 actual parameter values later
682 */
683 params[paramidx++].code = 0;
684 lstcpy(mlst, tlst);
685 anyPlural = TRUE;
686 }
687 } else
688 params[paramidx++] = tlst[0];
689 params[paramidx].code = EOF;
690 }
691 elms = (ElmElem *) addrTo(elms->next);
692 }
693 }
694
695 /* Now perform class checks */
696 if (elms->next == 0) /* No verb code, verb not declared! */
697 error(M_CANT0);
698
699 for (p = 0; params[p].code != EOF; p++) /* Mark all parameters unchecked */
700 checked[p] = FALSE;
701 for (cla = (ClaElem *) addrTo(elms->next); !endOfTable(cla); cla++) {
702 if (params[cla->code-1].code == 0) {
703 /* This was a multiple parameter, so check all and remove failing */
704 for (i = 0; mlst[i].code != EOF; i++) {
705 params[cla->code-1] = mlst[i];
706 if (!claCheck(cla)) {
707 /* Multiple could be both an explicit list of params and an ALL */
708 if (allLength == 0) {
709 char marker[80];
710 /*
711 It wasn't ALL, we need to say something about it, so
712 prepare a printout with $1/2/3
713 */
714 sprintf(marker, "($%ld)", (unsigned long) cla->code);
715 output(marker);
716 interpret(cla->stms);
717 para();
718 }
719 mlst[i].code = 0; /* In any case remove it from the list */
720 }
721 }
722 params[cla->code-1].code = 0;
723 } else {
724 if (!claCheck(cla)) {
725 interpret(cla->stms);
726 error(MSGMAX); /* Return to player without saying anything */
727 }
728 }
729 checked[cla->code-1] = TRUE; /* Remember that it's already checked */
730 }
731 /* Now check the rest of the parameters, must be objects */
732 for (p = 0; params[p].code != EOF; p++)
733 if (!checked[p]) {
734 if (params[p].code == 0) {
735 /* This was a multiple parameter, check all and remove failing */
736 for (i = 0; mlst[i].code != EOF; i++)
737 if (mlst[i].code != 0) /* Skip any empty slots */
738 if (!isObj(mlst[i].code))
739 mlst[i].code = 0;
740 } else if (!isObj(params[p].code))
741 error(M_CANT0);
742 }
743
744 /* Set verb code */
745 cur.vrb = ((Aword *) cla)[1]; /* Take first word after end of table! */
746
747 /* Finally, if ALL was used, try to find out what was applicable */
748 if (allLength > 0) {
749 for (p = 0; params[p].code != 0; p++); /* Find multiple marker */
750 for (i = 0; i < allLength; i++) {
751 if (mlst[i].code != 0) { /* Already empty? */
752 params[p] = mlst[i];
753 if (!possible())
754 mlst[i].code = 0; /* Remove this from list */
755 }
756 }
757 params[p].code = 0; /* Restore multiple marker */
758 compact(mlst);
759 if (lstlen(mlst) == 0) {
760 params[0].code = EOF;
761 error(M_WHAT_ALL);
762 }
763 } else if (anyPlural) {
764 compact(mlst);
765 if (lstlen(mlst) == 0)
766 /* If there where multiple parameters but non left, exit without a */
767 /* word, assuming we have already said enough */
768 error(MSGMAX);
769 }
770 plural = anyPlural; /* Remember that we found plural objects */
771 }
772
773
774 #ifdef _PROTOTYPES_
775 static void match(
776 ParamElem *mlst /* OUT - List of params allowed by multiple */
777 )
778 #else
779 static void match(mlst)
780 ParamElem *mlst; /* OUT - List of params allowed by multiple */
781 #endif
782 {
783 try(mlst); /* ... to understand what he said */
784 if (wrds[wrdidx] != EOF && !isConj(wrds[wrdidx]))
785 error(M_WHAT);
786 if (wrds[wrdidx] != EOF) /* More on this line? */
787 wrdidx++; /* If so skip the AND */
788 }
789
790
791 #ifdef _PROTOTYPES_
792 void parse(void)
793 #else
794 void parse()
795 #endif
796 {
797 if (mlst == NULL) { /* Allocate large enough paramlists */
798 mlst = (ParamElem *) allocate(sizeof(ParamElem)*(MAXENTITY+1));
799 mlst[0].code = EOF;
800 pmlst = (ParamElem *) allocate(sizeof(ParamElem)*(MAXENTITY+1));
801 params = (ParamElem *) allocate(sizeof(ParamElem)*(MAXENTITY+1));
802 params[0].code = EOF;
803 pparams = (ParamElem *) allocate(sizeof(ParamElem)*(MAXENTITY+1));
804 }
805
806 if (wrds[wrdidx] == EOF) {
807 wrdidx = 0;
808 scan();
809 } else if (anyOutput)
810 para();
811
812 allLength = 0;
813 paramidx = 0;
814 lstcpy(pparams, params);
815 params[0].code = EOF;
816 lstcpy(pmlst, mlst);
817 mlst[0].code = EOF;
818 if (isVerb(wrds[wrdidx])) {
819 vrbwrd = wrds[wrdidx];
820 vrbcode = dict[vrbwrd].code;
821 wrdidx++;
822 match(mlst);
823 action(mlst); /* mlst contains possible multiple params */
824 } else {
825 params[0].code = EOF;
826 pmlst[0].code = EOF;
827 nonverb();
828 }
829 }