in sources/ast.c [689:749]
cql_noexport void print_ast(ast_node *node, ast_node *parent, int32_t pad, bool_t flip) {
if (pad == 0) {
padbuffer[0] = '\0';
}
if (!node) {
return;
}
if (print_ast_value(node)) {
return;
}
if (is_ast_stmt_list(parent) && is_ast_stmt_list(node)) {
print_ast(node->left, node, pad, !node->right);
print_ast(node->right, node, pad, 1);
}
else {
if (pad == 2) {
cql_output("\n");
if (parent && is_ast_stmt_list(parent)) {
cql_output("The statement ending at line %d\n\n", node->lineno);
gen_stmt_level = 1;
EXTRACT_STMT_AND_MISC_ATTRS(stmt, misc_attrs, parent);
if (misc_attrs) {
gen_misc_attrs_to_stdout(misc_attrs);
}
gen_one_stmt_to_stdout(stmt);
cql_output("\n");
#if defined(CQL_AMALGAM_LEAN) && !defined(CQL_AMALGAM_SEM)
// sem off, nothing to print here
#else
// print any error text
if (stmt->sem && stmt->sem->sem_type == SEM_TYPE_ERROR && stmt->sem->error) {
cql_output("%s\n", stmt->sem->error);
}
#endif
}
}
print_ast_type(node);
if (flip && pad >= 2) {
padbuffer[pad-2] = ' ';
}
if (pad == 0) {
padbuffer[pad] = ' ';
}
else {
padbuffer[pad] = '|';
}
padbuffer[pad+1] = ' ';
padbuffer[pad+2] = '\0';
print_ast(node->left, node, pad+2, !node->right);
print_ast(node->right, node, pad+2, 1);
padbuffer[pad] = '\0';
}
}