* parse.y (yylex): should pushback proper char after '<<'.

* parse.y (range_op, cond0, cond): get rid of doubled warnings.

* parse.y (value_expr): reduce recursion level.

* parse.y (logop): ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2578 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2002-06-18 03:53:23 +00:00
Родитель 9c44d6a05c
Коммит 12c00312aa
3 изменённых файлов: 66 добавлений и 39 удалений

Просмотреть файл

@ -1,3 +1,13 @@
Tue Jun 18 12:50:17 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
* parse.y (yylex): should pushback proper char after '<<'.
* parse.y (range_op, cond0, cond): get rid of doubled warnings.
* parse.y (value_expr): reduce recursion level.
* parse.y (logop): ditto.
Mon Jun 17 10:51:37 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net> Mon Jun 17 10:51:37 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
* dln.c (dln_load): need to preserve dln_strerror() result, * dln.c (dln_load): need to preserve dln_strerror() result,

91
parse.y
Просмотреть файл

@ -3215,7 +3215,7 @@ yylex()
return tLEQ; return tLEQ;
} }
if (c == '<') { if (c == '<') {
if (nextc() == '=') { if ((c = nextc()) == '=') {
lex_state = EXPR_BEG; lex_state = EXPR_BEG;
yylval.id = tLSHFT; yylval.id = tLSHFT;
return tOP_ASGN; return tOP_ASGN;
@ -4643,47 +4643,55 @@ static int
value_expr(node) value_expr(node)
NODE *node; NODE *node;
{ {
if (node == 0) return Qtrue; while (node) {
switch (nd_type(node)) {
case NODE_CLASS:
case NODE_MODULE:
case NODE_DEFN:
case NODE_DEFS:
rb_warning("void value expression");
return Qfalse;
switch (nd_type(node)) { case NODE_RETURN:
case NODE_CLASS: case NODE_BREAK:
case NODE_MODULE: case NODE_NEXT:
case NODE_DEFN: case NODE_REDO:
case NODE_DEFS: case NODE_RETRY:
rb_warning("void value expression"); yyerror("void value expression");
return Qfalse; /* or "control never reach"? */
return Qfalse;
case NODE_RETURN: case NODE_BLOCK:
case NODE_BREAK: while (node->nd_next) {
case NODE_NEXT: node = node->nd_next;
case NODE_REDO: }
case NODE_RETRY: node = node->nd_head;
yyerror("void value expression"); break;
/* or "control never reach"? */
return Qfalse;
case NODE_BLOCK: case NODE_BEGIN:
while (node->nd_next) { node = node->nd_body;
break;
case NODE_IF:
if (!value_expr(node->nd_body)) return Qfalse;
node = node->nd_else;
break;
case NODE_AND:
case NODE_OR:
node = node->nd_2nd;
break;
case NODE_NEWLINE:
node = node->nd_next; node = node->nd_next;
break;
default:
return Qtrue;
} }
return value_expr(node->nd_head);
case NODE_BEGIN:
return value_expr(node->nd_body);
case NODE_IF:
return value_expr(node->nd_body) && value_expr(node->nd_else);
case NODE_AND:
case NODE_OR:
return value_expr(node->nd_2nd);
case NODE_NEWLINE:
return value_expr(node->nd_next);
default:
return Qtrue;
} }
return Qtrue;
} }
static void static void
@ -4876,6 +4884,7 @@ range_op(node)
if (!e_option_supplied()) return node; if (!e_option_supplied()) return node;
if (node == 0) return 0; if (node == 0) return 0;
value_expr(node);
node = cond0(node); node = cond0(node);
type = nd_type(node); type = nd_type(node);
if (type == NODE_NEWLINE) node = node->nd_next; if (type == NODE_NEWLINE) node = node->nd_next;
@ -4893,7 +4902,6 @@ cond0(node)
enum node_type type = nd_type(node); enum node_type type = nd_type(node);
assign_in_cond(node); assign_in_cond(node);
value_expr(node);
switch (type) { switch (type) {
case NODE_DSTR: case NODE_DSTR:
@ -4945,6 +4953,7 @@ cond(node)
NODE *node; NODE *node;
{ {
if (node == 0) return 0; if (node == 0) return 0;
value_expr(node);
if (nd_type(node) == NODE_NEWLINE){ if (nd_type(node) == NODE_NEWLINE){
node->nd_next = cond0(node->nd_next); node->nd_next = cond0(node->nd_next);
return node; return node;
@ -4958,6 +4967,14 @@ logop(type, left, right)
NODE *left, *right; NODE *left, *right;
{ {
value_expr(left); value_expr(left);
if (nd_type(left) == type) {
NODE *node = left, *second;
while ((second = node->nd_2nd) != 0 && nd_type(second) == type) {
node = second;
}
node->nd_2nd = rb_node_newnode(type, second, right, 0);
return left;
}
return rb_node_newnode(type, left, right, 0); return rb_node_newnode(type, left, right, 0);
} }

Просмотреть файл

@ -1,4 +1,4 @@
#define RUBY_VERSION "1.7.2" #define RUBY_VERSION "1.7.2"
#define RUBY_RELEASE_DATE "2002-06-17" #define RUBY_RELEASE_DATE "2002-06-18"
#define RUBY_VERSION_CODE 172 #define RUBY_VERSION_CODE 172
#define RUBY_RELEASE_CODE 20020617 #define RUBY_RELEASE_CODE 20020618