Mercurial > hg > octave-lyh
comparison libinterp/parse-tree/lex.ll @ 16337:6bfd8dbd7d3c
don't swallow statements that follow comment lines (bug #38549)
* lex.h, lex.ll (finish_comment): Delete second arg,
looking_at_continuation. Never unput '\n'. Change all callers.
(<LINE_COMMENT_START>{S}*{CCHAR}.*{NL}): Unput '\n' here if looking at
end of line comment.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Tue, 19 Mar 2013 18:03:23 -0400 |
parents | 06aa4c0f2018 |
children | 11115c237231 |
comparison
equal
deleted
inserted
replaced
16336:0ce49f9fb171 | 16337:6bfd8dbd7d3c |
---|---|
535 curr_lexer->mark_previous_token_trailing_space (); | 535 curr_lexer->mark_previous_token_trailing_space (); |
536 | 536 |
537 curr_lexer->finish_comment (octave_comment_elt::end_of_line); | 537 curr_lexer->finish_comment (octave_comment_elt::end_of_line); |
538 | 538 |
539 curr_lexer->pop_start_state (); | 539 curr_lexer->pop_start_state (); |
540 | |
541 curr_lexer->xunput ('\n'); | |
542 curr_lexer->input_line_number--; | |
540 } | 543 } |
541 } | 544 } |
542 | 545 |
543 %{ | 546 %{ |
544 // End of a block of full-line comments. | 547 // End of a block of full-line comments. |
2114 | 2117 |
2115 if (have_comment) | 2118 if (have_comment) |
2116 { | 2119 { |
2117 comment_text = &yytxt[offset]; | 2120 comment_text = &yytxt[offset]; |
2118 | 2121 |
2119 finish_comment (octave_comment_elt::end_of_line, true); | 2122 finish_comment (octave_comment_elt::end_of_line); |
2120 } | 2123 } |
2121 | 2124 |
2122 decrement_promptflag (); | 2125 decrement_promptflag (); |
2123 input_line_number++; | 2126 input_line_number++; |
2124 current_input_column = 1; | 2127 current_input_column = 1; |
2125 } | 2128 } |
2126 | 2129 |
2127 void | 2130 void |
2128 octave_base_lexer::finish_comment (octave_comment_elt::comment_type typ, | 2131 octave_base_lexer::finish_comment (octave_comment_elt::comment_type typ) |
2129 bool looking_at_continuation) | |
2130 { | 2132 { |
2131 bool copyright = looks_like_copyright (comment_text); | 2133 bool copyright = looks_like_copyright (comment_text); |
2132 | 2134 |
2133 if (nesting_level.none () && help_text.empty () | 2135 if (nesting_level.none () && help_text.empty () |
2134 && ! comment_text.empty () && ! copyright) | 2136 && ! comment_text.empty () && ! copyright) |
2140 octave_comment_buffer::append (comment_text, typ); | 2142 octave_comment_buffer::append (comment_text, typ); |
2141 | 2143 |
2142 comment_text = ""; | 2144 comment_text = ""; |
2143 | 2145 |
2144 at_beginning_of_statement = true; | 2146 at_beginning_of_statement = true; |
2145 | |
2146 if (! looking_at_continuation) | |
2147 { | |
2148 xunput ('\n'); | |
2149 // Adjust for newline that was not really in the input stream. | |
2150 input_line_number--; | |
2151 } | |
2152 } | 2147 } |
2153 | 2148 |
2154 // We have seen a backslash and need to find out if it should be | 2149 // We have seen a backslash and need to find out if it should be |
2155 // treated as a continuation character. If so, this eats it, up to | 2150 // treated as a continuation character. If so, this eats it, up to |
2156 // and including the new line character. | 2151 // and including the new line character. |