Mercurial > hg > octave-lyh
changeset 14533:e6aa044253eb
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.
author | Max Brister <max@2bass.com> |
---|---|
date | Wed, 04 Apr 2012 20:59:57 -0600 |
parents | 2946642797d6 |
children | ad2ff36996b8 |
files | src/oct-parse.yy |
diffstat | 1 files changed, 13 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/src/oct-parse.yy +++ b/src/oct-parse.yy @@ -460,7 +460,7 @@ // Nonterminals we construct. %type <comment_type> stash_comment function_beg classdef_beg %type <comment_type> properties_beg methods_beg events_beg enum_beg -%type <sep_type> sep_no_nl opt_sep_no_nl sep opt_sep +%type <sep_type> sep_no_nl opt_sep_no_nl sep opt_sep opt_comma %type <tree_type> input %type <tree_constant_type> string constant magic_colon %type <tree_anon_fcn_handle_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, ,