QString Document::prettyPrintedFunction(const QString &name) const { if (!m_functions.contains(name)) { THROW(EIncorrectRpnCode()); } PrettyPrinter prettyPrinter(this); return prettyPrinter.process(m_functions.value(name), name); }
void prettyPrinter(AST* node) { int i ; addTab (numTab) ; AST_printAST (node->type) ; if(node->size != 0) { for(i=0; i<node->size; i++) { fprintf(stdout, " []"); } } if(node->stringVal != NULL) fprintf(stdout, " [%s]", node->stringVal); if(node->type == AST_NUMINT) fprintf(stdout, " [%d]", node->intVal); Symbols_printSYM (node->symbol_type) ; if(node->firstChild == NULL) fprintf(stdout, " @%d\n", node->line); else if(node->firstChild != NULL) { fprintf(stdout, " @%d { \n", node->line); numTab++ ; prettyPrinter(node->firstChild) ; addTab (numTab) ; fprintf(stdout, " }\n"); } if(node->nextSibling != NULL) prettyPrinter(node->nextSibling) ; else numTab--; }
int main (void) { //yydebug = 1; yyparse(); prettyPrinter(programa) ; error = Symbols_annotate(programa) ; if (error == 1) //prettyPrinter(programa) ; if (error == 0) return 0 ; else return 1 ; }