예제 #1
0
파일: main.c 프로젝트: ludongzhou/tiger
Table_ interpExpList(A_expList exps, Table_ t) {
    if (exps->kind == A_lastExpList) {
        return interpExp(exps->u.last, t).t;
    } else {
        return interpExpList(exps->u.pair.tail, interpExp(exps->u.pair.head, t).t);
    }
}
예제 #2
0
파일: main.c 프로젝트: ludongzhou/tiger
Table_ interpStm(A_stm s, Table_ t) {
    if (s->kind == A_compoundStm) {
        t = interpStm(s->u.compound.stm1, t);
        t = interpStm(s->u.compound.stm2, t);
        return t;
    } else if (s->kind == A_assignStm) {
        struct IntAndTable int_and_table = interpExp(s->u.assign.exp, t);
        return update(int_and_table.t, s->u.assign.id, int_and_table.i);
    } else {
        return interpExpList(s->u.print.exps, t);
    }
}
예제 #3
0
파일: interp.c 프로젝트: legenddcr/Tiger
static struct IntAndTable interpExpList(A_expList expList, Table_ t)
{
  /* expression list can only appear in print statement. Implement print here */
  assert (expList != NULL);
  
  if (expList->kind == A_pairExpList) {
    struct IntAndTable iat = interpExp(expList->u.pair.head, t);
    printf("%d ", iat.i);
    return interpExpList(expList->u.pair.tail, iat.t);
  }
  else {
    struct IntAndTable iat = interpExp(expList->u.last, t);
    printf("%d ", iat.i);
    return iat;
  }
}
예제 #4
0
파일: interp.c 프로젝트: legenddcr/Tiger
static Table_ interpStm(A_stm stm, Table_ t)
{
  if (stm == NULL)
    return NULL;

  if (stm->kind == A_compoundStm)
    return interpStm(stm->u.compound.stm2, interpStm(stm->u.compound.stm1, t));
  else if (stm->kind == A_assignStm)
    return update(t, stm->u.assign.id, interpExp(stm->u.assign.exp, t).i);
  else {
    struct IntAndTable iat = interpExpList(stm->u.print.exps, t);
    //printf("%d", iat.i);
    printf("\n");
    return iat.t;
  }
}