Mercurial > hg > octave-lyh
annotate src/pt-cmd.h @ 8844:c84a5b6377c4
better handling of end of script/function no-op command
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Mon, 23 Feb 2009 12:55:32 -0500 |
parents | 73c4516fae10 |
children | 35cd375d4bb3 |
rev | line source |
---|---|
494 | 1 /* |
2 | |
7017 | 3 Copyright (C) 1994, 1995, 1996, 1997, 2000, 2001, 2002, 2004, 2005, |
4 2006, 2007 John W. Eaton | |
494 | 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. | |
494 | 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/>. | |
494 | 21 |
22 */ | |
23 | |
24 #if !defined (octave_tree_cmd_h) | |
25 #define octave_tree_cmd_h 1 | |
26 | |
2982 | 27 #include <string> |
494 | 28 |
2124 | 29 class tree_walker; |
30 | |
7715
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
31 #include "ov-fcn.h" |
2988 | 32 #include "pt.h" |
3770 | 33 #include "pt-bp.h" |
7336 | 34 #include "symtab.h" |
578 | 35 |
36 // A base class for commands. | |
37 | |
494 | 38 class |
39 tree_command : public tree | |
40 { | |
578 | 41 public: |
2124 | 42 |
2982 | 43 tree_command (int l = -1, int c = -1) |
44 : tree (l, c) { } | |
578 | 45 |
1270 | 46 virtual ~tree_command (void) { } |
47 | |
7767
71f068b22fcc
scope and context fixes for function handles
John W. Eaton <jwe@octave.org>
parents:
7715
diff
changeset
|
48 virtual tree_command *dup (symbol_table::scope_id, |
71f068b22fcc
scope and context fixes for function handles
John W. Eaton <jwe@octave.org>
parents:
7715
diff
changeset
|
49 symbol_table::context_id context) = 0; |
5861 | 50 |
2988 | 51 private: |
52 | |
53 // No copying! | |
54 | |
55 tree_command (const tree_command&); | |
56 | |
57 tree_command& operator = (const tree_command&); | |
494 | 58 }; |
59 | |
2620 | 60 // No-op. |
61 | |
62 class | |
63 tree_no_op_command : public tree_command | |
64 { | |
65 public: | |
66 | |
3523 | 67 tree_no_op_command (const std::string& cmd = "no_op", int l = -1, int c = -1) |
8844
c84a5b6377c4
better handling of end of script/function no-op command
John W. Eaton <jwe@octave.org>
parents:
8658
diff
changeset
|
68 : tree_command (l, c), eof (cmd == "endfunction" || cmd == "endscript"), |
c84a5b6377c4
better handling of end of script/function no-op command
John W. Eaton <jwe@octave.org>
parents:
8658
diff
changeset
|
69 orig_cmd (cmd) { } |
2620 | 70 |
71 ~tree_no_op_command (void) { } | |
72 | |
7767
71f068b22fcc
scope and context fixes for function handles
John W. Eaton <jwe@octave.org>
parents:
7715
diff
changeset
|
73 tree_command *dup (symbol_table::scope_id scope, |
71f068b22fcc
scope and context fixes for function handles
John W. Eaton <jwe@octave.org>
parents:
7715
diff
changeset
|
74 symbol_table::context_id context); |
5861 | 75 |
2620 | 76 void accept (tree_walker& tw); |
77 | |
8844
c84a5b6377c4
better handling of end of script/function no-op command
John W. Eaton <jwe@octave.org>
parents:
8658
diff
changeset
|
78 bool is_end_of_fcn_or_script (void) const { return eof; } |
c84a5b6377c4
better handling of end of script/function no-op command
John W. Eaton <jwe@octave.org>
parents:
8658
diff
changeset
|
79 |
3523 | 80 std::string original_command (void) { return orig_cmd; } |
2620 | 81 |
82 private: | |
83 | |
8844
c84a5b6377c4
better handling of end of script/function no-op command
John W. Eaton <jwe@octave.org>
parents:
8658
diff
changeset
|
84 bool eof; |
c84a5b6377c4
better handling of end of script/function no-op command
John W. Eaton <jwe@octave.org>
parents:
8658
diff
changeset
|
85 |
3523 | 86 std::string orig_cmd; |
2988 | 87 |
88 // No copying! | |
89 | |
90 tree_no_op_command (const tree_no_op_command&); | |
91 | |
92 tree_no_op_command& operator = (const tree_no_op_command&); | |
2620 | 93 }; |
94 | |
7715
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
95 // Function definition. |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
96 |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
97 class |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
98 tree_function_def : public tree_command |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
99 { |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
100 public: |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
101 |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
102 tree_function_def (octave_function *f, int l = -1, int c = -1) |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
103 : tree_command (l, c), fcn (f) { } |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
104 |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
105 ~tree_function_def (void) { } |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
106 |
7767
71f068b22fcc
scope and context fixes for function handles
John W. Eaton <jwe@octave.org>
parents:
7715
diff
changeset
|
107 tree_command *dup (symbol_table::scope_id scope, |
71f068b22fcc
scope and context fixes for function handles
John W. Eaton <jwe@octave.org>
parents:
7715
diff
changeset
|
108 symbol_table::context_id context); |
7715
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
109 |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
110 void accept (tree_walker& tw); |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
111 |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
7767
diff
changeset
|
112 octave_value function (void) { return fcn; } |
7715
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
113 |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
114 private: |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
115 |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
116 octave_value fcn; |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
117 |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
118 tree_function_def (const octave_value& v, int l = -1, int c = -1) |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
119 : tree_command (l, c), fcn (v) { } |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
120 |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
121 // No copying! |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
122 |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
123 tree_function_def (const tree_function_def&); |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
124 |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
125 tree_function_def& operator = (const tree_function_def&); |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
126 }; |
5b4d278ec828
parse scripts completely before executing
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
127 |
494 | 128 #endif |
129 | |
130 /* | |
131 ;;; Local Variables: *** | |
132 ;;; mode: C++ *** | |
133 ;;; End: *** | |
134 */ |