Mercurial > hg > octave-lyh
diff libinterp/parse-tree/lex.ll @ 16320:09f0cb9cac7d
don't modify symbol table scope in the parser
* symtab.h (symbol_table::insert): Accept scope as argument.
* lex.h (symbol_table_context): New class.
(octave_lexer::symtab_context: New data member.
* parse-private.h: Delete.
* parse.h, oct-parse.in.yy (parser_symtab_context): Delete global
variable and all uses.
* lex.ll (octave_lexer::reset): Clear symtab_context.
(octave_base_lexer::handle_superclass_identifier,
octave_base_lexer::handle_meta_identifier,
octave_base_lexer::handle_identifier): Get current symbol table scope
for parsing from symtab_context. Use it to insert new variables in
the symbol table.
* oct-parse.in.yy (ABORT_PARSE): Don't pop symtab_context.
(push_fcn_symtab, param_list_beg): Push newly allocated scope on the
symtab_context stack. Don't modify symbol table scope.
(make_anon_fcn_handle): Get function scope from symtab_context instead
of the symbol table. Pop symtab_context.
(start_function): Get function scope from symtab_context instead
of the symbol table.
(octave_base_parser::recover_from_parsing_function):
Pop symtab_context.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Sat, 16 Mar 2013 02:02:43 -0400 |
parents | e608de76742c |
children | fc565603ccbb |
line wrap: on
line diff
--- a/libinterp/parse-tree/lex.ll +++ b/libinterp/parse-tree/lex.ll @@ -84,7 +84,6 @@ #include "lex.h" #include "ov.h" #include "parse.h" -#include "parse-private.h" #include "pt-all.h" #include "symtab.h" #include "token.h" @@ -1622,7 +1621,7 @@ // Start off on the right foot. clear_start_state (); - parser_symtab_context.clear (); + symtab_context.clear (); // We do want a prompt by default. promptflag (1); @@ -2403,11 +2402,14 @@ return LEXICAL_ERROR; } - push_token (new token (SUPERCLASSREF, - meth.empty () ? 0 : &(symbol_table::insert (meth)), - cls.empty () ? 0 : &(symbol_table::insert (cls)), - pkg.empty () ? 0 : &(symbol_table::insert (pkg)), - input_line_number, current_input_column)); + symbol_table::scope_id sid = symtab_context.curr_scope (); + + push_token (new token + (SUPERCLASSREF, + meth.empty () ? 0 : &(symbol_table::insert (meth, sid)), + cls.empty () ? 0 : &(symbol_table::insert (cls, sid)), + pkg.empty () ? 0 : &(symbol_table::insert (pkg, sid)), + input_line_number, current_input_column)); current_input_column += flex_yyleng (); @@ -2435,10 +2437,13 @@ return LEXICAL_ERROR; } - push_token (new token (METAQUERY, - cls.empty () ? 0 : &(symbol_table::insert (cls)), - pkg.empty () ? 0 : &(symbol_table::insert (pkg)), - input_line_number, current_input_column)); + symbol_table::scope_id sid = symtab_context.curr_scope (); + + push_token (new token + (METAQUERY, + cls.empty () ? 0 : &(symbol_table::insert (cls, sid)), + pkg.empty () ? 0 : &(symbol_table::insert (pkg, sid)), + input_line_number, current_input_column)); current_input_column += flex_yyleng (); @@ -2527,7 +2532,9 @@ if (tok == "end") tok = "__end__"; - token *tok_val = new token (NAME, &(symbol_table::insert (tok)), + symbol_table::scope_id sid = symtab_context.curr_scope (); + + token *tok_val = new token (NAME, &(symbol_table::insert (tok, sid)), input_line_number, current_input_column); if (at_beginning_of_statement