|
关于Basic程序解释器及编译原理的简单化(1)---Basic器的语法分析及主要代码(10) char *t; if (argc!=2) { printf ("usage: run <filename>\n"); exit (1); } /* allocate memory for the program */ if (!(p_buf=(char *)malloc(PROG_SIZE))) { printf ("allocation failure"); exit (1); } /* load the program to execute */ if (!load_program(p_buf,argv[1])) exit(1); if (setjmp(e_buf)) exit(1); /* initialize the long jump */ prog = p_buf; scan_labels(); /* find the labels in the program */ ftos = 0; /* initialize the FOR stack index */ gtos = 0; /* initialize the GOSUB stack index */ do { token_type = get_token(); /* check for assignment stack */ if (token_type==VARIABLE) { putback(); /* return the varto the input stream */ assignment(); /* must 1: assignment statemnet */ } else /* is command */ switch (tok) { case PRINT: print();
|