diff src/parse.y @ 3883:69b6bd271277

[project @ 2002-04-02 21:05:10 by jwe]
author jwe
date Tue, 02 Apr 2002 21:05:10 +0000
parents c34d631dee18
children 1dbe160ea0d1
line wrap: on
line diff
--- a/src/parse.y	Tue Apr 02 18:25:48 2002 +0000
+++ b/src/parse.y	Tue Apr 02 21:05:10 2002 +0000
@@ -462,12 +462,6 @@
 		    promptflag = 1;
 		    YYACCEPT;
 		  }
-		| END_OF_INPUT
-		  {
-		    global_command = 0;
-		    promptflag = 1;
-		    YYACCEPT;
-		  }
 		| simple_list parse_error
 		  { ABORT_PARSE; }
 		| parse_error
@@ -476,6 +470,11 @@
 
 input1		: '\n'
 		  { $$ = 0; }
+		| END_OF_INPUT
+		  {
+		    parser_end_of_input = 1;
+		    $$ = 0;
+		  }
 		| simple_list
 		  { $$ = $1; }
 		| simple_list '\n'
@@ -2732,10 +2731,12 @@
   unwind_protect_bool (line_editing);
   unwind_protect_bool (input_from_command_line_file);
   unwind_protect_bool (get_input_from_eval_string);
+  unwind_protect_bool (parser_end_of_input);
 
   line_editing = false;
   input_from_command_line_file = false;
   get_input_from_eval_string = false;
+  parser_end_of_input = false;
 
   unwind_protect_ptr (curr_sym_tab);
 
@@ -2746,36 +2747,39 @@
 
       retval = yyparse ();
 
-      if (retval == 0 && global_command)
-	{
-	  global_command->eval ();
-
-	  delete global_command;
-
-	  global_command = 0;
-
-	  bool quit = (tree_return_command::returning
-		       || tree_break_command::breaking);
-
-	  if (tree_return_command::returning)
-	    tree_return_command::returning = 0;
-
-	  if (tree_break_command::breaking)
-	    tree_break_command::breaking--;
-
-	  if (error_state)
+      if (retval == 0)
+        {
+          if (global_command)
 	    {
-	      error ("near line %d of file `%s'", input_line_number,
-		     curr_fcn_file_full_name.c_str ());
-
-	      break;
+	      global_command->eval ();
+
+	      delete global_command;
+
+	      global_command = 0;
+
+	      bool quit = (tree_return_command::returning
+			   || tree_break_command::breaking);
+
+	      if (tree_return_command::returning)
+		tree_return_command::returning = 0;
+
+	      if (tree_break_command::breaking)
+		tree_break_command::breaking--;
+
+	      if (error_state)
+		{
+		  error ("near line %d of file `%s'", input_line_number,
+			 curr_fcn_file_full_name.c_str ());
+
+		  break;
+		}
+
+	      if (quit)
+		break;
 	    }
-
-	  if (quit)
+	  else if (parser_end_of_input)
 	    break;
-	}
-      else
-	break;
+        }
     }
   while (retval == 0);
 
@@ -3141,12 +3145,14 @@
 	  unwind_protect_bool (reading_fcn_file);
 	  unwind_protect_bool (input_from_command_line_file);
 	  unwind_protect_bool (get_input_from_eval_string);
+	  unwind_protect_bool (parser_end_of_input);
 
 	  Vecho_executing_commands = ECHO_OFF;
 	  Vsaving_history = false;
 	  reading_fcn_file = true;
 	  input_from_command_line_file = false;
 	  get_input_from_eval_string = false;
+	  parser_end_of_input = false;
 
 	  YY_BUFFER_STATE old_buf = current_buffer ();
 	  YY_BUFFER_STATE new_buf = create_buffer (ffile);
@@ -3406,11 +3412,13 @@
   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_bool (parser_end_of_input);
   unwind_protect_str (current_eval_string);
 
   get_input_from_eval_string = true;
   input_from_eval_string_pending = true;
   input_from_command_line_file = false;
+  parser_end_of_input = false;
   current_eval_string = s;
 
   unwind_protect_ptr (global_command);
@@ -3431,22 +3439,25 @@
 
       tree_statement_list *command = global_command;
 
-      if (parse_status == 0 && command)
+      if (parse_status == 0)
         {
-	  retval = command->eval (silent, nargout);
-
-	  delete command;
-
-	  command = 0;
-
-	  if (error_state
-	      || tree_return_command::returning
-	      || tree_break_command::breaking
-	      || tree_continue_command::continuing)
+	  if (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 if (parser_end_of_input)
 	    break;
-	}
-      else
-	break;
+        }
     }
   while (parse_status == 0);