1739
|
1 /* |
|
2 |
2847
|
3 Copyright (C) 1996, 1997 John W. Eaton |
1739
|
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 |
|
19 Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
|
20 |
|
21 */ |
|
22 |
2980
|
23 #if !defined (octave_tree_expr_h) |
|
24 #define octave_tree_expr_h 1 |
1739
|
25 |
|
26 #if defined (__GNUG__) |
|
27 #pragma interface |
|
28 #endif |
|
29 |
2980
|
30 #include <string> |
2124
|
31 |
2879
|
32 class octave_value; |
2979
|
33 class octave_lvalue; |
2879
|
34 |
2980
|
35 #include "pt-base.h" |
2124
|
36 |
2980
|
37 // A base class for expressions. |
1739
|
38 |
|
39 class |
2980
|
40 tree_expression : public tree |
2388
|
41 { |
|
42 public: |
|
43 |
2980
|
44 tree_expression (int l = -1, int c = -1) |
|
45 : tree (l, c), num_parens (0), postfix_indexed (false), |
|
46 print_flag (false) { } |
2388
|
47 |
2980
|
48 virtual ~tree_expression (void) { } |
2388
|
49 |
2980
|
50 virtual bool is_constant (void) const |
|
51 { return false; } |
2388
|
52 |
2980
|
53 virtual bool is_matrix_constant (void) const |
|
54 { return false; } |
2388
|
55 |
2980
|
56 virtual bool is_identifier (void) const |
|
57 { return false; } |
1739
|
58 |
2980
|
59 virtual bool is_index_expression (void) const |
|
60 { return false; } |
1739
|
61 |
2980
|
62 virtual bool is_indirect_ref (void) const |
|
63 { return false; } |
1739
|
64 |
2980
|
65 virtual bool is_assignment_expression (void) const |
|
66 { return false; } |
1739
|
67 |
2980
|
68 virtual bool is_prefix_expression (void) const |
|
69 { return false; } |
1739
|
70 |
2980
|
71 virtual bool is_logically_true (const char *); |
1739
|
72 |
2980
|
73 virtual bool lvalue_ok (void) const |
|
74 { return false; } |
1739
|
75 |
2980
|
76 virtual bool rvalue_ok (void) const |
|
77 { return false; } |
2124
|
78 |
2980
|
79 virtual octave_value rvalue (void); |
1739
|
80 |
2980
|
81 virtual octave_value_list rvalue (int nargout); |
2879
|
82 |
2980
|
83 virtual octave_lvalue lvalue (void); |
2879
|
84 |
2980
|
85 int paren_count (void) const |
|
86 { return num_parens; } |
2124
|
87 |
2980
|
88 bool is_postfix_indexed (void) const |
|
89 { return postfix_indexed; } |
2124
|
90 |
2980
|
91 bool print_result (void) const |
|
92 { return print_flag; } |
1739
|
93 |
2980
|
94 virtual string oper (void) const |
|
95 { return "<unknown>"; } |
1739
|
96 |
2980
|
97 virtual string name (void) const |
|
98 { return "<unknown>"; } |
2124
|
99 |
2980
|
100 virtual string original_text (void) const; |
1739
|
101 |
2980
|
102 tree_expression *mark_in_parens (void) |
1739
|
103 { |
2980
|
104 num_parens++; |
|
105 return this; |
1739
|
106 } |
|
107 |
2980
|
108 tree_expression *mark_postfix_indexed (void) |
|
109 { |
|
110 postfix_indexed = true; |
|
111 return this; |
|
112 } |
2971
|
113 |
2980
|
114 tree_expression *set_print_flag (bool print) |
|
115 { |
|
116 print_flag = print; |
|
117 return this; |
|
118 } |
2971
|
119 |
2980
|
120 protected: |
2971
|
121 |
2980
|
122 // A count of the number of times this expression appears directly |
|
123 // inside a set of parentheses. |
|
124 // |
|
125 // (((e1)) + e2) ==> 2 for expression e1 |
|
126 // ==> 1 for expression ((e1)) + e2 |
|
127 // ==> 0 for expression e2 |
|
128 int num_parens; |
2971
|
129 |
2980
|
130 // A flag that says whether this expression has an index associated |
|
131 // with it. See the code in tree_identifier::rvalue for the rationale. |
|
132 bool postfix_indexed; |
2971
|
133 |
2980
|
134 // Print result of rvalue for this expression? |
|
135 bool print_flag; |
2971
|
136 }; |
|
137 |
1739
|
138 #endif |
|
139 |
|
140 /* |
|
141 ;;; Local Variables: *** |
|
142 ;;; mode: C++ *** |
|
143 ;;; End: *** |
|
144 */ |