diff src/parse.y @ 3877:55648fc616c8

[project @ 2002-03-07 23:00:09 by jwe]
author jwe
date Thu, 07 Mar 2002 23:00:10 +0000
parents 87f85453b6b7
children c21ae2c5840f
line wrap: on
line diff
--- a/src/parse.y	Thu Mar 07 18:57:46 2002 +0000
+++ b/src/parse.y	Thu Mar 07 23:00:10 2002 +0000
@@ -2204,7 +2204,8 @@
   int c = break_tok->column ();
 
   if (lexer_flags.looping || lexer_flags.defining_func
-      || reading_script_file || evaluating_function_body)
+      || reading_script_file || evaluating_function_body
+      || evaluating_looping_command)
     retval = new tree_break_command (l, c);
   else
     retval = new tree_no_op_command ("break", l, c);
@@ -2222,7 +2223,7 @@
   int l = continue_tok->line ();
   int c = continue_tok->column ();
 
-  if (lexer_flags.looping)
+  if (lexer_flags.looping || evaluating_looping_command)
     retval = new tree_continue_command (l, c);
   else
     retval = new tree_no_op_command ("continue", l, c);
@@ -3135,11 +3136,13 @@
 	  unwind_protect_bool (Vsaving_history);
 	  unwind_protect_bool (reading_fcn_file);
 	  unwind_protect_bool (input_from_command_line_file);
+	  unwind_protect_bool (get_input_from_eval_string);
 
 	  Vecho_executing_commands = ECHO_OFF;
 	  Vsaving_history = false;
 	  reading_fcn_file = true;
 	  input_from_command_line_file = false;
+	  get_input_from_eval_string = false;
 
 	  YY_BUFFER_STATE old_buf = current_buffer ();
 	  YY_BUFFER_STATE new_buf = create_buffer (ffile);
@@ -3390,17 +3393,22 @@
 octave_value_list
 eval_string (const std::string& s, bool silent, int& parse_status, int nargout)
 {
+  octave_value_list retval;
+
   unwind_protect::begin_frame ("eval_string");
 
   unwind_protect_bool (get_input_from_eval_string);
+  unwind_protect_bool (input_from_eval_string_pending);
   unwind_protect_bool (input_from_command_line_file);
-  unwind_protect_ptr (global_command);
   unwind_protect_str (current_eval_string);
 
   get_input_from_eval_string = true;
+  input_from_eval_string_pending = true;
   input_from_command_line_file = false;
   current_eval_string = s;
 
+  unwind_protect_ptr (global_command);
+
   YY_BUFFER_STATE old_buf = current_buffer ();
   YY_BUFFER_STATE new_buf = create_buffer (0);
 
@@ -3411,26 +3419,33 @@
 
   unwind_protect_ptr (curr_sym_tab);
 
-  reset_parser ();
-
-  parse_status = yyparse ();
-
-  // Important to reset the idea of where input is coming from before
-  // trying to eval the command we just parsed -- it might contain the
-  // name of an function file that still needs to be parsed!
-
-  tree_statement_list *command = global_command;
+  do
+    {
+      parse_status = yyparse ();
+
+      tree_statement_list *command = global_command;
+
+      if (parse_status == 0 && command)
+        {
+	  retval = command->eval (silent, nargout);
+
+	  delete command;
+
+	  command = 0;
+
+	  if (error_state
+	      || tree_return_command::returning
+	      || tree_break_command::breaking
+	      || tree_continue_command::continuing)
+	    break;
+	}
+      else
+	break;
+    }
+  while (parse_status == 0);
 
   unwind_protect::run_frame ("eval_string");
 
-  octave_value_list retval;
-
-  if (parse_status == 0 && command)
-    {
-      retval = command->eval (silent, nargout);
-      delete command;
-    }
-
   return retval;
 }