static void print_compact(FILE* fp, ast_t* ast, size_t indent, bool type) { for(size_t i = 0; i < indent; i++) fprintf(fp, in); ast_t* child = ast->child; bool parens = type || (child != NULL) || (ast->type != NULL); if(parens) fprintf(fp, type ? "[" : "("); print_token(fp, ast->t); if(ast->symtab != NULL) fprintf(fp, ":scope"); while(child != NULL) { fprintf(fp, " "); print_compact(fp, child, 0, false); child = child->sibling; } if(ast->type != NULL) { fprintf(fp, " "); print_compact(fp, ast->type, 0, true); } if(parens) fprintf(fp, type ? "]" : ")"); }
static void print(FILE* fp, ast_t* ast, size_t indent, bool type) { size_t len = length(ast, indent, type); if(len < width) print_compact(fp, ast, indent, type); else print_extended(fp, ast, indent, type); fprintf(fp, "\n"); }
void SXNode::disp(std::ostream& stream, bool more) const { // Find out which noded can be inlined std::map<const SXNode*, casadi_int> nodeind; can_inline(nodeind); // Print expression vector<string> intermed; string s = print_compact(nodeind, intermed); // Print intermediate expressions for (casadi_int i=0; i<intermed.size(); ++i) stream << "@" << (i+1) << "=" << intermed[i] << ", "; // Print this stream << s; }