Mercurial > hg > octave-lyh
annotate src/pt-stmt.h @ 8283:54c25dc5b17d
parse.y: fix comment
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Tue, 28 Oct 2008 13:04:32 -0400 |
parents | 71f068b22fcc |
children | 02de6775f1fe |
rev | line source |
---|---|
2982 | 1 /* |
2 | |
7017 | 3 Copyright (C) 1996, 1997, 2000, 2001, 2002, 2004, 2005, 2006, 2007 |
4 John W. Eaton | |
2982 | 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. | |
2982 | 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/>. | |
2982 | 21 |
22 */ | |
23 | |
24 #if !defined (octave_tree_stmt_h) | |
25 #define octave_tree_stmt_h 1 | |
26 | |
27 class octave_value_list; | |
28 | |
29 class tree_command; | |
30 class tree_expression; | |
31 | |
32 class tree_walker; | |
33 | |
7552
6070c3bd69c4
Arbitrary call stack access for external debuggers changeset
ryanru@PrinceHumperdinck
parents:
7336
diff
changeset
|
34 #include <deque> |
6070c3bd69c4
Arbitrary call stack access for external debuggers changeset
ryanru@PrinceHumperdinck
parents:
7336
diff
changeset
|
35 |
4219 | 36 #include "base-list.h" |
3665 | 37 #include "comment-list.h" |
7336 | 38 #include "symtab.h" |
3665 | 39 |
2982 | 40 // A statement is either a command to execute or an expression to |
41 // evaluate. | |
42 | |
43 class | |
44 tree_statement | |
45 { | |
46 public: | |
47 | |
48 tree_statement (void) | |
3665 | 49 : cmd (0), expr (0), comm (0), print_flag (true) { } |
2982 | 50 |
3665 | 51 tree_statement (tree_command *c, octave_comment_list *cl) |
52 : cmd (c), expr (0), comm (cl), print_flag (true) { } | |
2982 | 53 |
3665 | 54 tree_statement (tree_expression *e, octave_comment_list *cl) |
55 : cmd (0), expr (e), comm (cl), print_flag (true) { } | |
2982 | 56 |
57 ~tree_statement (void); | |
58 | |
3933 | 59 void set_print_flag (bool print) { print_flag = print; } |
2982 | 60 |
3933 | 61 bool is_command (void) { return cmd != 0; } |
2982 | 62 |
3933 | 63 bool is_expression (void) { return expr != 0; } |
2982 | 64 |
65 int line (void); | |
66 int column (void); | |
67 | |
68 void maybe_echo_code (bool in_function_body); | |
69 | |
70 bool print_result (void) { return print_flag; } | |
71 | |
72 tree_command *command (void) { return cmd; } | |
73 | |
7736 | 74 octave_value_list eval (bool silent, int nargout, |
75 bool in_function_or_script_body); | |
2982 | 76 |
77 tree_expression *expression (void) { return expr; } | |
78 | |
3665 | 79 octave_comment_list *comment_text (void) { return comm; } |
80 | |
4935 | 81 // Allow modification of this statement. Note that there is no |
82 // checking. If you use these, are you sure you knwo what you are | |
83 // doing? | |
84 | |
85 void set_command (tree_command *c) { cmd = c; } | |
86 | |
87 void set_expression (tree_expression *e) { expr = e; } | |
88 | |
7767
71f068b22fcc
scope and context fixes for function handles
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
89 tree_statement *dup (symbol_table::scope_id scope, |
71f068b22fcc
scope and context fixes for function handles
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
90 symbol_table::context_id context); |
5861 | 91 |
2982 | 92 void accept (tree_walker& tw); |
93 | |
94 private: | |
95 | |
96 // Only one of cmd or expr can be valid at once. | |
97 | |
98 // Command to execute. | |
99 tree_command *cmd; | |
100 | |
101 // Expression to evaluate. | |
102 tree_expression *expr; | |
103 | |
3665 | 104 // Comment associated with this statement. |
105 octave_comment_list *comm; | |
106 | |
2982 | 107 // Print result of eval for this command? |
108 bool print_flag; | |
2988 | 109 |
110 // No copying! | |
111 tree_statement (const tree_statement&); | |
112 | |
113 tree_statement& operator = (const tree_statement&); | |
2982 | 114 }; |
115 | |
116 // A list of statements to evaluate. | |
117 | |
118 class | |
4219 | 119 tree_statement_list : public octave_base_list<tree_statement *> |
2982 | 120 { |
121 public: | |
122 | |
123 tree_statement_list (void) | |
7736 | 124 : function_body (false), script_body (false) { } |
2982 | 125 |
126 tree_statement_list (tree_statement *s) | |
7736 | 127 : function_body (false), script_body (false) { append (s); } |
2982 | 128 |
129 ~tree_statement_list (void) | |
130 { | |
4219 | 131 while (! empty ()) |
2982 | 132 { |
4219 | 133 iterator p = begin (); |
134 delete *p; | |
135 erase (p); | |
2982 | 136 } |
137 } | |
138 | |
139 void mark_as_function_body (void) { function_body = true; } | |
140 | |
7736 | 141 void mark_as_script_body (void) { script_body = true; } |
142 | |
2982 | 143 octave_value_list eval (bool silent = false, int nargout = 0); |
144 | |
3770 | 145 int set_breakpoint (int line); |
146 | |
147 void delete_breakpoint (int line); | |
148 | |
149 octave_value_list list_breakpoints (void); | |
150 | |
7767
71f068b22fcc
scope and context fixes for function handles
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
151 tree_statement_list *dup (symbol_table::scope_id scope, |
71f068b22fcc
scope and context fixes for function handles
John W. Eaton <jwe@octave.org>
parents:
7736
diff
changeset
|
152 symbol_table::context_id context); |
5861 | 153 |
2982 | 154 void accept (tree_walker& tw); |
155 | |
156 private: | |
157 | |
158 // Does this list of statements make up the body of a function? | |
159 bool function_body; | |
2988 | 160 |
7736 | 161 // Does this list of statements make up the body of a script? |
162 bool script_body; | |
163 | |
2988 | 164 // No copying! |
165 | |
166 tree_statement_list (const tree_statement_list&); | |
167 | |
168 tree_statement_list& operator = (const tree_statement_list&); | |
2982 | 169 }; |
170 | |
171 #endif | |
172 | |
173 /* | |
174 ;;; Local Variables: *** | |
175 ;;; mode: C++ *** | |
176 ;;; End: *** | |
177 */ |