diff libinterp/parse-tree/lex.ll @ 29723:6858992dfadf

enter symbols into current scope in parser instead of lexer * lex.h, lex.ll (base_lexer::is_variable): Eliminate unused SCOPE argument. Change all uses. * oct-parse.yy (identifer): Enter NAME in current scope here instead of in lexer. * token.h, token.cc (token::m_sr): Delete member variable and all uses. (token::symbol_name): Delete method. Use token::text where this method was used prevoiusly. (token::sym_rec, token::is_symbol): Delete methods and all uses. (token::sym_rec_token): Delete enum value and all uses. Use string_token instead. (token::isstring): New method. (token::tok_info): Delete overload for symbol_record objects.
author John W. Eaton <jwe@octave.org>
date Tue, 01 Jun 2021 16:57:40 -0400
parents ce4436d2b206
children c19f8cbe0fd5
line wrap: on
line diff
--- a/libinterp/parse-tree/lex.ll	Wed Jun 02 20:05:45 2021 +0200
+++ b/libinterp/parse-tree/lex.ll	Tue Jun 01 16:57:40 2021 -0400
@@ -2354,8 +2354,8 @@
   {
     token *tok = m_tokens.front ();
 
-    if (tok && tok->is_symbol ())
-      m_pending_local_variables.insert (tok->symbol_name ());
+    if (tok && tok->isstring ())
+      m_pending_local_variables.insert (tok->text ());
   }
 
   void
@@ -2654,8 +2654,7 @@
   }
 
   bool
-  base_lexer::is_variable (const std::string& name,
-                           const symbol_scope& /*scope*/)
+  base_lexer::is_variable (const std::string& name)
   {
     return ((m_interpreter.at_top_level ()
              && m_interpreter.is_variable (name))
@@ -3555,13 +3554,7 @@
         return count_token_internal (kw_token);
       }
 
-    // Find the token in the symbol table.
-
-    symbol_scope scope = m_symtab_context.curr_scope ();
-
-    symbol_record sr = (scope ? scope.insert (ident) : symbol_record (ident));
-
-    token *tok = new token (NAME, sr, m_tok_beg, m_tok_end);
+    token *tok = new token (NAME, ident, m_tok_beg, m_tok_end);
 
     // The following symbols are handled specially so that things like
     //
@@ -3572,7 +3565,7 @@
 
     if (m_at_beginning_of_statement
         && ! (m_parsing_anon_fcn_body
-              || is_variable (ident, scope)
+              || is_variable (ident)
               || ident == "e" || ident == "pi"
               || ident == "I" || ident == "i"
               || ident == "J" || ident == "j"
@@ -3748,8 +3741,7 @@
       case NAME:
         {
           token *tok_val = current_token ();
-          symbol_record sr = tok_val->sym_rec ();
-          std::cerr << "NAME [" << sr.name () << "]\n";
+          std::cerr << "NAME [" << tok_val->text () << "]\n";
         }
         break;