⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tree.cpp

📁 c语言的简化编译器
💻 CPP
📖 第 1 页 / 共 2 页
字号:
  p->kind = plusK;
  p->val.plusE.left = left;
  p->val.plusE.right = right;
  p->next = NULL;
  return p;
}

struct EXP *makeEXPminus(struct EXP *left,struct  EXP *right)
{
  EXP *p = NEW(EXP);
  p->type = NULL;
  p->lineno = lineno;
  p->kind = minusK;
  p->val.minusE.left = left;
  p->val.minusE.right = right;
  p->next = NULL;
  return p;
}

struct EXP *makeEXPmult(struct EXP *left, struct EXP *right)
{
  EXP *p = NEW(EXP);
  p->type = NULL;
  p->lineno = lineno;
  p->kind = multK;
  p->val.multE.left = left;
  p->val.multE.right = right;
  p->next = NULL;\
  return p;
}

struct EXP *makeEXPdiv(struct EXP *left,struct  EXP *right)
{
  EXP *p = NEW(EXP);
  p->type = NULL;
  p->lineno = lineno;
  p->kind = divK;
  p->val.divE.left = left;
  p->val.divE.right = right;
  p->next = NULL;
  return p;
}

struct EXP *makeEXPmodulo(struct EXP *left,struct  EXP *right)
{
  EXP *p = NEW(EXP);
  p->type = NULL;
  p->lineno = lineno;
  p->kind = moduloK;
  p->val.moduloE.left = left;
  p->val.moduloE.right = right;
  p->next = NULL;
  return p;
}

struct EXP *makeEXPand(struct EXP *left,struct  EXP *right)
{
  EXP *p = NEW(EXP);
  p->type = NULL;
  p->lineno = lineno;
  p->kind = andK;
  p->val.andE.left = left;
  p->val.andE.right = right;
  p->next = NULL;
  return p;
}

struct EXP *makeEXPor(struct EXP *left,struct  EXP *right)
{
  EXP *p = NEW(EXP);
  p->type = NULL;
  p->lineno = lineno;
  p->kind = orK;
  p->val.orE.left = left;
  p->val.orE.right = right;
  p->next = NULL;
  return p;
}


struct EXP *makeEXPcall(char *name,struct  EXP *arguments)
{
  EXP *p = NEW(EXP);
  p->type = NULL;
  p->lineno = lineno;
  p->kind = callK;
  p->val.callE.name = name;
  p->val.callE.arguments = arguments;
  p->next = NULL;
  return p;
}


struct EXP *makeEXPcast(struct TYPE *type,struct  EXP *exp)
{
  EXP *p = NEW(EXP);
  p->type = NULL;
  p->lineno = lineno;
  p->kind = castK;
  p->val.castE.type = type;
  p->val.castE.exp = exp;
  p->next = NULL;
  return p;
}


struct LVALUE *makeLVALUEid(char *id)
{
  LVALUE *p = NEW(LVALUE);
  p->lineno = lineno;
  p->kind = idK;
  p->val.idL = id;
  return p;
}




/* ********* CODE ******************* */

CODE *makeCODEnop(CODE *next)
{ CODE *c;
  c = NEW(CODE);
  c->kind = nopCK;
  c->visited = 0;
  c->next = next;
  return c;
}

 
CODE *makeCODEimul(CODE *next)
{ CODE *c;
  c = NEW(CODE);
  c->kind = imulCK;
  c->visited = 0;
  c->next = next;
  return c;
}
 
CODE *makeCODEineg(CODE *next)
{ CODE *c;
  c = NEW(CODE);
  c->kind = inegCK;
  c->visited = 0;
  c->next = next;
  return c;
}
 
CODE *makeCODEirem(CODE *next)
{ CODE *c;
  c = NEW(CODE);
  c->kind = iremCK;
  c->visited = 0;
  c->next = next;
  return c;
}
 
CODE *makeCODEisub(CODE *next)
{ CODE *c;
  c = NEW(CODE);
  c->kind = isubCK;
  c->visited = 0;
  c->next = next;
  return c;
}

CODE *makeCODEidiv(CODE *next)
{ CODE *c;
  c = NEW(CODE);
  c->kind = idivCK;
  c->visited = 0;
  c->next = next;
  return c;
}
 
CODE *makeCODEiadd(CODE *next)
{ CODE *c;
  c = NEW(CODE);
  c->kind = iaddCK;
  c->visited = 0;
  c->next = next;
  return c;
}


CODE *makeCODEaadd(CODE *next)
{ CODE *c;
  c = NEW(CODE);
  c->kind = aaddCK;
  c->visited = 0;
  c->next = next;
  return c;
}


CODE *makeCODElabel(int label, CODE *next)
{ CODE *c;
  c = NEW(CODE);
  c->kind = labelCK;
  c->visited = 0;
  c->val.labelC = label;
  c->next = next;
  return c;
}
 
CODE *makeCODEgoto(int label, CODE *next)
{ CODE *c;
  c = NEW(CODE);
  c->kind = gotoCK;
  c->visited = 0;
  c->val.gotoC = label;
  c->next = next;
  return c;
}
 
CODE *makeCODEifeq(int label, CODE *next)
{ CODE *c;
  c = NEW(CODE);
  c->kind = ifeqCK;
  c->visited = 0;
  c->val.ifeqC = label;
  c->next = next;
  return c;
}
 
CODE *makeCODEifne(int label, CODE *next)
{ CODE *c;
  c = NEW(CODE);
  c->kind = ifneCK;
  c->visited = 0;
  c->val.ifneC = label;
  c->next = next;
  return c;
}
 
CODE *makeCODEif_acmpeq(int label, CODE *next)
{ CODE *c;
  c = NEW(CODE);
  c->kind = if_acmpeqCK;
  c->visited = 0;
  c->val.if_acmpeqC = label;
  c->next = next;
  return c;
}
 
CODE *makeCODEif_acmpne(int label, CODE *next)
{ CODE *c;
  c = NEW(CODE);
  c->kind = if_acmpneCK;
  c->visited = 0;
  c->val.if_acmpneC = label;
  c->next = next;
  return c;
}

 
CODE *makeCODEif_icmpeq(int label, CODE *next)
{ CODE *c;
  c = NEW(CODE);
  c->kind = if_icmpeqCK;
  c->visited = 0;
  c->val.if_icmpeqC = label;
  c->next = next;
  return c;
}
 
CODE *makeCODEif_icmpgt(int label, CODE *next)
{ CODE *c;
  c = NEW(CODE);
  c->kind = if_icmpgtCK;
  c->visited = 0;
  c->val.if_icmpgtC = label;
  c->next = next;
  return c;
}
 
CODE *makeCODEif_icmplt(int label, CODE *next)
{ CODE *c;
  c = NEW(CODE);
  c->kind = if_icmpltCK;
  c->visited = 0;
  c->val.if_icmpltC = label;
  c->next = next;
  return c;
}
 
CODE *makeCODEif_icmple(int label, CODE *next)
{ CODE *c;
  c = NEW(CODE);
  c->kind = if_icmpleCK;
  c->visited = 0;
  c->val.if_icmpleC = label;
  c->next = next;
  return c;
}
 
CODE *makeCODEif_icmpge(int label, CODE *next)
{ CODE *c;
  c = NEW(CODE);
  c->kind = if_icmpgeCK;
  c->visited = 0;
  c->val.if_icmpgeC = label;
  c->next = next;
  return c;
}
 
CODE *makeCODEif_icmpne(int label, CODE *next)
{ CODE *c;
  c = NEW(CODE);
  c->kind = if_icmpneCK;
  c->visited = 0;
  c->val.if_icmpneC = label;
  c->next = next;
  return c;
}
 
CODE *makeCODEireturn(CODE *next)
{ CODE *c;
  c = NEW(CODE);
  c->kind = ireturnCK;
  c->visited = 0;
  c->next = next;
  return c;
}
 
CODE *makeCODEareturn(CODE *next)
{ CODE *c;
  c = NEW(CODE);
  c->kind = areturnCK;
  c->visited = 0;
  c->next = next;
  return c;
}
 
CODE *makeCODEreturn(CODE *next)
{ CODE *c;
  c = NEW(CODE);
  c->kind = returnCK;
  c->visited = 0;
  c->next = next;
  return c;
}
 
CODE *makeCODEaload(int arg, CODE *next)
{ CODE *c;
  c = NEW(CODE);
  c->kind = aloadCK;
  c->visited = 0;
  c->val.aloadC = arg;
  c->next = next;
  return c;
}

CODE *makeCODEastore(int arg, CODE *next)
{ CODE *c;
  c = NEW(CODE);
  c->kind = astoreCK;
  c->visited = 0;
  c->val.astoreC = arg;
  c->next = next;
  return c;
}
 
CODE *makeCODEiload(int arg, CODE *next)
{ CODE *c;
  c = NEW(CODE);
  c->kind = iloadCK;
  c->visited = 0;
  c->val.iloadC = arg;
  c->next = next;
  return c;
}
 
CODE *makeCODEistore(int arg, CODE *next)
{ CODE *c;
  c = NEW(CODE);
  c->kind = istoreCK;
  c->visited = 0;
  c->val.istoreC = arg;
  c->next = next;
  return c;
}
 
 
CODE *makeCODEdup(CODE *next)
{ CODE *c;
  c = NEW(CODE);
  c->kind = dupCK;
  c->visited = 0;
  c->next = next;
  return c;
}
 
CODE *makeCODEpop(CODE *next)
{ CODE *c;
  c = NEW(CODE);
  c->kind = popCK;
  c->visited = 0;
  c->next = next;
  return c;
}

 
CODE *makeCODEldc_int(int arg, CODE *next)
{ CODE *c;
  c = NEW(CODE); 
  c->kind = ldc_intCK; 
  c->visited = 0;
  c->val.ldc_intC = arg; 
  c->next = next;
  return c;
}
 
 
CODE *makeCODEldc_string(char *arg, CODE *next)
{ CODE *c;
  c = NEW(CODE);
  c->kind = ldc_stringCK;
  c->visited = 0;
  c->val.ldc_stringC = arg;
  c->next = next;
  return c;
}
 
 
CODE *makeCODEcall(char *arg, char* signature, CODE *next)
{ CODE *c;
  c = NEW(CODE);
  c->kind = callCK;
  c->visited = 0;
  c->val.callVals.callC = arg;
  c->val.callVals.callSignatureC = signature;
  c->next = next;
  return c;
}



CODE *makeCODEsetint(EntityKind kind, CODE *next)
{ CODE *c;
  c = NEW(CODE);
  
  switch(kind) {
    case mdlEntity:
      c->kind = setint_mdlCK;
      break;
    case particleEntity:
      c->kind = setint_particleCK;
      break;
    case playerEntity:
      c->kind = setint_plyCK;
      break;     
    case lightEntity:
      c->kind = setint_lightCK;
      break;     
    case cameraEntity:
      c->kind = setint_camCK;
      break;     
  }
    
  c->visited = 0;
  c->next = next;
  return c;
}



CODE *makeCODEsleep(CODE *next) 
{ CODE *c;
  c = NEW(CODE);
  c->kind = sleepCK;
  c->visited = 0;
  c->next = next;
  return c;
}

CODE *makeCODEsleepUntilTriggered(CODE *next) 
{ CODE *c;
  c = NEW(CODE);
  c->kind = sleep_trigCK;
  c->visited = 0;
  c->next = next;
  return c;
}



CODE *makeCODEcast(TYPE *source, TYPE *dest, CODE *next) {
	
 CODE *c;
 c = NEW(CODE);
 
 if (source->kind == intK && dest->kind == stringK)
   c->kind = cast_inttostringCK; 
 
 if (source->kind == stringK && dest->kind == intK)
   c->kind = cast_stringtointCK; 
   
 if (source->kind == boolK && dest->kind == stringK)
   c->kind = cast_booltostringCK;   
  
  c->visited = 0;
  c->next = next;
  return c;	
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -