Mercurial > hg > octave-nkf
changeset 16105:b7de58feb2d3
move block_comment_nesting_level to lexical_feedback_class
* lex.h, lex.ll (block_comment_nesting_level): Move global
variable to lexical_feedback class. Change all uses.
(reset_parser): Don't reset block_comment_nesting_level.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Mon, 25 Feb 2013 21:59:40 -0500 |
parents | c8974e28da59 |
children | 031117f4db7c |
files | libinterp/parse-tree/lex.h libinterp/parse-tree/lex.ll |
diffstat | 2 files changed, 12 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- a/libinterp/parse-tree/lex.h +++ b/libinterp/parse-tree/lex.h @@ -150,6 +150,7 @@ input_line_number (1), current_input_column (1), bracketflag (0), braceflag (0), looping (0), defining_func (0), looking_at_function_handle (0), + block_comment_nesting_level (0), looking_at_object_index (), parsed_function_name (), pending_local_variables (), nesting_level () { @@ -180,6 +181,7 @@ looping (lf.looping), defining_func (lf.defining_func), looking_at_function_handle (lf.looking_at_function_handle), + block_comment_nesting_level (lf.block_comment_nesting_level), looking_at_object_index (lf.looking_at_object_index), parsed_function_name (lf.parsed_function_name), pending_local_variables (lf.pending_local_variables), @@ -213,6 +215,7 @@ looping = lf.looping; defining_func = lf.defining_func; looking_at_function_handle = lf.looking_at_function_handle; + block_comment_nesting_level = lf.block_comment_nesting_level, looking_at_object_index = lf.looking_at_object_index; parsed_function_name = lf.parsed_function_name; pending_local_variables = lf.pending_local_variables; @@ -308,6 +311,9 @@ // Nonzero means we are parsing a function handle. int looking_at_function_handle; + // Nestng level for blcok comments. + int block_comment_nesting_level; + // If the front of the list is TRUE, the closest paren, brace, or // bracket nesting is an index for an object. std::list<bool> looking_at_object_index;
--- a/libinterp/parse-tree/lex.ll +++ b/libinterp/parse-tree/lex.ll @@ -235,10 +235,6 @@ static unsigned int Vtoken_count = 0; -// The start state that was in effect when the beginning of a block -// comment was noticed. -static int block_comment_nesting_level = 0; - // Internal variable for lexer debugging state. static bool lexer_debug_flag = false; @@ -661,7 +657,7 @@ <<EOF>> { LEXER_DEBUG ("<<EOF>>"); - if (block_comment_nesting_level != 0) + if (lexer_flags.block_comment_nesting_level != 0) { warning ("block comment open at end of input"); @@ -839,7 +835,7 @@ lexer_flags.input_line_number++; lexer_flags.current_input_column = 1; - block_comment_nesting_level++; + lexer_flags.block_comment_nesting_level++; promptflag--; bool eof = false; @@ -1063,9 +1059,6 @@ // We do want a prompt by default. promptflag = 1; - // We are not in a block comment. - block_comment_nesting_level = 0; - // Clear out the stack of token info used to track line and column // numbers. while (! token_stack.empty ()) @@ -1680,15 +1673,15 @@ if (type == '{') { - block_comment_nesting_level++; + lexer_flags.block_comment_nesting_level++; promptflag--; } else { - block_comment_nesting_level--; + lexer_flags.block_comment_nesting_level--; promptflag++; - if (block_comment_nesting_level == 0) + if (lexer_flags.block_comment_nesting_level == 0) { buf += grab_comment_block (reader, true, eof); @@ -1788,7 +1781,7 @@ at_bol = true; done = true; - block_comment_nesting_level++; + lexer_flags.block_comment_nesting_level++; promptflag--; buf += grab_block_comment (reader, eof);