# HG changeset patch # User Max Brister # Date 1333594797 21600 # Node ID e6aa044253eb72dcb52b407f45ae63f5e547f7e9 # Parent 2946642797d6ed9f60d73937076d129d31ca2e34 Allow comma at the end of an assignment list (bug #35645) * src/oct-parse.yy (opt_comma): New rule. (assign_lhs): Optionally allow for trailing comma. diff -r 2946642797d6 -r e6aa044253eb src/oct-parse.yy --- a/src/oct-parse.yy Thu Apr 05 22:51:24 2012 -0700 +++ b/src/oct-parse.yy Wed Apr 04 20:59:57 2012 -0600 @@ -460,7 +460,7 @@ // Nonterminals we construct. %type stash_comment function_beg classdef_beg %type properties_beg methods_beg events_beg enum_beg -%type sep_no_nl opt_sep_no_nl sep opt_sep +%type sep_no_nl opt_sep_no_nl sep opt_sep opt_comma %type input %type string constant magic_colon %type anon_fcn_handle @@ -906,7 +906,7 @@ $$ = new tree_argument_list ($1); $$->mark_as_simple_assign_lhs (); } - | '[' arg_list CLOSE_BRACE + | '[' arg_list opt_comma CLOSE_BRACE { $$ = $2; lexer_flags.looking_at_matrix_or_assign_lhs = false; @@ -1672,6 +1672,12 @@ { $$ = $1; } ; +opt_comma : // empty + { $$ = 0; } + | ',' + { $$ = ','; } + ; + %% // Generic error messages. @@ -4553,6 +4559,11 @@ %!endfunction %!assert (__f(), 2) +% bug #35645 +%!test +%! [a,] = gcd (1,2); +%! [a,b,] = gcd (1, 2); + */ DEFUN (assignin, args, ,