Mercurial > hg > octave-nkf
annotate src/pt-exp.h @ 9585:06b8b51dca48
also handle user-defined graphics properties in new property name validation scheme
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Fri, 28 Aug 2009 18:37:31 -0400 |
parents | eb63fbe60fab |
children | cd96d29c5efa |
rev | line source |
---|---|
1739 | 1 /* |
2 | |
8920 | 3 Copyright (C) 1996, 1997, 2000, 2002, 2003, 2004, 2005, 2006, 2007, |
4 2008, 2009 John W. Eaton | |
1739 | 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 | |
7016 | 10 Free Software Foundation; either version 3 of the License, or (at your |
11 option) any later version. | |
1739 | 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 | |
7016 | 19 along with Octave; see the file COPYING. If not, see |
20 <http://www.gnu.org/licenses/>. | |
1739 | 21 |
22 */ | |
23 | |
2980 | 24 #if !defined (octave_tree_expr_h) |
25 #define octave_tree_expr_h 1 | |
1739 | 26 |
2980 | 27 #include <string> |
2124 | 28 |
2879 | 29 class octave_value; |
2979 | 30 class octave_lvalue; |
2879 | 31 |
2988 | 32 #include "pt.h" |
7336 | 33 #include "symtab.h" |
2124 | 34 |
2980 | 35 // A base class for expressions. |
1739 | 36 |
37 class | |
2980 | 38 tree_expression : public tree |
2388 | 39 { |
40 public: | |
41 | |
2980 | 42 tree_expression (int l = -1, int c = -1) |
43 : tree (l, c), num_parens (0), postfix_indexed (false), | |
44 print_flag (false) { } | |
2388 | 45 |
2980 | 46 virtual ~tree_expression (void) { } |
2388 | 47 |
4267 | 48 virtual bool has_magic_end (void) const = 0; |
49 | |
7767
71f068b22fcc
scope and context fixes for function handles
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
50 virtual tree_expression *dup (symbol_table::scope_id, |
8913
35cd375d4bb3
make tree::dup functions const
John W. Eaton <jwe@octave.org>
parents:
8658
diff
changeset
|
51 symbol_table::context_id context) const = 0; |
5861 | 52 |
3933 | 53 virtual bool is_constant (void) const { return false; } |
2388 | 54 |
3933 | 55 virtual bool is_matrix_constant (void) const { return false; } |
2388 | 56 |
3933 | 57 virtual bool is_identifier (void) const { return false; } |
1739 | 58 |
3933 | 59 virtual bool is_index_expression (void) const { return false; } |
1739 | 60 |
3933 | 61 virtual bool is_assignment_expression (void) const { return false; } |
1739 | 62 |
3933 | 63 virtual bool is_prefix_expression (void) const { return false; } |
1739 | 64 |
7800
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7767
diff
changeset
|
65 virtual bool is_unary_expression (void) const { return false; } |
5861b95e9879
support for compound operators, implement trans_mul, mul_trans, herm_mul and mul_herm
Jaroslav Hajek <highegg@gmail.com>
parents:
7767
diff
changeset
|
66 |
4023 | 67 virtual bool is_binary_expression (void) const { return false; } |
68 | |
69 virtual bool is_boolean_expression (void) const { return false; } | |
70 | |
2980 | 71 virtual bool is_logically_true (const char *); |
1739 | 72 |
3933 | 73 virtual bool lvalue_ok (void) const { return false; } |
1739 | 74 |
3933 | 75 virtual bool rvalue_ok (void) const { return false; } |
2124 | 76 |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
7800
diff
changeset
|
77 virtual octave_value rvalue1 (int nargout = 1); |
1739 | 78 |
2980 | 79 virtual octave_value_list rvalue (int nargout); |
2879 | 80 |
2980 | 81 virtual octave_lvalue lvalue (void); |
2879 | 82 |
3933 | 83 int paren_count (void) const { return num_parens; } |
2124 | 84 |
3933 | 85 bool is_postfix_indexed (void) const { return postfix_indexed; } |
2124 | 86 |
3933 | 87 bool print_result (void) const { return print_flag; } |
1739 | 88 |
3933 | 89 virtual std::string oper (void) const { return "<unknown>"; } |
1739 | 90 |
3933 | 91 virtual std::string name (void) const { return "<unknown>"; } |
2124 | 92 |
3523 | 93 virtual std::string original_text (void) const; |
1739 | 94 |
2980 | 95 tree_expression *mark_in_parens (void) |
1739 | 96 { |
2980 | 97 num_parens++; |
98 return this; | |
1739 | 99 } |
100 | |
2980 | 101 tree_expression *mark_postfix_indexed (void) |
102 { | |
103 postfix_indexed = true; | |
104 return this; | |
105 } | |
2971 | 106 |
2980 | 107 tree_expression *set_print_flag (bool print) |
108 { | |
109 print_flag = print; | |
110 return this; | |
111 } | |
2971 | 112 |
8913
35cd375d4bb3
make tree::dup functions const
John W. Eaton <jwe@octave.org>
parents:
8658
diff
changeset
|
113 virtual void copy_base (const tree_expression& e) |
5861 | 114 { |
115 num_parens = e.num_parens; | |
116 postfix_indexed = e.postfix_indexed; | |
117 print_flag = e.print_flag; | |
118 } | |
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; | |
2988 | 136 |
137 private: | |
138 | |
139 // No copying! | |
140 | |
141 tree_expression (const tree_expression&); | |
142 | |
143 tree_expression& operator = (const tree_expression&); | |
2971 | 144 }; |
145 | |
1739 | 146 #endif |
147 | |
148 /* | |
149 ;;; Local Variables: *** | |
150 ;;; mode: C++ *** | |
151 ;;; End: *** | |
152 */ |