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 |
|
41 class tree_constant; |
|
42 class tree_identifier; |
|
43 class tree_argument_list; |
|
44 |
|
45 /* |
|
46 * Base class for the parse tree. |
|
47 */ |
|
48 class |
|
49 tree |
|
50 { |
|
51 public: |
|
52 enum matrix_dir |
|
53 { |
|
54 md_none, |
|
55 md_right, |
|
56 md_down, |
|
57 }; |
|
58 |
|
59 enum expression_type |
|
60 { |
|
61 unknown, |
|
62 assignment, |
|
63 simple_assignment, |
|
64 multi_assignment, |
|
65 add, |
|
66 subtract, |
|
67 multiply, |
|
68 el_mul, |
|
69 divide, |
|
70 el_div, |
|
71 leftdiv, |
|
72 el_leftdiv, |
|
73 power, |
|
74 elem_pow, |
|
75 cmp_lt, |
|
76 cmp_le, |
|
77 cmp_eq, |
|
78 cmp_ge, |
|
79 cmp_gt, |
|
80 cmp_ne, |
|
81 and, |
|
82 or, |
|
83 not, |
|
84 unot, |
|
85 uminus, |
|
86 hermitian, |
|
87 transpose, |
|
88 colon, |
|
89 index, |
|
90 increment, |
|
91 decrement, |
|
92 }; |
|
93 |
|
94 virtual ~tree (void) { } |
|
95 |
|
96 // Only the finest cheese... |
|
97 virtual int is_identifier (void) |
|
98 { return 0; } |
|
99 |
|
100 virtual int is_constant (void) |
|
101 { return 0; } |
|
102 |
|
103 virtual int is_builtin (void) |
|
104 { return 0; } |
|
105 |
|
106 virtual int is_index_expression (void) |
|
107 { return 0; } |
|
108 |
|
109 virtual int is_assignment_expression (void) |
|
110 { return 0; } |
|
111 |
|
112 virtual tree *def (void) |
|
113 { assert (0); return (tree *) NULL; } |
|
114 |
|
115 virtual char *name (void) |
|
116 { assert (0); return (char *) NULL; } |
|
117 |
|
118 virtual int max_expected_args (void) |
|
119 { assert (0); return 0; } |
|
120 |
|
121 virtual void set_print_flag (int print) |
|
122 { assert (0); } |
|
123 |
|
124 virtual tree_constant assign (tree_constant& t, tree_constant *args, |
|
125 int nargs); |
|
126 |
|
127 virtual void bump_value (tree::expression_type) |
|
128 { assert (0); } |
|
129 |
|
130 virtual void stash_m_file_name (char *s) |
|
131 { assert (0); } |
|
132 |
|
133 virtual void stash_m_file_time (time_t t) |
|
134 { assert (0); } |
|
135 |
|
136 virtual char *m_file_name (void) |
|
137 { return (char *) NULL; } |
|
138 |
|
139 virtual time_t time_parsed (void) |
|
140 { assert (0); return 0; } |
|
141 |
|
142 virtual tree_constant eval (int print) = 0; |
|
143 |
|
144 virtual tree_constant *eval (int print, int nargout); |
|
145 |
|
146 virtual tree_constant eval (int argc, char **argv, int print); |
|
147 |
|
148 virtual tree_constant *eval (tree_constant *args, int n_in, int nout, |
|
149 int print) |
|
150 { assert (0); return NULL_TREE_CONST; } |
|
151 |
|
152 virtual int save (ostream& os, int mark_as_global = 0) |
|
153 { assert (0); return 0; } |
143
|
154 |
|
155 virtual int line (void) { return line_num; } |
|
156 virtual int column (void) { return column_num; } |
|
157 |
|
158 protected: |
|
159 int line_num; |
|
160 int column_num; |
1
|
161 }; |
|
162 |
|
163 #endif |
|
164 |
|
165 /* |
|
166 ;;; Local Variables: *** |
|
167 ;;; mode: C++ *** |
|
168 ;;; page-delimiter: "^/\\*" *** |
|
169 ;;; End: *** |
|
170 */ |