static void dump_astree_rec (FILE *outfile, astree root, int depth) { astree child = NULL; if (root == NULL) return; assert (is_astree (root)); //fprintf (outfile, "%*s%s ", depth * 3, "", root->lexinfo); dump_node (outfile, root, depth); fprintf (outfile, "\n"); for (child = root->first; child != NULL; child = child->next) { dump_astree_rec (outfile, child, depth + 1); } }
static void dump_astree_rec (FILE* outfile, astree* root, int depth) { if (root == NULL) return; dump_node (outfile, root); fprintf (outfile, "\n"); for (size_t child = 0; child < root->children.size(); ++child) { dump_astree_rec (outfile, root->children[child], depth + 1); } }
static void dump_astree_rec (FILE *outfile, astree root, int depth) { astree child = NULL; if (root == NULL) return; assert (is_astree (root)); const char *tname = get_yytname(root->symbol); if (strstr (tname, "TOK_") == tname) tname += 4; if(depth == 0){ fprintf (outfile, "%*s%s \"%s\" %d.%d.%03d ", depth * 3, "", tname, root->lexinfo, root->filenr, root->linenr, root->offset); } else{ int i; for(i =0 ; i < depth; ++i){ fprintf(outfile, "%*s ", 1, "|"); } fprintf (outfile, "%s \"%s\" %d.%d.%03d ", tname, root->lexinfo, root->filenr, root->linenr, root->offset); } // dump_node (outfile, root, depth); fprintf (outfile, "\n"); for (child = root->first; child != NULL; child = child->next) { dump_astree_rec (outfile, child, depth + 1); } }
void dump_astree (FILE* outfile, astree* root) { dump_astree_rec (outfile, root, 0); fflush (NULL); }