comparison src/lex.l @ 4613:d1786f2d8a3c

[project @ 2003-11-14 22:46:19 by jwe]
author jwe
date Fri, 14 Nov 2003 22:46:19 +0000
parents d44675070f1a
children d95dd6ae89fd
comparison
equal deleted inserted replaced
4612:d44675070f1a 4613:d1786f2d8a3c
752 lexer_flags.convert_spaces_to_comma = true; 752 lexer_flags.convert_spaces_to_comma = true;
753 753
754 promptflag--; 754 promptflag--;
755 eat_whitespace (); 755 eat_whitespace ();
756 756
757 lexer_flags.bracketflag++; 757 lexer_flags.braceflag++;
758 BEGIN (MATRIX_START); 758 BEGIN (MATRIX_START);
759 return '{'; 759 return '{';
760 } 760 }
761 761
762 "}" { 762 "}" {
1504 } 1504 }
1505 else if (c0 == '.') 1505 else if (c0 == '.')
1506 { 1506 {
1507 int c1 = yyinput (); 1507 int c1 = yyinput ();
1508 un_op = (c1 == '\''); 1508 un_op = (c1 == '\'');
1509 yyunput (c1, yytext);
1510 }
1511 else if (c0 == '+')
1512 {
1513 int c1 = yyinput ();
1514 un_op = (c1 == '+');
1515 yyunput (c1, yytext);
1516 }
1517 else if (c0 == '-')
1518 {
1519 int c1 = yyinput ();
1520 un_op = (c1 == '-');
1509 yyunput (c1, yytext); 1521 yyunput (c1, yytext);
1510 } 1522 }
1511 1523
1512 yyunput (c0, yytext); 1524 yyunput (c0, yytext);
1513 1525
2232 int retval = bracket_type; 2244 int retval = bracket_type;
2233 2245
2234 if (! nesting_level.none ()) 2246 if (! nesting_level.none ())
2235 { 2247 {
2236 nesting_level.remove (); 2248 nesting_level.remove ();
2237 lexer_flags.bracketflag--; 2249
2238 } 2250 if (bracket_type == ']')
2239 2251 lexer_flags.bracketflag--;
2240 if (lexer_flags.bracketflag == 0) 2252 else if (bracket_type == '}')
2253 lexer_flags.braceflag--;
2254 else
2255 panic_impossible ();
2256 }
2257
2258 if (lexer_flags.bracketflag == 0 && lexer_flags.braceflag == 0)
2241 BEGIN (INITIAL); 2259 BEGIN (INITIAL);
2242 2260
2243 if (bracket_type == ']' 2261 if (bracket_type == ']'
2244 && next_token_is_assign_op () 2262 && next_token_is_assign_op ()
2245 && ! lexer_flags.looking_at_return_list) 2263 && ! lexer_flags.looking_at_return_list)
2246 { 2264 {
2247 retval = CLOSE_BRACE; 2265 retval = CLOSE_BRACE;
2248 } 2266 }
2249 else 2267 else if ((lexer_flags.bracketflag || lexer_flags.braceflag)
2250 { 2268 && lexer_flags.convert_spaces_to_comma
2251 int c1 = yyinput (); 2269 && (nesting_level.is_bracket ()
2252 yyunput (c1, yytext); 2270 || (nesting_level.is_brace ()
2253 2271 && ! lexer_flags.looking_at_object_index)))
2254 if (lexer_flags.bracketflag) 2272 {
2273 int bin_op = next_token_is_bin_op (spc_gobbled);
2274
2275 int postfix_un_op = next_token_is_postfix_unary_op (spc_gobbled);
2276
2277 int sep_op = next_token_is_sep_op ();
2278
2279 if (! (postfix_un_op || bin_op || sep_op))
2255 { 2280 {
2256 int bin_op = next_token_is_bin_op (spc_gobbled); 2281 maybe_warn_separator_insert (',');
2257 2282
2258 int postfix_un_op = next_token_is_postfix_unary_op (spc_gobbled); 2283 yyunput (',', yytext);
2259 2284 return retval;
2260 int sep_op = next_token_is_sep_op ();
2261
2262 if (! (postfix_un_op || bin_op || sep_op)
2263 && nesting_level.is_bracket_or_brace ()
2264 && lexer_flags.convert_spaces_to_comma)
2265 {
2266 maybe_warn_separator_insert (',');
2267
2268 yyunput (',', yytext);
2269 return retval;
2270 }
2271 } 2285 }
2272 } 2286 }
2273 2287
2274 lexer_flags.quote_is_transpose = true; 2288 lexer_flags.quote_is_transpose = true;
2275 lexer_flags.cant_be_identifier = false; 2289 lexer_flags.cant_be_identifier = false;
2279 } 2293 }
2280 2294
2281 static void 2295 static void
2282 maybe_unput_comma (int spc_gobbled) 2296 maybe_unput_comma (int spc_gobbled)
2283 { 2297 {
2284 if (nesting_level.is_bracket_or_brace ()) 2298 if (nesting_level.is_bracket ()
2299 || (nesting_level.is_brace ()
2300 && ! lexer_flags.looking_at_object_index))
2285 { 2301 {
2286 int bin_op = next_token_is_bin_op (spc_gobbled); 2302 int bin_op = next_token_is_bin_op (spc_gobbled);
2287 2303
2288 int postfix_un_op = next_token_is_postfix_unary_op (spc_gobbled); 2304 int postfix_un_op = next_token_is_postfix_unary_op (spc_gobbled);
2289 2305
2497 lexical_feedback::init (void) 2513 lexical_feedback::init (void)
2498 { 2514 {
2499 // Not initially defining a matrix list. 2515 // Not initially defining a matrix list.
2500 bracketflag = 0; 2516 bracketflag = 0;
2501 2517
2518 // Not initially defining a cell array list.
2519 braceflag = 0;
2520
2502 // Not initially inside a loop or if statement. 2521 // Not initially inside a loop or if statement.
2503 looping = 0; 2522 looping = 0;
2504 2523
2505 // Not initially defining a function. 2524 // Not initially defining a function.
2506 beginning_of_function = false; 2525 beginning_of_function = false;