Mercurial > octave
annotate src/pt-exp.h @ 10832:1b2fcd122c6a
allow user detect ignored outputs in m-functions
author | Jaroslav Hajek <highegg@gmail.com> |
---|---|
date | Thu, 29 Jul 2010 12:45:23 +0200 |
parents | f3b65e1ae355 |
children | 5677f3f7b5fa |
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> |
10832
1b2fcd122c6a
allow user detect ignored outputs in m-functions
Jaroslav Hajek <highegg@gmail.com>
parents:
10313
diff
changeset
|
28 #include <list> |
2124 | 29 |
2879 | 30 class octave_value; |
2979 | 31 class octave_lvalue; |
2879 | 32 |
2988 | 33 #include "pt.h" |
7336 | 34 #include "symtab.h" |
2124 | 35 |
2980 | 36 // A base class for expressions. |
1739 | 37 |
38 class | |
2980 | 39 tree_expression : public tree |
2388 | 40 { |
41 public: | |
42 | |
2980 | 43 tree_expression (int l = -1, int c = -1) |
44 : tree (l, c), num_parens (0), postfix_indexed (false), | |
45 print_flag (false) { } | |
2388 | 46 |
2980 | 47 virtual ~tree_expression (void) { } |
2388 | 48 |
4267 | 49 virtual bool has_magic_end (void) const = 0; |
50 | |
7767
71f068b22fcc
scope and context fixes for function handles
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
51 virtual tree_expression *dup (symbol_table::scope_id, |
10313 | 52 symbol_table::context_id context) const = 0; |
5861 | 53 |
3933 | 54 virtual bool is_constant (void) const { return false; } |
2388 | 55 |
3933 | 56 virtual bool is_matrix_constant (void) const { return false; } |
2388 | 57 |
3933 | 58 virtual bool is_identifier (void) const { return false; } |
1739 | 59 |
3933 | 60 virtual bool is_index_expression (void) const { return false; } |
1739 | 61 |
3933 | 62 virtual bool is_assignment_expression (void) const { return false; } |
1739 | 63 |
3933 | 64 virtual bool is_prefix_expression (void) const { return false; } |
1739 | 65 |
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
|
66 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
|
67 |
4023 | 68 virtual bool is_binary_expression (void) const { return false; } |
69 | |
70 virtual bool is_boolean_expression (void) const { return false; } | |
71 | |
2980 | 72 virtual bool is_logically_true (const char *); |
1739 | 73 |
3933 | 74 virtual bool lvalue_ok (void) const { return false; } |
1739 | 75 |
3933 | 76 virtual bool rvalue_ok (void) const { return false; } |
2124 | 77 |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
7800
diff
changeset
|
78 virtual octave_value rvalue1 (int nargout = 1); |
1739 | 79 |
2980 | 80 virtual octave_value_list rvalue (int nargout); |
2879 | 81 |
10832
1b2fcd122c6a
allow user detect ignored outputs in m-functions
Jaroslav Hajek <highegg@gmail.com>
parents:
10313
diff
changeset
|
82 virtual octave_value_list rvalue (int nargout, |
1b2fcd122c6a
allow user detect ignored outputs in m-functions
Jaroslav Hajek <highegg@gmail.com>
parents:
10313
diff
changeset
|
83 const std::list<octave_lvalue> *lvalue_list); |
1b2fcd122c6a
allow user detect ignored outputs in m-functions
Jaroslav Hajek <highegg@gmail.com>
parents:
10313
diff
changeset
|
84 |
2980 | 85 virtual octave_lvalue lvalue (void); |
2879 | 86 |
3933 | 87 int paren_count (void) const { return num_parens; } |
2124 | 88 |
3933 | 89 bool is_postfix_indexed (void) const { return postfix_indexed; } |
2124 | 90 |
3933 | 91 bool print_result (void) const { return print_flag; } |
1739 | 92 |
3933 | 93 virtual std::string oper (void) const { return "<unknown>"; } |
1739 | 94 |
3933 | 95 virtual std::string name (void) const { return "<unknown>"; } |
2124 | 96 |
3523 | 97 virtual std::string original_text (void) const; |
1739 | 98 |
2980 | 99 tree_expression *mark_in_parens (void) |
1739 | 100 { |
2980 | 101 num_parens++; |
102 return this; | |
1739 | 103 } |
104 | |
2980 | 105 tree_expression *mark_postfix_indexed (void) |
106 { | |
107 postfix_indexed = true; | |
108 return this; | |
109 } | |
2971 | 110 |
2980 | 111 tree_expression *set_print_flag (bool print) |
112 { | |
113 print_flag = print; | |
114 return this; | |
115 } | |
2971 | 116 |
8913
35cd375d4bb3
make tree::dup functions const
John W. Eaton <jwe@octave.org>
parents:
8658
diff
changeset
|
117 virtual void copy_base (const tree_expression& e) |
5861 | 118 { |
119 num_parens = e.num_parens; | |
120 postfix_indexed = e.postfix_indexed; | |
121 print_flag = e.print_flag; | |
122 } | |
123 | |
2980 | 124 protected: |
2971 | 125 |
2980 | 126 // A count of the number of times this expression appears directly |
127 // inside a set of parentheses. | |
128 // | |
129 // (((e1)) + e2) ==> 2 for expression e1 | |
130 // ==> 1 for expression ((e1)) + e2 | |
131 // ==> 0 for expression e2 | |
132 int num_parens; | |
2971 | 133 |
2980 | 134 // A flag that says whether this expression has an index associated |
135 // with it. See the code in tree_identifier::rvalue for the rationale. | |
136 bool postfix_indexed; | |
2971 | 137 |
2980 | 138 // Print result of rvalue for this expression? |
139 bool print_flag; | |
2988 | 140 |
141 private: | |
142 | |
143 // No copying! | |
144 | |
145 tree_expression (const tree_expression&); | |
146 | |
147 tree_expression& operator = (const tree_expression&); | |
2971 | 148 }; |
149 | |
1739 | 150 #endif |