comparison libinterp/parse-tree/lex.ll @ 16363:d16c255299c0

recognize block comment begin while processing line comments (bug #38559) * lex.ll (<LINE_COMMENT_START>{S}*{CCHAR}.*{NL}): Recognize line that matches ^{S}*\{{S}*\n as end of a block of line comments. ({S}+): Change pattern from {S}*.
author John W. Eaton <jwe@octave.org>
date Sat, 23 Mar 2013 16:58:39 -0400
parents e1dcd834751f
children 1e064963c90a
comparison
equal deleted inserted replaced
16362:b9e510a1f308 16363:d16c255299c0
516 } 516 }
517 else 517 else
518 break; 518 break;
519 } 519 }
520 520
521 size_t num_comment_chars = 0;
522
521 while (i < len) 523 while (i < len)
522 { 524 {
523 char c = yytext[i]; 525 char c = yytext[i];
524 if (c == '#' || c == '%') 526 if (c == '#' || c == '%')
525 i++; 527 {
528 num_comment_chars++;
529 i++;
530 }
526 else 531 else
527 break; 532 break;
528 } 533 }
529 534
530 curr_lexer->comment_text += &yytext[i]; 535 curr_lexer->comment_text += &yytext[i];
531 536
532 if (! full_line_comment) 537 if (full_line_comment)
538 {
539 if (yytext[i++] == '{')
540 {
541 bool looks_like_block_comment = true;
542
543 while (i < len)
544 {
545 char c = yytext[i++];
546 if (! (c == ' ' || c == '\t' || c == '\n'))
547 {
548 looks_like_block_comment = false;
549 break;
550 }
551 }
552
553 if (looks_like_block_comment)
554 {
555 yyless (0);
556
557 curr_lexer->finish_comment (octave_comment_elt::full_line);
558
559 curr_lexer->pop_start_state ();
560 }
561 }
562 }
563 else
533 { 564 {
534 if (have_space) 565 if (have_space)
535 curr_lexer->mark_previous_token_trailing_space (); 566 curr_lexer->mark_previous_token_trailing_space ();
536 567
537 curr_lexer->finish_comment (octave_comment_elt::end_of_line); 568 curr_lexer->finish_comment (octave_comment_elt::end_of_line);
628 %{ 659 %{
629 // Eat whitespace. Whitespace inside matrix constants is handled by 660 // Eat whitespace. Whitespace inside matrix constants is handled by
630 // the <MATRIX_START> start state code above. 661 // the <MATRIX_START> start state code above.
631 %} 662 %}
632 663
633 {S}* { 664 {S}+ {
634 curr_lexer->current_input_column += yyleng; 665 curr_lexer->current_input_column += yyleng;
635 666
636 curr_lexer->mark_previous_token_trailing_space (); 667 curr_lexer->mark_previous_token_trailing_space ();
637 } 668 }
638 669