From 8232622071b61db04cd6f0e3a32b7608360e6b25 Mon Sep 17 00:00:00 2001 From: nobu Date: Fri, 18 Oct 2002 14:13:41 +0000 Subject: [PATCH] * parse.y (value_expr0): allow return/break/next/redo/retry in rhs of logical operator. [ruby-dev:18534] * parse.y (remove_begin): eliminate useless NODE_BEGIN. [ruby-dev:18535] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2971 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 8 ++++++++ parse.y | 35 ++++++++++++++++++++++++++++++----- version.h | 4 ++-- 3 files changed, 40 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index f09985e3f2..a6804db67d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +Fri Oct 18 23:11:21 2002 Nobuyoshi Nakada + + * parse.y (value_expr0): allow return/break/next/redo/retry in rhs + of logical operator. [ruby-dev:18534] + + * parse.y (remove_begin): eliminate useless NODE_BEGIN. + [ruby-dev:18535] + Fri Oct 18 01:02:44 2002 Akinori MUSHA * hash.c, eval.c: Use (*_NSGetEnviron()) instead of environ on diff --git a/parse.y b/parse.y index b9ca1fa96c..9d057aa66a 100644 --- a/parse.y +++ b/parse.y @@ -119,9 +119,12 @@ static NODE *logop(); static NODE *newline_node(); static void fixpos(); -static int value_expr(); -static void void_expr(); +static int value_expr0(); +static void void_expr0(); static void void_stmts(); +static NODE *remove_begin(); +#define value_expr(node) value_expr0((node) = remove_begin(node)) +#define void_expr(node) void_expr0((node) = remove_begin(node)) static NODE *block_append(); static NODE *list_append(); @@ -4697,9 +4700,11 @@ node_assign(lhs, rhs) } static int -value_expr(node) +value_expr0(node) NODE *node; { + int cond = 0; + while (node) { switch (nd_type(node)) { case NODE_CLASS: @@ -4714,7 +4719,7 @@ value_expr(node) case NODE_NEXT: case NODE_REDO: case NODE_RETRY: - yyerror("void value expression"); + if (!cond) yyerror("void value expression"); /* or "control never reach"? */ return Qfalse; @@ -4736,6 +4741,7 @@ value_expr(node) case NODE_AND: case NODE_OR: + cond = 1; node = node->nd_2nd; break; @@ -4752,7 +4758,7 @@ value_expr(node) } static void -void_expr(node) +void_expr0(node) NODE *node; { char *useless = 0; @@ -4862,6 +4868,25 @@ void_stmts(node) } } +static NODE * +remove_begin(node) + NODE *node; +{ + NODE **n = &node; + while (*n) { + switch (nd_type(*n)) { + case NODE_NEWLINE: + n = &(*n)->nd_next; + continue; + case NODE_BEGIN: + *n = (*n)->nd_body; + default: + return node; + } + } + return node; +} + static int assign_in_cond(node) NODE *node; diff --git a/version.h b/version.h index 52d3d08d52..13ae7be488 100644 --- a/version.h +++ b/version.h @@ -1,4 +1,4 @@ #define RUBY_VERSION "1.7.3" -#define RUBY_RELEASE_DATE "2002-10-17" +#define RUBY_RELEASE_DATE "2002-10-18" #define RUBY_VERSION_CODE 173 -#define RUBY_RELEASE_CODE 20021017 +#define RUBY_RELEASE_CODE 20021018