diff src/lex.l @ 8001:ff9e7873f8ea

improve handling of command-style names in matrix_or_assign_lhs context
author John W. Eaton <jwe@octave.org>
date Thu, 31 Jul 2008 13:11:14 -0400
parents cce16b4e0970
children 0ef13e15319b
line wrap: on
line diff
--- a/src/lex.l	Thu Jul 31 05:53:02 2008 -0400
+++ b/src/lex.l	Thu Jul 31 13:11:14 2008 -0400
@@ -39,6 +39,7 @@
 #include <cctype>
 #include <cstring>
 
+#include <set>
 #include <sstream>
 #include <string>
 #include <stack>
@@ -1203,10 +1204,12 @@
 static bool
 is_variable (const std::string& name)
 {
-  return symbol_table::is_variable (name);
+  return (symbol_table::is_variable (name)
+	  || (lexer_flags.pending_local_variables.find (name)
+	      != lexer_flags.pending_local_variables.end ()));
 }
 
-static void
+void
 force_local_variable (const std::string& name)
 {
   octave_value& val = symbol_table::varref (name);
@@ -2494,11 +2497,14 @@
       if (next_tok_is_eq
 	  || lexer_flags.looking_at_return_list
 	  || (lexer_flags.looking_at_parameter_list
-	      && ! lexer_flags.looking_at_initializer_expression)
-	  || lexer_flags.looking_at_matrix_or_assign_lhs)
+	      && ! lexer_flags.looking_at_initializer_expression))
 	{
 	  force_local_variable (tok);
 	}
+      else if (lexer_flags.looking_at_matrix_or_assign_lhs)
+	{
+	  lexer_flags.pending_local_variables.insert (tok);
+	}
       else if (! (next_tok_is_paren || lexer_flags.looking_at_object_index))
 	{
 	  BEGIN (COMMAND_START);
@@ -2589,6 +2595,9 @@
 
   // Quote marks strings intially.
   quote_is_transpose = false;
+
+  // Set of identifiers that might be local variable names is empty.
+  pending_local_variables.clear ();
 }
 
 bool