Mercurial > hg > octave-lyh
changeset 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 | b9e510a1f308 |
children | 1e064963c90a |
files | libinterp/parse-tree/lex.ll |
diffstat | 1 files changed, 35 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/libinterp/parse-tree/lex.ll +++ b/libinterp/parse-tree/lex.ll @@ -518,18 +518,49 @@ break; } + size_t num_comment_chars = 0; + while (i < len) { char c = yytext[i]; if (c == '#' || c == '%') - i++; + { + num_comment_chars++; + i++; + } else break; } - + curr_lexer->comment_text += &yytext[i]; - if (! full_line_comment) + if (full_line_comment) + { + if (yytext[i++] == '{') + { + bool looks_like_block_comment = true; + + while (i < len) + { + char c = yytext[i++]; + if (! (c == ' ' || c == '\t' || c == '\n')) + { + looks_like_block_comment = false; + break; + } + } + + if (looks_like_block_comment) + { + yyless (0); + + curr_lexer->finish_comment (octave_comment_elt::full_line); + + curr_lexer->pop_start_state (); + } + } + } + else { if (have_space) curr_lexer->mark_previous_token_trailing_space (); @@ -630,7 +661,7 @@ // the <MATRIX_START> start state code above. %} -{S}* { +{S}+ { curr_lexer->current_input_column += yyleng; curr_lexer->mark_previous_token_trailing_space ();