2980
|
1 /* |
|
2 |
|
3 Copyright (C) 1996, 1997 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 |
7016
|
9 Free Software Foundation; either version 3 of the License, or (at your |
|
10 option) any later version. |
2980
|
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 |
7016
|
18 along with Octave; see the file COPYING. If not, see |
|
19 <http://www.gnu.org/licenses/>. |
2980
|
20 |
|
21 */ |
|
22 |
|
23 #if !defined (octave_tree_colon_h) |
|
24 #define octave_tree_colon 1 |
|
25 |
|
26 #include <string> |
|
27 |
|
28 class tree_walker; |
|
29 |
|
30 class octave_value; |
|
31 class octave_value_list; |
|
32 class octave_lvalue; |
|
33 |
|
34 #include "pt-exp.h" |
|
35 |
|
36 // Colon expressions. |
|
37 |
|
38 class |
|
39 tree_colon_expression : public tree_expression |
|
40 { |
|
41 public: |
|
42 |
|
43 tree_colon_expression (int l = -1, int c = -1) |
2990
|
44 : tree_expression (l, c), op_base (0), op_limit (0), |
|
45 op_increment (0), save_base (false) { } |
2980
|
46 |
|
47 tree_colon_expression (tree_expression *e, int l = -1, int c = -1) |
2990
|
48 : tree_expression (l, c), op_base (e), op_limit (0), |
|
49 op_increment (0), save_base (false) { } |
2980
|
50 |
5861
|
51 tree_colon_expression (tree_expression *bas, tree_expression *lim, |
|
52 tree_expression *inc, int l = -1, int c = -1) |
|
53 : tree_expression (l, c), op_base (bas), op_limit (lim), |
|
54 op_increment (inc), save_base (false) { } |
|
55 |
2980
|
56 ~tree_colon_expression (void) |
|
57 { |
2990
|
58 if (! save_base) |
|
59 delete op_base; |
|
60 |
2980
|
61 delete op_limit; |
|
62 delete op_increment; |
|
63 } |
|
64 |
4267
|
65 bool has_magic_end (void) const |
|
66 { |
|
67 return ((op_base && op_base->has_magic_end ()) |
|
68 || (op_limit && op_limit->has_magic_end ()) |
|
69 || (op_increment && op_increment->has_magic_end ())); |
|
70 } |
|
71 |
2990
|
72 void preserve_base (void) { save_base = true; } |
|
73 |
2980
|
74 tree_colon_expression *append (tree_expression *t); |
|
75 |
3933
|
76 bool rvalue_ok (void) const { return true; } |
2980
|
77 |
|
78 octave_value rvalue (void); |
|
79 |
|
80 octave_value_list rvalue (int nargout); |
|
81 |
5347
|
82 void eval_error (const std::string& s = std::string ()) const; |
2980
|
83 |
|
84 tree_expression *base (void) { return op_base; } |
|
85 |
|
86 tree_expression *limit (void) { return op_limit; } |
|
87 |
|
88 tree_expression *increment (void) { return op_increment; } |
|
89 |
5066
|
90 int line (void) const; |
|
91 int column (void) const; |
|
92 |
5861
|
93 tree_expression *dup (symbol_table *sym_tab); |
|
94 |
2980
|
95 void accept (tree_walker& tw); |
|
96 |
|
97 private: |
|
98 |
|
99 // The components of the expression. |
|
100 tree_expression *op_base; |
|
101 tree_expression *op_limit; |
|
102 tree_expression *op_increment; |
2988
|
103 |
2990
|
104 bool save_base; |
|
105 |
5347
|
106 octave_value |
|
107 make_range (const Matrix& m_base, const Matrix& m_limit, |
5349
|
108 const Matrix& m_increment, bool result_is_str, |
|
109 bool dq_str) const; |
5347
|
110 |
|
111 octave_value |
|
112 make_range (const octave_value& ov_base, const octave_value& ov_limit, |
|
113 const octave_value& ov_increment) const; |
|
114 |
2988
|
115 // No copying! |
|
116 |
|
117 tree_colon_expression (const tree_colon_expression&); |
|
118 |
|
119 tree_colon_expression& operator = (const tree_colon_expression&); |
2980
|
120 }; |
|
121 |
|
122 #endif |
|
123 |
|
124 /* |
|
125 ;;; Local Variables: *** |
|
126 ;;; mode: C++ *** |
|
127 ;;; End: *** |
|
128 */ |