亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? chap29.lst

?? c語言大全及例程源碼
?? LST
?? 第 1 頁 / 共 4 頁
字號:
    exit(1);
  }

  prog--; /* back up to opening ( */
  strcpy(token, "main");
  call(); /* call main() to start interpreting */

  return 0;
}

/* Interpret a single statement or block of code. When
   interp_block() returns from its initial call, the final
   brace (or a return) in main() has been encountered.
*/
void interp_block(void)
{
  int value;
  char block = 0;

  do {
    token_type = get_token();

    /* If interpreting single statement, return on
       first semicolon.
    */

    /* see what kind of token is up */
    if(token_type == IDENTIFIER) {
      /* Not a keyword, so process expression. */
      putback();  /* restore token to input stream for
                     further processing by eval_exp() */
      eval_exp(&value);  /* process the expression */
      if(*token!=';') sntx_err(SEMI_EXPECTED);
    }
    else if(token_type==BLOCK) { /* if block delimiter */
      if(*token == '{') /* is a block */
        block = 1; /* interpreting block, not statement */
      else return; /* is a }, so return */
    }
    else /* is keyword */
      switch(tok) {
        case CHAR:
        case INT:     /* declare local variables */
          putback();
          decl_local();
          break;
        case RETURN:  /* return from function call */
          func_ret();
          return;
        case IF:      /* process an if statement */
          exec_if();
          break;
        case ELSE:    /* process an else statement */
          find_eob(); /* find end of else block
                         and continue execution */
          break;
        case WHILE:   /* process a while loop */
          exec_while();
          break;
        case DO:      /* process a do-while loop */
          exec_do();
          break;
        case FOR:     /* process a for loop */
          exec_for();
          break;
        case END:
          exit(0);
      }
  } while (tok != FINISHED && block);
}

/* Load a program. */
int load_program(char *p, char *fname)
{
  FILE *fp;
  int i=0;

  if((fp=fopen(fname, "rb"))==NULL) return 0;

  i = 0;
  do {
    *p = getc(fp);
    p++; i++;
  } while(!feof(fp) && i<PROG_SIZE);

  if(*(p-2) == 0x1a) *(p-2) = '\0'; /* null terminate the program */
  else *(p-1) = '\0';
  fclose(fp);
  return 1;
}

/* Find the location of all functions in the program
   and store global variables. */
void prescan(void)
{
  char *p, *tp;
  char temp[32];
  int datatype; 
  int brace = 0;  /* When 0, this var tells us that
                     current source position is outside
                     of any function. */

  p = prog;
  func_index = 0;
  do {
    while(brace) {  /* bypass code inside functions */
      get_token();
      if(*token == '{') brace++;
      if(*token == '}') brace--;
    }

    tp = prog; /* save current position */
    get_token();
    /* global var type or function return type */
    if(tok==CHAR || tok==INT) { 
      datatype = tok; /* save data type */
      get_token();
      if(token_type == IDENTIFIER) {
        strcpy(temp, token);
        get_token();
        if(*token != '(') { /* must be global var */
          prog = tp; /* return to start of declaration */
          decl_global();
        }
        else if(*token == '(') {  /* must be a function */
          func_table[func_index].loc = prog;
          func_table[func_index].ret_type = datatype;
          strcpy(func_table[func_index].func_name, temp);
          func_index++;
          while(*prog != ')') prog++;
          prog++;
          /* now prog points to opening curly 
             brace of function */
        }
        else putback();
      }
    }
    else if(*token == '{') brace++;
  } while(tok != FINISHED);
  prog = p;
}

/* Return the entry point of the specified function.
   Return NULL if not found.
*/
char *find_func(char *name)
{
  register int i;

  for(i=0; i < func_index; i++)
    if(!strcmp(name, func_table[i].func_name))
      return func_table[i].loc;

  return NULL;
 }

/* Declare a global variable. */
void decl_global(void)
{
  int vartype;

  get_token();  /* get type */

  vartype = tok; /* save var type */

  do { /* process comma-separated list */
    global_vars[gvar_index].v_type = vartype;
    global_vars[gvar_index].value = 0;  /* init to 0 */
    get_token();  /* get name */
    strcpy(global_vars[gvar_index].var_name, token);
    get_token();
    gvar_index++;
  } while(*token == ',');
  if(*token != ';') sntx_err(SEMI_EXPECTED);
}

/* Declare a local variable. */
void decl_local(void)
{
  struct var_type i;

  get_token();  /* get type */

  i.v_type = tok;
  i.value = 0;  /* init to 0 */

  do { /* process comma-separated list */
    get_token(); /* get var name */
    strcpy(i.var_name, token);
    local_push(i);
    get_token();
  } while(*token == ',');
  if(*token != ';') sntx_err(SEMI_EXPECTED);
}

/* Call a function. */
void call(void)
{
  char *loc, *temp;
  int lvartemp;

  loc = find_func(token); /* find entry point of function */
  if(loc == NULL)
    sntx_err(FUNC_UNDEF); /* function not defined */
  else {
    lvartemp = lvartos;  /* save local var stack index */
    get_args();  /* get function arguments */
    temp = prog; /* save return location */
    func_push(lvartemp);  /* save local var stack index */
    prog = loc;  /* reset prog to start of function */
    get_params(); /* load the function's parameters with
                     the values of the arguments */
    interp_block(); /* interpret the function */
    prog = temp; /* reset the program pointer */
    lvartos = func_pop(); /* reset the local var stack */
  }
}

/* Push the arguments to a function onto the local
   variable stack. */
void get_args(void)
{
  int value, count, temp[NUM_PARAMS];
  struct var_type i;

  count = 0;
  get_token();
  if(*token != '(') sntx_err(PAREN_EXPECTED);

  /* process a comma-separated list of values */
  do {
    eval_exp(&value);
    temp[count] = value;  /* save temporarily */
    get_token();
    count++;
  }while(*token == ',');
  count--;
  /* now, push on local_var_stack in reverse order */
  for(; count>=0; count--) {
    i.value = temp[count];
    i.v_type = ARG;
    local_push(i);
  }
}

/* Get function parameters. */
void get_params(void)
{
  struct var_type *p;
  int i;

  i = lvartos-1;
  do { /* process comma-separated list of parameters */
    get_token();
    p = &local_var_stack[i];
    if(*token != ')' ) {
      if(tok != INT && tok != CHAR)
        sntx_err(TYPE_EXPECTED);

      p->v_type = token_type;
      get_token();

      /* link parameter name with argument already on
         local var stack */
      strcpy(p->var_name, token);
      get_token();
      i--;
    }
    else break;
  } while(*token == ',');
  if(*token != ')') sntx_err(PAREN_EXPECTED);
}

/* Return from a function. */
void func_ret(void)
{
  int value;

  value = 0;
  /* get return value, if any */
  eval_exp(&value);

  ret_value = value;
}

/* Push a local variable. */
void local_push(struct var_type i)
{
  if(lvartos > NUM_LOCAL_VARS)
    sntx_err(TOO_MANY_LVARS);

  local_var_stack[lvartos] = i;
  lvartos++;
}

/* Pop index into local variable stack. */
int func_pop(void)
{
  functos--;
  if(functos < 0) sntx_err(RET_NOCALL);
  return call_stack[functos];
}

/* Push index of local variable stack. */
void func_push(int i)
{
  if(functos>NUM_FUNC)
   sntx_err(NEST_FUNC);
  call_stack[functos] = i;
  functos++;
}

/* Assign a value to a variable. */
void assign_var(char *var_name, int value)
{
  register int i;

  /* first, see if it's a local variable */
  for(i=lvartos-1; i >= call_stack[functos-1]; i--)  {
    if(!strcmp(local_var_stack[i].var_name, var_name)) {
      local_var_stack[i].value = value;
      return;
    }
  }
  if(i < call_stack[functos-1])
  /* if not local, try global var table */
    for(i=0; i < NUM_GLOBAL_VARS; i++)
      if(!strcmp(global_vars[i].var_name, var_name)) {
        global_vars[i].value = value;
        return;
      }
  sntx_err(NOT_VAR); /* variable not found */
}

/* Find the value of a variable. */
int find_var(char *s)
{
  register int i;

  /* first, see if it's a local variable */
  for(i=lvartos-1; i >= call_stack[functos-1]; i--)
    if(!strcmp(local_var_stack[i].var_name, token))
      return local_var_stack[i].value;

  /* otherwise, try global vars */
  for(i=0; i < NUM_GLOBAL_VARS; i++)
    if(!strcmp(global_vars[i].var_name, s))
      return global_vars[i].value;

  sntx_err(NOT_VAR); /* variable not found */
  return -1; 
}

/* Determine if an identifier is a variable. Return
   1 if variable is found; 0 otherwise.
*/
int is_var(char *s)
{
  register int i;

  /* first, see if it's a local variable */
  for(i=lvartos-1; i >= call_stack[functos-1]; i--)
    if(!strcmp(local_var_stack[i].var_name, token))
      return 1;

  /* otherwise, try global vars */
  for(i=0; i < NUM_GLOBAL_VARS; i++)
    if(!strcmp(global_vars[i].var_name, s))
      return 1;

  return 0;
}

/* Execute an if statement. */
void exec_if(void)
{
  int cond;

  eval_exp(&cond); /* get if expression */

  if(cond) { /* is true so process target of IF */
    interp_block();
  }
  else { /* otherwise skip around IF block and
            process the ELSE, if present */
    find_eob(); /* find start of next line */
    get_token();

    if(tok != ELSE) {
      putback();  /* restore token if
                     no ELSE is present */
      return;
    }
    interp_block();
  }
}

/* Execute a while loop. */
void exec_while(void)
{
  int cond;
  char *temp;

  putback();
  temp = prog;  /* save location of top of while loop */
  get_token();
  eval_exp(&cond);  /* check the conditional expression */
  if(cond) interp_block();  /* if true, interpret */
  else {  /* otherwise, skip around loop */
    find_eob();
    return;
  }
  prog = temp;  /* loop back to top */
}

/* Execute a do loop. */
void exec_do(void)
{
  int cond;
  char *temp;

  putback();
  temp = prog;  /* save location of top of do loop */

  get_token(); /* get start of loop */
  interp_block(); /* interpret loop */
  get_token();
  if(tok != WHILE) sntx_err(WHILE_EXPECTED);
  eval_exp(&cond); /* check the loop condition */
  if(cond) prog = temp; /* if true loop; otherwise,
                           continue on */
}

/* Find the end of a block. */
void find_eob(void)
{
  int brace;

  get_token();
  brace = 1;
  do {
    get_token();
    if(*token == '{') brace++;
    else if(*token == '}') brace--;
  } while(brace);
}

/* Execute a for loop. */
void exec_for(void)
{
  int cond;
  char *temp, *temp2;
  int brace ;

  get_token();
  eval_exp(&cond);  /* initialization expression */
  if(*token != ';') sntx_err(SEMI_EXPECTED);
  prog++; /* get past the ; */
  temp = prog;
  for(;;) {
    eval_exp(&cond);  /* check the condition */
    if(*token != ';') sntx_err(SEMI_EXPECTED);
    prog++; /* get past the ; */
    temp2 = prog;

    /* find the start of the for block */
    brace = 1;
    while(brace) {
      get_token();
      if(*token == '(') brace++;
      if(*token == ')') brace--;
    }

    if(cond) interp_block();  /* if true, interpret */
    else {  /* otherwise, skip around loop */
      find_eob();
      return;
    }
    prog = temp2;
    eval_exp(&cond); /* do the increment */
    prog = temp;  /* loop back to top */
  }
}

listing 10
/* Declare a local variable. */
void decl_local(void)
{
  struct var_type i;

  get_token();  /* get type */

  i.v_type = tok;
  i.value = 0;  /* init to 0 */

  do { /* process comma-separated list */
    get_token(); /* get var name */
    strcpy(i.var_name, token);
    local_push(i);
    get_token();
  } while(*token == ',');
  if(*token != ';') sntx_err(SEMI_EXPECTED);
}

/* Push a local variable. */
void local_push(struct var_type i)
{
  if(lvartos > NUM_LOCAL_VARS)
    sntx_err(TOO_MANY_LVARS);

  local_var_stack[lvartos] = i;
  lvartos++;
}

listing 11
/* Call a function. */
void call(void)
{
  char *loc, *temp;
  int lvartemp;

  loc = find_func(token); /* find entry point of function */
  if(loc == NULL)
    sntx_err(FUNC_UNDEF); /* function not defined */
  else {

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
日韩精品五月天| 美女视频一区在线观看| 爽好多水快深点欧美视频| 久久www免费人成看片高清| 男男成人高潮片免费网站| 婷婷久久综合九色综合伊人色| 国产精品久久久久久久久搜平片| 欧美国产日韩在线观看| 亚洲欧美国产77777| 欧美aaaaaa午夜精品| 成人免费观看男女羞羞视频| 色呦呦日韩精品| 欧美一区二区三区日韩视频| 国产精品理论在线观看| 日本视频免费一区| 91成人免费在线视频| 精品国产一二三| 一区二区三区资源| 另类人妖一区二区av| 成人av综合在线| 99国产精品国产精品毛片| 欧美一区二区三区啪啪| 日韩美女视频一区| 精品一区二区三区免费播放 | 97精品超碰一区二区三区| 在线电影一区二区三区| 亚洲一区二区在线免费看| 国产成人亚洲综合a∨婷婷| 7777精品伊人久久久大香线蕉经典版下载| 精品久久久久一区二区国产| 亚洲va韩国va欧美va| av亚洲产国偷v产偷v自拍| 精品精品欲导航| 蜜乳av一区二区三区| 日韩视频免费观看高清完整版 | 一区二区三区美女视频| 欧美一级高清片| 国产精品三级久久久久三级| 紧缚奴在线一区二区三区| 在线观看91av| 蜜臀av性久久久久蜜臀aⅴ四虎| 99久久国产综合精品女不卡| 国产亚洲精品bt天堂精选| 成人久久18免费网站麻豆| 国产偷国产偷精品高清尤物| 风间由美一区二区三区在线观看| 亚洲国产欧美另类丝袜| 中文字幕乱码亚洲精品一区| 精品国产乱码久久久久久影片| 色婷婷av一区二区三区之一色屋| 国产综合成人久久大片91| 日韩电影在线一区二区三区| 欧美成人国产一区二区| 91天堂素人约啪| 国产一区二区精品久久91| 亚洲一二三四区不卡| 欧美日韩国产综合一区二区三区| 美女视频黄频大全不卡视频在线播放| 欧美国产日韩在线观看| 欧美理论电影在线| 99re这里只有精品6| 国产一区二区三区免费看| 日韩国产一二三区| 国产精品美女久久久久久久久久久 | 亚洲电影激情视频网站| 亚洲欧美激情在线| 99国产精品久久久久久久久久久| 国产精品综合视频| 337p粉嫩大胆色噜噜噜噜亚洲| 蜜臀国产一区二区三区在线播放| 亚洲电影一级片| 蜜臀久久99精品久久久久久9| 久久不见久久见免费视频7| 捆绑调教美女网站视频一区| 激情亚洲综合在线| 成人黄色综合网站| 欧美日本高清视频在线观看| 欧美一区二区精品久久911| 日韩一级片在线观看| 久久嫩草精品久久久精品| 国产 欧美在线| 久久99久国产精品黄毛片色诱| 日韩免费高清视频| 免费一级欧美片在线观看| 久久看人人爽人人| 精品少妇一区二区三区视频免付费 | 91啪亚洲精品| 国产精品乱码人人做人人爱| 欧美成人aa大片| 欧美日韩一区久久| 欧美日韩在线一区二区| 欧美日韩国产高清一区二区 | 国产精品久久一卡二卡| 欧美专区在线观看一区| 91丝袜美女网| 91丨porny丨首页| 欧美专区日韩专区| 91麻豆精品国产91久久久更新时间| 69堂成人精品免费视频| 日韩欧美亚洲国产精品字幕久久久 | 在线成人av网站| 日韩欧美在线一区二区三区| 久久夜色精品国产噜噜av| 亚洲国产经典视频| 亚洲影视资源网| 日韩激情一区二区| 国产曰批免费观看久久久| 成人小视频在线| 在线观看日产精品| 久久综合网色—综合色88| 国产精品无遮挡| 午夜久久久影院| 国产精品一区二区黑丝| 在线观看一区二区视频| 日韩午夜电影在线观看| 综合在线观看色| 麻豆成人av在线| 99久久婷婷国产综合精品电影 | 美女视频黄 久久| 成人免费视频app| 欧美日韩精品综合在线| 日本一区二区三区高清不卡| 亚洲一区视频在线观看视频| 国产在线精品一区二区夜色| 色伊人久久综合中文字幕| 日韩欧美成人激情| 亚洲美女在线一区| 国产精品自拍网站| 欧美日韩一区不卡| 国产精品美女久久久久aⅴ| 日本欧美大码aⅴ在线播放| 成人国产视频在线观看| 欧美电影免费观看高清完整版 | 蜜桃av噜噜一区| 色哟哟日韩精品| 欧美—级在线免费片| 日本欧美久久久久免费播放网| 97精品电影院| 久久精品一区二区三区四区| 日韩高清不卡一区二区三区| 不卡的电影网站| 久久久99精品久久| 美女网站视频久久| 欧美无砖砖区免费| 亚洲视频一区二区在线| 丁香婷婷综合激情五月色| 欧美一区二区三区在线视频| 亚洲精品日韩一| k8久久久一区二区三区 | 欧美日韩美女一区二区| 亚洲天天做日日做天天谢日日欢| 国内精品不卡在线| 日韩精品在线一区| 日韩高清在线一区| 欧美女孩性生活视频| 综合婷婷亚洲小说| 成人18视频日本| 日本一区二区免费在线| 韩国女主播一区二区三区| 日韩亚洲欧美成人一区| 首页国产欧美久久| 欧美在线观看一二区| 亚洲精品欧美在线| 91国偷自产一区二区开放时间 | 亚洲精品第1页| 91在线观看成人| 亚洲欧美色综合| 91在线观看美女| 亚洲激情在线激情| 色婷婷综合久色| 亚洲午夜视频在线| 欧美综合天天夜夜久久| 一区二区三区日韩欧美精品 | 亚洲午夜精品在线| 在线免费观看日本一区| 亚洲韩国一区二区三区| 欧美日韩在线三区| 日本在线不卡视频| 精品日韩一区二区三区| 国产成人精品亚洲777人妖 | 97se亚洲国产综合自在线不卡| 国产精品白丝在线| 日本精品一级二级| 亚洲国产精品自拍| 欧美一区二区久久| 国产一区二区三区免费播放| 久久久99久久精品欧美| 国产99久久久国产精品免费看| 成人欧美一区二区三区白人| 在线观看91视频| 蜜桃视频免费观看一区| 久久久久高清精品| 91麻豆福利精品推荐| 午夜精品一区二区三区免费视频| 欧美一区二区黄| 国产成人精品一区二| 亚洲一区在线电影| 2023国产精华国产精品| 99re成人在线| 免费成人在线视频观看|