changeset 17324:8e2906e2fb26

avoid reduce/reduce conflict in parser rules * oct-parse.in.yy (return_list): Don't accept multiple values outside of square brackets by using identifier instead of return_list1. * pt-misc.h (tree_argument_list::tree_argument_list): New constructor with tree_identifier* as argument. * test/nest/varg_nest2.m: Fix syntax of function declaration.
author John W. Eaton <jwe@octave.org>
date Thu, 22 Aug 2013 14:48:09 -0400
parents 3abed16370ad
children 56fe31b248de
files libinterp/parse-tree/oct-parse.in.yy libinterp/parse-tree/pt-misc.h test/nest/varg_nest2.m
diffstat 3 files changed, 19 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/libinterp/parse-tree/oct-parse.in.yy
+++ b/libinterp/parse-tree/oct-parse.in.yy
@@ -1086,19 +1086,31 @@
 return_list     : '[' ']'
                   {
                     lexer.looking_at_return_list = false;
+
                     $$ = new tree_parameter_list ();
                   }
-                | return_list1
+                | identifier
                   {
                     lexer.looking_at_return_list = false;
-                    if ($1->validate (tree_parameter_list::out))
-                      $$ = $1;
+
+                    tree_parameter_list *tmp = new tree_parameter_list ($1);
+
+                    // Even though this parameter list can contain only
+                    // a single identifier, we still need to validate it
+                    // to check for varargin or varargout.
+
+                    if (tmp->validate (tree_parameter_list::out))
+                      $$ = tmp;
                     else
                       ABORT_PARSE;
                   }
                 | '[' return_list1 ']'
                   {
                     lexer.looking_at_return_list = false;
+
+                    // Check for duplicate parameter names, varargin,
+                    // or varargout.
+
                     if ($2->validate (tree_parameter_list::out))
                       $$ = $2;
                     else
--- a/libinterp/parse-tree/pt-misc.h
+++ b/libinterp/parse-tree/pt-misc.h
@@ -59,6 +59,9 @@
   tree_parameter_list (tree_decl_elt *t)
     : marked_for_varargs (0) { append (t); }
 
+  tree_parameter_list (tree_identifier *id)
+    : marked_for_varargs (0) { append (new tree_decl_elt (id)); }
+
   ~tree_parameter_list (void);
 
   void mark_as_formal_parameters (void);
--- a/test/nest/varg_nest2.m
+++ b/test/nest/varg_nest2.m
@@ -6,7 +6,7 @@
     x = a;
   endif
 
-  function a, b = f
+  function [a, b] = f
     if nargout == 2
       a = b = 5;
     endif