Mercurial > octave
comparison src/oct-parse.yy @ 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 | e0d66b8b0c63 |
children | be18c9e359bf |
comparison
equal
deleted
inserted
replaced
14532:2946642797d6 | 14533:e6aa044253eb |
---|---|
458 %token CLOSE_BRACE | 458 %token CLOSE_BRACE |
459 | 459 |
460 // Nonterminals we construct. | 460 // Nonterminals we construct. |
461 %type <comment_type> stash_comment function_beg classdef_beg | 461 %type <comment_type> stash_comment function_beg classdef_beg |
462 %type <comment_type> properties_beg methods_beg events_beg enum_beg | 462 %type <comment_type> properties_beg methods_beg events_beg enum_beg |
463 %type <sep_type> sep_no_nl opt_sep_no_nl sep opt_sep | 463 %type <sep_type> sep_no_nl opt_sep_no_nl sep opt_sep opt_comma |
464 %type <tree_type> input | 464 %type <tree_type> input |
465 %type <tree_constant_type> string constant magic_colon | 465 %type <tree_constant_type> string constant magic_colon |
466 %type <tree_anon_fcn_handle_type> anon_fcn_handle | 466 %type <tree_anon_fcn_handle_type> anon_fcn_handle |
467 %type <tree_fcn_handle_type> fcn_handle | 467 %type <tree_fcn_handle_type> fcn_handle |
468 %type <tree_matrix_type> matrix_rows matrix_rows1 | 468 %type <tree_matrix_type> matrix_rows matrix_rows1 |
904 assign_lhs : simple_expr | 904 assign_lhs : simple_expr |
905 { | 905 { |
906 $$ = new tree_argument_list ($1); | 906 $$ = new tree_argument_list ($1); |
907 $$->mark_as_simple_assign_lhs (); | 907 $$->mark_as_simple_assign_lhs (); |
908 } | 908 } |
909 | '[' arg_list CLOSE_BRACE | 909 | '[' arg_list opt_comma CLOSE_BRACE |
910 { | 910 { |
911 $$ = $2; | 911 $$ = $2; |
912 lexer_flags.looking_at_matrix_or_assign_lhs = false; | 912 lexer_flags.looking_at_matrix_or_assign_lhs = false; |
913 for (std::set<std::string>::const_iterator p = lexer_flags.pending_local_variables.begin (); | 913 for (std::set<std::string>::const_iterator p = lexer_flags.pending_local_variables.begin (); |
914 p != lexer_flags.pending_local_variables.end (); | 914 p != lexer_flags.pending_local_variables.end (); |
1668 | 1668 |
1669 opt_sep : // empty | 1669 opt_sep : // empty |
1670 { $$ = 0; } | 1670 { $$ = 0; } |
1671 | sep | 1671 | sep |
1672 { $$ = $1; } | 1672 { $$ = $1; } |
1673 ; | |
1674 | |
1675 opt_comma : // empty | |
1676 { $$ = 0; } | |
1677 | ',' | |
1678 { $$ = ','; } | |
1673 ; | 1679 ; |
1674 | 1680 |
1675 %% | 1681 %% |
1676 | 1682 |
1677 // Generic error messages. | 1683 // Generic error messages. |
4551 %! eval ("flipud = 2;"); | 4557 %! eval ("flipud = 2;"); |
4552 %! y = flipud; | 4558 %! y = flipud; |
4553 %!endfunction | 4559 %!endfunction |
4554 %!assert (__f(), 2) | 4560 %!assert (__f(), 2) |
4555 | 4561 |
4562 % bug #35645 | |
4563 %!test | |
4564 %! [a,] = gcd (1,2); | |
4565 %! [a,b,] = gcd (1, 2); | |
4566 | |
4556 */ | 4567 */ |
4557 | 4568 |
4558 DEFUN (assignin, args, , | 4569 DEFUN (assignin, args, , |
4559 "-*- texinfo -*-\n\ | 4570 "-*- texinfo -*-\n\ |
4560 @deftypefn {Built-in Function} {} assignin (@var{context}, @var{varname}, @var{value})\n\ | 4571 @deftypefn {Built-in Function} {} assignin (@var{context}, @var{varname}, @var{value})\n\ |