GNU Octave  4.0.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
pt-pr-code.cc
Go to the documentation of this file.
1 /*
2 
3 Copyright (C) 1996-2015 John W. Eaton
4 
5 This file is part of Octave.
6 
7 Octave is free software; you can redistribute it and/or modify it
8 under the terms of the GNU General Public License as published by the
9 Free Software Foundation; either version 3 of the License, or (at your
10 option) any later version.
11 
12 Octave is distributed in the hope that it will be useful, but WITHOUT
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 for more details.
16 
17 You should have received a copy of the GNU General Public License
18 along with Octave; see the file COPYING. If not, see
19 <http://www.gnu.org/licenses/>.
20 
21 */
22 
23 #ifdef HAVE_CONFIG_H
24 #include <config.h>
25 #endif
26 
27 #include <cctype>
28 
29 #include <iostream>
30 
31 #include "comment-list.h"
32 #include "error.h"
33 #include "ov-usr-fcn.h"
34 #include "pr-output.h"
35 #include "pt-all.h"
36 
37 void
39 {
40  indent ();
41 
42  print_parens (afh, "(");
43 
44  os << "@(";
45 
46  tree_parameter_list *param_list = afh.parameter_list ();
47 
48  if (param_list)
49  param_list->accept (*this);
50 
51  os << ") ";
52 
53  print_fcn_handle_body (afh.body ());
54 
55  print_parens (afh, ")");
56 }
57 
58 void
60 {
62 
63  while (p != lst.end ())
64  {
65  tree_expression *elt = *p++;
66 
67  if (elt)
68  {
69  elt->accept (*this);
70 
71  if (p != lst.end ())
72  os << ", ";
73  }
74  }
75 }
76 
77 void
79 {
80  indent ();
81 
82  print_parens (expr, "(");
83 
84  tree_expression *op1 = expr.lhs ();
85 
86  if (op1)
87  op1->accept (*this);
88 
89  os << " " << expr.oper () << " ";
90 
91  tree_expression *op2 = expr.rhs ();
92 
93  if (op2)
94  op2->accept (*this);
95 
96  print_parens (expr, ")");
97 }
98 
99 void
101 {
102  indent ();
103 
104  os << "break";
105 }
106 
107 void
109 {
110  indent ();
111 
112  print_parens (expr, "(");
113 
114  tree_expression *op1 = expr.base ();
115 
116  if (op1)
117  op1->accept (*this);
118 
119  // Stupid syntax.
120 
121  tree_expression *op3 = expr.increment ();
122 
123  if (op3)
124  {
125  os << ":";
126  op3->accept (*this);
127  }
128 
129  tree_expression *op2 = expr.limit ();
130 
131  if (op2)
132  {
133  os << ":";
134  op2->accept (*this);
135  }
136 
137  print_parens (expr, ")");
138 }
139 
140 void
142 {
143  indent ();
144 
145  os << "continue";
146 }
147 
148 void
150 {
151  indent ();
152 
153  os << cmd.name () << " ";
154 
155  tree_decl_init_list *init_list = cmd.initializer_list ();
156 
157  if (init_list)
158  init_list->accept (*this);
159 }
160 
161 void
163 {
164  do_decl_command (cmd);
165 }
166 
167 void
169 {
170  do_decl_command (cmd);
171 }
172 
173 void
175 {
176  tree_identifier *id = cmd.ident ();
177 
178  if (id)
179  id->accept (*this);
180 
181  tree_expression *expr = cmd.expression ();
182 
183  if (expr)
184  {
185  os << " = ";
186 
187  expr->accept (*this);
188  }
189 }
190 
191 void
193 {
195 
196  while (p != lst.end ())
197  {
198  tree_decl_elt *elt = *p++;
199 
200  if (elt)
201  {
202  elt->accept (*this);
203 
204  if (p != lst.end ())
205  os << ", ";
206  }
207  }
208 }
209 
210 void
212 {
214 
215  indent ();
216 
217  os << (cmd.in_parallel () ? "parfor " : "for ");
218 
219  tree_expression *lhs = cmd.left_hand_side ();
220 
221  tree_expression *maxproc = cmd.maxproc_expr ();
222 
223  if (maxproc)
224  os << "(";
225 
226  if (lhs)
227  lhs->accept (*this);
228 
229  os << " = ";
230 
231  tree_expression *expr = cmd.control_expr ();
232 
233  if (expr)
234  expr->accept (*this);
235 
236  if (maxproc)
237  {
238  os << ", ";
239  maxproc->accept (*this);
240  os << ")";
241  }
242 
243  newline ();
244 
245  tree_statement_list *list = cmd.body ();
246 
247  if (list)
248  {
250 
251  list->accept (*this);
252 
254  }
255 
257 
258  indent ();
259 
260  os << (cmd.in_parallel () ? "endparfor" : "endfor");
261 }
262 
263 void
265 {
267 
268  indent ();
269 
270  os << "for [";
271  nesting.push ('[');
272 
273  tree_argument_list *lhs = cmd.left_hand_side ();
274 
275  if (lhs)
276  lhs->accept (*this);
277 
278  nesting.pop ();
279  os << "] = ";
280 
281  tree_expression *expr = cmd.control_expr ();
282 
283  if (expr)
284  expr->accept (*this);
285 
286  newline ();
287 
288  tree_statement_list *list = cmd.body ();
289 
290  if (list)
291  {
293 
294  list->accept (*this);
295 
297  }
298 
300 
301  indent ();
302 
303  os << "endfor";
304 }
305 
306 void
308 {
309  reset ();
310 
311  tree_statement_list *cmd_list = fcn.body ();
312 
313  if (cmd_list)
314  cmd_list->accept (*this);
315 }
316 
317 void
319 {
320  reset ();
321 
323 
324  tree_statement_list *cmd_list = fcn.body ();
325 
326  if (cmd_list)
327  {
329 
330  cmd_list->accept (*this);
331 
333  }
334 
336 }
337 
338 void
340 {
341  octave_comment_list *leading_comment = fcn.leading_comment ();
342 
343  if (leading_comment)
344  {
345  print_comment_list (leading_comment);
346  newline ();
347  }
348 
349  indent ();
350 
351  os << "function ";
352 
353  tree_parameter_list *ret_list = fcn.return_list ();
354 
355  if (ret_list)
356  {
357  bool takes_var_return = fcn.takes_var_return ();
358 
359  int len = ret_list->length ();
360 
361  if (len > 1 || takes_var_return)
362  {
363  os << "[";
364  nesting.push ('[');
365  }
366 
367  ret_list->accept (*this);
368 
369  if (takes_var_return)
370  {
371  if (len > 0)
372  os << ", ";
373 
374  os << "varargout";
375  }
376 
377  if (len > 1 || takes_var_return)
378  {
379  nesting.pop ();
380  os << "]";
381  }
382 
383  os << " = ";
384  }
385 
386  std::string fcn_name = fcn.name ();
387 
388  os << (fcn_name.empty () ? std::string ("(empty)") : fcn_name) << " ";
389 
390  tree_parameter_list *param_list = fcn.parameter_list ();
391 
392  if (param_list)
393  {
394  bool takes_varargs = fcn.takes_varargs ();
395 
396  int len = param_list->length ();
397 
398  if (len > 0 || takes_varargs)
399  {
400  os << "(";
401  nesting.push ('(');
402  }
403 
404  param_list->accept (*this);
405 
406  if (takes_varargs)
407  {
408  if (len > 0)
409  os << ", ";
410 
411  os << "varargin";
412  }
413 
414  if (len > 0 || takes_varargs)
415  {
416  nesting.pop ();
417  os << ")";
418  newline ();
419  }
420  }
421  else
422  {
423  os << "()";
424  newline ();
425  }
426 }
427 
428 void
430 {
432 
433  newline ();
434 }
435 
436 void
438 {
439  indent ();
440 
441  octave_value fcn = fdef.function ();
442 
443  octave_function *f = fcn.function_value ();
444 
445  if (f)
446  f->accept (*this);
447 }
448 
449 void
451 {
452  indent ();
453 
454  print_parens (id, "(");
455 
456  std::string nm = id.name ();
457  os << (nm.empty () ? std::string ("(empty)") : nm);
458 
459  print_parens (id, ")");
460 }
461 
462 void
464 {
465  tree_expression *expr = cmd.condition ();
466 
467  if (expr)
468  expr->accept (*this);
469 
470  newline ();
471 
472  tree_statement_list *list = cmd.commands ();
473 
474  if (list)
475  {
477 
478  list->accept (*this);
479 
481  }
482 }
483 
484 void
486 {
488 
489  indent ();
490 
491  os << "if ";
492 
493  tree_if_command_list *list = cmd.cmd_list ();
494 
495  if (list)
496  list->accept (*this);
497 
499 
500  indent ();
501 
502  os << "endif";
503 }
504 
505 void
507 {
509 
510  bool first_elt = true;
511 
512  while (p != lst.end ())
513  {
514  tree_if_clause *elt = *p++;
515 
516  if (elt)
517  {
518  if (! first_elt)
519  {
521 
522  indent ();
523 
524  if (elt->is_else_clause ())
525  os << "else";
526  else
527  os << "elseif ";
528  }
529 
530  elt->accept (*this);
531  }
532 
533  first_elt = false;
534  }
535 }
536 
537 void
539 {
540  indent ();
541 
542  print_parens (expr, "(");
543 
544  tree_expression *e = expr.expression ();
545 
546  if (e)
547  e->accept (*this);
548 
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 
553  int n = type_tags.length ();
554 
555  std::list<tree_argument_list *>::iterator p_arg_lists = arg_lists.begin ();
556  std::list<string_vector>::iterator p_arg_names = arg_names.begin ();
557 
558  for (int i = 0; i < n; i++)
559  {
560  switch (type_tags[i])
561  {
562  case '(':
563  {
564  char nc = nesting.top ();
565  if ((nc == '[' || nc == '{') && expr.paren_count () == 0)
566  os << "(";
567  else
568  os << " (";
569  nesting.push ('(');
570 
571  tree_argument_list *l = *p_arg_lists;
572  if (l)
573  l->accept (*this);
574 
575  nesting.pop ();
576  os << ")";
577  }
578  break;
579 
580  case '{':
581  {
582  char nc = nesting.top ();
583  if ((nc == '[' || nc == '{') && expr.paren_count () == 0)
584  os << "{";
585  else
586  os << " {";
587  // We only care about whitespace inside [] and {} when we
588  // are defining matrix and cell objects, not when indexing.
589  nesting.push ('(');
590 
591  tree_argument_list *l = *p_arg_lists;
592  if (l)
593  l->accept (*this);
594 
595  nesting.pop ();
596  os << "}";
597  }
598  break;
599 
600  case '.':
601  {
602  string_vector nm = *p_arg_names;
603  assert (nm.length () == 1);
604  os << "." << nm(0);
605  }
606  break;
607 
608  default:
609  panic_impossible ();
610  }
611 
612  p_arg_lists++;
613  p_arg_names++;
614  }
615 
616  print_parens (expr, ")");
617 }
618 
619 void
621 {
622  indent ();
623 
624  print_parens (lst, "(");
625 
626  os << "[";
627  nesting.push ('[');
628 
629  tree_matrix::iterator p = lst.begin ();
630 
631  while (p != lst.end ())
632  {
633  tree_argument_list *elt = *p++;
634 
635  if (elt)
636  {
637  elt->accept (*this);
638 
639  if (p != lst.end ())
640  os << "; ";
641  }
642  }
643 
644  nesting.pop ();
645  os << "]";
646 
647  print_parens (lst, ")");
648 }
649 
650 void
652 {
653  indent ();
654 
655  print_parens (lst, "(");
656 
657  os << "{";
658  nesting.push ('{');
659 
660  tree_cell::iterator p = lst.begin ();
661 
662  while (p != lst.end ())
663  {
664  tree_argument_list *elt = *p++;
665 
666  if (elt)
667  {
668  elt->accept (*this);
669 
670  if (p != lst.end ())
671  os << "; ";
672  }
673  }
674 
675  nesting.pop ();
676  os << "}";
677 
678  print_parens (lst, ")");
679 }
680 
681 void
683 {
684  indent ();
685 
686  print_parens (expr, "(");
687 
688  tree_argument_list *lhs = expr.left_hand_side ();
689 
690  if (lhs)
691  {
692  int len = lhs->length ();
693 
694  if (len > 1)
695  {
696  os << "[";
697  nesting.push ('[');
698  }
699 
700  lhs->accept (*this);
701 
702  if (len > 1)
703  {
704  nesting.pop ();
705  os << "]";
706  }
707  }
708 
709  os << " " << expr.oper () << " ";
710 
711  tree_expression *rhs = expr.right_hand_side ();
712 
713  if (rhs)
714  rhs->accept (*this);
715 
716  print_parens (expr, ")");
717 }
718 
719 void
721 {
722  indent ();
723 
724  os << cmd.original_command ();
725 }
726 
727 void
729 {
730  indent ();
731 
732  print_parens (val, "(");
733 
734  val.print_raw (os, true, print_original_text);
735 
736  print_parens (val, ")");
737 }
738 
739 void
741 {
742  indent ();
743 
744  print_parens (fh, "(");
745 
746  fh.print_raw (os, true, print_original_text);
747 
748  print_parens (fh, ")");
749 }
750 
751 void
753 {
754  indent ();
755 
756  print_parens (fc, "(");
757 
758  fc.print_raw (os, true, print_original_text);
759 
760  print_parens (fc, ")");
761 }
762 
763 void
765 {
767 
768  while (p != lst.end ())
769  {
770  tree_decl_elt *elt = *p++;
771 
772  if (elt)
773  {
774  elt->accept (*this);
775 
776  if (p != lst.end ())
777  os << ", ";
778  }
779  }
780 }
781 
782 void
784 {
785  indent ();
786 
787  print_parens (expr, "(");
788 
789  tree_expression *e = expr.operand ();
790 
791  if (e)
792  e->accept (*this);
793 
794  os << expr.oper ();
795 
796  print_parens (expr, ")");
797 }
798 
799 void
801 {
802  indent ();
803 
804  print_parens (expr, "(");
805 
806  os << expr.oper ();
807 
808  tree_expression *e = expr.operand ();
809 
810  if (e)
811  e->accept (*this);
812 
813  print_parens (expr, ")");
814 }
815 
816 void
818 {
819  indent ();
820 
821  os << "return";
822 }
823 
824 void
826 {
828 
829  while (p != lst.end ())
830  {
831  tree_index_expression *elt = *p++;
832 
833  if (elt)
834  {
835  elt->accept (*this);
836 
837  if (p != lst.end ())
838  os << ", ";
839  }
840  }
841 }
842 
843 void
845 {
846  indent ();
847 
848  print_parens (expr, "(");
849 
850  tree_expression *lhs = expr.left_hand_side ();
851 
852  if (lhs)
853  lhs->accept (*this);
854 
855  os << " " << expr.oper () << " ";
856 
857  tree_expression *rhs = expr.right_hand_side ();
858 
859  if (rhs)
860  rhs->accept (*this);
861 
862  print_parens (expr, ")");
863 }
864 
865 void
867 {
869 
870  tree_command *cmd = stmt.command ();
871 
872  if (cmd)
873  {
874  cmd->accept (*this);
875 
876  if (! stmt.print_result ())
877  {
878  os << ";";
879  newline (" ");
880  }
881  else
882  newline ();
883  }
884  else
885  {
886  tree_expression *expr = stmt.expression ();
887 
888  if (expr)
889  {
890  expr->accept (*this);
891 
892  if (! stmt.print_result ())
893  {
894  os << ";";
895  newline (" ");
896  }
897  else
898  newline ();
899  }
900  }
901 }
902 
903 void
905 {
906  for (tree_statement_list::iterator p = lst.begin (); p != lst.end (); p++)
907  {
908  tree_statement *elt = *p;
909 
910  if (elt)
911  elt->accept (*this);
912  }
913 }
914 
915 void
917 {
919 
920  indent ();
921 
922  if (cs.is_default_case ())
923  os << "otherwise";
924  else
925  os << "case ";
926 
927  tree_expression *label = cs.case_label ();
928 
929  if (label)
930  label->accept (*this);
931 
932  newline ();
933 
934  tree_statement_list *list = cs.commands ();
935 
936  if (list)
937  {
939 
940  list->accept (*this);
941 
942  newline ();
943 
945  }
946 }
947 
948 void
950 {
952 
953  while (p != lst.end ())
954  {
955  tree_switch_case *elt = *p++;
956 
957  if (elt)
958  elt->accept (*this);
959  }
960 }
961 
962 void
964 {
966 
967  indent ();
968 
969  os << "switch ";
970 
971  tree_expression *expr = cmd.switch_value ();
972 
973  if (expr)
974  expr->accept (*this);
975 
976  newline ();
977 
978  tree_switch_case_list *list = cmd.case_list ();
979 
980  if (list)
981  {
983 
984  list->accept (*this);
985 
987  }
988 
990 
991  indent ();
992 
993  os << "endswitch";
994 }
995 
996 void
998 {
1000 
1001  indent ();
1002 
1003  os << "try";
1004 
1005  newline ();
1006 
1007  tree_statement_list *try_code = cmd.body ();
1008  tree_identifier *expr_id = cmd.identifier ();
1009 
1010  if (try_code)
1011  {
1013 
1014  try_code->accept (*this);
1015 
1017  }
1018 
1020 
1021  indent ();
1022 
1023  os << "catch";
1024 
1025  if (expr_id)
1026  {
1027  os << " ";
1028  expr_id->accept (*this);
1029  }
1030 
1031  newline ();
1032 
1033  tree_statement_list *catch_code = cmd.cleanup ();
1034 
1035  if (catch_code)
1036  {
1038 
1039  catch_code->accept (*this);
1040 
1042  }
1043 
1045 
1046  indent ();
1047 
1048  os << "end_try_catch";
1049 }
1050 
1051 void
1053 {
1055 
1056  indent ();
1057 
1058  os << "unwind_protect";
1059 
1060  newline ();
1061 
1062  tree_statement_list *unwind_protect_code = cmd.body ();
1063 
1064  if (unwind_protect_code)
1065  {
1067 
1068  unwind_protect_code->accept (*this);
1069 
1071  }
1072 
1074 
1075  indent ();
1076 
1077  os << "unwind_protect_cleanup";
1078 
1079  newline ();
1080 
1081  tree_statement_list *cleanup_code = cmd.cleanup ();
1082 
1083  if (cleanup_code)
1084  {
1086 
1087  cleanup_code->accept (*this);
1088 
1090  }
1091 
1093 
1094  indent ();
1095 
1096  os << "end_unwind_protect";
1097 }
1098 
1099 void
1101 {
1103 
1104  indent ();
1105 
1106  os << "while ";
1107 
1108  tree_expression *expr = cmd.condition ();
1109 
1110  if (expr)
1111  expr->accept (*this);
1112 
1113  newline ();
1114 
1115  tree_statement_list *list = cmd.body ();
1116 
1117  if (list)
1118  {
1120 
1121  list->accept (*this);
1122 
1124  }
1125 
1127 
1128  indent ();
1129 
1130  os << "endwhile";
1131 }
1132 
1133 void
1135 {
1137 
1138  indent ();
1139 
1140  os << "do";
1141 
1142  newline ();
1143 
1144  tree_statement_list *list = cmd.body ();
1145 
1146  if (list)
1147  {
1149 
1150  list->accept (*this);
1151 
1153  }
1154 
1156 
1157  indent ();
1158 
1159  os << "until ";
1160 
1161  tree_expression *expr = cmd.condition ();
1162 
1163  if (expr)
1164  expr->accept (*this);
1165 
1166  newline ();
1167 }
1168 
1169 void
1171 {
1172  if (b)
1173  {
1174  assert (b->length () == 1);
1175 
1176  tree_statement *s = b->front ();
1177 
1178  if (s)
1179  {
1180  if (s->is_expression ())
1181  {
1182  tree_expression *e = s->expression ();
1183 
1184  if (e)
1185  {
1187  e->accept (*this);
1189  }
1190  }
1191  else
1192  {
1193  tree_command *c = s->command ();
1194 
1196  c->accept (*this);
1198  }
1199  }
1200  }
1201 }
1202 
1203 // Each print_code() function should call this before printing anything.
1204 
1205 void
1207 {
1208  assert (curr_print_indent_level >= 0);
1209 
1210  if (beginning_of_line)
1211  {
1212  os << prefix;
1213 
1214  os << std::string (curr_print_indent_level, ' ');
1215 
1216  beginning_of_line = false;
1217  }
1218 }
1219 
1220 // All print_code() functions should use this to print new lines.
1221 
1222 void
1223 tree_print_code::newline (const char *alt_txt)
1224 {
1225  if (suppress_newlines)
1226  os << alt_txt;
1227  else
1228  {
1229  // Print prefix for blank lines.
1230  indent ();
1231 
1232  os << "\n";
1233 
1234  beginning_of_line = true;
1235  }
1236 }
1237 
1238 // For ressetting print_code state.
1239 
1240 void
1242 {
1243  beginning_of_line = true;
1245  while (nesting.top () != 'n')
1246  nesting.pop ();
1247 }
1248 
1249 void
1250 tree_print_code::print_parens (const tree_expression& expr, const char *txt)
1251 {
1252  int n = expr.paren_count ();
1253 
1254  for (int i = 0; i < n; i++)
1255  os << txt;
1256 }
1257 
1258 void
1260 {
1261  bool printed_something = false;
1262 
1263  bool prev_char_was_newline = false;
1264 
1265  std::string comment = elt.text ();
1266 
1267  size_t len = comment.length ();
1268 
1269  size_t i = 0;
1270 
1271  while (i < len && comment[i++] == '\n')
1272  ; /* Skip leading new lines. */
1273  i--;
1274 
1275  while (i < len)
1276  {
1277  char c = comment[i++];
1278 
1279  if (c == '\n')
1280  {
1281  if (prev_char_was_newline)
1282  {
1283  printed_something = true;
1284 
1285  indent ();
1286 
1287  os << "##";
1288  }
1289 
1290  newline ();
1291 
1292  prev_char_was_newline = true;
1293  }
1294  else
1295  {
1296  if (beginning_of_line)
1297  {
1298  printed_something = true;
1299 
1300  indent ();
1301 
1302  os << "##";
1303 
1304  if (! (isspace (c) || c == '!'))
1305  os << " ";
1306  }
1307 
1308  os << static_cast<char> (c);
1309 
1310  prev_char_was_newline = false;
1311  }
1312  }
1313 
1314  if (printed_something && ! beginning_of_line)
1315  newline ();
1316 }
1317 
1318 void
1320 {
1321  if (comment_list)
1322  {
1323  octave_comment_list::iterator p = comment_list->begin ();
1324 
1325  while (p != comment_list->end ())
1326  {
1327  octave_comment_elt elt = *p++;
1328 
1329  print_comment_elt (elt);
1330 
1331  if (p != comment_list->end ())
1332  newline ();
1333  }
1334  }
1335 }
1336 
1337 void
1339 {
1341 
1342  print_comment_list (comment_list);
1343 
1345 }
tree_expression * operand(void)
Definition: pt-unop.h:60
void visit_unwind_protect_command(tree_unwind_protect_command &)
Definition: pt-pr-code.cc:1052
void visit_statement(tree_statement &)
Definition: pt-pr-code.cc:866
octave_comment_list * leading_comment(void)
Definition: pt-select.h:137
octave_comment_list * trailing_comment(void)
Definition: pt-loop.h:297
tree_identifier * identifier(void)
Definition: pt-except.h:57
void visit_if_command_list(tree_if_command_list &)
Definition: pt-pr-code.cc:506
size_t length(void) const
Definition: base-list.h:45
octave_comment_list * leading_comment(void)
Definition: pt-except.h:127
octave_comment_list * comment_text(void)
Definition: pt-stmt.h:85
bool print_result(void)
Definition: pt-stmt.cc:68
bool takes_var_return(void) const
Definition: ov-usr-fcn.cc:367
void accept(tree_walker &tw)
Definition: pt-select.cc:169
void visit_parameter_list(tree_parameter_list &)
Definition: pt-pr-code.cc:764
tree_statement_list * cleanup(void)
Definition: pt-except.h:125
void visit_funcall(tree_funcall &)
Definition: pt-pr-code.cc:752
int paren_count(void) const
Definition: pt-exp.h:88
void decrement_indent_level(void)
Definition: pt-pr-code.h:171
tree_expression * left_hand_side(void)
Definition: pt-assign.h:70
void visit_return_command(tree_return_command &)
Definition: pt-pr-code.cc:817
tree_expression * switch_value(void)
Definition: pt-select.h:268
octave_comment_list * middle_comment(void)
Definition: pt-except.h:65
tree_parameter_list * parameter_list(void)
Definition: ov-usr-fcn.h:376
void visit_octave_user_function_header(octave_user_function &)
Definition: pt-pr-code.cc:339
tree_expression * control_expr(void)
Definition: pt-loop.h:291
tree_argument_list * left_hand_side(void)
Definition: pt-assign.h:137
void accept(tree_walker &tw)
Definition: pt-stmt.cc:289
std::string original_command(void)
Definition: pt-cmd.h:84
void print_raw(std::ostream &os, bool pr_as_read_syntax=false, bool pr_orig_txt=true)
Definition: pt-funcall.cc:41
void visit_identifier(tree_identifier &)
Definition: pt-pr-code.cc:450
void visit_statement_list(tree_statement_list &)
Definition: pt-pr-code.cc:904
bool is_default_case(void)
Definition: pt-select.h:185
tree_command * command(void)
Definition: pt-stmt.h:81
void print_comment_list(octave_comment_list *comment_list)
Definition: pt-pr-code.cc:1319
void visit_multi_assignment(tree_multi_assignment &)
Definition: pt-pr-code.cc:682
std::string name(void) const
Definition: ov-fcn.h:161
tree_switch_case_list * case_list(void)
Definition: pt-select.h:270
octave_comment_list * trailing_comment(void)
Definition: pt-loop.h:216
void visit_if_clause(tree_if_clause &)
Definition: pt-pr-code.cc:463
bool print_original_text
Definition: pt-pr-code.h:154
bool beginning_of_line
Definition: pt-pr-code.h:160
void visit_try_catch_command(tree_try_catch_command &)
Definition: pt-pr-code.cc:997
octave_comment_list * trailing_comment(void)
Definition: ov-usr-fcn.h:384
octave_comment_list * leading_comment(void)
Definition: pt-loop.h:214
void visit_binary_expression(tree_binary_expression &)
Definition: pt-pr-code.cc:78
tree_statement_list * commands(void)
Definition: pt-select.h:61
octave_comment_list * trailing_comment(void)
Definition: pt-except.h:131
octave_comment_list * leading_comment(void)
Definition: ov-usr-fcn.h:382
elt_type & front(void)
Definition: base-list.h:92
tree_expression * expression(void)
Definition: pt-idx.h:72
tree_expression * case_label(void)
Definition: pt-select.h:189
octave_comment_list * leading_comment(void)
Definition: pt-select.h:272
void increment_indent_level(void)
Definition: pt-pr-code.h:169
void visit_decl_elt(tree_decl_elt &)
Definition: pt-pr-code.cc:174
void visit_decl_init_list(tree_decl_init_list &)
Definition: pt-pr-code.cc:192
void visit_while_command(tree_while_command &)
Definition: pt-pr-code.cc:1100
std::string type_tags(void)
Definition: pt-idx.h:76
std::list< string_vector > arg_names(void)
Definition: pt-idx.h:78
tree_argument_list * left_hand_side(void)
Definition: pt-loop.h:289
bool takes_varargs(void) const
Definition: ov-usr-fcn.cc:361
void visit_octave_user_function(octave_user_function &)
Definition: pt-pr-code.cc:318
tree_identifier * ident(void)
Definition: pt-decl.h:85
tree_decl_init_list * initializer_list(void)
Definition: pt-decl.h:160
octave_comment_list * leading_comment(void)
Definition: pt-loop.h:295
void visit_complex_for_command(tree_complex_for_command &)
Definition: pt-pr-code.cc:264
void visit_cell(tree_cell &)
Definition: pt-pr-code.cc:651
tree_statement_list * body(void)
Definition: pt-loop.h:293
tree_expression * increment(void)
Definition: pt-colon.h:89
tree_if_command_list * cmd_list(void)
Definition: pt-select.h:135
tree_statement_list * body(void)
Definition: pt-loop.h:212
octave_comment_list * leading_comment(void)
Definition: pt-loop.h:84
std::string oper(void) const
Definition: pt-binop.cc:160
std::list< tree_expression * >::iterator iterator
Definition: base-list.h:36
std::ostream & os
Definition: pt-pr-code.h:148
tree_expression * maxproc_expr(void)
Definition: pt-loop.h:210
void visit_no_op_command(tree_no_op_command &)
Definition: pt-pr-code.cc:720
void visit_prefix_expression(tree_prefix_expression &)
Definition: pt-pr-code.cc:800
iterator end(void)
Definition: base-list.h:81
void accept(tree_walker &tw)
Definition: pt-id.cc:158
void visit_octave_user_script(octave_user_script &)
Definition: pt-pr-code.cc:307
tree_expression * right_hand_side(void)
Definition: pt-assign.h:72
std::list< tree_argument_list * > arg_lists(void)
Definition: pt-idx.h:74
void visit_persistent_command(tree_persistent_command &)
Definition: pt-pr-code.cc:168
tree_expression * condition(void)
Definition: pt-select.h:59
F77_RET_T const double const double * f
void visit_argument_list(tree_argument_list &)
Definition: pt-pr-code.cc:59
void visit_fcn_handle(tree_fcn_handle &)
Definition: pt-pr-code.cc:740
tree_expression * control_expr(void)
Definition: pt-loop.h:208
std::string oper(void) const
Definition: pt-assign.cc:152
tree_parameter_list * return_list(void)
Definition: ov-usr-fcn.h:378
void accept(tree_walker &tw)
Definition: pt-stmt.cc:176
void visit_switch_command(tree_switch_command &)
Definition: pt-pr-code.cc:963
void visit_index_expression(tree_index_expression &)
Definition: pt-pr-code.cc:538
void visit_function_def(tree_function_def &)
Definition: pt-pr-code.cc:437
void visit_anon_fcn_handle(tree_anon_fcn_handle &)
Definition: pt-pr-code.cc:38
void visit_postfix_expression(tree_postfix_expression &)
Definition: pt-pr-code.cc:783
tree_expression * limit(void)
Definition: pt-colon.h:87
octave_value function(void)
Definition: pt-cmd.h:116
std::string oper(void) const
Definition: pt-unop.cc:39
tree_statement_list * body(void)
Definition: pt-except.h:123
#define panic_impossible()
Definition: error.h:33
void reset(void)
Definition: pt-pr-code.cc:1241
tree_expression * lhs(void)
Definition: pt-binop.h:95
tree_expression * left_hand_side(void)
Definition: pt-loop.h:206
tree_statement_list * body(void)
Definition: pt-except.h:59
void accept(tree_walker &tw)
Definition: pt-decl.cc:103
void visit_switch_case(tree_switch_case &)
Definition: pt-pr-code.cc:916
void accept(tree_walker &tw)
Definition: pt-select.cc:193
octave_comment_list * middle_comment(void)
Definition: pt-except.h:129
tree_statement_list * commands(void)
Definition: pt-select.h:191
tree_statement_list * cleanup(void)
Definition: pt-except.h:61
iterator begin(void)
Definition: base-list.h:78
void print_parens(const tree_expression &expr, const char *txt)
Definition: pt-pr-code.cc:1250
void visit_colon_expression(tree_colon_expression &)
Definition: pt-pr-code.cc:108
octave_function * function_value(bool silent=false) const
Definition: ov.cc:1597
void print_raw(std::ostream &os, bool pr_as_read_syntax=false, bool pr_orig_txt=true)
std::string oper(void) const
Definition: pt-assign.cc:372
octave_comment_list * trailing_comment(void)
Definition: pt-select.h:139
octave_comment_list * trailing_comment(void)
Definition: pt-except.h:67
void accept(tree_walker &tw)
Definition: pt-arg-list.cc:352
std::string text(void) const
Definition: comment-list.h:69
octave_idx_type length(void) const
Number of elements in the array.
Definition: Array.h:267
void visit_octave_user_function_trailer(octave_user_function &)
Definition: pt-pr-code.cc:429
tree_statement_list * body(void)
Definition: ov-usr-fcn.h:140
void visit_switch_case_list(tree_switch_case_list &)
Definition: pt-pr-code.cc:949
tree_expression * rhs(void)
Definition: pt-binop.h:96
bool is_else_clause(void)
Definition: pt-select.h:57
octave_comment_list * trailing_comment(void)
Definition: pt-loop.h:86
void visit_return_list(tree_return_list &)
Definition: pt-pr-code.cc:825
void print_comment_elt(const octave_comment_elt &comment_elt)
Definition: pt-pr-code.cc:1259
void visit_global_command(tree_global_command &)
Definition: pt-pr-code.cc:162
tree_expression * expression(void)
Definition: pt-stmt.h:83
std::string name(void)
Definition: pt-decl.h:162
void accept(tree_walker &tw)
Definition: pt-idx.cc:720
tree_statement_list * body(void) const
void visit_continue_command(tree_continue_command &)
Definition: pt-pr-code.cc:141
void accept(tree_walker &tw)
Definition: pt-decl.cc:79
octave_comment_list * leading_comment(void)
Definition: pt-select.h:193
tree_expression * expression(void)
Definition: pt-decl.h:89
void visit_constant(tree_constant &)
Definition: pt-pr-code.cc:728
void accept(tree_walker &tw)
Definition: pt-select.cc:81
void visit_do_until_command(tree_do_until_command &)
Definition: pt-pr-code.cc:1134
void visit_simple_assignment(tree_simple_assignment &)
Definition: pt-pr-code.cc:844
octave_comment_list * leading_comment(void)
Definition: pt-select.h:63
void do_decl_command(tree_decl_command &cmd)
Definition: pt-pr-code.cc:149
void newline(const char *alt_txt=", ")
Definition: pt-pr-code.cc:1223
void indent(void)
Definition: pt-pr-code.cc:1206
void accept(tree_walker &tw)
Definition: pt-select.cc:57
virtual void accept(tree_walker &)
Definition: ov-fcn.h:177
void visit_break_command(tree_break_command &)
Definition: pt-pr-code.cc:100
std::stack< char > nesting
Definition: pt-pr-code.h:152
tree_parameter_list * parameter_list(void) const
tree_expression * base(void)
Definition: pt-colon.h:85
tree_statement_list * body(void)
Definition: pt-loop.h:82
void print_raw(std::ostream &os, bool pr_as_read_syntax=false, bool pr_orig_txt=true)
Definition: pt-const.cc:49
octave_comment_list * leading_comment(void)
Definition: pt-except.h:63
void visit_if_command(tree_if_command &)
Definition: pt-pr-code.cc:485
void print_fcn_handle_body(tree_statement_list *)
Definition: pt-pr-code.cc:1170
void visit_simple_for_command(tree_simple_for_command &)
Definition: pt-pr-code.cc:211
std::string prefix
Definition: pt-pr-code.h:150
tree_statement_list * body(void)
Definition: ov-usr-fcn.h:380
bool in_parallel(void)
Definition: pt-loop.h:204
int curr_print_indent_level
Definition: pt-pr-code.h:157
tree_expression * right_hand_side(void)
Definition: pt-assign.h:139
octave_base_list< tree_argument_list * >::iterator iterator
Definition: pt-array-list.h:39
virtual void accept(tree_walker &tw)=0
void print_indented_comment(octave_comment_list *comment_list)
Definition: pt-pr-code.cc:1338
void accept(tree_walker &tw)
Definition: pt-misc.cc:332
void visit_matrix(tree_matrix &)
Definition: pt-pr-code.cc:620
tree_expression * condition(void)
Definition: pt-loop.h:80