diff src/parse.y @ 4207:fa3482b34599

[project @ 2002-12-03 18:22:05 by jwe]
author jwe
date Tue, 03 Dec 2002 18:22:51 +0000
parents bf9c5ca4c3f3
children 23d06c9e1edd
line wrap: on
line diff
--- a/src/parse.y	Fri Nov 29 20:13:01 2002 +0000
+++ b/src/parse.y	Tue Dec 03 18:22:51 2002 +0000
@@ -219,17 +219,17 @@
 		  tree_expression *expr, tree_statement_list *body,
 		  token *end_tok, octave_comment_list *lc);
 
-// Build a break expression.
-static tree_expression *
-make_break_expression (token *break_tok);
-
-// Build a continue expression.
-static tree_expression *
-make_continue_expression (token *continue_tok);
-
-// Build a return expression.
-static tree_expression *
-make_return_expression (token *return_tok);
+// Build a break command.
+static tree_command *
+make_break_command (token *break_tok);
+
+// Build a continue command.
+static tree_command *
+make_continue_command (token *continue_tok);
+
+// Build a return command.
+static tree_command *
+make_return_command (token *return_tok);
 
 // Start an if command.
 static tree_if_command_list *
@@ -418,9 +418,8 @@
 %type <tree_matrix_type> matrix_rows matrix_rows1
 %type <tree_cell_type> cell_rows cell_rows1
 %type <tree_expression_type> title matrix cell
-%type <tree_expression_type> primary_expr postfix_expr prefix_expr
-%type <tree_expression_type> binary_expr simple_expr colon_expr
-%type <tree_expression_type> assign_expr jump_expr expression
+%type <tree_expression_type> primary_expr postfix_expr prefix_expr binary_expr
+%type <tree_expression_type> simple_expr colon_expr assign_expr expression
 %type <tree_identifier_type> identifier
 %type <octave_user_function_type> function1 function2 function3
 %type <tree_index_expression_type> word_list_cmd
@@ -430,7 +429,7 @@
 %type <tree_parameter_list_type> param_list param_list1
 %type <tree_parameter_list_type> return_list return_list1
 %type <tree_command_type> command select_command loop_command
-%type <tree_command_type> except_command function
+%type <tree_command_type> jump_command except_command function
 %type <tree_if_command_type> if_command
 %type <tree_if_clause_type> elseif_clause else_clause
 %type <tree_if_command_list_type> if_cmd_list1 if_cmd_list
@@ -787,8 +786,6 @@
 
 simple_expr	: colon_expr
 		  { $$ = $1; }
-		| jump_expr
-		  { $$ = $1; }
 		| simple_expr LSHIFT simple_expr
 		  { $$ = make_binary_op (LSHIFT, $1, $2, $3); }
 		| simple_expr RSHIFT simple_expr
@@ -894,6 +891,8 @@
 		  { $$ = $1; }
 		| loop_command
 		  { $$ = $1; }
+		| jump_command
+		  { $$ = $1; }
 		| except_command
 		  { $$ = $1; }
 		| function
@@ -1042,19 +1041,19 @@
 // Jumping
 // =======
 
-jump_expr	: BREAK
+jump_command	: BREAK
 		  {
-		    if (! ($$ = make_break_expression ($1)))
+		    if (! ($$ = make_break_command ($1)))
 		      ABORT_PARSE;
 		  }
 		| CONTINUE
 		  {
-		    if (! ($$ = make_continue_expression ($1)))
+		    if (! ($$ = make_continue_command ($1)))
 		      ABORT_PARSE;
 		  }
 		| FUNC_RET
 		  {
-		    if (! ($$ = make_return_expression ($1)))
+		    if (! ($$ = make_return_command ($1)))
 		      ABORT_PARSE;
 		  }
 		;
@@ -2244,12 +2243,12 @@
   return retval;
 }
 
-// Build a break expression.
-
-static tree_expression *
-make_break_expression (token *break_tok)
+// Build a break command.
+
+static tree_command *
+make_break_command (token *break_tok)
 {
-  tree_expression *retval = 0;
+  tree_command *retval = 0;
 
   int l = break_tok->line ();
   int c = break_tok->column ();
@@ -2257,46 +2256,46 @@
   if (lexer_flags.looping || lexer_flags.defining_func
       || reading_script_file || evaluating_function_body
       || evaluating_looping_command)
-    retval = new tree_break_expression (l, c);
+    retval = new tree_break_command (l, c);
   else
-    yyerror ("invalid use of break");
+    retval = new tree_no_op_command ("break", l, c);
 
   return retval;
 }
 
-// Build a continue expression.
-
-static tree_expression *
-make_continue_expression (token *continue_tok)
+// Build a continue command.
+
+static tree_command *
+make_continue_command (token *continue_tok)
 {
-  tree_expression *retval = 0;
+  tree_command *retval = 0;
 
   int l = continue_tok->line ();
   int c = continue_tok->column ();
 
   if (lexer_flags.looping || evaluating_looping_command)
-    retval = new tree_continue_expression (l, c);
+    retval = new tree_continue_command (l, c);
   else
-    yyerror ("invalid use of continue");
+    retval = new tree_no_op_command ("continue", l, c);
 
   return retval;
 }
 
-// Build a return expression.
-
-static tree_expression *
-make_return_expression (token *return_tok)
+// Build a return command.
+
+static tree_command *
+make_return_command (token *return_tok)
 {
-  tree_expression *retval = 0;
+  tree_command *retval = 0;
 
   int l = return_tok->line ();
   int c = return_tok->column ();
 
   if (lexer_flags.defining_func || reading_script_file
       || evaluating_function_body)
-    retval = new tree_return_expression (l, c);
+    retval = new tree_return_command (l, c);
   else
-    yyerror ("invalid use of return");
+    retval = new tree_no_op_command ("return", l, c);
 
   return retval;
 }
@@ -2866,14 +2865,14 @@
 
 	      OCTAVE_QUIT;
 
-	      bool quit = (tree_return_expression::returning
-			   || tree_break_expression::breaking);
-
-	      if (tree_return_expression::returning)
-		tree_return_expression::returning = 0;
-
-	      if (tree_break_expression::breaking)
-		tree_break_expression::breaking--;
+	      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)
 		{
@@ -3559,9 +3558,9 @@
 	      command = 0;
 
 	      if (error_state
-		  || tree_return_expression::returning
-		  || tree_break_expression::breaking
-		  || tree_continue_expression::continuing)
+		  || tree_return_command::returning
+		  || tree_break_command::breaking
+		  || tree_continue_command::continuing)
 		break;
 	    }
 	  else if (parser_end_of_input)