Mercurial > hg > octave-nkf
annotate libinterp/parse-tree/pt-exp.h @ 20717:0fdba3fdf40e stable
mkoctfile: Apply default C++ compiler flags when linking oct-file (bug #45280)
* mkoctfile.in.cc: Include the value of "ALL_CXXFLAGS" in the oct-file link
command line.
author | Mike Miller <mtmiller@octave.org> |
---|---|
date | Tue, 22 Sep 2015 23:12:22 +0200 |
parents | 4197fc428c7d |
children |
rev | line source |
---|---|
1739 | 1 /* |
2 | |
19898
4197fc428c7d
maint: Update copyright notices for 2015.
John W. Eaton <jwe@octave.org>
parents:
19589
diff
changeset
|
3 Copyright (C) 1996-2015 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 | |
17822
ebb3ef964372
maint: Use common #define syntax "octave_filename_h" in h_files.
Rik <rik@octave.org>
parents:
17787
diff
changeset
|
23 #if !defined (octave_pt_exp_h) |
ebb3ef964372
maint: Use common #define syntax "octave_filename_h" in h_files.
Rik <rik@octave.org>
parents:
17787
diff
changeset
|
24 #define octave_pt_exp_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) |
15954
46ca8488de92
Re-engineer tree_expression postfix handling to make it more flexible.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15606
diff
changeset
|
43 : tree (l, c), num_parens (0), postfix_index_type ('\0'), |
19589
b39cbe9f3bb0
allow ranges to be disabled
John W. Eaton <jwe@octave.org>
parents:
18131
diff
changeset
|
44 for_cmd_expr (false), 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 |
16273
c5e5f6ccac5d
9/10 commits reworking the lexer
John W. Eaton <jwe@octave.org>
parents:
15606
diff
changeset
|
55 virtual bool is_matrix (void) const { return false; } |
c5e5f6ccac5d
9/10 commits reworking the lexer
John W. Eaton <jwe@octave.org>
parents:
15606
diff
changeset
|
56 |
c5e5f6ccac5d
9/10 commits reworking the lexer
John W. Eaton <jwe@octave.org>
parents:
15606
diff
changeset
|
57 virtual bool is_cell (void) const { return false; } |
2388 | 58 |
3933 | 59 virtual bool is_identifier (void) const { return false; } |
1739 | 60 |
3933 | 61 virtual bool is_index_expression (void) const { return false; } |
1739 | 62 |
3933 | 63 virtual bool is_assignment_expression (void) const { return false; } |
1739 | 64 |
3933 | 65 virtual bool is_prefix_expression (void) const { return false; } |
1739 | 66 |
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
|
67 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
|
68 |
4023 | 69 virtual bool is_binary_expression (void) const { return false; } |
70 | |
71 virtual bool is_boolean_expression (void) const { return false; } | |
72 | |
2980 | 73 virtual bool is_logically_true (const char *); |
1739 | 74 |
3933 | 75 virtual bool lvalue_ok (void) const { return false; } |
1739 | 76 |
3933 | 77 virtual bool rvalue_ok (void) const { return false; } |
2124 | 78 |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
7800
diff
changeset
|
79 virtual octave_value rvalue1 (int nargout = 1); |
1739 | 80 |
2980 | 81 virtual octave_value_list rvalue (int nargout); |
2879 | 82 |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
83 virtual octave_value_list |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
84 rvalue (int nargout, const std::list<octave_lvalue> *lvalue_list); |
10832
1b2fcd122c6a
allow user detect ignored outputs in m-functions
Jaroslav Hajek <highegg@gmail.com>
parents:
10313
diff
changeset
|
85 |
2980 | 86 virtual octave_lvalue lvalue (void); |
2879 | 87 |
3933 | 88 int paren_count (void) const { return num_parens; } |
2124 | 89 |
15954
46ca8488de92
Re-engineer tree_expression postfix handling to make it more flexible.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15606
diff
changeset
|
90 bool is_postfix_indexed (void) const { return (postfix_index_type != '\0'); } |
46ca8488de92
Re-engineer tree_expression postfix handling to make it more flexible.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15606
diff
changeset
|
91 |
46ca8488de92
Re-engineer tree_expression postfix handling to make it more flexible.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15606
diff
changeset
|
92 char postfix_index (void) const { return postfix_index_type; } |
2124 | 93 |
15606
fb9dffe5fbfb
The silent_functions flag no longer modifies the parse tree
Max Brister <max@2bass.com>
parents:
15195
diff
changeset
|
94 // 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
|
95 // 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
|
96 // tree_evaluator::statement_printing_enabled. |
3933 | 97 bool print_result (void) const { return print_flag; } |
1739 | 98 |
3933 | 99 virtual std::string oper (void) const { return "<unknown>"; } |
1739 | 100 |
3933 | 101 virtual std::string name (void) const { return "<unknown>"; } |
2124 | 102 |
3523 | 103 virtual std::string original_text (void) const; |
1739 | 104 |
18126
d76f790b4eec
enable do_braindead_shortcircuit_evaluation by default and deprecate
John W. Eaton <jwe@octave.org>
parents:
17822
diff
changeset
|
105 virtual void mark_braindead_shortcircuit (void) { } |
11091
5677f3f7b5fa
Matlab compatible short-circuit behavior for & and | operators
John W. Eaton <jwe@octave.org>
parents:
10832
diff
changeset
|
106 |
19589
b39cbe9f3bb0
allow ranges to be disabled
John W. Eaton <jwe@octave.org>
parents:
18131
diff
changeset
|
107 void mark_as_for_cmd_expr (void) { for_cmd_expr = true; } |
b39cbe9f3bb0
allow ranges to be disabled
John W. Eaton <jwe@octave.org>
parents:
18131
diff
changeset
|
108 |
b39cbe9f3bb0
allow ranges to be disabled
John W. Eaton <jwe@octave.org>
parents:
18131
diff
changeset
|
109 bool is_for_cmd_expr (void) const { return for_cmd_expr; } |
b39cbe9f3bb0
allow ranges to be disabled
John W. Eaton <jwe@octave.org>
parents:
18131
diff
changeset
|
110 |
2980 | 111 tree_expression *mark_in_parens (void) |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
112 { |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
113 num_parens++; |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
114 return this; |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
115 } |
1739 | 116 |
15954
46ca8488de92
Re-engineer tree_expression postfix handling to make it more flexible.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15606
diff
changeset
|
117 tree_expression *set_postfix_index (char type) |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
118 { |
17856
97e49b588f5d
maint: periodic merge of default to classdef
John W. Eaton <jwe@octave.org>
diff
changeset
|
119 postfix_index_type = type; |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
120 return this; |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
121 } |
2971 | 122 |
2980 | 123 tree_expression *set_print_flag (bool print) |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
124 { |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
125 print_flag = print; |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
126 return this; |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
127 } |
2971 | 128 |
8913
35cd375d4bb3
make tree::dup functions const
John W. Eaton <jwe@octave.org>
parents:
8658
diff
changeset
|
129 virtual void copy_base (const tree_expression& e) |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
130 { |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
131 num_parens = e.num_parens; |
17856
97e49b588f5d
maint: periodic merge of default to classdef
John W. Eaton <jwe@octave.org>
diff
changeset
|
132 postfix_index_type = e.postfix_index_type; |
17787
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
133 print_flag = e.print_flag; |
175b392e91fe
Use GNU style coding conventions for code in libinterp/
Rik <rik@octave.org>
parents:
17744
diff
changeset
|
134 } |
5861 | 135 |
2980 | 136 protected: |
2971 | 137 |
2980 | 138 // A count of the number of times this expression appears directly |
139 // inside a set of parentheses. | |
140 // | |
141 // (((e1)) + e2) ==> 2 for expression e1 | |
142 // ==> 1 for expression ((e1)) + e2 | |
143 // ==> 0 for expression e2 | |
144 int num_parens; | |
2971 | 145 |
15954
46ca8488de92
Re-engineer tree_expression postfix handling to make it more flexible.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15606
diff
changeset
|
146 // The first index type associated with this expression. This field |
46ca8488de92
Re-engineer tree_expression postfix handling to make it more flexible.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15606
diff
changeset
|
147 // is 0 (character '\0') if the expression has no associated index. |
46ca8488de92
Re-engineer tree_expression postfix handling to make it more flexible.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15606
diff
changeset
|
148 // See the code in tree_identifier::rvalue for the rationale. |
46ca8488de92
Re-engineer tree_expression postfix handling to make it more flexible.
Michael Goffioul <michael.goffioul@gmail.com>
parents:
15606
diff
changeset
|
149 char postfix_index_type; |
2971 | 150 |
19589
b39cbe9f3bb0
allow ranges to be disabled
John W. Eaton <jwe@octave.org>
parents:
18131
diff
changeset
|
151 // TRUE if this expression is the EXPR in for loop: |
b39cbe9f3bb0
allow ranges to be disabled
John W. Eaton <jwe@octave.org>
parents:
18131
diff
changeset
|
152 // FOR i = EXPR ... END |
b39cbe9f3bb0
allow ranges to be disabled
John W. Eaton <jwe@octave.org>
parents:
18131
diff
changeset
|
153 bool for_cmd_expr; |
b39cbe9f3bb0
allow ranges to be disabled
John W. Eaton <jwe@octave.org>
parents:
18131
diff
changeset
|
154 |
2980 | 155 // Print result of rvalue for this expression? |
156 bool print_flag; | |
2988 | 157 |
158 private: | |
159 | |
160 // No copying! | |
161 | |
162 tree_expression (const tree_expression&); | |
163 | |
164 tree_expression& operator = (const tree_expression&); | |
2971 | 165 }; |
166 | |
1739 | 167 #endif |