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-select.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_select_h)
24 #define octave_pt_select_h 1
25 
26 #include "octave-config.h"
27 
28 class expression;
30 
31 class tree_walker;
32 
33 #include "base-list.h"
34 #include "comment-list.h"
35 #include "pt-cmd.h"
36 #include "symtab.h"
37 
38 // If.
39 
40 class
41 tree_if_clause : public tree
42 {
43 public:
44 
45  tree_if_clause (int l = -1, int c = -1)
46  : tree (l, c), expr (0), list (0), lead_comm (0) { }
47 
49  int l = -1, int c = -1)
50  : tree (l, c), expr (0), list (sl), lead_comm (lc) { }
51 
53  octave_comment_list *lc = 0,
54  int l = -1, int c = -1)
55  : tree (l, c), expr (e), list (sl), lead_comm (lc) { }
56 
57  ~tree_if_clause (void);
58 
59  bool is_else_clause (void) { return ! expr; }
60 
61  tree_expression *condition (void) { return expr; }
62 
63  tree_statement_list *commands (void) { return list; }
64 
65  octave_comment_list *leading_comment (void) { return lead_comm; }
66 
69 
70  void accept (tree_walker& tw);
71 
72 private:
73 
74  // The condition to test.
76 
77  // The list of statements to evaluate if expr is true.
79 
80  // Comment preceding ELSE or ELSEIF token.
82 
83  // No copying!
84 
86 
88 };
89 
90 class
92 {
93 public:
94 
96 
98 
100  {
101  while (! empty ())
102  {
103  iterator p = begin ();
104  delete *p;
105  erase (p);
106  }
107  }
108 
111 
112  void accept (tree_walker& tw);
113 
114 private:
115 
116  // No copying!
117 
119 
121 };
122 
123 class
125 {
126 public:
127 
128  tree_if_command (int l = -1, int c = -1)
129  : tree_command (l, c), list (0), lead_comm (0), trail_comm (0) { }
130 
132  octave_comment_list *tc, int l = -1, int c = -1)
133  : tree_command (l, c), list (lst), lead_comm (lc), trail_comm (tc) { }
134 
135  ~tree_if_command (void);
136 
137  tree_if_command_list *cmd_list (void) { return list; }
138 
139  octave_comment_list *leading_comment (void) { return lead_comm; }
140 
141  octave_comment_list *trailing_comment (void) { return trail_comm; }
142 
145 
146  void accept (tree_walker& tw);
147 
148 private:
149 
150  // List of if commands (if, elseif, elseif, ... else, endif)
152 
153  // Comment preceding IF token.
155 
156  // Comment preceding ENDIF token.
158 
159  // No copying!
160 
162 
164 };
165 
166 // Switch.
167 
168 class
169 tree_switch_case : public tree
170 {
171 public:
172 
173  tree_switch_case (int l = -1, int c = -1)
174  : tree (l, c), label (0), list (0), lead_comm (0) { }
175 
177  int l = -1, int c = -1)
178  : tree (l, c), label (0), list (sl), lead_comm (lc) { }
179 
181  octave_comment_list *lc = 0,
182  int l = -1, int c = -1)
183  : tree (l, c), label (e), list (sl), lead_comm (lc) { }
184 
185  ~tree_switch_case (void);
186 
187  bool is_default_case (void) { return ! label; }
188 
189  bool label_matches (const octave_value& val);
190 
191  tree_expression *case_label (void) { return label; }
192 
193  tree_statement_list *commands (void) { return list; }
194 
195  octave_comment_list *leading_comment (void) { return lead_comm; }
196 
199 
200  void accept (tree_walker& tw);
201 
202 private:
203 
204  // The case label.
206 
207  // The list of statements to evaluate if the label matches.
209 
210  // Comment preceding CASE or OTHERWISE token.
212 
213  // No copying!
214 
216 
218 };
219 
220 class
222 {
223 public:
224 
226 
228 
230  {
231  while (! empty ())
232  {
233  iterator p = begin ();
234  delete *p;
235  erase (p);
236  }
237  }
238 
241 
242  void accept (tree_walker& tw);
243 
244 private:
245 
246  // No copying!
247 
249 
251 };
252 
253 class
255 {
256 public:
257 
258  tree_switch_command (int l = -1, int c = -1)
259  : tree_command (l, c), expr (0), list (0), lead_comm (0),
260  trail_comm (0) { }
261 
264  int l = -1, int c = -1)
265  : tree_command (l, c), expr (e), list (lst), lead_comm (lc),
266  trail_comm (tc) { }
267 
268  ~tree_switch_command (void);
269 
270  tree_expression *switch_value (void) { return expr; }
271 
273 
274  octave_comment_list *leading_comment (void) { return lead_comm; }
275 
276  octave_comment_list *trailing_comment (void) { return trail_comm; }
277 
280 
281  void accept (tree_walker& tw);
282 
283 private:
284 
285  // Value on which to switch.
287 
288  // List of cases (case 1, case 2, ..., default)
290 
291  // Comment preceding SWITCH token.
293 
294  // Comment preceding ENDSWITCH token.
296 
297  // No copying!
298 
300 
302 };
303 
304 #endif
octave_comment_list * leading_comment(void)
Definition: pt-select.h:139
tree_if_command(tree_if_command_list *lst, octave_comment_list *lc, octave_comment_list *tc, int l=-1, int c=-1)
Definition: pt-select.h:131
~tree_switch_case_list(void)
Definition: pt-select.h:229
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:728
tree_expression * switch_value(void)
Definition: pt-select.h:270
identity matrix If supplied two scalar respectively For allows like xample val
Definition: data.cc:5068
tree_if_command_list(void)
Definition: pt-select.h:95
bool is_default_case(void)
Definition: pt-select.h:187
octave_comment_list * lead_comm
Definition: pt-select.h:154
tree_switch_case_list * case_list(void)
Definition: pt-select.h:272
tree_switch_case(tree_statement_list *sl, octave_comment_list *lc=0, int l=-1, int c=-1)
Definition: pt-select.h:176
std::list< tree_if_clause * >::iterator iterator
Definition: base-list.h:40
tree_statement_list * commands(void)
Definition: pt-select.h:63
OCTAVE_EXPORT octave_value_list return the number of command line arguments passed to Octave If called with the optional argument the function t
Definition: ov-usr-fcn.cc:935
tree_expression * case_label(void)
Definition: pt-select.h:191
octave_comment_list * leading_comment(void)
Definition: pt-select.h:274
octave_comment_list * trailing_comment(void)
Definition: pt-select.h:276
tree_if_clause(tree_statement_list *sl, octave_comment_list *lc=0, int l=-1, int c=-1)
Definition: pt-select.h:48
i e
Definition: data.cc:2724
octave_comment_list * trail_comm
Definition: pt-select.h:157
tree_switch_case(tree_expression *e, tree_statement_list *sl, octave_comment_list *lc=0, int l=-1, int c=-1)
Definition: pt-select.h:180
tree_switch_command(tree_expression *e, tree_switch_case_list *lst, octave_comment_list *lc, octave_comment_list *tc, int l=-1, int c=-1)
Definition: pt-select.h:262
tree_switch_case_list * list
Definition: pt-select.h:289
tree_switch_command(int l=-1, int c=-1)
Definition: pt-select.h:258
tree_if_command_list * cmd_list(void)
Definition: pt-select.h:137
OCTAVE_EXPORT octave_value_list any number nd example oindent prints the prompt xample Pick a any number!nd example oindent and waits for the user to enter a value The string entered by the user is evaluated as an expression
Definition: input.cc:871
tree_if_command(int l=-1, int c=-1)
Definition: pt-select.h:128
tree_statement_list * list
Definition: pt-select.h:208
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
tree_expression * condition(void)
Definition: pt-select.h:61
octave_comment_list * lead_comm
Definition: pt-select.h:211
static llvm::LLVMContext & context
Definition: jit-typeinfo.cc:76
tree_if_command_list(tree_if_clause *t)
Definition: pt-select.h:97
bool append
Definition: load-save.cc:1582
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
tree_statement_list * commands(void)
Definition: pt-select.h:193
tree_if_clause(tree_expression *e, tree_statement_list *sl, octave_comment_list *lc=0, int l=-1, int c=-1)
Definition: pt-select.h:52
octave_comment_list * trailing_comment(void)
Definition: pt-select.h:141
tree_expression * label
Definition: pt-select.h:205
tree_statement_list * list
Definition: pt-select.h:78
bool is_else_clause(void)
Definition: pt-select.h:59
tree_expression * expr
Definition: pt-select.h:286
p
Definition: lu.cc:138
Definition: pt.h:39
tree_if_clause(int l=-1, int c=-1)
Definition: pt-select.h:45
octave_comment_list * leading_comment(void)
Definition: pt-select.h:195
octave_comment_list * trail_comm
Definition: pt-select.h:295
octave_comment_list * leading_comment(void)
Definition: pt-select.h:65
tree_expression * expr
Definition: pt-select.h:75
octave_comment_list * lead_comm
Definition: pt-select.h:81
tree_switch_case(int l=-1, int c=-1)
Definition: pt-select.h:173
octave_comment_list * lead_comm
Definition: pt-select.h:292
tree_switch_case_list(tree_switch_case *t)
Definition: pt-select.h:227
tree_if_command_list * list
Definition: pt-select.h:151
tree_walker & operator=(const tree_walker &)
~tree_if_command_list(void)
Definition: pt-select.h:99