Esempio n. 1
0
/**
 * non-declaration statement
 */
do_statement () {
        if (amatch ("if", 2)) {
                doif ();
                lastst = STIF;
        } else if (amatch ("while", 5)) {
                dowhile ();
                lastst = STWHILE;
        } else if (amatch ("switch", 6)) {
                doswitch ();
                lastst = STSWITCH;
        } else if (amatch ("do", 2)) {
                dodo ();
                need_semicolon ();
                lastst = STDO;
        } else if (amatch ("for", 3)) {
                dofor ();
                lastst = STFOR;
        } else if (amatch ("return", 6)) {
                doreturn ();
                need_semicolon ();
                lastst = STRETURN;
        } else if (amatch ("break", 5)) {
                dobreak ();
                need_semicolon ();
                lastst = STBREAK;
        } else if (amatch ("continue", 8)) {
                docont ();
                need_semicolon ();
                lastst = STCONT;
        } else if (match (";"))
                ;
        else if (amatch ("case", 4)) {
                docase ();
                lastst = statement (NO);
        } else if (amatch ("default", 7)) {
                dodefault ();
                lastst = statement (NO);
        } else if (match ("__asm__")) {
                doasm ();
                lastst = STASM;
        } else if (match("#")) {
                kill();
        } else if (match ("{"))
                do_compound (NO);
        else {
                expression (YES);
/*              if (match (":")) {
                        dolabel ();
                        lastst = statement (NO);
                } else {
*/                      need_semicolon ();
                        lastst = STEXP;
/*              }
*/      }
}
Esempio n. 2
0
File: bas1.c Progetto: LGTMCU/f32c
int
main(int argc, char **argv)
{
	int i = 0;
	int fp;

#ifdef f32c
	setup_f32c();
	maxfiles = MAXFILES;
#else
	catchsignal();
#endif
	startfp();              /* start up the floating point hardware */

	setup_fb();		/* video framebuffer */
#ifndef f32c
	setupfiles(argc,argv);
	setupmyterm();		/* set up files after processing files */
#endif
	program = 0;
	clear();
	prints("Rabbit BASIC version 2.1.3 (built " __DATE__ ")\n");
	if(setexit() == ERR_RESET){
		drop_fns();
		execute();	/* execute the line */
	}
	drop_fns();
	docont();
	stocurlin=0;            /* say we are in immeadiate mode */
	if(cursor)              /* put cursor on a blank line */
		prints( (char *)nl);
	
	if (firstrun && (
#ifdef f32c
	    (fp = open("d:autoexec.bas",0)) > 0 ||
#endif
	    (fp = open("autoexec.bas",0)) > 0)) {
		firstrun = 0;
		readfi(fp, 0, 0);
		close(fp);
        	clear();
        	if (program) {
        		stocurlin=program;
        		point= program->lin;
        		elsecount=0;
        		execute();
		}
	}
	firstrun = 0;

	prints("Ready\n");

	for(;;){
		do{
			trapped=0;
			line[0] = '>';
			line[1] = 0;
			VOID edit( (ival)1, (ival)1, (ival)0);
		}while( trapped || ( !(i=compile(1, nline, 0)) && !linenumber));
		if(!linenumber)
			break;
		insert(i);
	}
	if(inserted){
		inserted=0;
		clear();
		closeall();
	}

#ifdef MSDOS
	lcount = 0;
#endif
	clr_stack(bstack);	/* reset the gosub stack */
	bstack = estack = 0;
	if(str_used)		/* free any spare strings */
		FREE_STR(str_used);

	trap_env.e_stolin = 0;	/* disable error traps */
	intrap=0;               /* say we are not in the error trap */
	trapped=0;              /* say we haven't got a cntrl-c */
	cursor=0;               /* cursor is at start of line */
	elsecount=0;            /* disallow elses as terminators */
	point=nline;            /* start executing at start of input line */
	stocurlin=0;            /* start of current line is null- see 'next' */
	execute();              /* execute the line */
	return(-1);             /* see note below */
}