diff src/oct-parse.yy @ 10188:97ae300aa73a

improve implementation of break, continue, and return commands
author John W. Eaton <jwe@octave.org>
date Fri, 22 Jan 2010 14:37:33 -0500
parents cd96d29c5efa
children 37a08e0ce2dc
line wrap: on
line diff
--- a/src/oct-parse.yy	Fri Jan 22 12:12:21 2010 -0500
+++ b/src/oct-parse.yy	Fri Jan 22 14:37:33 2010 -0500
@@ -2488,16 +2488,7 @@
   int l = break_tok->line ();
   int c = break_tok->column ();
 
-  // We check to see if we are evaluating a function, script, or loop
-  // so that we don't turn eval ("break;") inside a function, script,
-  // or loop into a no-op command.
-
-  if (lexer_flags.looping || current_function_depth > 0
-      || reading_script_file || tree_evaluator::in_fcn_or_script_body
-      || tree_evaluator::in_loop_command)
-    retval = new tree_break_command (l, c);
-  else
-    retval = new tree_no_op_command ("break", l, c);
+  retval = new tree_break_command (l, c);
 
   return retval;
 }
@@ -2512,13 +2503,7 @@
   int l = continue_tok->line ();
   int c = continue_tok->column ();
 
-  // We check to see if we are evaluating a loop so that we don't turn
-  // eval ("continue;") into a no-op command inside a loop.
-
-  if (lexer_flags.looping || tree_evaluator::in_loop_command)
-    retval = new tree_continue_command (l, c);
-  else
-    retval = new tree_no_op_command ("continue", l, c);
+  retval = new tree_continue_command (l, c);
 
   return retval;
 }
@@ -2533,24 +2518,7 @@
   int l = return_tok->line ();
   int c = return_tok->column ();
 
-  if (Vdebugging)
-    {
-      Vdebugging = false;
-
-      retval = new tree_no_op_command ("return", l, c);
-    }
-  else
-    {
-      // We check to see if we are evaluating a function or script so
-      // that we don't turn eval ("return;") inside a function, script,
-      // or loop into a no-op command.
-
-      if (current_function_depth > 0 || reading_script_file
-          || tree_evaluator::in_fcn_or_script_body)
-        retval = new tree_return_command (l, c);
-      else
-        retval = new tree_no_op_command ("return", l, c);
-    }
+  retval = new tree_return_command (l, c);
 
   return retval;
 }