Mercurial > hg > octave-lyh
diff src/lex.l @ 4633:d95dd6ae89fd
[project @ 2003-11-19 18:32:50 by jwe]
author | jwe |
---|---|
date | Wed, 19 Nov 2003 18:32:51 +0000 |
parents | d1786f2d8a3c |
children | e1c2d8ca8bc0 |
line wrap: on
line diff
--- a/src/lex.l +++ b/src/lex.l @@ -2238,6 +2238,14 @@ return retval; } +static bool +next_token_is_index_op (void) +{ + int c = yyinput (); + yyunput (c, yytext); + return c == '(' || c == '{'; +} + static int handle_close_bracket (bool spc_gobbled, int bracket_type) { @@ -2270,18 +2278,31 @@ || (nesting_level.is_brace () && ! lexer_flags.looking_at_object_index))) { - int bin_op = next_token_is_bin_op (spc_gobbled); - - int postfix_un_op = next_token_is_postfix_unary_op (spc_gobbled); - - int sep_op = next_token_is_sep_op (); - - if (! (postfix_un_op || bin_op || sep_op)) + bool index_op = next_token_is_index_op (); + + // Don't insert comma if we are looking at something like + // + // [x{i}{j}] or [x{i}(j)] + // + // but do if we are looking at + // + // [x{i} {j}] or [x{i} (j)] + + if (spc_gobbled || ! (bracket_type == '}' && index_op)) { - maybe_warn_separator_insert (','); - - yyunput (',', yytext); - return retval; + bool bin_op = next_token_is_bin_op (spc_gobbled); + + bool postfix_un_op = next_token_is_postfix_unary_op (spc_gobbled); + + bool sep_op = next_token_is_sep_op (); + + if (! (postfix_un_op || bin_op || sep_op)) + { + maybe_warn_separator_insert (','); + + yyunput (',', yytext); + return retval; + } } }