changeset 18492:e4c319ed2414 stable

Fix regression, allow space-separated cell array of function handles (bug #41569) * lex.ll ("@"): Unput comma before function handle when after whitespace in an array context. * parser.tst: New test case.
author Mike Miller <mtmiller@ieee.org>
date Thu, 20 Feb 2014 09:24:59 -0500
parents 477b5916cafe
children 3cac3d7f003f 35100920494f
files libinterp/parse-tree/lex.ll test/parser.tst
diffstat 2 files changed, 29 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/libinterp/parse-tree/lex.ll	Thu Feb 20 00:44:14 2014 -0500
+++ b/libinterp/parse-tree/lex.ll	Thu Feb 20 09:24:59 2014 -0500
@@ -1099,6 +1099,8 @@
   }
 
 "@" {
+    curr_lexer->lexer_debug ("@");
+
     if (curr_lexer->previous_token_may_be_command ()
         &&  curr_lexer->space_follows_previous_token ())
       {
@@ -1107,15 +1109,26 @@
       }
     else
       {
-        curr_lexer->lexer_debug ("@");
-
-        curr_lexer->current_input_column++;
-
-        curr_lexer->looking_at_function_handle++;
-        curr_lexer->looking_for_object_index = false;
-        curr_lexer->at_beginning_of_statement = false;
-
-        return curr_lexer->count_token ('@');
+        int tok = curr_lexer->previous_token_value ();
+
+        if (curr_lexer->whitespace_is_significant ()
+            && curr_lexer->space_follows_previous_token ()
+            && ! (tok == '[' || tok == '{'
+                  || curr_lexer->previous_token_is_binop ()))
+          {
+            yyless (0);
+            unput (',');
+          }
+        else
+          {
+            curr_lexer->current_input_column++;
+
+            curr_lexer->looking_at_function_handle++;
+            curr_lexer->looking_for_object_index = false;
+            curr_lexer->at_beginning_of_statement = false;
+
+            return curr_lexer->count_token ('@');
+          }
       }
   }
 
--- a/test/parser.tst	Thu Feb 20 00:44:14 2014 -0500
+++ b/test/parser.tst	Thu Feb 20 09:24:59 2014 -0500
@@ -287,3 +287,10 @@
 %! a = [97 ... % comment
 %!      'b'];
 %! assert (a, 'ab');
+
+## Check that a cell array containing function handles is parsed
+## correctly with or without commas.
+%!test
+%! a = {1, @sin, 2, @cos};
+%! b = {1 @sin 2 @cos};
+%! assert (a, b)