* parse.y (yylex): 'do' should return kDO_BLOCK on EXPR_ENDARG.

* parse.y (singleton): "def (()).a end" dumped core.

* parse.y (range_op): node may be null.

* parse.y (match_gen): ditto.

* parse.y (arg): void value check for "..", "...", "!", and "not".

* parse.y (match_gen): void value check for "=~".

* parse.y (value_expr): check NODE_AND and NODE_OR recursively.

* parse.y (cond0): void value check added for conditionals.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2558 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
matz 2002-06-12 09:22:20 +00:00
Родитель 94f86651d6
Коммит 91511afa9c
2 изменённых файлов: 71 добавлений и 31 удалений

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

@ -2,6 +2,16 @@ Wed Jun 12 02:38:00 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
* parse.y (stmt): fix typo.
Wed Jun 12 01:10:55 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
* parse.y (yylex): 'do' should return kDO_BLOCK on EXPR_ENDARG.
* parse.y (singleton): "def (()).a end" dumped core.
* parse.y (range_op): node may be null.
* parse.y (match_gen): ditto.
Tue Jun 11 19:20:34 2002 WATANABE Hirofumi <eban@ruby-lang.org>
* configure.in (LIBRUBY): rename to lib$(LIBRUBY_SO).a on Cygwin/MinGW.
@ -9,6 +19,16 @@ Tue Jun 11 19:20:34 2002 WATANABE Hirofumi <eban@ruby-lang.org>
* configure.in, cygwin/GNUmakefile: use dllwrap when --disable-shared
is specified.
Tue Jun 11 17:12:04 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
* parse.y (arg): void value check for "..", "...", "!", and "not".
* parse.y (match_gen): void value check for "=~".
* parse.y (value_expr): check NODE_AND and NODE_OR recursively.
* parse.y (cond0): void value check added for conditionals.
Tue Jun 11 13:18:47 2002 Shugo Maeda <shugo@ruby-lang.org>
* lib/net/ftp.rb (noop): new method.

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

@ -898,10 +898,14 @@ arg : lhs '=' arg
}
| arg tDOT2 arg
{
value_expr($1);
value_expr($3);
$$ = NEW_DOT2($1, $3);
}
| arg tDOT3 arg
{
value_expr($1);
value_expr($3);
$$ = NEW_DOT3($1, $3);
}
| arg '+' arg
@ -1003,7 +1007,6 @@ arg : lhs '=' arg
}
| '!' arg
{
value_expr($2);
$$ = NEW_NOT(cond($2));
}
| '~' arg
@ -1292,7 +1295,7 @@ primary : literal
}
| tLPAREN_ARG expr {lex_state = EXPR_ENDARG;} ')'
{
rb_warning("%s (...) interpreted as grouped expression", rb_id2name($<id>1));
rb_warning("(...) interpreted as grouped expression");
$$ = $2;
}
| tLPAREN compstmt ')'
@ -1983,19 +1986,24 @@ singleton : var_ref
}
| '(' {lex_state = EXPR_BEG;} expr opt_nl ')'
{
switch (nd_type($3)) {
case NODE_STR:
case NODE_DSTR:
case NODE_XSTR:
case NODE_DXSTR:
case NODE_DREGX:
case NODE_LIT:
case NODE_ARRAY:
case NODE_ZARRAY:
yyerror("can't define single method for literals.");
default:
value_expr($3);
break;
if ($3 == 0) {
yyerror("can't define single method for ().");
}
else {
switch (nd_type($3)) {
case NODE_STR:
case NODE_DSTR:
case NODE_XSTR:
case NODE_DXSTR:
case NODE_DREGX:
case NODE_LIT:
case NODE_ARRAY:
case NODE_ZARRAY:
yyerror("can't define single method for literals");
default:
value_expr($3);
break;
}
}
$$ = $3;
}
@ -3980,6 +3988,8 @@ yylex()
if (COND_P()) return kDO_COND;
if (CMDARG_P() && state != EXPR_CMDARG)
return kDO_BLOCK;
if (state == EXPR_ENDARG)
return kDO_BLOCK;
return kDO;
}
if (state == EXPR_BEG)
@ -4380,25 +4390,31 @@ match_gen(node1, node2)
{
local_cnt('~');
switch (nd_type(node1)) {
case NODE_DREGX:
case NODE_DREGX_ONCE:
return NEW_MATCH2(node1, node2);
case NODE_LIT:
if (TYPE(node1->nd_lit) == T_REGEXP) {
value_expr(node1);
value_expr(node2);
if (node1) {
switch (nd_type(node1)) {
case NODE_DREGX:
case NODE_DREGX_ONCE:
return NEW_MATCH2(node1, node2);
case NODE_LIT:
if (TYPE(node1->nd_lit) == T_REGEXP) {
return NEW_MATCH2(node1, node2);
}
}
}
switch (nd_type(node2)) {
case NODE_DREGX:
case NODE_DREGX_ONCE:
return NEW_MATCH3(node2, node1);
case NODE_LIT:
if (TYPE(node2->nd_lit) == T_REGEXP) {
if (node2) {
switch (nd_type(node2)) {
case NODE_DREGX:
case NODE_DREGX_ONCE:
return NEW_MATCH3(node2, node1);
case NODE_LIT:
if (TYPE(node2->nd_lit) == T_REGEXP) {
return NEW_MATCH3(node2, node1);
}
}
}
@ -4519,7 +4535,6 @@ aryset(recv, idx)
NODE *recv, *idx;
{
value_expr(recv);
return NEW_CALL(recv, tASET, idx);
}
@ -4538,7 +4553,6 @@ attrset(recv, id)
ID id;
{
value_expr(recv);
return NEW_CALL(recv, rb_id_attrset(id), 0);
}
@ -4647,6 +4661,10 @@ value_expr(node)
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);
@ -4843,6 +4861,7 @@ range_op(node)
enum node_type type;
if (!e_option_supplied()) return node;
if (node == 0) return 0;
node = cond0(node);
type = nd_type(node);
@ -4861,6 +4880,7 @@ cond0(node)
enum node_type type = nd_type(node);
assign_in_cond(node);
value_expr(node);
switch (type) {
case NODE_DSTR: