Mercurial > hg > octave-nkf
annotate libinterp/parse-tree/pt-fcn-handle.h @ 16113:7c5e5e97a3bc
move static lexer helper functions to lexical_feedback class
* lex.ll, lex.h oct-parse.yy (do_comma_insert_check, text_yyinput,
xunput, fixup_column_count, inside_any_object_index, is_keyword_token,
is_variable, grab_block_comment, grab_comment_block, process_comment,
next_token_is_sep_op, next_token_is_postfix_unary_op,
next_token_is_bin_op, scan_for_comments, eat_whitespace,
handle_number, have_continuation, have_ellipsis_continuation,
eat_continuation, handle_string, next_token_is_assign_op,
next_token_is_index_op, handle_close_bracket, maybe_unput_comma,
next_token_can_follow_bin_op, looks_like_command_arg,
handle_superclass_identifier, handle_meta_identifier,
handle_identifier, maybe_warn_separator_insert,
gripe_single_quote_string, gripe_matlab_incompatible,
maybe_gripe_matlab_incompatible_comment,
gripe_matlab_incompatible_continuation,
gripe_matlab_incompatible_operator): Declare as members of
lexical_feedback class. Change all callers.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Tue, 26 Feb 2013 02:40:32 -0500 |
parents | 2fc554ffbc28 |
children | d63878346099 |
rev | line source |
---|---|
4343 | 1 /* |
2 | |
14138
72c96de7a403
maint: update copyright notices for 2012
John W. Eaton <jwe@octave.org>
parents:
13125
diff
changeset
|
3 Copyright (C) 2003-2012 John W. Eaton |
4343 | 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. | |
4343 | 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/>. | |
4343 | 20 |
21 */ | |
22 | |
23 #if !defined (octave_tree_fcn_handle_h) | |
24 #define octave_fcn_handle_h 1 | |
25 | |
8950
d865363208d6
include <iosfwd> instead of <iostream> in header files
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
26 #include <iosfwd> |
4343 | 27 #include <string> |
28 | |
29 #include "pt-bp.h" | |
30 #include "pt-exp.h" | |
5861 | 31 #include "pt-misc.h" |
32 #include "pt-stmt.h" | |
7336 | 33 #include "symtab.h" |
4343 | 34 |
35 class octave_value_list; | |
36 | |
37 class tree_walker; | |
38 | |
39 #include "ov.h" | |
6505 | 40 #include "ov-usr-fcn.h" |
7336 | 41 #include "symtab.h" |
4343 | 42 |
43 class | |
44 tree_fcn_handle : public tree_expression | |
45 { | |
46 public: | |
47 | |
48 tree_fcn_handle (int l = -1, int c = -1) | |
49 : tree_expression (l, c), nm () { } | |
50 | |
51 tree_fcn_handle (const std::string& n, int l = -1, int c = -1) | |
52 : tree_expression (l, c), nm (n) { } | |
53 | |
54 ~tree_fcn_handle (void) { } | |
55 | |
56 bool has_magic_end (void) const { return false; } | |
57 | |
58 void print (std::ostream& os, bool pr_as_read_syntax = false, | |
10313 | 59 bool pr_orig_txt = true); |
4343 | 60 |
61 void print_raw (std::ostream& os, bool pr_as_read_syntax = false, | |
10313 | 62 bool pr_orig_txt = true); |
4343 | 63 |
5043 | 64 std::string name (void) const { return nm; } |
65 | |
4343 | 66 bool rvalue_ok (void) const { return true; } |
67 | |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
7767
diff
changeset
|
68 octave_value rvalue1 (int nargout = 1); |
4343 | 69 |
70 octave_value_list rvalue (int nargout); | |
71 | |
7767
71f068b22fcc
scope and context fixes for function handles
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
72 tree_expression *dup (symbol_table::scope_id scope, |
10313 | 73 symbol_table::context_id context) const; |
5861 | 74 |
4343 | 75 void accept (tree_walker& tw); |
76 | |
77 private: | |
78 | |
79 // The name of this function handle. | |
80 std::string nm; | |
81 | |
82 // No copying! | |
83 | |
84 tree_fcn_handle (const tree_fcn_handle&); | |
85 | |
86 tree_fcn_handle& operator = (const tree_fcn_handle&); | |
87 }; | |
88 | |
5861 | 89 class |
90 tree_anon_fcn_handle : public tree_expression | |
91 { | |
92 public: | |
93 | |
94 tree_anon_fcn_handle (int l = -1, int c = -1) | |
13125
34a49d076155
Show row/column for anonymous functions in the profiler
Daniel Kraft <d@domob.eu>
parents:
11523
diff
changeset
|
95 : tree_expression (l, c), fcn (0), file_name () { } |
5861 | 96 |
6505 | 97 tree_anon_fcn_handle (tree_parameter_list *pl, tree_parameter_list *rl, |
10313 | 98 tree_statement_list *cl, symbol_table::scope_id sid, |
99 int l = -1, int c = -1) | |
7336 | 100 : tree_expression (l, c), |
13125
34a49d076155
Show row/column for anonymous functions in the profiler
Daniel Kraft <d@domob.eu>
parents:
11523
diff
changeset
|
101 fcn (new octave_user_function (sid, pl, rl, cl)), |
34a49d076155
Show row/column for anonymous functions in the profiler
Daniel Kraft <d@domob.eu>
parents:
11523
diff
changeset
|
102 file_name () { } |
5861 | 103 |
7336 | 104 ~tree_anon_fcn_handle (void) { delete fcn; } |
5861 | 105 |
106 bool has_magic_end (void) const { return false; } | |
107 | |
108 bool rvalue_ok (void) const { return true; } | |
109 | |
8658
73c4516fae10
New evaluator and debugger derived from tree-walker class
John W. Eaton <jwe@octave.org>
parents:
7767
diff
changeset
|
110 octave_value rvalue1 (int nargout = 1); |
5861 | 111 |
112 octave_value_list rvalue (int nargout); | |
113 | |
8913
35cd375d4bb3
make tree::dup functions const
John W. Eaton <jwe@octave.org>
parents:
8658
diff
changeset
|
114 tree_parameter_list *parameter_list (void) const |
7336 | 115 { |
116 return fcn ? fcn->parameter_list () : 0; | |
117 } | |
5861 | 118 |
8913
35cd375d4bb3
make tree::dup functions const
John W. Eaton <jwe@octave.org>
parents:
8658
diff
changeset
|
119 tree_parameter_list *return_list (void) const |
7336 | 120 { |
121 return fcn ? fcn->return_list () : 0; | |
122 } | |
5861 | 123 |
8913
35cd375d4bb3
make tree::dup functions const
John W. Eaton <jwe@octave.org>
parents:
8658
diff
changeset
|
124 tree_statement_list *body (void) const |
35cd375d4bb3
make tree::dup functions const
John W. Eaton <jwe@octave.org>
parents:
8658
diff
changeset
|
125 { |
35cd375d4bb3
make tree::dup functions const
John W. Eaton <jwe@octave.org>
parents:
8658
diff
changeset
|
126 return fcn ? fcn->body () : 0; |
35cd375d4bb3
make tree::dup functions const
John W. Eaton <jwe@octave.org>
parents:
8658
diff
changeset
|
127 } |
7336 | 128 |
8913
35cd375d4bb3
make tree::dup functions const
John W. Eaton <jwe@octave.org>
parents:
8658
diff
changeset
|
129 symbol_table::scope_id scope (void) const |
35cd375d4bb3
make tree::dup functions const
John W. Eaton <jwe@octave.org>
parents:
8658
diff
changeset
|
130 { |
35cd375d4bb3
make tree::dup functions const
John W. Eaton <jwe@octave.org>
parents:
8658
diff
changeset
|
131 return fcn ? fcn->scope () : -1; |
35cd375d4bb3
make tree::dup functions const
John W. Eaton <jwe@octave.org>
parents:
8658
diff
changeset
|
132 } |
7336 | 133 |
7767
71f068b22fcc
scope and context fixes for function handles
John W. Eaton <jwe@octave.org>
parents:
7336
diff
changeset
|
134 tree_expression *dup (symbol_table::scope_id scope, |
10313 | 135 symbol_table::context_id context) const; |
5861 | 136 |
137 void accept (tree_walker& tw); | |
138 | |
13125
34a49d076155
Show row/column for anonymous functions in the profiler
Daniel Kraft <d@domob.eu>
parents:
11523
diff
changeset
|
139 void stash_file_name (const std::string& file) { file_name = file; } |
34a49d076155
Show row/column for anonymous functions in the profiler
Daniel Kraft <d@domob.eu>
parents:
11523
diff
changeset
|
140 |
5861 | 141 private: |
142 | |
6505 | 143 // The function. |
7336 | 144 octave_user_function *fcn; |
5861 | 145 |
13125
34a49d076155
Show row/column for anonymous functions in the profiler
Daniel Kraft <d@domob.eu>
parents:
11523
diff
changeset
|
146 // Filename where the handle was defined. |
34a49d076155
Show row/column for anonymous functions in the profiler
Daniel Kraft <d@domob.eu>
parents:
11523
diff
changeset
|
147 std::string file_name; |
34a49d076155
Show row/column for anonymous functions in the profiler
Daniel Kraft <d@domob.eu>
parents:
11523
diff
changeset
|
148 |
5861 | 149 // No copying! |
150 | |
151 tree_anon_fcn_handle (const tree_anon_fcn_handle&); | |
152 | |
153 tree_anon_fcn_handle& operator = (const tree_anon_fcn_handle&); | |
154 }; | |
155 | |
4343 | 156 #endif |