26#if defined (HAVE_CONFIG_H)
40OCTAVE_NORETURN
static void
41error_unexpected (
const char *name)
43 error (
"unexpected call to %s - please report this bug", name);
51 print_parens (afh,
"(");
58 param_list->
accept (*
this);
62 print_parens (afh,
")");
68 auto p = lst.begin ();
70 while (p != lst.end ())
90 m_os <<
"arguments ... endarguments";
96 error_unexpected (
"tree_print_code::visit_args_block_attribute_list");
102 error_unexpected (
"tree_print_code::visit_args_block_validation_list");
108 error_unexpected (
"tree_print_code::visit_arg_validation");
114 error_unexpected (
"tree_print_code::visit_arg_size_spec");
120 error_unexpected (
"tree_print_code::visit_arg_validation_fcns");
128 print_parens (expr,
"(");
135 m_os <<
' ' << expr.
oper () <<
' ';
142 print_parens (expr,
")");
158 print_parens (expr,
"(");
183 print_parens (expr,
")");
199 m_os << cmd.
name () <<
' ';
204 init_list->
accept (*
this);
210 auto p = lst.begin ();
212 while (p != lst.end ())
283 increment_indent_level ();
287 decrement_indent_level ();
292 m_os << (cmd.
in_parallel () ?
"endparfor" :
"endfor");
303 m_nesting.push (
'[');
324 increment_indent_level ();
328 decrement_indent_level ();
351 increment_indent_level ();
355 decrement_indent_level ();
385 increment_indent_level ();
400 if (! leading_comments.
empty ())
402 print_comment_list (leading_comments);
418 std::string fcn_name = fcn.
name ();
420 m_os << (fcn_name.empty () ?
"(empty)" : fcn_name) <<
' ';
425 param_list->accept (*
this);
456 print_parens (
id,
"(");
458 std::string nm =
id.name ();
459 m_os << (nm.empty () ?
"(empty)" : nm);
461 print_parens (
id,
")");
478 increment_indent_level ();
482 decrement_indent_level ();
508 auto p = lst.begin ();
510 bool first_elt =
true;
512 while (p != lst.end ())
542 print_parens (expr,
"(");
549 std::list<tree_argument_list *> arg_lists = expr.
arg_lists ();
550 std::string type_tags = expr.
type_tags ();
551 std::list<string_vector> arg_names = expr.
arg_names ();
552 std::list<tree_expression *> dyn_fields = expr.
dyn_fields ();
554 int n = type_tags.length ();
556 auto p_arg_lists = arg_lists.begin ();
557 auto p_arg_names = arg_names.begin ();
558 auto p_dyn_fields = dyn_fields.begin ();
560 for (
int i = 0; i < n; i++)
562 switch (type_tags[i])
566 char nc = m_nesting.top ();
567 if ((nc ==
'[' || nc ==
'{') && expr.
delim_count () == 0)
571 m_nesting.push (
'(');
584 char nc = m_nesting.top ();
585 if ((nc ==
'[' || nc ==
'{') && expr.
delim_count () == 0)
591 m_nesting.push (
'(');
604 std::string fn = (*p_arg_names)(0);
611 m_nesting.push (
'(');
624 error (
"unexpected: index not '(', '{', or '.' in tree_print_code::visit_index_expression - please report this bug");
632 print_parens (expr,
")");
640 print_parens (lst,
"(");
643 m_nesting.push (
'[');
645 auto p = lst.begin ();
647 while (p != lst.end ())
663 print_parens (lst,
")");
671 print_parens (lst,
"(");
674 m_nesting.push (
'{');
676 auto p = lst.begin ();
678 while (p != lst.end ())
694 print_parens (lst,
")");
702 print_parens (expr,
"(");
708 int len = lhs->size ();
713 m_nesting.push (
'[');
725 m_os <<
' ' << expr.
oper () <<
' ';
732 print_parens (expr,
")");
739 decrement_indent_level ();
751 print_parens (val,
"(");
753 val.
print_raw (m_os,
true, m_print_original_text);
755 print_parens (val,
")");
763 print_parens (fh,
"(");
765 fh.
print_raw (m_os,
true, m_print_original_text);
767 print_parens (fh,
")");
778 m_nesting.push (
'(');
782 int len = lst.size ();
789 m_nesting.push (
'[');
793 auto p = lst.begin ();
795 while (p != lst.end ())
818 int len = lst.size ();
835 print_parens (expr,
"(");
842 m_os << expr.
oper ();
844 print_parens (expr,
")");
852 print_parens (expr,
"(");
854 m_os << expr.
oper ();
861 print_parens (expr,
")");
877 print_parens (expr,
"(");
884 m_os <<
' ' << expr.
oper () <<
' ';
891 print_parens (expr,
")");
959 increment_indent_level ();
965 decrement_indent_level ();
989 increment_indent_level ();
993 decrement_indent_level ();
1000 m_os <<
"endswitch";
1019 increment_indent_level ();
1021 try_code->
accept (*
this);
1023 decrement_indent_level ();
1042 increment_indent_level ();
1044 catch_code->
accept (*
this);
1046 decrement_indent_level ();
1051 m_os <<
"end_try_catch";
1061 m_os <<
"unwind_protect";
1067 if (unwind_protect_code)
1069 increment_indent_level ();
1071 unwind_protect_code->
accept (*
this);
1073 decrement_indent_level ();
1078 m_os <<
"unwind_protect_cleanup";
1086 increment_indent_level ();
1088 cleanup_code->
accept (*
this);
1090 decrement_indent_level ();
1095 m_os <<
"end_unwind_protect";
1118 increment_indent_level ();
1122 decrement_indent_level ();
1145 increment_indent_level ();
1149 decrement_indent_level ();
1181 m_suppress_newlines++;
1183 m_suppress_newlines--;
1190tree_print_code::indent ()
1194 if (m_beginning_of_line)
1198 m_os << std::string (m_curr_print_indent_level,
' ');
1200 m_beginning_of_line =
false;
1207tree_print_code::newline (
const char *alt_txt)
1209 if (m_suppress_newlines)
1218 m_beginning_of_line =
true;
1225tree_print_code::reset ()
1227 m_beginning_of_line =
true;
1228 m_curr_print_indent_level = 0;
1229 while (m_nesting.top () !=
'n')
1234tree_print_code::print_parens (
const tree_expression& expr,
const char *txt)
1238 for (
int i = 0; i < n; i++)
1243tree_print_code::print_comment_elt (
const comment_elt& elt)
1245 bool printed_something =
false;
1247 bool prev_char_was_newline =
false;
1249 std::string comment = elt.
text ();
1251 std::size_t
len = comment.length ();
1255 while (i <
len && comment[i++] ==
'\n')
1261 char c = comment[i++];
1265 if (prev_char_was_newline)
1267 printed_something =
true;
1276 prev_char_was_newline =
true;
1280 if (m_beginning_of_line)
1282 printed_something =
true;
1288 if (! (isspace (c) || c ==
'!'))
1292 m_os << static_cast<char> (c);
1294 prev_char_was_newline =
false;
1298 if (printed_something && ! m_beginning_of_line)
1311 print_comment_elt (elt);
1321 increment_indent_level ();
1325 decrement_indent_level ();
1328OCTAVE_END_NAMESPACE(octave)
virtual void accept(octave::tree_walker &)
octave::tree_statement_list * body()
octave::tree_parameter_list * parameter_list()
octave::comment_list trailing_comments() const
octave::comment_list leading_comments() const
octave::tree_parameter_list * return_list()
octave_function * function_value(bool silent=false) const
tree_parameter_list * parameter_list() const
tree_expression * expression() const
void accept(tree_walker &tw)
tree_expression * limit()
tree_expression * increment()
tree_argument_list * left_hand_side()
tree_statement_list * body()
tree_expression * control_expr()
void print_raw(std::ostream &os, bool pr_as_read_syntax=false, bool pr_orig_txt=true)
tree_decl_init_list * initializer_list()
tree_expression * expression()
tree_identifier * ident()
void accept(tree_walker &tw)
void accept(tree_walker &tw)
tree_expression * condition()
tree_statement_list * body()
size_t delim_count() const
void print_raw(std::ostream &os, bool pr_as_read_syntax=false, bool pr_orig_txt=true)
void accept(tree_walker &tw)
void accept(tree_walker &tw)
tree_statement_list * commands()
tree_expression * condition()
comment_list leading_comments() const
void accept(tree_walker &tw)
tree_if_command_list * cmd_list()
comment_list leading_comments() const
tree_expression * expression()
std::list< tree_expression * > dyn_fields()
std::list< tree_argument_list * > arg_lists()
std::list< string_vector > arg_names()
tree_expression * right_hand_side()
tree_argument_list * left_hand_side()
std::string original_command()
bool is_end_of_fcn_or_script() const
void accept(tree_walker &tw)
bool takes_varargs() const
bool is_input_list() const
std::string varargs_symbol_name() const
void visit_binary_expression(tree_binary_expression &)
void visit_continue_command(tree_continue_command &)
void visit_switch_case(tree_switch_case &)
void visit_decl_init_list(tree_decl_init_list &)
void visit_constant(tree_constant &)
void visit_postfix_expression(tree_postfix_expression &)
void visit_superclass_ref(tree_superclass_ref &)
void visit_no_op_command(tree_no_op_command &)
void visit_args_block_attribute_list(tree_args_block_attribute_list &)
void visit_while_command(tree_while_command &)
void visit_fcn_handle(tree_fcn_handle &)
void visit_arguments_block(tree_arguments_block &)
void visit_switch_command(tree_switch_command &)
void visit_prefix_expression(tree_prefix_expression &)
void visit_octave_user_function_header(octave_user_function &)
void visit_simple_assignment(tree_simple_assignment &)
void visit_decl_command(tree_decl_command &)
void visit_if_clause(tree_if_clause &)
void visit_index_expression(tree_index_expression &)
void print_fcn_handle_body(tree_expression *)
void visit_statement(tree_statement &)
void visit_break_command(tree_break_command &)
void visit_return_command(tree_return_command &)
void visit_if_command(tree_if_command &)
void visit_unwind_protect_command(tree_unwind_protect_command &)
void visit_identifier(tree_identifier &)
void visit_complex_for_command(tree_complex_for_command &)
void visit_multi_assignment(tree_multi_assignment &)
void visit_matrix(tree_matrix &)
void visit_if_command_list(tree_if_command_list &)
void visit_try_catch_command(tree_try_catch_command &)
void visit_do_until_command(tree_do_until_command &)
void visit_arg_validation(tree_arg_validation &)
void visit_octave_user_function(octave_user_function &)
void visit_parameter_list(tree_parameter_list &)
void visit_statement_list(tree_statement_list &)
void visit_spmd_command(tree_spmd_command &)
void visit_decl_elt(tree_decl_elt &)
void visit_args_block_validation_list(tree_args_block_validation_list &)
void visit_arg_size_spec(tree_arg_size_spec &)
void visit_simple_for_command(tree_simple_for_command &)
void visit_anon_fcn_handle(tree_anon_fcn_handle &)
void visit_argument_list(tree_argument_list &)
void visit_colon_expression(tree_colon_expression &)
void visit_octave_user_script(octave_user_script &)
void visit_arg_validation_fcns(tree_arg_validation_fcns &)
void visit_cell(tree_cell &)
void visit_octave_user_function_trailer(octave_user_function &)
void visit_metaclass_query(tree_metaclass_query &)
void visit_function_def(tree_function_def &)
tree_expression * right_hand_side()
tree_expression * left_hand_side()
tree_expression * maxproc_expr()
tree_expression * left_hand_side()
tree_expression * control_expr()
tree_statement_list * body()
tree_statement_list * body()
void accept(tree_walker &tw)
tree_expression * expression()
comment_list leading_comments() const
std::string method_name() const
std::string class_name() const
void accept(tree_walker &tw)
tree_expression * case_label()
tree_statement_list * commands()
comment_list leading_comments() const
tree_switch_case_list * case_list()
tree_expression * switch_value()
comment_list leading_comments() const
tree_identifier * identifier()
tree_statement_list * cleanup()
tree_statement_list * body()
tree_expression * operand()
tree_statement_list * cleanup()
tree_statement_list * body()
tree_statement_list * body()
tree_expression * condition()
virtual comment_list leading_comments() const
virtual void accept(tree_walker &tw)=0
OCTAVE_BEGIN_NAMESPACE(octave) static octave_value daspk_fcn
void error(const char *fmt,...)
F77_RET_T const F77_DBLE const F77_DBLE * f
#define panic_unless(cond)