GNU Octave  4.2.1
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-stmt.h
Go to the documentation of this file.
1 /*
2 
3 Copyright (C) 1996-2017 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 #if ! defined (octave_pt_stmt_h)
24 #define octave_pt_stmt_h 1
25 
26 #include "octave-config.h"
27 
28 class octave_value_list;
29 
30 class tree_command;
31 class tree_expression;
32 
33 class tree_walker;
34 
35 #include <deque>
36 
37 #include "base-list.h"
38 #include "comment-list.h"
39 #include "debug.h"
40 #include "symtab.h"
41 #include "pt.h"
42 
43 // A statement is either a command to execute or an expression to
44 // evaluate.
45 
46 class
47 tree_statement : public tree
48 {
49 public:
50 
52  : cmd (0), expr (0), comm (0) { }
53 
55  : cmd (c), expr (0), comm (cl) { }
56 
58  : cmd (0), expr (e), comm (cl) { }
59 
60  ~tree_statement (void);
61 
62  void set_print_flag (bool print_flag);
63 
64  bool print_result (void);
65 
66  bool is_command (void) const { return cmd != 0; }
67 
68  bool is_expression (void) const { return expr != 0; }
69 
70  void set_breakpoint (const std::string& condition);
71 
72  void delete_breakpoint (void);
73 
74  bool is_breakpoint (bool check_valid = false) const;
75  std::string bp_cond () const;
76 
77  int line (void) const;
78  int column (void) const;
79 
80  void set_location (int l, int c);
81 
82  void echo_code (void);
83 
84  tree_command *command (void) { return cmd; }
85 
86  tree_expression *expression (void) { return expr; }
87 
88  octave_comment_list *comment_text (void) { return comm; }
89 
90  bool is_null_statement (void) const { return ! (cmd || expr || comm); }
91 
92  bool is_end_of_fcn_or_script (void) const;
93 
94  bool is_end_of_file (void) const;
95 
96  // Allow modification of this statement. Note that there is no
97  // checking. If you use these, are you sure you knwo what you are
98  // doing?
99 
100  void set_command (tree_command *c) { cmd = c; }
101 
102  void set_expression (tree_expression *e) { expr = e; }
103 
106 
107  void accept (tree_walker& tw);
108 
109 private:
110 
111  // Only one of cmd or expr can be valid at once.
112 
113  // Command to execute.
115 
116  // Expression to evaluate.
118 
119  // Comment associated with this statement.
121 
122  // No copying!
124 
126 };
127 
128 // A list of statements to evaluate.
129 
130 class
132 {
133 public:
134 
136  : function_body (false), anon_function_body (false),
137  script_body (false) { }
138 
140  : function_body (false), anon_function_body (false),
141  script_body (false) { append (s); }
142 
144  {
145  while (! empty ())
146  {
147  iterator p = begin ();
148  delete *p;
149  erase (p);
150  }
151  }
152 
153  void mark_as_function_body (void) { function_body = true; }
154 
155  void mark_as_anon_function_body (void) { anon_function_body = true; }
156 
157  void mark_as_script_body (void) { script_body = true; }
158 
159  bool is_function_body (void) const { return function_body; }
160 
161  bool is_anon_function_body (void) const { return anon_function_body; }
162 
163  bool is_script_body (void) const { return script_body; }
164 
165  int set_breakpoint (int line, const std::string& condition);
166 
167  void delete_breakpoint (int line);
168 
169  octave_value_list list_breakpoints (void);
170 
171  std::list<bp_type> breakpoints_and_conds (void);
172 
173  bp_table::intmap add_breakpoint (const std::string& file,
174  const bp_table::intmap& line,
175  const std::string& condition);
176 
177  bp_table::intmap remove_all_breakpoints (const std::string& file);
178 
181 
182  void accept (tree_walker& tw);
183 
184 private:
185 
186  // Does this list of statements make up the body of a function?
188 
189  // Does this list of statements make up the body of a function?
191 
192  // Does this list of statements make up the body of a script?
194 
195  // No copying!
196 
198 
200 };
201 
202 #endif
OCTAVE_EXPORT octave_value_list column
Definition: sparse.cc:123
octave_comment_list * comment_text(void)
Definition: pt-stmt.h:88
For example cd octave end example noindent changes the current working directory to file
Definition: dirfns.cc:120
bool anon_function_body
Definition: pt-stmt.h:190
tree_statement(void)
Definition: pt-stmt.h:51
tree_statement(tree_expression *e, octave_comment_list *cl)
Definition: pt-stmt.h:57
tree_command * cmd
Definition: pt-stmt.h:114
tree_command * command(void)
Definition: pt-stmt.h:84
tree_expression * expr
Definition: pt-stmt.h:117
std::list< tree_statement * >::iterator iterator
Definition: base-list.h:40
bool is_anon_function_body(void) const
Definition: pt-stmt.h:161
tree_statement_list(tree_statement *s)
Definition: pt-stmt.h:139
octave_comment_list * comm
Definition: pt-stmt.h:120
s
Definition: file-io.cc:2682
i e
Definition: data.cc:2724
create a structure array and initialize its values The dimensions of each cell array of values must match Singleton cells and non cell values are repeated so that they fill the entire array If the cells are empty
Definition: ov-struct.cc:1688
static llvm::LLVMContext & context
Definition: jit-typeinfo.cc:76
std::map< int, int > intmap
Definition: debug.h:60
is false
Definition: cellfun.cc:398
bool append
Definition: load-save.cc:1582
void set_command(tree_command *c)
Definition: pt-stmt.h:100
the sparsity preserving column transformation such that that defines the pivoting threshold can be given in which case it defines the c
Definition: lu.cc:138
void mark_as_anon_function_body(void)
Definition: pt-stmt.h:155
void set_expression(tree_expression *e)
Definition: pt-stmt.h:102
bool is_script_body(void) const
Definition: pt-stmt.h:163
bool is_command(void) const
Definition: pt-stmt.h:66
p
Definition: lu.cc:138
tree_expression * expression(void)
Definition: pt-stmt.h:86
Definition: pt.h:39
void mark_as_function_body(void)
Definition: pt-stmt.h:153
bool is_expression(void) const
Definition: pt-stmt.h:68
bool is_function_body(void) const
Definition: pt-stmt.h:159
bool is_null_statement(void) const
Definition: pt-stmt.h:90
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:854
void mark_as_script_body(void)
Definition: pt-stmt.h:157
tree_statement(tree_command *c, octave_comment_list *cl)
Definition: pt-stmt.h:54
tree_walker & operator=(const tree_walker &)
tree_statement_list(void)
Definition: pt-stmt.h:135
~tree_statement_list(void)
Definition: pt-stmt.h:143