예제 #1
0
파일: main.c 프로젝트: luser-dr00g/inca
int mainloop(){
    static int *buf = NULL;
    static int buflen;
    int expn;
    char *prompt = "        ";
    int last_was_assn;

    while((buf?buf[0]=0:0), get_line(prompt, &buf, &buflen, &expn)){

        IFDEBUG(2,
            for (int i=0;i<expn;i++)
                DEBUG(2,"%04x ", buf[i]);
            DEBUG(2,"\n");
            );

        array expr = array_new_dims(expn);
        memcpy(expr->data,buf,expn*sizeof(int));

        object e = scan_expression(expr, env);

        object x = execute(e, env, &last_was_assn);
        //object x = execute_expression(a, env, &last_was_assn);
        DEBUG(2, "last_was_assn = %d\n", last_was_assn);
        IFDEBUG(2, print(x, 10, 1));

        if (!last_was_assn && x!=mark)
            print(x, 0, 1);
    }
예제 #2
0
int command (void)
/***** command
	scan a command and interpret it.
	return, if the user wants to quit.
*****/
{	header *expr;
	int ret=c_none;
	quit=0; error=0; errorout=0;
	while(1)
	{	scan_space();
		if (*next) break;
		else next_line();
	}
	if (*next==1) return ret;
	expr=scan_expression();
	if (!expr) { newram=endlocal; return ret; }
	if (error)
	{	newram=endlocal;
		print_error(next);
		next=input_line; input_line[0]=0;
		return ret;
	}
	if (expr==&commandheader)
	{	newram=endlocal;
		return commandtype;
	}
	switch (expr->type)
	{	case s_real :
		case s_complex :
		case s_matrix :
		case s_cmatrix :
		case s_imatrix :
		case s_string :
		case s_interval :
			if (*next!=';') give_out(expr);
			if (*next==',' || *next==';') next++;
			break;
		case s_reference :
		case s_submatrix :
		case s_csubmatrix :
		case s_isubmatrix :
			do_assignment(expr);
			break;
		default : break;
	}
	if (error) print_error(next);
	newram=endlocal;
	if (error) { next=input_line; input_line[0]=0; }
	return ret;
}