# HG changeset patch # User John W. Eaton # Date 1364072319 14400 # Node ID d16c255299c069ff4dcf8f88321be73467322750 # Parent b9e510a1f308ecbc9639e1e4aa52457cffaf86c9 recognize block comment begin while processing line comments (bug #38559) * lex.ll ({S}*{CCHAR}.*{NL}): Recognize line that matches ^{S}*\{{S}*\n as end of a block of line comments. ({S}+): Change pattern from {S}*. diff -r b9e510a1f308 -r d16c255299c0 libinterp/parse-tree/lex.ll --- a/libinterp/parse-tree/lex.ll Sat Mar 23 15:55:45 2013 -0400 +++ b/libinterp/parse-tree/lex.ll Sat Mar 23 16:58:39 2013 -0400 @@ -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 start state code above. %} -{S}* { +{S}+ { curr_lexer->current_input_column += yyleng; curr_lexer->mark_previous_token_trailing_space ();