Mercurial > hg > octave-lyh
annotate libinterp/parse-tree/pt-exp.h @ 16104:c8974e28da59
move nesting_level to lexical_feedback class
* lex.h, lex.ll (brace_bracket_paren_nesting_level): Rename to
bbp_nesting_level and nest class definition inside lexical_feedback
class.
(nesting_level): Move global variable to lexical_feedback_class.
Change all uses.
(reset_parser): Don't clear nesting_level.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Mon, 25 Feb 2013 21:54:15 -0500 |
parents | fb9dffe5fbfb |
children | 46ca8488de92 c5e5f6ccac5d |
rev | line source |
---|---|
1739 | 1 /* |
2 | |
14138
72c96de7a403
maint: update copyright notices for 2012
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
3 Copyright (C) 1996-2012 John W. Eaton |
1739 | 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 | |
7016 | 9 Free Software Foundation; either version 3 of the License, or (at your |
10 option) any later version. | |
1739 | 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 | |
7016 | 18 along with Octave; see the file COPYING. If not, see |
19 <http://www.gnu.org/licenses/>. | |
1739 | 20 |
21 */ | |
22 | |
2980 | 23 #if !defined (octave_tree_expr_h) |
24 #define octave_tree_expr_h 1 | |
1739 | 25 |
2980 | 26 #include <string> |
10832
1b2fcd122c6a
allow user detect ignored outputs in m-functions
Jaroslav Hajek <highegg@gmail.com>
parents:
10313
diff
changeset
|
27 #include <list> |
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, |
10313 | 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 |
10832
1b2fcd122c6a
allow user detect ignored outputs in m-functions
Jaroslav Hajek <highegg@gmail.com>
parents:
10313
diff
changeset
|
81 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
|
82 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
|
83 |
2980 | 84 virtual octave_lvalue lvalue (void); |
2879 | 85 |
3933 | 86 int paren_count (void) const { return num_parens; } |
2124 | 87 |
3933 | 88 bool is_postfix_indexed (void) const { return postfix_indexed; } |
2124 | 89 |
15606
fb9dffe5fbfb
The silent_functions flag no longer modifies the parse tree
Max Brister <max@2bass.com>
parents:
15195
diff
changeset
|
90 // Check if the result of the expression should be printed. |
fb9dffe5fbfb
The silent_functions flag no longer modifies the parse tree
Max Brister <max@2bass.com>
parents:
15195
diff
changeset
|
91 // Should normally be used in conjunction with |
fb9dffe5fbfb
The silent_functions flag no longer modifies the parse tree
Max Brister <max@2bass.com>
parents:
15195
diff
changeset
|
92 // tree_evaluator::statement_printing_enabled. |
3933 | 93 bool print_result (void) const { return print_flag; } |
1739 | 94 |
3933 | 95 virtual std::string oper (void) const { return "<unknown>"; } |
1739 | 96 |
3933 | 97 virtual std::string name (void) const { return "<unknown>"; } |
2124 | 98 |
3523 | 99 virtual std::string original_text (void) const; |
1739 | 100 |
11091
5677f3f7b5fa
Matlab compatible short-circuit behavior for & and | operators
John W. Eaton <jwe@octave.org>
parents:
10832
diff
changeset
|
101 virtual void mark_braindead_shortcircuit (const std::string&) { } |
5677f3f7b5fa
Matlab compatible short-circuit behavior for & and | operators
John W. Eaton <jwe@octave.org>
parents:
10832
diff
changeset
|
102 |
2980 | 103 tree_expression *mark_in_parens (void) |
1739 | 104 { |
2980 | 105 num_parens++; |
106 return this; | |
1739 | 107 } |
108 | |
2980 | 109 tree_expression *mark_postfix_indexed (void) |
110 { | |
111 postfix_indexed = true; | |
112 return this; | |
113 } | |
2971 | 114 |
2980 | 115 tree_expression *set_print_flag (bool print) |
116 { | |
117 print_flag = print; | |
118 return this; | |
119 } | |
2971 | 120 |
8913
35cd375d4bb3
make tree::dup functions const
John W. Eaton <jwe@octave.org>
parents:
8658
diff
changeset
|
121 virtual void copy_base (const tree_expression& e) |
5861 | 122 { |
123 num_parens = e.num_parens; | |
124 postfix_indexed = e.postfix_indexed; | |
125 print_flag = e.print_flag; | |
126 } | |
127 | |
2980 | 128 protected: |
2971 | 129 |
2980 | 130 // A count of the number of times this expression appears directly |
131 // inside a set of parentheses. | |
132 // | |
133 // (((e1)) + e2) ==> 2 for expression e1 | |
134 // ==> 1 for expression ((e1)) + e2 | |
135 // ==> 0 for expression e2 | |
136 int num_parens; | |
2971 | 137 |
2980 | 138 // A flag that says whether this expression has an index associated |
139 // with it. See the code in tree_identifier::rvalue for the rationale. | |
140 bool postfix_indexed; | |
2971 | 141 |
2980 | 142 // Print result of rvalue for this expression? |
143 bool print_flag; | |
2988 | 144 |
145 private: | |
146 | |
147 // No copying! | |
148 | |
149 tree_expression (const tree_expression&); | |
150 | |
151 tree_expression& operator = (const tree_expression&); | |
2971 | 152 }; |
153 | |
1739 | 154 #endif |