Example #1
0
File: ast.c Project: 8l/fcc
void astDestroy (ast* Node) {
    for (ast *Current = Node->firstChild, *Next = Current ? Current->nextSibling : 0;
         Current;
         Current = Next, Next = Next ? Next->nextSibling : 0)
        astDestroy(Current);

    if (Node->l)
        astDestroy(Node->l);

    if (Node->r && Node->tag != astUsing)
        astDestroy(Node->r);

    if (Node->dt)
        typeDestroy(Node->dt);

    free(Node->literal);
    free(Node);
}
Example #2
0
File: ast.c Project: Fedjmike/tush
void astDestroy (ast* node) {
    if (node->l)
        astDestroy(node->l);

    if (node->r)
        astDestroy(node->r);

    vectorFreeObjs(&node->children, (vectorDtor) astDestroy);

    if (   node->kind == astStrLit || node->kind == astFileLit
        || node->kind == astGlobLit)
        free(node->literal.str);

    if (node->kind == astFnLit && node->captured) {
        vectorFree(node->captured);
        /*Stored indirectly*/
        free(node->captured);
    }

    free(node);
}
Example #3
0
void parserDestroy(Parser* parser) {
    // compileWaitQueueDestroy(&parser->file_queue);
    // compileCacheTreeDestroy(&parser->file_cache);

    if (parser->ast != NULL)
        astDestroy(parser->ast);
    if (parser->lexer != NULL)
        lexerDestroy(parser->lexer);
    if (parser->cur_scope != NULL)
        scopeDestroy(parser->cur_scope);

    parser->lexer     = NULL;
    parser->ast       = NULL;
    parser->cur_scope = NULL;
    parser->cur_token = NULL;
    parser->err_count = 0;
}