Example #1
0
static ucell get_myself(void)
{
        static ucell **myself = NULL;
	if( !myself )
		myself = (ucell**)findword("my-self") + 1;
	return (*myself && **myself) ? (ucell)**myself : 0;
}
Example #2
0
bool findword(int irow, int icol, const string& word_to_check, int i){
	int rows = sizeof(boboard) / sizeof(boboard[0]);
	int cols = sizeof(boboard[0]) / sizeof(boboard[0][0]);
	if(irow-1<0) 
		rstart=irow;
	else 
		rstart=irow-1;
	if(icol-1<0)
		cstart=icol;
	else 
 		cstart=icol-1;
	if(irow+1>borows) 
		rend=irow;
	else 
		rend=irow+1;
	if(icol+1>bocols)
		cend=icol;
	else 
 		cend=icol+1;
for(int r=rstart; r<=rend; r++){
	for(int c=cstart; c<=cend; c++){
		if (boboard[r][c]==word_to_check[i]){
			location[i]=r*cols+c;
			if(i<word_to_check.size-1)
				return findword(r, c, word_to_check[i+1]);
			else
				return true;
		}
	}
}




}
Example #3
0
static
int printf_console(const char *fmt, ...)
{
    cell tmp;

    char buf[512];
    va_list args;
    int i;

    va_start(args, fmt);
    i = vsnprintf(buf, sizeof(buf), fmt, args);
    va_end(args);

    /* Push to the Forth interpreter for console output */
    tmp = rstackcnt;

    PUSH(pointer2cell(buf));
    PUSH((int)strlen(buf));
    trampoline[1] = findword("type");

    PUSHR(PC);
    PC = pointer2cell(trampoline);

    while (rstackcnt > tmp) {
        dbg_interp_printk("printf_console: NEXT\n");
        next();
    }

    return i;
}
int main()
{
	int i;
	char paragraph[50];             //paragraph string
	int sizeofpara;                 //size of paragraph
	char wrongword[50];             //word going to be replaced
	int wsize;                      //size of the wrong word
	char correctword[50];           //replacing word
	int csize;                      //size of the correct word
	int wrongwordposition;          //position where wrong word is located in the paragraph

	printf("Enter the paragraph :\n");
	readline(paragraph);                            //paragraph input
	sizeofpara = strlen(paragraph);
M:
	printf("Enter the word to be removed :\n");
	readline(wrongword);                            //wrongword input
	wsize = strlen(wrongword);

	wrongwordposition = findword(paragraph , sizeofpara , wrongword , wsize);   //finding wrong word
	if (wrongwordposition > sizeofpara) {
	    goto M;                                     //since word is not found requesting to input again
	} else {
        removeword(paragraph , sizeofpara , wrongwordposition , wsize);             //removing wrong word
	}
	printf("Enter the word you want to replace it with :\n");
    readline(correctword);                          //correct word input
    csize = strlen(correctword);

    insertword(paragraph , sizeofpara - wsize , wrongwordposition , correctword , csize);   //replacing with correct word

	return 0;
}
Example #5
0
static ucell get_myself(void)
{
    static ucell *myselfptr = NULL;
    if (myselfptr == NULL) {
        myselfptr = (ucell*)cell2pointer(findword("my-self")) + 1;
    }
    ucell *myself = (ucell*)cell2pointer(*myselfptr);
    return (myself != NULL) ? *myself : 0;
}
Example #6
0
cell
_eword( const char *word, xt_t *cache_xt, int nargs )
{
	static xt_t catch_xt = 0;
	cell ret = -1;

	if( !catch_xt )
		catch_xt = findword("catch");
	if( !*cache_xt )
		*cache_xt = findword( (char*)word );

	if( *cache_xt ) {
		PUSH_xt( *cache_xt );
		enterforth( catch_xt );
		if( (ret=POP()) )
			dstackcnt -= nargs;
	}
	return ret;
}
Example #7
0
int openbios(void)
{
#ifdef CONFIG_DEBUG_CONSOLE
#ifdef CONFIG_DEBUG_CONSOLE_SERIAL
	uart_init(CONFIG_SERIAL_PORT, CONFIG_SERIAL_SPEED);
#endif
	/* Clear the screen.  */
	cls();
#endif

        collect_sys_info(&sys_info);

        dict = (unsigned char *)sys_info.dict_start;
        dicthead = (cell)sys_info.dict_end;
        last = sys_info.dict_last;
        dictlimit = sys_info.dict_limit;

	forth_init();

	relocate(&sys_info);

#ifdef CONFIG_DEBUG_CONSOLE_VGA
	video_init();
#endif
#ifdef CONFIG_DEBUG_BOOT
	printk("forth started.\n");
	printk("initializing memory...");
#endif

	init_memory();

#ifdef CONFIG_DEBUG_BOOT
	printk("done\n");
#endif

	PUSH_xt( bind_noname_func(arch_init) );
	fword("PREPOST-initializer");

	PC = (ucell)findword("initialize-of");

	if (!PC) {
		printk("panic: no dictionary entry point.\n");
		return -1;
	}
#ifdef CONFIG_DEBUG_DICTIONARY
	printk("done (%d bytes).\n", dicthead);
	printk("Jumping to dictionary...\n");
#endif

	enterforth((xt_t)PC);

	return 0;
}
Example #8
0
/* note: only the built-in dictionary is searched */
int
_fword( const char *word, xt_t *cache_xt )
{
	if( !*cache_xt )
		*cache_xt = findword( (char*)word );

	if( *cache_xt ) {
		enterforth( *cache_xt );
		return 0;
	}
	return -1;
}
Example #9
0
ucell findxtfromcell(ucell incell)
{
	ucell usesvocab = findword("vocabularies?") + sizeof(cell);
	unsigned int i;

	if (read_ucell(cell2pointer(usesvocab))) {
		/* Vocabularies are in use, so search each one in turn */
		ucell numvocabs = findword("#order") + sizeof(cell);

		for (i = 0; i < read_ucell(cell2pointer(numvocabs)); i++) {
			ucell vocabs = findword("vocabularies") + 2 * sizeof(cell);
			ucell semis = findxtfromcell_wordlist(incell, read_cell(cell2pointer(vocabs + (i * sizeof(cell))))); 	

			/* If we get a non-zero result, we found the xt in this vocab */
			if (semis)
				return semis;
		}
	} else { 
		/* Vocabularies not in use */
		return findxtfromcell_wordlist(incell, read_ucell(last));
	}

	return 0;
}
Example #10
0
BogglePlayer::vector<int> isOnBoard(const string& word_to_check){
int rows = sizeof(boboard) / sizeof(boboard[0]);
int cols = sizeof(boboard[0]) / sizeof(boboard[0][0]);
bool iffind = false;
	for(unsigned int r=0; r<rows; r++){
		for(unsigned int c=0; c<cols; c++){
			if(boboard[r][c]==word_to_check[0]){
				location[0]=r*cols+c;
				iffind = findword(r, c, word_to_check, 1);	
			}
		}
	}
if (!iffind)
	return location.clear();
else
	return location;

}
Example #11
0
void Node::findword(string localStr, int posistion , class Node *root)
{
	if( (root->NodeStr!= localStr) && (root->ptrs[localStr[posistion]] != NULL) )
	{
		findword(localStr,posistion+1,root->ptrs[localStr[posistion]]);
	}
	else
	{
		if( localStr == root->NodeStr)
		{
			cout<<endl<<localStr<<" and "<<root->NodeStr<<" Correct"<<endl;
		}
		else
		{
			cout<<"\n\nWord not found!";
		}
	}

}
Example #12
0
static
int getchar_console(void)
{
    cell tmp;

    /* Push to the Forth interpreter for console output */
    tmp = rstackcnt;

    trampoline[1] = findword("key");

    PUSHR(PC);
    PC = pointer2cell(trampoline);

    while (rstackcnt > tmp) {
        dbg_interp_printk("getchar_console: NEXT\n");
        next();
    }

    return POP();
}
Example #13
0
void x86_exception(struct eregs *info)
{
	if(info->vector <= 18) {
		printk("\nUnexpected Exception: %s",
				exception_names[info->vector]);
	} else {
		printk("\nUnexpected Exception: %d", info->vector);
	}

	printk(
		" @ %02x:%08lx - Halting\n"
		"Code: %d eflags: %08lx\n"
		"eax: %08lx ebx: %08lx ecx: %08lx edx: %08lx\n"
		"edi: %08lx esi: %08lx ebp: %08lx esp: %08lx\n",
		info->cs, (unsigned long)info->eip,
		info->error_code, (unsigned long)info->eflags,
		(unsigned long)info->eax, (unsigned long)info->ebx,
		(unsigned long)info->ecx, (unsigned long)info->edx,
		(unsigned long)info->edi, (unsigned long)info->esi,
		(unsigned long)info->ebp, (unsigned long)info->esp);

        printk("\ndict=0x%x here=0x%x(dict+0x%x) pc=0x%x(dict+0x%x)\n",
               (ucell)dict, (ucell)dict + dicthead, dicthead, PC, PC - (ucell) dict);
        printk("dstackcnt=%d rstackcnt=%d\n",
               dstackcnt, rstackcnt);

	rstackcnt=0;
	dstackcnt=0;

	PC=findword("outer-interpreter");

	info->eip=(uint32_t)&do_nothing;

/*
	for (;;)
		asm("hlt;");
		;
*/
}
Example #14
0
 bool wordBreak(string s, vector<string>& wordDict) {
     
     int n = s.size();
     vector<bool> memo(n+1,false);
     memo[0] = true;
     for(int i=1; i<=n; i++)
     {
         for(int j=0; j<=i-1; j++)
         {
             if(memo[j]==true)
             {
                 string temp = s.substr(j,i-j);
                 if(findword(temp,wordDict))
                 {
                     memo[i] = true;
                     break;
                 }
             }
         }
     }
     return memo[n];
 }
Example #15
0
int
main(int argc, char *argv[])
{
	int ch, done;
	char *bspec, *p, *seed;

	batch = debug = reuse = selfuse;
	bspec = seed = NULL;
	minlength = -1;
	tlimit = 180;		/* 3 minutes is standard */

	while ((ch = getopt(argc, argv, "Bbcds:t:w:")) != -1)
		switch(ch) {
		case 'B':
			grid = 5;
			break;
		case 'b':
			batch = 1;
			break;
		case 'c':
			challenge = 1;
			break;
		case 'd':
			debug = 1;
			break;
		case 's':
			seed = optarg;
			break;
		case 't':
			if ((tlimit = atoi(optarg)) < 1)
				errx(1, "bad time limit");
			break;
		case 'w':
			if ((minlength = atoi(optarg)) < 3)
				errx(1, "min word length must be > 2");
			break;
		case '?':
		default:
			usage();
		}
	argc -= optind;
	argv += optind;

	/* process final arguments */
	if (argc > 0) {
		if (strcmp(argv[0], "+") == 0)
			reuse = 1;
		else if (strcmp(argv[0], "++") == 0)
			selfuse = 1;
	}

	if (reuse || selfuse) {
		argc -= 1;
		argv += 1;
	}

	if (argc > 0) {
		if (islower(argv[0][0])) {
			if (strlen(argv[0]) != ncubes) {
				usage();
			} else {
				/* This board is assumed to be valid... */
				bspec = argv[0];
			}
		} else {
		  	usage();
		}
	}

	if (batch && bspec == NULL)
		errx(1, "must give both -b and a board setup");

	init();
	if (batch) {
		newgame(bspec);
		while ((p = batchword(stdin)) != NULL)
			(void) printf("%s\n", p);
		exit(0);
	}
	setup(seed);
	prompt("Loading the dictionary...");
	if ((dictfp = opendict(DICT)) == NULL) {
		warn("%s", DICT);
		cleanup();
		exit(1);
	}
#ifdef LOADDICT
	if (loaddict(dictfp) < 0) {
		warnx("can't load %s", DICT);
		cleanup();
		exit(1);
	}
	(void)fclose(dictfp);
	dictfp = NULL;
#endif
	if (loadindex(DICTINDEX) < 0) {
		warnx("can't load %s", DICTINDEX);
		cleanup();
		exit(1);
	}

	prompt("Type <space> to begin...");
	while (inputch() != ' ');

	for (done = 0; !done;) {
		newgame(bspec);
		bspec = NULL;	/* reset for subsequent games */
		playgame();
		prompt("Type <space> to continue, any cap to quit...");
		delay(10);	/* wait for user to quit typing */
		flushin(stdin);
		for (;;) {
			ch = inputch();
			if (ch == '\033')
				findword();
			else if (ch == '\014' || ch == '\022')	/* ^l or ^r */
				redraw();
			else {
				if (isupper(ch)) {
					done = 1;
					break;
				}
				if (ch == ' ')
					break;
			}
		}
	}
	cleanup();
	exit(0);
}
Example #16
0
// Main input routine
// - doesn't accept words longer than MAXWORDLEN or containing caps
char *boggle_getline(char *q)
{
    int ch, done;
    char *p;
    int row, col;

    p = q;
    done = 0;
    while (!done) {
	ch = timerch();
	switch (ch) {
	    case '\n':
	    case '\r':
	    case ' ':
		done = 1;
		break;
	    case '\033':
		findword();
		break;
	    case '\177':      // <del>
	    case '\010':      // <bs>
		if (p == q)
		    break;
		p--;
		getyx(stdscr, row, col);
		move(row, col - 1);
		clrtoeol();
		refresh();
		break;
	    case '\025':      // <^u>
	    case '\027':      // <^w>
		if (p == q)
		    break;
		getyx(stdscr, row, col);
		move(row, col - (int) (p - q));
		p = q;
		clrtoeol();
		refresh();
		break;
#ifdef SIGTSTP
	    case '\032':      // <^z>
		stop_catcher(0);
		break;
#endif
	    case '\023':      // <^s>
		stoptime();
		printw("<PAUSE>");
		refresh();
		while ((ch = inputch()) != '\021' && ch != '\023');
		move(crow, ccol);
		clrtoeol();
		refresh();
		starttime();
		break;
	    case '\003':      // <^c>
		cleanup();
		exit(0);
	     /*NOTREACHED*/ case '\004':	// <^d>
		done = 1;
		ch = EOF;
		break;
	    case '\014':      // <^l>
	    case '\022':      // <^r>
		redraw();
		break;
	    case '?':
		stoptime();
		if (help() < 0)
		    showstr("Can't open help file", 1);
		starttime();
		break;
	    default:
		if (!islower(ch))
		    break;
		if ((int) (p - q) == MAXWORDLEN) {
		    p = q;
		    badword();
		    break;
		}
		*p++ = ch;
		addch(ch);
		refresh();
		break;
	}
    }
    *p = '\0';
    if (ch == EOF)
	return (char *) NULL;
    return q;
}
Example #17
0
static int interpret_source(char *fil)
{
	FILE *f;
	char tib[160];
        cell num;
	char *test;

	const ucell SEMIS = (ucell)findword("(semis)");
	const ucell LIT = (ucell)findword("(lit)");
	const ucell DOBRANCH = (ucell)findword("dobranch");

	if ((f = fopen_include(fil)) == NULL) {
		printk("error while loading source file '%s'\n", fil);
		errors++;
		exit(1);
	}

	/* FIXME: We should read this file at
	 * once. No need to get it char by char
	 */

	while (!feof(f)) {
		xt_t res;
		parse_word(f, tib);

		/* if there is actually no word, we continue right away */
		if (strlen(tib) == 0) {
			continue;
		}

		/* Checking for builtin words that are needed to
		 * bootstrap the forth base dictionary.
		 */

		if (!strcmp(tib, "(")) {
			parse(f, tib, ')');
			continue;
		}

		if (!strcmp(tib, "\\")) {
			parse(f, tib, '\n');
			continue;
		}

		if (!strcmp(tib, ":")) {
			parse_word(f, tib);

#ifdef CONFIG_DEBUG_INTERPRETER
			printk("create colon word %s\n\n", tib);
#endif
			fcreate(tib, DOCOL);	/* see dict.h for DOCOL and other CFA ids */
			*state = (ucell) (-1);
			continue;
		}

		if (!strcmp(tib, ";")) {
#ifdef CONFIG_DEBUG_INTERPRETER
			printk("finish colon definition\n\n");
#endif
			writecell((cell)SEMIS);
			*state = (ucell) 0;
			reveal();
			continue;
		}

		if (!strcasecmp(tib, "variable")) {
			parse_word(f, tib);
#ifdef CONFIG_DEBUG_INTERPRETER
			printk("defining variable %s\n\n", tib);
#endif
			buildvariable(tib, 0);
			reveal();
			continue;
		}

		if (!strcasecmp(tib, "constant")) {
			parse_word(f, tib);
#ifdef CONFIG_DEBUG_INTERPRETER
			printk("defining constant %s\n\n", tib);
#endif
			buildconstant(tib, POP());
			reveal();
			continue;
		}

		if (!strcasecmp(tib, "value")) {
			parse_word(f, tib);
#ifdef CONFIG_DEBUG_INTERPRETER
			printk("defining value %s\n\n", tib);
#endif
			buildconstant(tib, POP());
			reveal();
			continue;
		}

		if (!strcasecmp(tib, "defer")) {
			parse_word(f, tib);
#ifdef CONFIG_DEBUG_INTERPRETER
			printk("defining defer word %s\n\n", tib);
#endif
			builddefer(tib);
			reveal();
			continue;
		}

		if (!strcasecmp(tib, "include")) {
			parse_word(f, tib);
#ifdef CONFIG_DEBUG_INTERPRETER
			printk("including file %s\n\n", tib);
#endif
			interpret_source(tib);
			continue;
		}

		if (!strcmp(tib, "[']")) {
			xt_t xt;
			parse_word(f, tib);
			xt = findword(tib);
			if (*state == 0) {
#ifdef CONFIG_DEBUG_INTERPRETER
				printk
				    ("writing address of %s to stack\n\n",
				     tib);
#endif
				PUSH_xt(xt);
			} else {
#ifdef CONFIG_DEBUG_INTERPRETER
				printk("writing lit, addr(%s) to dict\n\n",
				       tib);
#endif
				writecell(LIT);	/* lit */
				writecell((cell)xt);
			}
			continue;
			/* we have no error detection here */
		}

		if (!strcasecmp(tib, "s\"")) {
			int cnt;
			cell loco;

			cnt = parse(f, tib, '"');
#ifdef CONFIG_DEBUG_INTERPRETER
			printk("compiling string %s\n", tib);
#endif
			loco = dicthead + (6 * sizeof(cell));
			writecell(LIT);
			writecell(pointer2cell(dict) + loco);
			writecell(LIT);
                        writecell((ucell)cnt);
			writecell(DOBRANCH);
			loco = cnt + sizeof(cell) - 1;
			loco &= ~(sizeof(cell) - 1);
			writecell(loco);
			memcpy(dict + dicthead, tib, cnt);
			dicthead += cnt;
			paddict(sizeof(cell));
			continue;
		}

		/* look if tib is in dictionary. */
		/* should the dictionary be searched before the builtins ? */
		res = findword(tib);
		if (res) {
			u8 flags = read_byte((u8*)cell2pointer(res) -
						sizeof(cell) - 1);
#ifdef CONFIG_DEBUG_INTERPRETER
                        printk("%s is 0x%" FMT_CELL_x "\n", tib, (ucell) res);
#endif
			if (!(*state) || (flags & 3)) {
#ifdef CONFIG_DEBUG_INTERPRETER
                                printk("executing %s, %" FMT_CELL_d
                                       " (flags: %s %s)\n",
				       tib, res,
				       (flags & 1) ? "immediate" : "",
				       (flags & 2) ? "compile-only" : "");
#endif
				PC = (ucell)res;
				enterforth(res);
			} else {
#ifdef CONFIG_DEBUG_INTERPRETER
				printk("writing %s to dict\n\n", tib);
#endif
				writecell((cell)res);
			}
			continue;
		}

		/* if not look if it's a number */
		if (tib[0] == '-')
			num = strtoll(tib, &test, read_ucell(base));
		else
			num = strtoull(tib, &test, read_ucell(base));


		if (*test != 0) {
			/* what is it?? */
			printk("%s:%d: %s is not defined.\n\n", srcfilenames[cursrc - 1], srclines[cursrc - 1], tib);
			errors++;
#ifdef CONFIG_DEBUG_INTERPRETER
			continue;
#else
			return -1;
#endif
		}

		if (*state == 0) {
#ifdef CONFIG_DEBUG_INTERPRETER
                        printk("pushed %" FMT_CELL_x " to stack\n\n", num);
#endif
			PUSH(num);
		} else {
#ifdef CONFIG_DEBUG_INTERPRETER
                        printk("writing lit, %" FMT_CELL_x " to dict\n\n", num);
#endif
			writecell(LIT);	/* lit */
			writecell(num);
		}
	}

	fclose(f);
	cursrc--;

	return 0;
}
Example #18
0
File: scot.c Project: eddyc/csound
static void efindword(char *s)
{
    if (findword(s))
      scotferror(Str("Unexpected end of file"));
}
Example #19
0
static void
do_source_dbg(struct debug_xt *debug_xt_item)
{
    /* Forth source debugger implementation */
    char k, done = 0;

    /* Display current dstack */
    display_dbg_dstack();
    printf_console("\n");

    fstrncpy(xtname, lfa2nfa(read_ucell(cell2pointer(PC)) - sizeof(cell)), MAXNFALEN);
    printf_console("%p: %s ", cell2pointer(PC), xtname);

    /* If in trace mode, we just carry on */
    if (debug_xt_item->mode == DEBUG_MODE_TRACE) {
        return;
    }

    /* Otherwise in step mode, prompt for a keypress */
    k = getchar_console();

    /* Only proceed if done is true */
    while (!done) {
        switch (k) {

        case ' ':
        case '\n':
            /* Perform a single step */
            done = 1;
            break;

        case 'u':
        case 'U':
            /* Up - unmark current word for debug, mark its caller for
             * debugging and finish executing current word */

            /* Since this word could alter the rstack during its execution,
             * we only know the caller when (semis) is called for this xt.
             * Hence we mark the xt as a special DEBUG_MODE_STEPUP which
             * means we run as normal, but schedule the xt for deletion
             * at its corresponding (semis) word when we know the rstack
             * will be set to its final parent value */
            debug_xt_item->mode = DEBUG_MODE_STEPUP;
            done = 1;
            break;

        case 'd':
        case 'D':
            /* Down - mark current word for debug and step into it */
            done = add_debug_xt(read_ucell(cell2pointer(PC)));
            if (!done) {
                k = getchar_console();
            }
            break;

        case 't':
        case 'T':
            /* Trace mode */
            debug_xt_item->mode = DEBUG_MODE_TRACE;
            done = 1;
            break;

        case 'r':
        case 'R':
            /* Display rstack */
            display_dbg_rstack();
            done = 0;
            k = getchar_console();
            break;

        case 'f':
        case 'F':
            /* Start subordinate Forth interpreter */
            PUSHR(PC - sizeof(cell));
            PC = findword("outer-interpreter") + sizeof(ucell);

            /* Save rstack position for when we return */
            dbgrstackcnt = rstackcnt;
            done = 1;
            break;

        default:
            /* Display debug banner */
            printf_console(DEBUG_BANNER);
            k = getchar_console();
        }
    }
}
Example #20
0
/* parse1 - the main parser */
int parse1()
{
    int noun1,cnt1,noun2,cnt2;
    int preposition,flag;

    /* initialize */
    noun1 = noun2 = NIL; cnt1 = cnt2 = 0;
    nptr = aptr = 0;
    preposition = 0;
    flag = 0;

    /* initialize the parser result variables */
    actor = action = dobject = iobject = NIL;
    ndobjects = 0;

    /* get an input line */
    if (!get_line())
	return (FALSE);

    /* check for actor */
    if (wtype(*wptr) == WT_ADJECTIVE || wtype(*wptr) == WT_NOUN) {
	if ((actor = getnoun()) == NIL)
	    return (FALSE);
	flag |= A_ACTOR;
    }

    /* get verb phrase */
    if (!getverb())
	return (FALSE);

    /* direct object, preposition and indirect object */
    if (*wptr) {

	/* get the first set of noun phrases (direct objects) */
	noun1 = nptr+1;
	for (;;) {

            /* get the next direct object */
            if (getnoun() == NIL)
    		return (FALSE);
	    ++cnt1;

	    /* check for more direct objects */
	    if (*wptr == NIL || wtype(*wptr) != WT_CONJUNCTION)
		break;
	    wptr++;
	}

	/* get the preposition and indirect object */
	if (*wptr) {

	    /* get the preposition */
	    if (wtype(*wptr) == WT_PREPOSITION)
		preposition = *wptr++;

	    /* get the second set of noun phrases (indirect object) */
	    noun2 = nptr+1;
	    for (;;) {

        	/* get the next direct object */
        	if (getnoun() == NIL)
    		    return (FALSE);
		++cnt2;

		/* check for more direct objects */
		if (*wptr == NIL || wtype(*wptr) != WT_CONJUNCTION)
		    break;
		wptr++;
	    }
	}

	/* make sure this is the end of the sentence */
	if (*wptr) {
	    parse_error();
	    return (FALSE);
	}
    }

    /* setup the direct and indirect objects */
    if (preposition) {
	if (cnt2 > 1) {
	    parse_error();
	    return (FALSE);
	}
	dobject = noun1;
	ndobjects = cnt1;
	iobject = noun2;
    }
    else if (noun2) {
	if (cnt1 > 1) {
	    parse_error();
	    return (FALSE);
	}
	preposition = findword("to");
	dobject = noun2;
	ndobjects = cnt2;
	iobject = noun1;
    }
    else {
	dobject = noun1;
	ndobjects = cnt1;
    }

    /* setup the flags for the action lookup */
    if (dobject) flag |= A_DOBJECT;
    if (iobject) flag |= A_IOBJECT;

    /* find the action */
    if ((action = findaction(verbs,preposition,flag)) == NIL) {
	parse_error();
	return (FALSE);
    }

    /* return successfully */
    return (TRUE);
}
Example #21
0
static void builddefer(const char *name)
{
	fcreate(name, DODFR);	/* see dict.h for DODFR and other CFA ids */
        writecell((ucell)0);
	writecell((ucell)findword("(semis)"));
}