Advertisement
Guest User

Untitled

a guest
May 22nd, 2019
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.78 KB | None | 0 0
  1. void check_AST_Anotada(n1 root, int depth,n1 pai, int flag){
  2.     if(flagt == 2){ /*|| flagt == 1*/
  3.         int i;
  4.         char* desc_pai;
  5.         if(root != NULL){
  6.             if(strcmp(root->descricao,"Add") == 0 || strcmp(root->descricao,"Mul") == 0 || strcmp(root->descricao,"Sub") == 0 || strcmp(root->descricao,"Div") == 0){
  7.                 root->type = expression_Type(root);
  8.                 /*printf("%s - %s\n",root->descricao,root->type);*/
  9.             }
  10.             else if(strcmp(root->descricao,"Assign") == 0){
  11.                 /*Verificar se o id existe, se os filhos teem o mesmo tipo e ver se esta declarada com o mesmo tipo*/
  12.                 root->type = assign_type(root);
  13.                 /*printf("%s - %s\n",root->descricao,assign_type(root));*/
  14.             }
  15.             else if(strcmp(root->descricao,"Call") == 0){ /*Ver se os parametros estao todos coorrespondentes*/
  16.                 if(strcmp(Check_Type(root->filhos->valor,"return"),"none") == 0){
  17.                     root->type = "none";
  18.                 }
  19.                 else{
  20.                     root->type = Check_Type(root->filhos->valor,"return");
  21.                 }
  22.                
  23.             }
  24.             else if(strcmp(root->descricao,"Minus") == 0 || strcmp(root->descricao,"Plus")==0){
  25.                 /*Ver se é int ou float32*/
  26.                 root->type = expr_Unary_Type(root);
  27.             }
  28.             else if(strcmp(root->descricao,"Comma") == 0){
  29.                 root->type = expression_Comma_Type(root);
  30.             }
  31.             else if(strcmp(root->descricao,"ParseArgs") == 0){
  32.                 root->type = root->filhos->type;
  33.             }
  34.  
  35.             check_AST_Anotada(root->filhos, depth + 1, root, 0);
  36.  
  37.             check_AST_Anotada(root->irmaos, depth, pai , 1);
  38.         }
  39.     }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement