Mercurial > hg > octave-nkf
changeset 16139:2fd39ab12209
move a function and data member from lexical_feedback to octave_parser
* parse.h: Include lex.h.
* parse.h, oct-parse.yy (octave_parser::reset): New function.
(octave_parser::end_of_input): New data member.
(octave_parser::octave_parser): Initialize it.
* lex.h, lex.ll (lexical_feedback::reset): Rename from reset_parser.
(lexical_feedback::parser_end_of_input): Delete.
* input.cc (get_debug_input): Call octave_parser::reset, not
lexical_feedback::reset_parser.
* toplev.cc (main_loop): Likewise.
* oct-parse.yy (eval_string, parse_fcn_file): Likewise.
* toplev.cc (main_loop): Set octave_parser::end_of_input, not
lexical_feedback::parser_end_of_input.
* oct-parse.yy: Use octave_parser::end_of_input, not
lexical_feedback::parser_end_of_input.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Wed, 27 Feb 2013 13:09:33 -0500 |
parents | 284e2ca86ef7 |
children | c6b2409672e9 752a5de459c2 |
files | libinterp/interpfcn/input.cc libinterp/interpfcn/toplev.cc libinterp/parse-tree/lex.h libinterp/parse-tree/lex.ll libinterp/parse-tree/oct-parse.yy libinterp/parse-tree/parse.h |
diffstat | 6 files changed, 20 insertions(+), 14 deletions(-) [+] |
line wrap: on
line diff
--- a/libinterp/interpfcn/input.cc +++ b/libinterp/interpfcn/input.cc @@ -692,7 +692,7 @@ reset_error_handler (); - curr_lexer->reset_parser (); + curr_parser->reset (); // Save current value of global_command. middle_frame.protect_var (global_command);
--- a/libinterp/interpfcn/toplev.cc +++ b/libinterp/interpfcn/toplev.cc @@ -578,7 +578,7 @@ reset_error_handler (); - curr_lexer->reset_parser (); + curr_parser->reset (); if (symbol_table::at_top_level ()) tree_evaluator::reset_debug_state (); @@ -641,7 +641,7 @@ command_editor::increment_current_command_number (); } } - else if (curr_lexer->parser_end_of_input) + else if (curr_parser->end_of_input) break; } }
--- a/libinterp/parse-tree/lex.h +++ b/libinterp/parse-tree/lex.h @@ -182,7 +182,7 @@ 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), parser_end_of_input (false), + quote_is_transpose (false), input_line_number (1), current_input_column (1), bracketflag (0), braceflag (0), looping (0), defining_func (0), looking_at_function_handle (0), @@ -202,7 +202,7 @@ looking_at_object_index.push_front (false); } - void reset_parser (void); + void reset (void); void prep_for_script_file (void); @@ -350,9 +350,6 @@ // 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; - // The current input line number. int input_line_number;
--- a/libinterp/parse-tree/lex.ll +++ b/libinterp/parse-tree/lex.ll @@ -1376,7 +1376,7 @@ } void -lexical_feedback::reset_parser (void) +lexical_feedback::reset (void) { // Start off on the right foot. BEGIN (INITIAL);
--- a/libinterp/parse-tree/oct-parse.yy +++ b/libinterp/parse-tree/oct-parse.yy @@ -365,7 +365,7 @@ { $$ = 0; } | END_OF_INPUT { - curr_lexer->parser_end_of_input = 1; + curr_parser->end_of_input = true; $$ = 0; } | simple_list @@ -3345,7 +3345,7 @@ curr_parser = new octave_parser (); frame.add_fcn (octave_parser::cleanup, curr_parser); - curr_lexer->reset_parser (); + curr_parser->reset (); std::string help_txt = gobble_leading_white_space (ffile, eof); @@ -4190,7 +4190,7 @@ do { - curr_lexer->reset_parser (); + curr_parser->reset (); frame.protect_var (global_command); @@ -4264,7 +4264,7 @@ || tree_continue_command::continuing) break; } - else if (curr_lexer->parser_end_of_input) + else if (curr_parser->end_of_input) break; } }
--- a/libinterp/parse-tree/parse.h +++ b/libinterp/parse-tree/parse.h @@ -29,6 +29,7 @@ #include <stack> +#include "lex.h" #include "token.h" extern int octave_lex (void); @@ -136,10 +137,15 @@ { public: - octave_parser (void) { } + octave_parser (void) : end_of_input (false) { } ~octave_parser (void) { } + void reset (void) + { + curr_lexer->reset (); + } + int run (void); // Error mesages for mismatched end tokens. @@ -320,6 +326,9 @@ append_statement_list (tree_statement_list *list, char sep, tree_statement *stmt, bool warn_missing_semi); + // TRUE means that we have encountered EOF on the input stream. + bool end_of_input; + // For unwind protect. static void cleanup (octave_parser *parser) { delete parser; }