Mercurial > hg > octave-lojdl
changeset 16281:1bbc2fc552cf
adjust line and column info when inserting new text in lexer input stream
* lex.ll: Adjust line and column position info when inserting text
that was not part of the original input stream.
(octave_lexer::text_yyinput, octave_lexer::xunput): Don't update line
and column info.
(<MATRIX>{NL}): Increment line number and reset column number.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Mon, 11 Mar 2013 17:10:36 -0400 |
parents | 8c17cd370477 |
children | 82ff1c5bbff0 9a85870f2bc1 |
files | libinterp/parse-tree/lex.ll |
diffstat | 1 files changed, 29 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/libinterp/parse-tree/lex.ll +++ b/libinterp/parse-tree/lex.ll @@ -170,6 +170,8 @@ { \ yyless (0); \ curr_lexer->xunput (','); \ + /* Adjust for comma that was not really in the input stream. */ \ + curr_lexer->current_input_column--; \ } \ else \ { \ @@ -289,6 +291,9 @@ <MATRIX_START>{NL} { curr_lexer->lexer_debug ("<MATRIX_START>{NL}"); + curr_lexer->input_line_number++; + curr_lexer->current_input_column = 1; + if (curr_lexer->nesting_level.is_paren ()) curr_lexer->gripe_matlab_incompatible ("bare newline inside parentheses"); else @@ -296,7 +301,11 @@ int tok = curr_lexer->previous_token_value (); if (! (tok == ';' || tok == '[' || tok == '{')) - curr_lexer->xunput (';'); + { + curr_lexer->xunput (';'); + // Adjust for semicolon that was not really in the input stream. + curr_lexer->current_input_column--; + } } } @@ -363,6 +372,8 @@ { yyless (0); curr_lexer->xunput (','); + // Adjust for comma that was not really in the input stream. + curr_lexer->current_input_column--; } else { @@ -768,6 +779,8 @@ { yyless (0); curr_lexer->xunput (','); + // Adjust for comma that was not really in the input stream. + curr_lexer->current_input_column--; } } else @@ -834,6 +847,8 @@ { yyless (0); curr_lexer->xunput (','); + // Adjust for comma that was not really in the input stream. + curr_lexer->current_input_column--; } } else @@ -924,6 +939,8 @@ { yyless (0); curr_lexer->xunput (','); + // Adjust for comma that was not really in the input stream. + curr_lexer->current_input_column--; } else return tok; @@ -938,6 +955,8 @@ { yyless (0); curr_lexer->xunput (','); + // Adjust for comma that was not really in the input stream. + curr_lexer->current_input_column--; } else return tok; @@ -962,6 +981,8 @@ { yyless (0); curr_lexer->xunput (','); + // Adjust for comma that was not really in the input stream. + curr_lexer->current_input_column--; } else { @@ -1060,6 +1081,8 @@ { yyless (0); curr_lexer->xunput (','); + // Adjust for comma that was not really in the input stream. + curr_lexer->current_input_column--; } else { @@ -1759,9 +1782,6 @@ } } - if (c == '\n') - input_line_number++; - return c; } @@ -1777,9 +1797,6 @@ std::cerr << std::endl; } - if (c == '\n') - input_line_number--; - yyunput (c, buf, scanner); } } @@ -2181,7 +2198,11 @@ at_beginning_of_statement = true; if (! looking_at_continuation) - xunput ('\n'); + { + xunput ('\n'); + // Adjust for newline that was not really in the input stream. + input_line_number--; + } } // We have seen a backslash and need to find out if it should be