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