Mercurial > octave-libgccjit
annotate libinterp/parse-tree/parse.h @ 16133:249d62b3fac8
new class for parser state
* oct-parse.yy, parse.h (octave_parser): New class
(curr_parser): New global variable.
* oct-parse.yy (eval_string, parse_fcn_file): Save curr_parser on
unwind_protect stack. Create new curr_parser and arrange for it to be
cleaned up.
* toplev.cc (main_loop): Likewise.
* input.cc (get_debug_input): Likewise.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Tue, 26 Feb 2013 20:10:00 -0500 |
parents | 6884401b2fbb |
children | ec9c6222ef5a |
rev | line source |
---|---|
1 | 1 /* |
2 | |
14138
72c96de7a403
maint: update copyright notices for 2012
John W. Eaton <jwe@octave.org>
parents:
13970
diff
changeset
|
3 Copyright (C) 1993-2012 John W. Eaton |
1 | 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. | |
1 | 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/>. | |
1 | 20 |
21 */ | |
22 | |
383 | 23 #if !defined (octave_parse_h) |
24 #define octave_parse_h 1 | |
1 | 25 |
3021 | 26 #include <cstdio> |
27 | |
1755 | 28 #include <string> |
29 | |
4426 | 30 #include <stack> |
31 | |
4753 | 32 extern int octave_lex (void); |
1 | 33 |
34 class tree; | |
35 class tree_matrix; | |
36 class tree_identifier; | |
13970 | 37 class tree_statement_list; |
7102 | 38 class octave_function; |
3772 | 39 |
40 #include "oct-obj.h" | |
1 | 41 |
42 // Nonzero means print parser debugging info (-d). | |
4753 | 43 extern int octave_debug; |
1 | 44 |
338 | 45 // Buffer for help text snagged from function files. |
4426 | 46 extern std::stack<std::string> help_buf; |
1 | 47 |
3021 | 48 // TRUE means we are using readline. |
49 extern bool line_editing; | |
50 | |
51 // TRUE means we printed messages about reading startup files. | |
52 extern bool reading_startup_message_printed; | |
53 | |
54 // TRUE means input is coming from startup file. | |
55 extern bool input_from_startup_file; | |
56 | |
7336 | 57 // Name of the current class when we are parsing class methods or |
58 // constructors. | |
59 extern std::string current_class_name; | |
60 | |
6109 | 61 extern OCTINTERP_API std::string |
5484 | 62 get_help_from_file (const std::string& nm, bool& symbol_found, |
10313 | 63 std::string& file); |
5931 | 64 |
6109 | 65 extern OCTINTERP_API std::string |
5931 | 66 get_help_from_file (const std::string& nm, bool& symbol_found); |
5484 | 67 |
6109 | 68 extern OCTINTERP_API std::string lookup_autoload (const std::string& nm); |
3021 | 69 |
6109 | 70 extern OCTINTERP_API string_vector autoloaded_functions (void); |
5592 | 71 |
6109 | 72 extern OCTINTERP_API string_vector reverse_lookup_autoload (const std::string& nm); |
5592 | 73 |
7336 | 74 extern OCTINTERP_API octave_function * |
75 load_fcn_from_file (const std::string& file_name, | |
10313 | 76 const std::string& dir_name = std::string (), |
77 const std::string& dispatch_type = std::string (), | |
78 const std::string& fcn_name = std::string (), | |
79 bool autoload = false); | |
3021 | 80 |
6109 | 81 extern OCTINTERP_API void |
5975 | 82 source_file (const std::string& file_name, |
10313 | 83 const std::string& context = std::string (), |
84 bool verbose = false, bool require_file = true, | |
85 const std::string& warn_for = std::string ()); | |
4486 | 86 |
6109 | 87 extern OCTINTERP_API octave_value_list |
3772 | 88 feval (const std::string& name, |
89 const octave_value_list& args = octave_value_list (), | |
90 int nargout = 0); | |
3156 | 91 |
6109 | 92 extern OCTINTERP_API octave_value_list |
4342 | 93 feval (octave_function *fcn, |
94 const octave_value_list& args = octave_value_list (), | |
95 int nargout = 0); | |
96 | |
6109 | 97 extern OCTINTERP_API octave_value_list |
3772 | 98 feval (const octave_value_list& args, int nargout = 0); |
3021 | 99 |
6109 | 100 extern OCTINTERP_API octave_value_list |
3523 | 101 eval_string (const std::string&, bool silent, int& parse_status, int hargout); |
3099 | 102 |
6109 | 103 extern OCTINTERP_API octave_value |
3523 | 104 eval_string (const std::string&, bool silent, int& parse_status); |
3021 | 105 |
13970 | 106 extern OCTINTERP_API void cleanup_statement_list (tree_statement_list **lst); |
107 | |
16109
229eb14653fd
new entry point for parser
John W. Eaton <jwe@octave.org>
parents:
16103
diff
changeset
|
108 extern OCTINTERP_API int octave_parse_input (void); |
229eb14653fd
new entry point for parser
John W. Eaton <jwe@octave.org>
parents:
16103
diff
changeset
|
109 |
16133
249d62b3fac8
new class for parser state
John W. Eaton <jwe@octave.org>
parents:
16122
diff
changeset
|
110 class |
249d62b3fac8
new class for parser state
John W. Eaton <jwe@octave.org>
parents:
16122
diff
changeset
|
111 octave_parser |
249d62b3fac8
new class for parser state
John W. Eaton <jwe@octave.org>
parents:
16122
diff
changeset
|
112 { |
249d62b3fac8
new class for parser state
John W. Eaton <jwe@octave.org>
parents:
16122
diff
changeset
|
113 public: |
249d62b3fac8
new class for parser state
John W. Eaton <jwe@octave.org>
parents:
16122
diff
changeset
|
114 |
249d62b3fac8
new class for parser state
John W. Eaton <jwe@octave.org>
parents:
16122
diff
changeset
|
115 octave_parser (void) { } |
249d62b3fac8
new class for parser state
John W. Eaton <jwe@octave.org>
parents:
16122
diff
changeset
|
116 |
249d62b3fac8
new class for parser state
John W. Eaton <jwe@octave.org>
parents:
16122
diff
changeset
|
117 ~octave_parser (void) { } |
249d62b3fac8
new class for parser state
John W. Eaton <jwe@octave.org>
parents:
16122
diff
changeset
|
118 |
249d62b3fac8
new class for parser state
John W. Eaton <jwe@octave.org>
parents:
16122
diff
changeset
|
119 // For unwind protect. |
249d62b3fac8
new class for parser state
John W. Eaton <jwe@octave.org>
parents:
16122
diff
changeset
|
120 static void cleanup (octave_parser *parser) { delete parser; } |
249d62b3fac8
new class for parser state
John W. Eaton <jwe@octave.org>
parents:
16122
diff
changeset
|
121 |
249d62b3fac8
new class for parser state
John W. Eaton <jwe@octave.org>
parents:
16122
diff
changeset
|
122 private: |
249d62b3fac8
new class for parser state
John W. Eaton <jwe@octave.org>
parents:
16122
diff
changeset
|
123 |
249d62b3fac8
new class for parser state
John W. Eaton <jwe@octave.org>
parents:
16122
diff
changeset
|
124 // No copying! |
249d62b3fac8
new class for parser state
John W. Eaton <jwe@octave.org>
parents:
16122
diff
changeset
|
125 |
249d62b3fac8
new class for parser state
John W. Eaton <jwe@octave.org>
parents:
16122
diff
changeset
|
126 octave_parser (const octave_parser&); |
249d62b3fac8
new class for parser state
John W. Eaton <jwe@octave.org>
parents:
16122
diff
changeset
|
127 |
249d62b3fac8
new class for parser state
John W. Eaton <jwe@octave.org>
parents:
16122
diff
changeset
|
128 octave_parser& operator = (const octave_parser&); |
249d62b3fac8
new class for parser state
John W. Eaton <jwe@octave.org>
parents:
16122
diff
changeset
|
129 }; |
249d62b3fac8
new class for parser state
John W. Eaton <jwe@octave.org>
parents:
16122
diff
changeset
|
130 |
249d62b3fac8
new class for parser state
John W. Eaton <jwe@octave.org>
parents:
16122
diff
changeset
|
131 // The current state of the parser. |
249d62b3fac8
new class for parser state
John W. Eaton <jwe@octave.org>
parents:
16122
diff
changeset
|
132 extern octave_parser *curr_parser; |
249d62b3fac8
new class for parser state
John W. Eaton <jwe@octave.org>
parents:
16122
diff
changeset
|
133 |
1 | 134 #endif |