Mercurial > hg > octave-nkf
changeset 16102:679a54d274d9
move global parser_end_of_input variable to lexical_feedback class
* lex.h, lex.ll (parser_end_of_input): Move global variable to
lexical_feedback class. Change all uses.
(reset_parser): Don't reset parser_end_of_input here.
* oct-parse.yy (eval_string, parse_fcn_file): Add lexer_flags object
to unwind_protect stack. Don't protect parser_end_of_input.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Mon, 25 Feb 2013 20:26:52 -0500 |
parents | 8d19626b38ae |
children | 6434f70f0ee0 |
files | libinterp/interpfcn/toplev.cc libinterp/parse-tree/lex.h libinterp/parse-tree/lex.ll libinterp/parse-tree/oct-parse.yy |
diffstat | 4 files changed, 17 insertions(+), 16 deletions(-) [+] |
line wrap: on
line diff
--- a/libinterp/interpfcn/toplev.cc +++ b/libinterp/interpfcn/toplev.cc @@ -632,7 +632,7 @@ command_editor::increment_current_command_number (); } } - else if (parser_end_of_input) + else if (lexer_flags.parser_end_of_input) break; } }
--- a/libinterp/parse-tree/lex.h +++ b/libinterp/parse-tree/lex.h @@ -71,7 +71,8 @@ looking_for_object_index (false), looking_at_indirect_ref (false), parsing_class_method (false), maybe_classdef_get_set_method (false), parsing_classdef (false), - quote_is_transpose (false), bracketflag (0), braceflag (0), + quote_is_transpose (false), parser_end_of_input (false), + bracketflag (0), braceflag (0), looping (0), defining_func (0), looking_at_function_handle (0), looking_at_object_index (), parsed_function_name (), pending_local_variables () @@ -95,6 +96,7 @@ maybe_classdef_get_set_method (lf.maybe_classdef_get_set_method), parsing_classdef (lf.parsing_classdef), quote_is_transpose (lf.quote_is_transpose), + parser_end_of_input (lf.parser_end_of_input), bracketflag (lf.bracketflag), braceflag (lf.braceflag), looping (lf.looping), @@ -124,6 +126,7 @@ maybe_classdef_get_set_method = lf.maybe_classdef_get_set_method; parsing_classdef = lf.parsing_classdef; quote_is_transpose = lf.quote_is_transpose; + parser_end_of_input = lf.parser_end_of_input; bracketflag = lf.bracketflag; braceflag = lf.braceflag; looping = lf.looping; @@ -199,6 +202,9 @@ // Return transpose or start a string? bool quote_is_transpose; + // TRUE means that we have encountered EOF on the input stream. + bool parser_end_of_input; + // Square bracket level count. int bracketflag; @@ -248,9 +254,6 @@ extern std::string grab_comment_block (stream_reader& reader, bool at_bol, bool& eof); -// TRUE means that we have encountered EOF on the input stream. -extern bool parser_end_of_input; - // Flags that need to be shared between the lexer and parser. extern lexical_feedback lexer_flags;
--- a/libinterp/parse-tree/lex.ll +++ b/libinterp/parse-tree/lex.ll @@ -210,9 +210,6 @@ } \ while (0) -// TRUE means that we have encountered EOF on the input stream. -bool parser_end_of_input = false; - // The state of the lexer. lexical_feedback lexer_flags; @@ -1112,8 +1109,6 @@ // Start off on the right foot. BEGIN (INITIAL); - parser_end_of_input = false; - parser_symtab_context.clear (); // We do want a prompt by default.
--- a/libinterp/parse-tree/oct-parse.yy +++ b/libinterp/parse-tree/oct-parse.yy @@ -562,7 +562,7 @@ { $$ = 0; } | END_OF_INPUT { - parser_end_of_input = 1; + lexer_flags.parser_end_of_input = 1; $$ = 0; } | simple_list @@ -3517,16 +3517,17 @@ { std::string file_type; + frame.protect_var (lexer_flags); + frame.protect_var (get_input_from_eval_string); - frame.protect_var (parser_end_of_input); frame.protect_var (reading_fcn_file); frame.protect_var (reading_script_file); frame.protect_var (reading_classdef_file); frame.protect_var (Vecho_executing_commands); + lexer_flags = lexical_feedback (); get_input_from_eval_string = false; - parser_end_of_input = false; if (! force_script && looking_at_function_keyword (ffile)) { @@ -4312,10 +4313,11 @@ unwind_protect frame; + frame.protect_var (lexer_flags); + frame.protect_var (input_line_number); frame.protect_var (current_input_column); frame.protect_var (get_input_from_eval_string); - frame.protect_var (parser_end_of_input); frame.protect_var (line_editing); frame.protect_var (current_eval_string); frame.protect_var (current_function_depth); @@ -4327,10 +4329,11 @@ frame.protect_var (reading_script_file); frame.protect_var (reading_classdef_file); + lexer_flags = lexical_feedback (); + input_line_number = 1; current_input_column = 1; get_input_from_eval_string = true; - parser_end_of_input = false; line_editing = false; current_function_depth = 0; function_scopes.clear (); @@ -4427,7 +4430,7 @@ || tree_continue_command::continuing) break; } - else if (parser_end_of_input) + else if (lexer_flags.parser_end_of_input) break; } }