494
|
1 /* |
|
2 |
2847
|
3 Copyright (C) 1996, 1997 John W. Eaton |
494
|
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 |
1315
|
19 Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
494
|
20 |
|
21 */ |
|
22 |
|
23 #if !defined (octave_tree_expr_h) |
|
24 #define octave_tree_expr_h 1 |
|
25 |
1297
|
26 #if defined (__GNUG__) |
|
27 #pragma interface |
|
28 #endif |
|
29 |
2530
|
30 #include <string> |
|
31 |
2086
|
32 class octave_value; |
2960
|
33 class octave_variable_reference; |
494
|
34 |
1740
|
35 #include "pt-base.h" |
494
|
36 |
578
|
37 // A base class for expressions. |
|
38 |
494
|
39 class |
|
40 tree_expression : public tree |
|
41 { |
|
42 public: |
581
|
43 |
2960
|
44 tree_expression (int l = -1, int c = -1) |
2961
|
45 : tree (l, c), num_parens (0) { } |
494
|
46 |
878
|
47 virtual ~tree_expression (void) { } |
494
|
48 |
1827
|
49 virtual bool is_constant (void) const |
|
50 { return false; } |
1623
|
51 |
1827
|
52 virtual bool is_matrix_constant (void) const |
|
53 { return false; } |
1623
|
54 |
1827
|
55 virtual bool is_multi_val_ret_expression (void) const |
|
56 { return false; } |
666
|
57 |
1827
|
58 virtual bool is_identifier (void) const |
|
59 { return false; } |
494
|
60 |
1827
|
61 virtual bool is_indirect_ref (void) const |
|
62 { return false; } |
748
|
63 |
1827
|
64 virtual bool is_index_expression (void) const |
|
65 { return false; } |
494
|
66 |
1827
|
67 virtual bool is_assignment_expression (void) const |
|
68 { return false; } |
494
|
69 |
1827
|
70 virtual bool is_prefix_expression (void) const |
|
71 { return false; } |
494
|
72 |
1827
|
73 virtual bool is_logically_true (const char *); |
1491
|
74 |
2961
|
75 virtual int paren_count (void) const |
|
76 { return num_parens; } |
2124
|
77 |
1740
|
78 virtual void mark_for_possible_ans_assign (void); |
494
|
79 |
2858
|
80 virtual octave_value eval (bool print = false) = 0; |
578
|
81 |
2960
|
82 virtual octave_variable_reference reference (void); |
|
83 |
2961
|
84 virtual string oper (void) const |
|
85 { return "<unknown>"; } |
2464
|
86 |
2530
|
87 virtual string original_text (void) const; |
|
88 |
2961
|
89 tree_expression *mark_in_parens (void) |
|
90 { |
|
91 num_parens++; |
|
92 return this; |
|
93 } |
2960
|
94 |
494
|
95 protected: |
2124
|
96 |
2961
|
97 // A count of the number of times this expression appears directly |
|
98 // inside a set of parentheses. |
|
99 // |
|
100 // (((e1)) + e2) ==> 2 for expression e1 |
|
101 // ==> 1 for expression ((e1)) + e2 |
|
102 // ==> 0 for expression e2 |
|
103 int num_parens; |
494
|
104 }; |
|
105 |
|
106 #endif |
|
107 |
|
108 /* |
|
109 ;;; Local Variables: *** |
|
110 ;;; mode: C++ *** |
|
111 ;;; End: *** |
|
112 */ |