void prettyEVENT(int indent, EVENT *event)
{
	indentprintf(indent, "");
	//prettyTYPE(function->type);
	printf("on \"%s\"",event->name);
	indentprintf(indent, "{\n");
	if (event->stms != NULL)
		prettySTM(indent+1, event->stms);
	indentprintf(indent, "}\n");
}
Пример #2
0
void prettySymbolTable(int indent, SymbolTable *sym)
{
  int i;
  
  indentprintf(indent, "/*\n");
  indentprintf(indent+1, "SymbolTable:\n");  

  for (i=0; i<HashSize; i++){
    if (sym->table[i] != NULL)
      prettySYMBOL(indent+1, sym->table[i]);
  }
  indentprintf(indent, "*/\n\n");
}
void prettyFUNCTION(int indent, FUNCTION *function)
{
	indentprintf(indent, "");
	//prettyTYPE(function->type);
	printf("function %s(",function->name);
	if (function->formals != NULL)
		prettyDECL(indent, function->formals);
	printf(")\n");
	indentprintf(indent, "{\n");
	if (function->stms != NULL)
		prettySTM(indent+1, function->stms);
	indentprintf(indent, "}\n");
}
Пример #4
0
void prettyPROGRAM(int indent, PROGRAM *program)
{
  indentprintf(indent, "program %s ",program->name);
  if (program->trigger != NULL)
   prettyTRIGGER(program->trigger);
  printf("\n");
 
  indentprintf(indent, "{\n");
  #if (PRINTSYMBOL)
    prettySymbolTable(indent+1, program->sym);
  #endif
  if (program->stms != NULL)
    prettySTM(indent+1, program->stms);
  indentprintf(indent, "}\n");
}
Пример #5
0
void prettyFUNCTION(int indent, FUNCTION *function)
{
  indentprintf(indent, "");
  prettyTYPE(function->type);
  printf("%s(",function->name);
  if (function->formals != NULL)
    prettyDECL(indent, function->formals);
  printf(")\n");
  indentprintf(indent, "{\n");
  #if (PRINTSYMBOL)
    prettySymbolTable(indent+1, function->sym);
  #endif
  if (function->stms != NULL)
    prettySTM(indent+1, function->stms);
  indentprintf(indent, "}\n");
}
Пример #6
0
void prettyDECL(int indent, DECL *decl)
{
  switch(decl->kind){
  case formalK:
    prettyTYPE(decl->type);
    printf("%s",decl->val.formalD.name);
    if(decl->next != NULL)
      printf(", ");
    break;
  case variableK:
    indentprintf(indent, "");
    prettyModifierKind(decl->val.variableD.modifier);
    prettyTYPE(decl->type);
    prettyIDENTIFIER(decl->val.variableD.identifiers);
    if (decl->val.variableD.initialization != NULL) {
      printf(" = ");
      prettyEXP(decl->val.variableD.initialization);
    }
    printf(";\n");
    break;
  case simplevarK:
    prettyTYPE(decl->type);
    printf("%s",decl->val.simplevarD.name);
    if (decl->val.simplevarD.initialization != NULL) {
      printf(" = ");
      prettyEXP(decl->val.simplevarD.initialization);
    }
    if(decl->next != NULL)
      printf(", ");
    break;
  }
  
  if(decl->next != NULL)
    prettyDECL(indent, decl->next);
}
Пример #7
0
void prettySYMBOL(int indent, SYMBOL *s)
{
  switch(s->kind) {
  case functionSym:
    indentprintf(indent, "Function ");
    break;
  case programSym:
    indentprintf(indent, "Program  ");
    break;
  case declSym:
    indentprintf(indent, "Variable ");
    break;
  }

  printf("%s\n", s->name);

  if (s->next != NULL)
    prettySYMBOL(indent, s->next);
}
Пример #8
0
void prettyTOPLEVEL(int indent, TOPLEVEL *toplevel)
{
  
  switch(toplevel->kind){
  case programK:
    prettyPROGRAM(indent, toplevel->val.programT);
    break;
  case functionK:
    prettyFUNCTION(indent, toplevel->val.functionT);
    break;
  }
  
  if(toplevel->next != NULL) {
    indentprintf(indent, "\n");
    prettyTOPLEVEL(indent, toplevel->next);
  }
}
void prettyTOPLEVEL(int indent, TOPLEVEL *toplevel)
{
	
	switch(toplevel->kind){
	case functionK:
		prettyFUNCTION(indent, toplevel->val.functionT);
		break;
	case eventK:
		prettyEVENT(indent, toplevel->val.eventT);
		break;
	case stmsK:
		prettySTM(indent, toplevel->val.stms);
		break;
	}
	
	if(toplevel->next != NULL) {
		indentprintf(indent, "\n");
		prettyTOPLEVEL(indent, toplevel->next);
	}
}
Пример #10
0
void prettySTM(int indent, STM *stm)
{
  switch (stm->kind) {
    case skipK:
      indentprintf(indent, ";\n");
      break;
    case expK:
      indentprintf(indent, "");
      prettyEXP(stm->val.expS);
      printf(";\n");
      break;
     case declstmK:
      prettyDECL(indent, stm->val.declstmS);
      break;
    case returnK:
      indentprintf(indent, "return ");
      if (stm->val.returnS.exp != NULL)
        prettyEXP(stm->val.returnS.exp);
      printf(";\n");
      break;
    case ifK:
      indentprintf(indent, "if (");
      prettyEXP(stm->val.ifS.condition);
      printf(")");
      prettySTM(indent, stm->val.ifS.body);
      break;
    case ifelseK:
      indentprintf(indent, "if (");
      prettyEXP(stm->val.ifelseS.condition);
      printf(")");
      prettySTM(indent, stm->val.ifelseS.thenpart);
      indentprintf(indent, " else ");
      prettySTM(indent, stm->val.ifelseS.elsepart);
      break;
    case whileK:
      indentprintf(indent, "while (");
      prettyEXP(stm->val.whileS.condition);
      printf(") ");
      prettySTM(indent, stm->val.whileS.body);
      break;
    case forK:
      indentprintf(indent, "for (");
      prettyFORINIT(indent, stm->val.forS.inits);
      printf("; ");
      prettyEXP(stm->val.forS.condition);
      printf("; ");
      prettyEXP(stm->val.forS.updates);
      printf(") ");
      prettySTM(indent, stm->val.forS.body);
      break;
  case sequenceK:
      prettySTM(indent, stm->val.sequenceS.first);
      prettySTM(indent, stm->val.sequenceS.second);
      break;
  case scopeK:
      printf("\n");
      indentprintf(indent, "{ /* new scope */\n");
      #if (PRINTSYMBOL)
        prettySymbolTable(indent+2, stm->val.scopeS.sym);
      #endif
      prettySTM(indent+1, stm->val.scopeS.stm);
      indentprintf(indent, "}\n");
      break;
  case setintK:
      indentprintf(indent,"setint(");
      prettyEntity(stm->val.setintS.kind);
      printf(", ");
      prettyEXP(stm->val.setintS.modelname);
      printf(",");      
      prettyEXP(stm->val.setintS.nr);
      printf(",");
      prettyEXP(stm->val.setintS.val);
      printf(")");
      break;
  case sleepK:
      indentprintf(indent,"sleep(");
      prettyEXP(stm->val.sleepS.time);
      printf(")"); 
      break;
   }
}
void prettySTM(int indent, STM *stm)
{
	switch (stm->kind) {
    case skipK:
		indentprintf(indent, ";\n");
		break;
    case expK:
		indentprintf(indent, "");
		prettyEXP(stm->val.expS);
		printf(";\n");
		break;
	case declstmK:
		prettyDECL(indent, stm->val.declstmS);
		break;
    case returnK:
		indentprintf(indent, "return ");
		if (stm->val.returnS.exp != NULL)
			prettyEXP(stm->val.returnS.exp);
		printf(";\n");
		break;
    case ifK:
		indentprintf(indent, "if (");
		prettyEXP(stm->val.ifS.condition);
		printf(")");
		prettySTM(indent, stm->val.ifS.body);
		break;
    case ifelseK:
		indentprintf(indent, "if (");
		prettyEXP(stm->val.ifelseS.condition);
		printf(")");
		prettySTM(indent, stm->val.ifelseS.thenpart);
		indentprintf(indent, " else ");
		prettySTM(indent, stm->val.ifelseS.elsepart);
		break;
    case whileK:
		indentprintf(indent, "while (");
		prettyEXP(stm->val.whileS.condition);
		printf(") ");
		prettySTM(indent, stm->val.whileS.body);
		break;
    case forK:
		indentprintf(indent, "for (");
		prettyFORINIT(indent, stm->val.forS.inits);
		printf("; ");
		prettyEXP(stm->val.forS.condition);
		printf("; ");
		prettyEXP(stm->val.forS.updates);
		printf(") ");
		prettySTM(indent, stm->val.forS.body);
		break;
	case sequenceK:
		prettySTM(indent, stm->val.sequenceS.first);
		prettySTM(indent, stm->val.sequenceS.second);
		break;
	case scopeK:
		printf("\n");
		indentprintf(indent, "{ /* new scope */\n");
		prettySTM(indent+1, stm->val.scopeS.stm);
		indentprintf(indent, "}\n");
		break;
	case sleepK:
		indentprintf(indent,"sleep(");
		prettyEXP(stm->val.sleepS.time);
		printf(")"); 
		break;
	case breakK:
		indentprintf(indent,"break;\n");
		break;
	case continueK:
		indentprintf(indent,"continue;\n");
		break;
	}
}