summaryrefslogtreecommitdiff
path: root/parse.y
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2001-05-22 08:28:11 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2001-05-22 08:28:11 +0000
commit315cd8341823e129ba5df0f420443e9d06d62c6f (patch)
tree2184e205b25e90012772f2ca77d419ed56a61bff /parse.y
parented6a2bd29f649369beb1b7935cf2625c60581c04 (diff)
* variable.c (rb_alias_variable): should not allow variable
aliasing if $SAFE >= 4. * parse.y (expr): "break" and "next" to take optional expression, which is used as a value for termination. [new, experimental] * eval.c (rb_eval): "break" can give value to terminating method. * eval.c (rb_eval): "break" and "next" to take optional expression. * eval.c (rb_yield_0): "next" can give value to terminating "yield". * eval.c (rb_iterate): "break" can give value to terminating method. * eval.c (proc_call): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@1441 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'parse.y')
-rw-r--r--parse.y49
1 files changed, 24 insertions, 25 deletions
diff --git a/parse.y b/parse.y
index 7e8d8b42a3..94df4497e2 100644
--- a/parse.y
+++ b/parse.y
@@ -426,21 +426,13 @@ expr : kRETURN ret_args
yyerror("return appeared outside of method");
$$ = NEW_RETURN($2);
}
- | kBREAK
+ | kBREAK ret_args
{
- $$ = NEW_BREAK();
+ $$ = NEW_BREAK($2);
}
- | kNEXT
- {
- $$ = NEW_NEXT();
- }
- | kREDO
- {
- $$ = NEW_REDO();
- }
- | kRETRY
+ | kNEXT ret_args
{
- $$ = NEW_RETRY();
+ $$ = NEW_NEXT($2);
}
| command_call
| expr kAND expr
@@ -1142,19 +1134,6 @@ primary : literal
{
$$ = NEW_HASH($2);
}
- | kRETURN '(' ret_args ')'
- {
- if (!compile_for_eval && !in_def && !in_single)
- yyerror("return appeared outside of method");
- value_expr($3);
- $$ = NEW_RETURN($3);
- }
- | kRETURN '(' ')'
- {
- if (!compile_for_eval && !in_def && !in_single)
- yyerror("return appeared outside of method");
- $$ = NEW_RETURN(0);
- }
| kRETURN
{
if (!compile_for_eval && !in_def && !in_single)
@@ -1359,6 +1338,22 @@ primary : literal
local_pop();
in_single--;
}
+ | kBREAK
+ {
+ $$ = NEW_BREAK(0);
+ }
+ | kNEXT
+ {
+ $$ = NEW_NEXT(0);
+ }
+ | kREDO
+ {
+ $$ = NEW_REDO();
+ }
+ | kRETRY
+ {
+ $$ = NEW_RETRY();
+ }
then : term
| kTHEN
@@ -1399,6 +1394,10 @@ opt_block_var : none
{
$$ = $2;
}
+ | '<' f_args '>'
+ {
+ $$ = (NODE*)2;
+ }
do_block : kDO_BLOCK