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