Mercurial > hg > octave-lyh
comparison libinterp/parse-tree/parse.h @ 16153:a57c2c8c8163
move some variables into the octave_parser class
* oct-parse.yy (fcn_comment_header): Delete unused variable.
* parse.h, oct-parse.yy (current_function_depth, function_scopes,
max_function_depth, parsing_subfunctions, endfunction_found,
current_class_name, autoloading, fcn_file_from_relative_lookup,
primary_fcn_ptr, primary_fcn_scope): Declare as member variables in
the octave_parser class. Change all uses. Don't unwind_protect.
(parse_fcn_file): New args, autoload and relative_lookup. Eliminate
optional arguments. Change all callers. Store autoload and
relative_lookup in curr_parser object.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Wed, 27 Feb 2013 21:43:34 -0500 |
parents | 49dfba4fd3c5 |
children | 0259254a3ccc 335041cc657a |
comparison
equal
deleted
inserted
replaced
16152:c48847a781d5 | 16153:a57c2c8c8163 |
---|---|
26 #include <cstdio> | 26 #include <cstdio> |
27 | 27 |
28 #include <string> | 28 #include <string> |
29 | 29 |
30 #include <stack> | 30 #include <stack> |
31 #include <vector> | |
32 #include <map> | |
31 | 33 |
32 #include "lex.h" | 34 #include "lex.h" |
35 #include "symtab.h" | |
33 #include "token.h" | 36 #include "token.h" |
34 | 37 |
35 class octave_comment_list; | 38 class octave_comment_list; |
36 class octave_function; | 39 class octave_function; |
37 class octave_user_function; | 40 class octave_user_function; |
77 extern bool reading_startup_message_printed; | 80 extern bool reading_startup_message_printed; |
78 | 81 |
79 // TRUE means input is coming from startup file. | 82 // TRUE means input is coming from startup file. |
80 extern bool input_from_startup_file; | 83 extern bool input_from_startup_file; |
81 | 84 |
82 // Name of the current class when we are parsing class methods or | |
83 // constructors. | |
84 extern std::string current_class_name; | |
85 | |
86 extern OCTINTERP_API std::string | 85 extern OCTINTERP_API std::string |
87 get_help_from_file (const std::string& nm, bool& symbol_found, | 86 get_help_from_file (const std::string& nm, bool& symbol_found, |
88 std::string& file); | 87 std::string& file); |
89 | 88 |
90 extern OCTINTERP_API std::string | 89 extern OCTINTERP_API std::string |
138 octave_parser | 137 octave_parser |
139 { | 138 { |
140 public: | 139 public: |
141 | 140 |
142 octave_parser (void) | 141 octave_parser (void) |
143 : end_of_input (false), curr_lexer (new lexical_feedback ()) | 142 : end_of_input (false), endfunction_found (false), |
143 autoloading (false), fcn_file_from_relative_lookup (false), | |
144 parsing_subfunctions (false), max_fcn_depth (0), | |
145 curr_fcn_depth (0), primary_fcn_scope (-1), | |
146 curr_class_name (), function_scopes (), primary_fcn_ptr (0), | |
147 curr_lexer (new lexical_feedback ()) | |
144 { | 148 { |
145 CURR_LEXER = curr_lexer; | 149 CURR_LEXER = curr_lexer; |
146 } | 150 } |
147 | 151 |
148 ~octave_parser (void) | 152 ~octave_parser (void) |
339 void bison_error (const char *s); | 343 void bison_error (const char *s); |
340 | 344 |
341 // TRUE means that we have encountered EOF on the input stream. | 345 // TRUE means that we have encountered EOF on the input stream. |
342 bool end_of_input; | 346 bool end_of_input; |
343 | 347 |
348 // Have we found an explicit end to a function? | |
349 bool endfunction_found; | |
350 | |
351 // TRUE means we are in the process of autoloading a function. | |
352 bool autoloading; | |
353 | |
354 // TRUE means the current function file was found in a relative path | |
355 // element. | |
356 bool fcn_file_from_relative_lookup; | |
357 | |
358 // FALSE if we are still at the primary function. Subfunctions can | |
359 // only be declared inside function files. | |
360 bool parsing_subfunctions; | |
361 | |
362 // Maximum function depth detected. Used to determine whether | |
363 // we have nested functions or just implicitly ended subfunctions. | |
364 int max_fcn_depth; | |
365 | |
366 // = 0 currently outside any function. | |
367 // = 1 inside the primary function or a subfunction. | |
368 // > 1 means we are looking at a function definition that seems to be | |
369 // inside a function. Note that the function still might not be a | |
370 // nested function. | |
371 int curr_fcn_depth; | |
372 | |
373 // Scope where we install all subfunctions and nested functions. Only | |
374 // used while reading function files. | |
375 symbol_table::scope_id primary_fcn_scope; | |
376 | |
377 // Name of the current class when we are parsing class methods or | |
378 // constructors. | |
379 std::string curr_class_name; | |
380 | |
381 // A stack holding the nested function scopes being parsed. | |
382 // We don't use std::stack, because we want the clear method. Also, we | |
383 // must access one from the top | |
384 std::vector<symbol_table::scope_id> function_scopes; | |
385 | |
386 // Pointer to the primary user function or user script function. | |
387 octave_function *primary_fcn_ptr; | |
388 | |
344 // State of the lexer. | 389 // State of the lexer. |
345 lexical_feedback *curr_lexer; | 390 lexical_feedback *curr_lexer; |
346 | 391 |
347 // For unwind protect. | 392 // For unwind protect. |
348 static void cleanup (octave_parser *parser) { delete parser; } | 393 static void cleanup (octave_parser *parser) { delete parser; } |