Example #1
0
void PrintParseTreeFormat(SYNTAX_TREE*  ast,
                          GRAMMAR_TABLE grammar)
{
    if (ast->numChildren > 0) {
        int i;
        for (i = 0; i < ast->numChildren; i++)
            PrintParseTreeFormat(ast->children[i], grammar);
    } else {
        if (ast->string && ast->token != gSymbolEndLine)
        {
            int i;
            for (i = 0; i < ast->length; i++)
                printf("%c", ast->string[i]);
        }
        else
        {
            printf("%s", GetElement(ast->token, grammar));
        }
    }
}
Example #2
0
void PrintStackTrace()
{
    CALLSTACK* stack = &gStackTrace;
    printf("Program halted on line %i.\n", (line_error+1));
    if (failed_production) {
        printf("Failed production: ");
        /* PrintParseTree(failed_production, CONTEXT_FREE_GRAMMAR); */
        PrintParseTreeFormat(failed_production, CONTEXT_FREE_GRAMMAR);
        printf("\n");
    }

    if (stack->fn_name) {
        printf("Printing stack trace:\n\n");
        int depth = 0; int i;
        while (stack) {
            for (i = 0; i < depth; i++) printf("  ");
            //printf("%i. %s:\n", depth, stack->fn_name);
            PrintFunction(stack->function);
            printf("\n");
            stack = stack->next;
            depth++;
        }
    }
}