1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* 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
This commit is contained in:
nobu 2002-10-18 14:13:41 +00:00
parent 6dfb5aa6ac
commit 8232622071
3 changed files with 40 additions and 7 deletions

View file

@ -1,3 +1,11 @@
Fri Oct 18 23:11:21 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
* 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 <knu@iDaemons.org> Fri Oct 18 01:02:44 2002 Akinori MUSHA <knu@iDaemons.org>
* hash.c, eval.c: Use (*_NSGetEnviron()) instead of environ on * hash.c, eval.c: Use (*_NSGetEnviron()) instead of environ on

35
parse.y
View file

@ -119,9 +119,12 @@ static NODE *logop();
static NODE *newline_node(); static NODE *newline_node();
static void fixpos(); static void fixpos();
static int value_expr(); static int value_expr0();
static void void_expr(); static void void_expr0();
static void void_stmts(); 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 *block_append();
static NODE *list_append(); static NODE *list_append();
@ -4697,9 +4700,11 @@ node_assign(lhs, rhs)
} }
static int static int
value_expr(node) value_expr0(node)
NODE *node; NODE *node;
{ {
int cond = 0;
while (node) { while (node) {
switch (nd_type(node)) { switch (nd_type(node)) {
case NODE_CLASS: case NODE_CLASS:
@ -4714,7 +4719,7 @@ value_expr(node)
case NODE_NEXT: case NODE_NEXT:
case NODE_REDO: case NODE_REDO:
case NODE_RETRY: case NODE_RETRY:
yyerror("void value expression"); if (!cond) yyerror("void value expression");
/* or "control never reach"? */ /* or "control never reach"? */
return Qfalse; return Qfalse;
@ -4736,6 +4741,7 @@ value_expr(node)
case NODE_AND: case NODE_AND:
case NODE_OR: case NODE_OR:
cond = 1;
node = node->nd_2nd; node = node->nd_2nd;
break; break;
@ -4752,7 +4758,7 @@ value_expr(node)
} }
static void static void
void_expr(node) void_expr0(node)
NODE *node; NODE *node;
{ {
char *useless = 0; 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 static int
assign_in_cond(node) assign_in_cond(node)
NODE *node; NODE *node;

View file

@ -1,4 +1,4 @@
#define RUBY_VERSION "1.7.3" #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_VERSION_CODE 173
#define RUBY_RELEASE_CODE 20021017 #define RUBY_RELEASE_CODE 20021018