comparison libinterp/parse-tree/lex.ll @ 16361:e1dcd834751f

and foo NUMBER as command syntax (bug #38565) * lex.ll ({NUMBER}{Im}, {D}+/\.[\*/\\^\']|{NUMBER}): Handle possible command syntax.
author John W. Eaton <jwe@octave.org>
date Sat, 23 Mar 2013 15:29:15 -0400
parents 11115c237231
children d16c255299c0
comparison
equal deleted inserted replaced
16360:11115c237231 16361:e1dcd834751f
562 %} 562 %}
563 563
564 {NUMBER}{Im} { 564 {NUMBER}{Im} {
565 curr_lexer->lexer_debug ("{NUMBER}{Im}"); 565 curr_lexer->lexer_debug ("{NUMBER}{Im}");
566 566
567 int tok = curr_lexer->previous_token_value (); 567 if (curr_lexer->previous_token_may_be_command ()
568 568 && curr_lexer->space_follows_previous_token ())
569 if (curr_lexer->whitespace_is_significant ()
570 && curr_lexer->space_follows_previous_token ()
571 && ! (tok == '[' || tok == '{'
572 || curr_lexer->previous_token_is_binop ()))
573 { 569 {
574 yyless (0); 570 yyless (0);
575 unput (','); 571 curr_lexer->push_start_state (COMMAND_START);
576 } 572 }
577 else 573 else
578 { 574 {
579 curr_lexer->handle_number (); 575 int tok = curr_lexer->previous_token_value ();
580 return curr_lexer->count_token_internal (IMAG_NUM); 576
577 if (curr_lexer->whitespace_is_significant ()
578 && curr_lexer->space_follows_previous_token ()
579 && ! (tok == '[' || tok == '{'
580 || curr_lexer->previous_token_is_binop ()))
581 {
582 yyless (0);
583 unput (',');
584 }
585 else
586 {
587 curr_lexer->handle_number ();
588 return curr_lexer->count_token_internal (IMAG_NUM);
589 }
581 } 590 }
582 } 591 }
583 592
584 %{ 593 %{
585 // Real numbers. Don't grab the '.' part of a dot operator as part of 594 // Real numbers. Don't grab the '.' part of a dot operator as part of
588 597
589 {D}+/\.[\*/\\^\'] | 598 {D}+/\.[\*/\\^\'] |
590 {NUMBER} { 599 {NUMBER} {
591 curr_lexer->lexer_debug ("{D}+/\\.[\\*/\\^\\']|{NUMBER}"); 600 curr_lexer->lexer_debug ("{D}+/\\.[\\*/\\^\\']|{NUMBER}");
592 601
593 int tok = curr_lexer->previous_token_value (); 602 if (curr_lexer->previous_token_may_be_command ()
594 603 && curr_lexer->space_follows_previous_token ())
595 if (curr_lexer->whitespace_is_significant () 604 {
596 && curr_lexer->space_follows_previous_token () 605 yyless (0);
597 && ! (tok == '[' || tok == '{' 606 curr_lexer->push_start_state (COMMAND_START);
598 || curr_lexer->previous_token_is_binop ())) 607 }
599 { 608 else
600 yyless (0); 609 {
601 unput (','); 610 int tok = curr_lexer->previous_token_value ();
602 } 611
603 else 612 if (curr_lexer->whitespace_is_significant ()
604 { 613 && curr_lexer->space_follows_previous_token ()
605 curr_lexer->handle_number (); 614 && ! (tok == '[' || tok == '{'
606 return curr_lexer->count_token_internal (NUM); 615 || curr_lexer->previous_token_is_binop ()))
607 } 616 {
617 yyless (0);
618 unput (',');
619 }
620 else
621 {
622 curr_lexer->handle_number ();
623 return curr_lexer->count_token_internal (NUM);
624 }
625 }
608 } 626 }
609 627
610 %{ 628 %{
611 // Eat whitespace. Whitespace inside matrix constants is handled by 629 // Eat whitespace. Whitespace inside matrix constants is handled by
612 // the <MATRIX_START> start state code above. 630 // the <MATRIX_START> start state code above.