Mercurial > octave-dspies
diff src/oct-parse.yy @ 14329:8d1ae996c122
also save and restore symbol table context in parser (bug #35448)
* parse-private.h: New file to define new symtab_context class.
* Makefile.am (octinclude_HEADERS): Include it in the list.
* lex.ll, oct-parse.yy: Include parse-private.h.
* lex.ll (reset_parser): Clear parser_symtab_context.
* parse.h (symtab_context): Delete variable declaration.
* oct-parse.yy (symtab_context): Delete variable definition.
(parser_symtab_context): New variable.
(ABORT_PARSE, make_anon_fcn_handle, recover_from_parsing_function):
Pop parser_symtab_context.
(push_fcn_symtab, param_list_beg): Push parser_symtab_context.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Sun, 05 Feb 2012 13:53:55 -0500 |
parents | 9e3983c8963c |
children | 97883071e8e4 |
line wrap: on
line diff
--- a/src/oct-parse.yy Sun Feb 05 13:16:07 2012 -0500 +++ b/src/oct-parse.yy Sun Feb 05 13:53:55 2012 -0500 @@ -68,6 +68,7 @@ #include "toplev.h" #include "pager.h" #include "parse.h" +#include "parse-private.h" #include "pt-all.h" #include "pt-eval.h" #include "symtab.h" @@ -126,7 +127,7 @@ static bool endfunction_found = false; // Keep track of symbol table information when parsing functions. -std::stack<symbol_table::scope_id> symtab_context; +symtab_context parser_symtab_context; // Name of the current class when we are parsing class methods or // constructors. @@ -365,11 +366,8 @@ { \ global_command = 0; \ yyerrok; \ - if (! symtab_context.empty ()) \ - { \ - symbol_table::set_scope (symtab_context.top ()); \ - symtab_context.pop (); \ - } \ + if (! parser_symtab_context.empty ()) \ + parser_symtab_context.pop (); \ if (interactive || forced_interactive) \ YYACCEPT; \ else \ @@ -1224,7 +1222,8 @@ if (max_function_depth < current_function_depth) max_function_depth = current_function_depth; - symtab_context.push (symbol_table::current_scope ()); + parser_symtab_context.push (); + symbol_table::set_scope (symbol_table::alloc_scope ()); if (! reading_script_file && current_function_depth == 1 @@ -1246,7 +1245,7 @@ if (lexer_flags.looking_at_function_handle) { - symtab_context.push (symbol_table::current_scope ()); + parser_symtab_context.push (); symbol_table::set_scope (symbol_table::alloc_scope ()); lexer_flags.looking_at_function_handle--; lexer_flags.looking_at_anon_fcn_args = true; @@ -2124,12 +2123,10 @@ symbol_table::scope_id fcn_scope = symbol_table::current_scope (); - if (symtab_context.empty ()) + if (parser_symtab_context.empty ()) panic_impossible (); - symbol_table::set_scope (symtab_context.top ()); - - symtab_context.pop (); + parser_symtab_context.pop (); stmt->set_print_flag (false); @@ -2972,11 +2969,10 @@ static void recover_from_parsing_function (void) { - if (symtab_context.empty ()) + if (parser_symtab_context.empty ()) panic_impossible (); - symbol_table::set_scope (symtab_context.top ()); - symtab_context.pop (); + parser_symtab_context.pop (); if (reading_fcn_file && current_function_depth == 1 && ! parsing_subfunctions)