Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void percorre_AST (n1 roots){
- n1 root = roots;
- int verificaIrmao = 1;
- root = root->filhos;
- scope_Root = init_Scope("Global");
- addPutcharGetChar();
- while(verificaIrmao == 1){
- if(strcmp(root->descricao,"VarDecl") == 0){
- adiciona_VarDecl(root);
- }
- else if(strcmp(root->descricao,"FuncDecl") == 0){
- if(checkFuncDecl(root->filhos->filhos->valor) == 0 && checkFuncInTable(root->filhos->filhos->valor) == 0){
- addFuncToGlogal(root);
- }
- }
- root=root->irmaos;
- if(root==NULL){
- verificaIrmao=0;
- }
- }
- printScopes();
- printf("\n");
- //imprime_AST(roots,0);
- imprime_AST_Anotada_Main(roots,0,"Program","Global");
- }
- void adiciona_VarDecl(n1 var_decl_Root){
- char* descricaoLower = NULL;
- table_Pointer tableCur = scope_Root->tabelas;
- if(checkVarDecl(var_decl_Root->filhos->irmaos->valor,scope_Root) == 0){
- while(tableCur->next != NULL){
- tableCur = tableCur->next;
- }
- tableCur->next = init_Table(var_decl_Root->filhos->irmaos->valor);
- descricaoLower = tornaPrimeiroCharEmLowerCase(var_decl_Root->filhos->descricao,descricaoLower);
- tableCur->next->type = descricaoLower;
- /*printf("%s\t%s\n",var_decl_Root->filhos->descricao,descricaoLower);*/
- var_decl_Root->filhos->irmaos->type = descricaoLower;
- tableCur->next->params = "VarDecl";
- }
- else{
- printf("Line %d, column %d: Symbol %s already defined\n",var_decl_Root->filhos->irmaos->line,var_decl_Root->filhos->irmaos->coluna,var_decl_Root->filhos->irmaos->valor);
- }
- return;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement