1
|
1 // tree-base.h -*- C++ -*- |
|
2 /* |
|
3 |
|
4 Copyright (C) 1992, 1993 John W. Eaton |
|
5 |
|
6 This file is part of Octave. |
|
7 |
|
8 Octave is free software; you can redistribute it and/or modify it |
|
9 under the terms of the GNU General Public License as published by the |
|
10 Free Software Foundation; either version 2, or (at your option) any |
|
11 later version. |
|
12 |
|
13 Octave is distributed in the hope that it will be useful, but WITHOUT |
|
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
16 for more details. |
|
17 |
|
18 You should have received a copy of the GNU General Public License |
|
19 along with Octave; see the file COPYING. If not, write to the Free |
|
20 Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. |
|
21 |
|
22 */ |
|
23 |
|
24 #if !defined (_tree_base_h) |
|
25 #define _tree_base_h 1 |
|
26 |
|
27 // NOTE: don\'t put #pragma interface here because there is no |
|
28 // corresponding tree-base.cc file that implements this class! |
|
29 |
|
30 #ifndef NULL_TREE |
|
31 #define NULL_TREE (tree *)NULL |
|
32 #endif |
|
33 |
|
34 #ifndef NULL_TREE_CONST |
|
35 #define NULL_TREE_CONST (tree_constant *)NULL |
|
36 #endif |
|
37 |
|
38 #include <time.h> |
|
39 #include <assert.h> |
|
40 |
164
|
41 class ostream; |
1
|
42 class tree_constant; |
|
43 class tree_identifier; |
|
44 class tree_argument_list; |
|
45 |
|
46 /* |
|
47 * Base class for the parse tree. |
|
48 */ |
|
49 class |
|
50 tree |
|
51 { |
|
52 public: |
|
53 enum matrix_dir |
|
54 { |
|
55 md_none, |
|
56 md_right, |
|
57 md_down, |
|
58 }; |
|
59 |
|
60 enum expression_type |
|
61 { |
|
62 unknown, |
|
63 assignment, |
|
64 simple_assignment, |
|
65 multi_assignment, |
|
66 add, |
|
67 subtract, |
|
68 multiply, |
|
69 el_mul, |
|
70 divide, |
|
71 el_div, |
|
72 leftdiv, |
|
73 el_leftdiv, |
|
74 power, |
|
75 elem_pow, |
|
76 cmp_lt, |
|
77 cmp_le, |
|
78 cmp_eq, |
|
79 cmp_ge, |
|
80 cmp_gt, |
|
81 cmp_ne, |
|
82 and, |
|
83 or, |
|
84 not, |
|
85 unot, |
|
86 uminus, |
|
87 hermitian, |
|
88 transpose, |
|
89 colon, |
|
90 index, |
|
91 increment, |
|
92 decrement, |
|
93 }; |
|
94 |
|
95 virtual ~tree (void) { } |
|
96 |
|
97 // Only the finest cheese... |
164
|
98 virtual int is_identifier (void) const |
1
|
99 { return 0; } |
|
100 |
164
|
101 virtual int is_constant (void) const |
1
|
102 { return 0; } |
|
103 |
164
|
104 virtual int is_builtin (void) const |
1
|
105 { return 0; } |
|
106 |
164
|
107 virtual int is_index_expression (void) const |
1
|
108 { return 0; } |
|
109 |
164
|
110 virtual int is_assignment_expression (void) const |
1
|
111 { return 0; } |
|
112 |
|
113 virtual tree *def (void) |
|
114 { assert (0); return (tree *) NULL; } |
|
115 |
|
116 virtual char *name (void) |
|
117 { assert (0); return (char *) NULL; } |
|
118 |
|
119 virtual int max_expected_args (void) |
|
120 { assert (0); return 0; } |
|
121 |
|
122 virtual void set_print_flag (int print) |
|
123 { assert (0); } |
|
124 |
|
125 virtual tree_constant assign (tree_constant& t, tree_constant *args, |
|
126 int nargs); |
|
127 |
|
128 virtual void bump_value (tree::expression_type) |
|
129 { assert (0); } |
|
130 |
|
131 virtual void stash_m_file_name (char *s) |
|
132 { assert (0); } |
|
133 |
|
134 virtual void stash_m_file_time (time_t t) |
|
135 { assert (0); } |
|
136 |
|
137 virtual char *m_file_name (void) |
|
138 { return (char *) NULL; } |
|
139 |
|
140 virtual time_t time_parsed (void) |
|
141 { assert (0); return 0; } |
|
142 |
|
143 virtual tree_constant eval (int print) = 0; |
|
144 |
|
145 virtual tree_constant *eval (int print, int nargout); |
|
146 |
|
147 virtual tree_constant eval (int argc, char **argv, int print); |
|
148 |
164
|
149 virtual tree_constant *eval (const tree_constant *args, int n_in, int nout, |
1
|
150 int print) |
|
151 { assert (0); return NULL_TREE_CONST; } |
|
152 |
|
153 virtual int save (ostream& os, int mark_as_global = 0) |
|
154 { assert (0); return 0; } |
143
|
155 |
164
|
156 virtual int line (void) const { return line_num; } |
|
157 virtual int column (void) const { return column_num; } |
143
|
158 |
|
159 protected: |
|
160 int line_num; |
|
161 int column_num; |
1
|
162 }; |
|
163 |
|
164 #endif |
|
165 |
|
166 /* |
|
167 ;;; Local Variables: *** |
|
168 ;;; mode: C++ *** |
|
169 ;;; page-delimiter: "^/\\*" *** |
|
170 ;;; End: *** |
|
171 */ |