* parse.y (primary): while/until statement modifiers to "begin"
statement now work as "do .. while" even when begin statement has "rescue" or "ensure" [new]. * parse.y (bodystmt): rescue/ensure is allowed at every bodies, i.e. method bodies, begin bodies, class bodies[new], and module bodies[new]. * ext/socket/socket.c (sock_addrinfo): should specify ai_socktype for getaddrinfo hints. * eval.c (rb_f_abort): embed aborting message into exception object [new]. * eval.c (terminate_process): utility function for exit and abort. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2285 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
2244b5fabf
commit
f60b87038d
27
ChangeLog
27
ChangeLog
@ -1,3 +1,30 @@
|
|||||||
|
Tue Mar 26 01:56:33 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||||
|
|
||||||
|
* parse.y (primary): while/until statement modifiers to "begin"
|
||||||
|
statement now work as "do .. while" even when begin statement
|
||||||
|
has "rescue" or "ensure" [new].
|
||||||
|
|
||||||
|
* parse.y (bodystmt): rescue/ensure is allowed at every bodies,
|
||||||
|
i.e. method bodies, begin bodies, class bodies[new], and module
|
||||||
|
bodies[new].
|
||||||
|
|
||||||
|
Mon Mar 25 22:10:04 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||||
|
|
||||||
|
* ext/socket/socket.c (sock_addrinfo): should specify ai_socktype
|
||||||
|
for getaddrinfo hints.
|
||||||
|
|
||||||
|
Mon Mar 25 17:18:48 2002 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
|
||||||
|
|
||||||
|
* dir.c (rb_push_glob): local variable 'maxnest' was
|
||||||
|
uninitialized.
|
||||||
|
|
||||||
|
Mon Mar 25 16:53:30 2002 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||||
|
|
||||||
|
* eval.c (rb_f_abort): embed aborting message into exception
|
||||||
|
object [new].
|
||||||
|
|
||||||
|
* eval.c (terminate_process): utility function for exit and abort.
|
||||||
|
|
||||||
Tue Mar 26 14:04:47 2002 okabe katsuyuki <HGC02147@nifty.ne.jp>
|
Tue Mar 26 14:04:47 2002 okabe katsuyuki <HGC02147@nifty.ne.jp>
|
||||||
|
|
||||||
* win32/mkexports.rb: support VC++.NET.
|
* win32/mkexports.rb: support VC++.NET.
|
||||||
|
44
eval.c
44
eval.c
@ -1091,8 +1091,6 @@ int ruby_in_eval;
|
|||||||
static void rb_thread_cleanup _((void));
|
static void rb_thread_cleanup _((void));
|
||||||
static void rb_thread_wait_other_threads _((void));
|
static void rb_thread_wait_other_threads _((void));
|
||||||
|
|
||||||
static int exit_status;
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
error_handle(ex)
|
error_handle(ex)
|
||||||
int ex;
|
int ex;
|
||||||
@ -1130,7 +1128,8 @@ error_handle(ex)
|
|||||||
case TAG_RAISE:
|
case TAG_RAISE:
|
||||||
case TAG_FATAL:
|
case TAG_FATAL:
|
||||||
if (rb_obj_is_kind_of(ruby_errinfo, rb_eSystemExit)) {
|
if (rb_obj_is_kind_of(ruby_errinfo, rb_eSystemExit)) {
|
||||||
ex = exit_status;
|
VALUE st = rb_iv_get(ruby_errinfo, "status");
|
||||||
|
ex = NUM2INT(st);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
error_print();
|
error_print();
|
||||||
@ -3453,17 +3452,25 @@ rb_mod_method_defined(mod, mid)
|
|||||||
return Qfalse;
|
return Qfalse;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NORETURN(static void terminate_process _((int, const char*, int)));
|
||||||
|
static void
|
||||||
|
terminate_process(status, mesg, mlen)
|
||||||
|
int status;
|
||||||
|
const char *mesg;
|
||||||
|
int mlen;
|
||||||
|
{
|
||||||
|
VALUE exit = rb_exc_new(rb_eSystemExit, mesg, mlen);
|
||||||
|
|
||||||
|
rb_iv_set(exit, "status", INT2NUM(status));
|
||||||
|
rb_exc_raise(exit);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
rb_exit(status)
|
rb_exit(status)
|
||||||
int status;
|
int status;
|
||||||
{
|
{
|
||||||
if (prot_tag) {
|
if (prot_tag) {
|
||||||
VALUE exit;
|
terminate_process(status, "exit", 4);
|
||||||
|
|
||||||
exit_status = status;
|
|
||||||
exit = rb_exc_new2(rb_eSystemExit, "exit");
|
|
||||||
rb_iv_set(exit, "status", INT2NUM(status));
|
|
||||||
rb_exc_raise(exit);
|
|
||||||
}
|
}
|
||||||
ruby_finalize();
|
ruby_finalize();
|
||||||
exit(status);
|
exit(status);
|
||||||
@ -3489,15 +3496,6 @@ rb_f_exit(argc, argv, obj)
|
|||||||
return Qnil; /* not reached */
|
return Qnil; /* not reached */
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
rb_abort()
|
|
||||||
{
|
|
||||||
if (!NIL_P(ruby_errinfo)) {
|
|
||||||
error_print();
|
|
||||||
}
|
|
||||||
rb_exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
rb_f_abort(argc, argv)
|
rb_f_abort(argc, argv)
|
||||||
int argc;
|
int argc;
|
||||||
@ -3505,14 +3503,18 @@ rb_f_abort(argc, argv)
|
|||||||
{
|
{
|
||||||
rb_secure(4);
|
rb_secure(4);
|
||||||
if (argc == 0) {
|
if (argc == 0) {
|
||||||
rb_abort();
|
if (!NIL_P(ruby_errinfo)) {
|
||||||
|
error_print();
|
||||||
|
}
|
||||||
|
rb_exit(1);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
VALUE mesg;
|
VALUE mesg;
|
||||||
|
|
||||||
rb_scan_args(argc, argv, "01", &mesg);
|
rb_scan_args(argc, argv, "1", &mesg);
|
||||||
|
StringValue(argv[0]);
|
||||||
rb_io_puts(argc, argv, rb_stderr);
|
rb_io_puts(argc, argv, rb_stderr);
|
||||||
rb_exit(1);
|
terminate_process(1, RSTRING(argv[0])->ptr, RSTRING(argv[0])->len);
|
||||||
}
|
}
|
||||||
return Qnil; /* not reached */
|
return Qnil; /* not reached */
|
||||||
}
|
}
|
||||||
|
@ -591,6 +591,7 @@ sock_addrinfo(host, port, flags)
|
|||||||
|
|
||||||
MEMZERO(&hints, struct addrinfo, 1);
|
MEMZERO(&hints, struct addrinfo, 1);
|
||||||
hints.ai_family = PF_UNSPEC;
|
hints.ai_family = PF_UNSPEC;
|
||||||
|
hints.ai_socktype = SOCK_STREAM;
|
||||||
hints.ai_flags = flags;
|
hints.ai_flags = flags;
|
||||||
error = getaddrinfo(hostp, portp, &hints, &res);
|
error = getaddrinfo(hostp, portp, &hints, &res);
|
||||||
if (error) {
|
if (error) {
|
||||||
|
190
parse.y
190
parse.y
@ -212,9 +212,9 @@ static void top_local_setup();
|
|||||||
|
|
||||||
%type <node> singleton string
|
%type <node> singleton string
|
||||||
%type <val> literal numeric
|
%type <val> literal numeric
|
||||||
%type <node> compstmt stmts stmt expr arg primary command command_call method_call
|
%type <node> bodystmt compstmt stmts stmt expr arg primary command command_call method_call
|
||||||
%type <node> expr_value arg_value primary_value block_call_value
|
%type <node> expr_value arg_value primary_value block_call_value
|
||||||
%type <node> if_tail opt_else case_body cases rescue exc_list exc_var ensure
|
%type <node> if_tail opt_else case_body cases opt_rescue exc_list exc_var opt_ensure
|
||||||
%type <node> args when_args call_args call_args2 open_args paren_args opt_paren_args
|
%type <node> args when_args call_args call_args2 open_args paren_args opt_paren_args
|
||||||
%type <node> command_args aref_args opt_block_arg block_arg var_ref var_lhs
|
%type <node> command_args aref_args opt_block_arg block_arg var_ref var_lhs
|
||||||
%type <node> mrhs mrhs_basic superclass block_call block_command
|
%type <node> mrhs mrhs_basic superclass block_call block_command
|
||||||
@ -304,12 +304,34 @@ program : {
|
|||||||
class_nest = 0;
|
class_nest = 0;
|
||||||
ruby_dyna_vars = $<vars>1;
|
ruby_dyna_vars = $<vars>1;
|
||||||
}
|
}
|
||||||
|
;
|
||||||
|
|
||||||
|
bodystmt : compstmt
|
||||||
|
opt_rescue
|
||||||
|
opt_else
|
||||||
|
opt_ensure
|
||||||
|
{
|
||||||
|
$$ = $1;
|
||||||
|
if ($2) {
|
||||||
|
$$ = NEW_RESCUE($1, $2, $3);
|
||||||
|
}
|
||||||
|
else if ($3) {
|
||||||
|
rb_warn("else without rescue is useless");
|
||||||
|
$$ = block_append($$, $4);
|
||||||
|
}
|
||||||
|
if ($4) {
|
||||||
|
$$ = NEW_ENSURE($$, $4);
|
||||||
|
}
|
||||||
|
fixpos($$, $1);
|
||||||
|
}
|
||||||
|
;
|
||||||
|
|
||||||
compstmt : stmts opt_terms
|
compstmt : stmts opt_terms
|
||||||
{
|
{
|
||||||
void_stmts($1);
|
void_stmts($1);
|
||||||
$$ = $1;
|
$$ = $1;
|
||||||
}
|
}
|
||||||
|
;
|
||||||
|
|
||||||
stmts : none
|
stmts : none
|
||||||
| stmt
|
| stmt
|
||||||
@ -324,6 +346,7 @@ stmts : none
|
|||||||
{
|
{
|
||||||
$$ = $2;
|
$$ = $2;
|
||||||
}
|
}
|
||||||
|
;
|
||||||
|
|
||||||
stmt : kALIAS fitem {lex_state = EXPR_FNAME;} fitem
|
stmt : kALIAS fitem {lex_state = EXPR_FNAME;} fitem
|
||||||
{
|
{
|
||||||
@ -510,6 +533,7 @@ stmt : kALIAS fitem {lex_state = EXPR_FNAME;} fitem
|
|||||||
$$ = $1;
|
$$ = $1;
|
||||||
}
|
}
|
||||||
| expr
|
| expr
|
||||||
|
;
|
||||||
|
|
||||||
expr : kRETURN call_args
|
expr : kRETURN call_args
|
||||||
{
|
{
|
||||||
@ -543,15 +567,18 @@ expr : kRETURN call_args
|
|||||||
$$ = NEW_NOT(cond($2));
|
$$ = NEW_NOT(cond($2));
|
||||||
}
|
}
|
||||||
| arg
|
| arg
|
||||||
|
;
|
||||||
|
|
||||||
expr_value : expr
|
expr_value : expr
|
||||||
{
|
{
|
||||||
value_expr($$);
|
value_expr($$);
|
||||||
$$ = $1;
|
$$ = $1;
|
||||||
}
|
}
|
||||||
|
;
|
||||||
|
|
||||||
command_call : command
|
command_call : command
|
||||||
| block_command
|
| block_command
|
||||||
|
;
|
||||||
|
|
||||||
block_command : block_call
|
block_command : block_call
|
||||||
| block_call_value '.' operation2 command_args
|
| block_call_value '.' operation2 command_args
|
||||||
@ -562,6 +589,7 @@ block_command : block_call
|
|||||||
{
|
{
|
||||||
$$ = new_call($1, $3, $4);
|
$$ = new_call($1, $3, $4);
|
||||||
}
|
}
|
||||||
|
;
|
||||||
|
|
||||||
command : operation command_args
|
command : operation command_args
|
||||||
{
|
{
|
||||||
@ -590,18 +618,21 @@ command : operation command_args
|
|||||||
$$ = NEW_YIELD(ret_args($2));
|
$$ = NEW_YIELD(ret_args($2));
|
||||||
fixpos($$, $2);
|
fixpos($$, $2);
|
||||||
}
|
}
|
||||||
|
;
|
||||||
|
|
||||||
mlhs : mlhs_basic
|
mlhs : mlhs_basic
|
||||||
| tLPAREN mlhs_entry ')'
|
| tLPAREN mlhs_entry ')'
|
||||||
{
|
{
|
||||||
$$ = $2;
|
$$ = $2;
|
||||||
}
|
}
|
||||||
|
;
|
||||||
|
|
||||||
mlhs_entry : mlhs_basic
|
mlhs_entry : mlhs_basic
|
||||||
| tLPAREN mlhs_entry ')'
|
| tLPAREN mlhs_entry ')'
|
||||||
{
|
{
|
||||||
$$ = NEW_MASGN(NEW_LIST($2), 0);
|
$$ = NEW_MASGN(NEW_LIST($2), 0);
|
||||||
}
|
}
|
||||||
|
;
|
||||||
|
|
||||||
mlhs_basic : mlhs_head
|
mlhs_basic : mlhs_head
|
||||||
{
|
{
|
||||||
@ -627,12 +658,14 @@ mlhs_basic : mlhs_head
|
|||||||
{
|
{
|
||||||
$$ = NEW_MASGN(0, -1);
|
$$ = NEW_MASGN(0, -1);
|
||||||
}
|
}
|
||||||
|
;
|
||||||
|
|
||||||
mlhs_item : mlhs_node
|
mlhs_item : mlhs_node
|
||||||
| tLPAREN mlhs_entry ')'
|
| tLPAREN mlhs_entry ')'
|
||||||
{
|
{
|
||||||
$$ = $2;
|
$$ = $2;
|
||||||
}
|
}
|
||||||
|
;
|
||||||
|
|
||||||
mlhs_head : mlhs_item ','
|
mlhs_head : mlhs_item ','
|
||||||
{
|
{
|
||||||
@ -642,6 +675,7 @@ mlhs_head : mlhs_item ','
|
|||||||
{
|
{
|
||||||
$$ = list_append($1, $2);
|
$$ = list_append($1, $2);
|
||||||
}
|
}
|
||||||
|
;
|
||||||
|
|
||||||
mlhs_node : variable
|
mlhs_node : variable
|
||||||
{
|
{
|
||||||
@ -668,6 +702,7 @@ mlhs_node : variable
|
|||||||
rb_backref_error($1);
|
rb_backref_error($1);
|
||||||
$$ = 0;
|
$$ = 0;
|
||||||
}
|
}
|
||||||
|
;
|
||||||
|
|
||||||
lhs : variable
|
lhs : variable
|
||||||
{
|
{
|
||||||
@ -694,12 +729,14 @@ lhs : variable
|
|||||||
rb_backref_error($1);
|
rb_backref_error($1);
|
||||||
$$ = 0;
|
$$ = 0;
|
||||||
}
|
}
|
||||||
|
;
|
||||||
|
|
||||||
cname : tIDENTIFIER
|
cname : tIDENTIFIER
|
||||||
{
|
{
|
||||||
yyerror("class/module name must be CONSTANT");
|
yyerror("class/module name must be CONSTANT");
|
||||||
}
|
}
|
||||||
| tCONSTANT
|
| tCONSTANT
|
||||||
|
;
|
||||||
|
|
||||||
fname : tIDENTIFIER
|
fname : tIDENTIFIER
|
||||||
| tCONSTANT
|
| tCONSTANT
|
||||||
@ -714,9 +751,11 @@ fname : tIDENTIFIER
|
|||||||
lex_state = EXPR_END;
|
lex_state = EXPR_END;
|
||||||
$$ = $<id>1;
|
$$ = $<id>1;
|
||||||
}
|
}
|
||||||
|
;
|
||||||
|
|
||||||
fitem : fname
|
fitem : fname
|
||||||
| symbol
|
| symbol
|
||||||
|
;
|
||||||
|
|
||||||
undef_list : fitem
|
undef_list : fitem
|
||||||
{
|
{
|
||||||
@ -726,6 +765,7 @@ undef_list : fitem
|
|||||||
{
|
{
|
||||||
$$ = block_append($1, NEW_UNDEF($4));
|
$$ = block_append($1, NEW_UNDEF($4));
|
||||||
}
|
}
|
||||||
|
;
|
||||||
|
|
||||||
op : '|' { $$ = '|'; }
|
op : '|' { $$ = '|'; }
|
||||||
| '^' { $$ = '^'; }
|
| '^' { $$ = '^'; }
|
||||||
@ -753,6 +793,7 @@ op : '|' { $$ = '|'; }
|
|||||||
| tAREF { $$ = tAREF; }
|
| tAREF { $$ = tAREF; }
|
||||||
| tASET { $$ = tASET; }
|
| tASET { $$ = tASET; }
|
||||||
| '`' { $$ = '`'; }
|
| '`' { $$ = '`'; }
|
||||||
|
;
|
||||||
|
|
||||||
reswords : k__LINE__ | k__FILE__ | klBEGIN | klEND
|
reswords : k__LINE__ | k__FILE__ | klBEGIN | klEND
|
||||||
| kALIAS | kAND | kBEGIN | kBREAK | kCASE | kCLASS | kDEF
|
| kALIAS | kAND | kBEGIN | kBREAK | kCASE | kCLASS | kDEF
|
||||||
@ -761,6 +802,7 @@ reswords : k__LINE__ | k__FILE__ | klBEGIN | klEND
|
|||||||
| kOR | kREDO | kRESCUE | kRETRY | kRETURN | kSELF | kSUPER
|
| kOR | kREDO | kRESCUE | kRETRY | kRETURN | kSELF | kSUPER
|
||||||
| kTHEN | kTRUE | kUNDEF | kUNLESS_MOD | kUNTIL_MOD | kWHEN
|
| kTHEN | kTRUE | kUNDEF | kUNLESS_MOD | kUNTIL_MOD | kWHEN
|
||||||
| kWHILE_MOD | kYIELD | kRESCUE_MOD
|
| kWHILE_MOD | kYIELD | kRESCUE_MOD
|
||||||
|
;
|
||||||
|
|
||||||
arg : lhs '=' arg
|
arg : lhs '=' arg
|
||||||
{
|
{
|
||||||
@ -1007,12 +1049,14 @@ arg : lhs '=' arg
|
|||||||
{
|
{
|
||||||
$$ = $1;
|
$$ = $1;
|
||||||
}
|
}
|
||||||
|
;
|
||||||
|
|
||||||
arg_value : arg
|
arg_value : arg
|
||||||
{
|
{
|
||||||
value_expr($1);
|
value_expr($1);
|
||||||
$$ = $1;
|
$$ = $1;
|
||||||
}
|
}
|
||||||
|
;
|
||||||
|
|
||||||
aref_args : none
|
aref_args : none
|
||||||
| command opt_nl
|
| command opt_nl
|
||||||
@ -1037,6 +1081,7 @@ aref_args : none
|
|||||||
value_expr($2);
|
value_expr($2);
|
||||||
$$ = NEW_RESTARY($2);
|
$$ = NEW_RESTARY($2);
|
||||||
}
|
}
|
||||||
|
;
|
||||||
|
|
||||||
paren_args : '(' none ')'
|
paren_args : '(' none ')'
|
||||||
{
|
{
|
||||||
@ -1054,9 +1099,11 @@ paren_args : '(' none ')'
|
|||||||
{
|
{
|
||||||
$$ = list_append($2, $4);
|
$$ = list_append($2, $4);
|
||||||
}
|
}
|
||||||
|
;
|
||||||
|
|
||||||
opt_paren_args : none
|
opt_paren_args : none
|
||||||
| paren_args
|
| paren_args
|
||||||
|
;
|
||||||
|
|
||||||
call_args : command
|
call_args : command
|
||||||
{
|
{
|
||||||
@ -1097,6 +1144,7 @@ call_args : command
|
|||||||
$$ = arg_blk_pass(NEW_RESTARGS($2), $3);
|
$$ = arg_blk_pass(NEW_RESTARGS($2), $3);
|
||||||
}
|
}
|
||||||
| block_arg
|
| block_arg
|
||||||
|
;
|
||||||
|
|
||||||
call_args2 : arg_value ',' args opt_block_arg
|
call_args2 : arg_value ',' args opt_block_arg
|
||||||
{
|
{
|
||||||
@ -1151,6 +1199,7 @@ call_args2 : arg_value ',' args opt_block_arg
|
|||||||
$$ = arg_blk_pass(NEW_RESTARGS($2), $3);
|
$$ = arg_blk_pass(NEW_RESTARGS($2), $3);
|
||||||
}
|
}
|
||||||
| block_arg
|
| block_arg
|
||||||
|
;
|
||||||
|
|
||||||
command_args : {
|
command_args : {
|
||||||
$<num>$ = cmdarg_stack;
|
$<num>$ = cmdarg_stack;
|
||||||
@ -1162,6 +1211,7 @@ command_args : {
|
|||||||
cmdarg_stack = $<num>1;
|
cmdarg_stack = $<num>1;
|
||||||
$$ = $2;
|
$$ = $2;
|
||||||
}
|
}
|
||||||
|
;
|
||||||
|
|
||||||
open_args : call_args
|
open_args : call_args
|
||||||
| tLPAREN_ARG {lex_state = EXPR_ENDARG;} ')'
|
| tLPAREN_ARG {lex_state = EXPR_ENDARG;} ')'
|
||||||
@ -1176,17 +1226,20 @@ open_args : call_args
|
|||||||
rb_id2name($<id>1));
|
rb_id2name($<id>1));
|
||||||
$$ = $2;
|
$$ = $2;
|
||||||
}
|
}
|
||||||
|
;
|
||||||
|
|
||||||
block_arg : tAMPER arg_value
|
block_arg : tAMPER arg_value
|
||||||
{
|
{
|
||||||
$$ = NEW_BLOCK_PASS($2);
|
$$ = NEW_BLOCK_PASS($2);
|
||||||
}
|
}
|
||||||
|
;
|
||||||
|
|
||||||
opt_block_arg : ',' block_arg
|
opt_block_arg : ',' block_arg
|
||||||
{
|
{
|
||||||
$$ = $2;
|
$$ = $2;
|
||||||
}
|
}
|
||||||
| none
|
| none
|
||||||
|
;
|
||||||
|
|
||||||
args : arg_value
|
args : arg_value
|
||||||
{
|
{
|
||||||
@ -1196,6 +1249,7 @@ args : arg_value
|
|||||||
{
|
{
|
||||||
$$ = list_append($1, $3);
|
$$ = list_append($1, $3);
|
||||||
}
|
}
|
||||||
|
;
|
||||||
|
|
||||||
mrhs : arg_value
|
mrhs : arg_value
|
||||||
{
|
{
|
||||||
@ -1205,6 +1259,7 @@ mrhs : arg_value
|
|||||||
{
|
{
|
||||||
$$ = NEW_REXPAND($1);
|
$$ = NEW_REXPAND($1);
|
||||||
}
|
}
|
||||||
|
;
|
||||||
|
|
||||||
mrhs_basic : args ',' arg_value
|
mrhs_basic : args ',' arg_value
|
||||||
{
|
{
|
||||||
@ -1218,6 +1273,7 @@ mrhs_basic : args ',' arg_value
|
|||||||
{
|
{
|
||||||
$$ = $2;
|
$$ = $2;
|
||||||
}
|
}
|
||||||
|
;
|
||||||
|
|
||||||
primary : literal
|
primary : literal
|
||||||
{
|
{
|
||||||
@ -1238,24 +1294,10 @@ primary : literal
|
|||||||
$$ = NEW_VCALL($1);
|
$$ = NEW_VCALL($1);
|
||||||
}
|
}
|
||||||
| kBEGIN
|
| kBEGIN
|
||||||
compstmt
|
bodystmt
|
||||||
rescue
|
|
||||||
opt_else
|
|
||||||
ensure
|
|
||||||
kEND
|
kEND
|
||||||
{
|
{
|
||||||
if (!$3 && !$4 && !$5)
|
|
||||||
$$ = NEW_BEGIN($2);
|
$$ = NEW_BEGIN($2);
|
||||||
else {
|
|
||||||
if ($3) $2 = NEW_RESCUE($2, $3, $4);
|
|
||||||
else if ($4) {
|
|
||||||
rb_warn("else without rescue is useless");
|
|
||||||
$2 = block_append($2, $4);
|
|
||||||
}
|
|
||||||
if ($5) $2 = NEW_ENSURE($2, $5);
|
|
||||||
$$ = $2;
|
|
||||||
}
|
|
||||||
fixpos($$, $2);
|
|
||||||
}
|
}
|
||||||
| tLPAREN_ARG expr {lex_state = EXPR_ENDARG;} ')'
|
| tLPAREN_ARG expr {lex_state = EXPR_ENDARG;} ')'
|
||||||
{
|
{
|
||||||
@ -1385,7 +1427,7 @@ primary : literal
|
|||||||
local_push(0);
|
local_push(0);
|
||||||
$<num>$ = ruby_sourceline;
|
$<num>$ = ruby_sourceline;
|
||||||
}
|
}
|
||||||
compstmt
|
bodystmt
|
||||||
kEND
|
kEND
|
||||||
{
|
{
|
||||||
$$ = NEW_CLASS($2, $5, $3);
|
$$ = NEW_CLASS($2, $5, $3);
|
||||||
@ -1405,7 +1447,7 @@ primary : literal
|
|||||||
class_nest++;
|
class_nest++;
|
||||||
local_push(0);
|
local_push(0);
|
||||||
}
|
}
|
||||||
compstmt
|
bodystmt
|
||||||
kEND
|
kEND
|
||||||
{
|
{
|
||||||
$$ = NEW_SCLASS($3, $7);
|
$$ = NEW_SCLASS($3, $7);
|
||||||
@ -1423,7 +1465,7 @@ primary : literal
|
|||||||
local_push(0);
|
local_push(0);
|
||||||
$<num>$ = ruby_sourceline;
|
$<num>$ = ruby_sourceline;
|
||||||
}
|
}
|
||||||
compstmt
|
bodystmt
|
||||||
kEND
|
kEND
|
||||||
{
|
{
|
||||||
$$ = NEW_MODULE($2, $4);
|
$$ = NEW_MODULE($2, $4);
|
||||||
@ -1441,19 +1483,9 @@ primary : literal
|
|||||||
local_push(0);
|
local_push(0);
|
||||||
}
|
}
|
||||||
f_arglist
|
f_arglist
|
||||||
compstmt
|
bodystmt
|
||||||
rescue
|
|
||||||
opt_else
|
|
||||||
ensure
|
|
||||||
kEND
|
kEND
|
||||||
{
|
{
|
||||||
if ($6) $5 = NEW_RESCUE($5, $6, $7);
|
|
||||||
else if ($7) {
|
|
||||||
rb_warn("else without rescue is useless");
|
|
||||||
$5 = block_append($5, $7);
|
|
||||||
}
|
|
||||||
if ($8) $5 = NEW_ENSURE($5, $8);
|
|
||||||
|
|
||||||
/* NOEX_PRIVATE for toplevel */
|
/* NOEX_PRIVATE for toplevel */
|
||||||
$$ = NEW_DEFN($2, $4, $5, class_nest?NOEX_PUBLIC:NOEX_PRIVATE);
|
$$ = NEW_DEFN($2, $4, $5, class_nest?NOEX_PUBLIC:NOEX_PRIVATE);
|
||||||
if (is_attrset_id($2)) $$->nd_noex = NOEX_PUBLIC;
|
if (is_attrset_id($2)) $$->nd_noex = NOEX_PUBLIC;
|
||||||
@ -1469,19 +1501,9 @@ primary : literal
|
|||||||
lex_state = EXPR_END; /* force for args */
|
lex_state = EXPR_END; /* force for args */
|
||||||
}
|
}
|
||||||
f_arglist
|
f_arglist
|
||||||
compstmt
|
bodystmt
|
||||||
rescue
|
|
||||||
opt_else
|
|
||||||
ensure
|
|
||||||
kEND
|
kEND
|
||||||
{
|
{
|
||||||
if ($9) $8 = NEW_RESCUE($8, $9, $10);
|
|
||||||
else if ($10) {
|
|
||||||
rb_warn("else without rescue is useless");
|
|
||||||
$8 = block_append($8, $10);
|
|
||||||
}
|
|
||||||
if ($11) $8 = NEW_ENSURE($8, $11);
|
|
||||||
|
|
||||||
$$ = NEW_DEFS($2, $5, $7, $8);
|
$$ = NEW_DEFS($2, $5, $7, $8);
|
||||||
fixpos($$, $2);
|
fixpos($$, $2);
|
||||||
local_pop();
|
local_pop();
|
||||||
@ -1503,19 +1525,23 @@ primary : literal
|
|||||||
{
|
{
|
||||||
$$ = NEW_RETRY();
|
$$ = NEW_RETRY();
|
||||||
}
|
}
|
||||||
|
;
|
||||||
|
|
||||||
primary_value : primary
|
primary_value : primary
|
||||||
{
|
{
|
||||||
value_expr($1);
|
value_expr($1);
|
||||||
$$ = $1;
|
$$ = $1;
|
||||||
}
|
}
|
||||||
|
;
|
||||||
|
|
||||||
then : term
|
then : term
|
||||||
| kTHEN
|
| kTHEN
|
||||||
| term kTHEN
|
| term kTHEN
|
||||||
|
;
|
||||||
|
|
||||||
do : term
|
do : term
|
||||||
| kDO_COND
|
| kDO_COND
|
||||||
|
;
|
||||||
|
|
||||||
if_tail : opt_else
|
if_tail : opt_else
|
||||||
| kELSIF expr_value then
|
| kELSIF expr_value then
|
||||||
@ -1525,15 +1551,18 @@ if_tail : opt_else
|
|||||||
$$ = NEW_IF(cond($2), $4, $5);
|
$$ = NEW_IF(cond($2), $4, $5);
|
||||||
fixpos($$, $2);
|
fixpos($$, $2);
|
||||||
}
|
}
|
||||||
|
;
|
||||||
|
|
||||||
opt_else : none
|
opt_else : none
|
||||||
| kELSE compstmt
|
| kELSE compstmt
|
||||||
{
|
{
|
||||||
$$ = $2;
|
$$ = $2;
|
||||||
}
|
}
|
||||||
|
;
|
||||||
|
|
||||||
block_var : lhs
|
block_var : lhs
|
||||||
| mlhs
|
| mlhs
|
||||||
|
;
|
||||||
|
|
||||||
opt_block_var : none
|
opt_block_var : none
|
||||||
| '|' /* none */ '|'
|
| '|' /* none */ '|'
|
||||||
@ -1548,6 +1577,7 @@ opt_block_var : none
|
|||||||
{
|
{
|
||||||
$$ = $2;
|
$$ = $2;
|
||||||
}
|
}
|
||||||
|
;
|
||||||
|
|
||||||
do_block : kDO_BLOCK
|
do_block : kDO_BLOCK
|
||||||
{
|
{
|
||||||
@ -1571,6 +1601,7 @@ do_block : kDO_BLOCK
|
|||||||
dyna_pop($<vars>2);
|
dyna_pop($<vars>2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
;
|
||||||
|
|
||||||
block_call : command do_block
|
block_call : command do_block
|
||||||
{
|
{
|
||||||
@ -1589,12 +1620,14 @@ block_call : command do_block
|
|||||||
{
|
{
|
||||||
$$ = new_call($1, $3, $4);
|
$$ = new_call($1, $3, $4);
|
||||||
}
|
}
|
||||||
|
;
|
||||||
|
|
||||||
block_call_value : block_call
|
block_call_value : block_call
|
||||||
{
|
{
|
||||||
value_expr($$);
|
value_expr($$);
|
||||||
$$ = $1;
|
$$ = $1;
|
||||||
}
|
}
|
||||||
|
;
|
||||||
|
|
||||||
method_call : operation paren_args
|
method_call : operation paren_args
|
||||||
{
|
{
|
||||||
@ -1629,6 +1662,7 @@ method_call : operation paren_args
|
|||||||
yyerror("super called outside of method");
|
yyerror("super called outside of method");
|
||||||
$$ = NEW_ZSUPER();
|
$$ = NEW_ZSUPER();
|
||||||
}
|
}
|
||||||
|
;
|
||||||
|
|
||||||
brace_block : '{'
|
brace_block : '{'
|
||||||
{
|
{
|
||||||
@ -1652,6 +1686,7 @@ brace_block : '{'
|
|||||||
fixpos($$, $4);
|
fixpos($$, $4);
|
||||||
dyna_pop($<vars>2);
|
dyna_pop($<vars>2);
|
||||||
}
|
}
|
||||||
|
;
|
||||||
|
|
||||||
case_body : kWHEN when_args then
|
case_body : kWHEN when_args then
|
||||||
compstmt
|
compstmt
|
||||||
@ -1659,6 +1694,7 @@ case_body : kWHEN when_args then
|
|||||||
{
|
{
|
||||||
$$ = NEW_WHEN($2, $4, $5);
|
$$ = NEW_WHEN($2, $4, $5);
|
||||||
}
|
}
|
||||||
|
;
|
||||||
|
|
||||||
when_args : args
|
when_args : args
|
||||||
| args ',' tSTAR arg_value
|
| args ',' tSTAR arg_value
|
||||||
@ -1669,22 +1705,15 @@ when_args : args
|
|||||||
{
|
{
|
||||||
$$ = NEW_LIST(NEW_WHEN($2, 0, 0));
|
$$ = NEW_LIST(NEW_WHEN($2, 0, 0));
|
||||||
}
|
}
|
||||||
|
;
|
||||||
|
|
||||||
cases : opt_else
|
cases : opt_else
|
||||||
| case_body
|
| case_body
|
||||||
|
;
|
||||||
|
|
||||||
exc_list : none
|
opt_rescue : kRESCUE exc_list exc_var then
|
||||||
| args
|
|
||||||
|
|
||||||
exc_var : tASSOC lhs
|
|
||||||
{
|
|
||||||
$$ = $2;
|
|
||||||
}
|
|
||||||
| none
|
|
||||||
|
|
||||||
rescue : kRESCUE exc_list exc_var then
|
|
||||||
compstmt
|
compstmt
|
||||||
rescue
|
opt_rescue
|
||||||
{
|
{
|
||||||
if ($3) {
|
if ($3) {
|
||||||
$3 = node_assign($3, NEW_GVAR(rb_intern("$!")));
|
$3 = node_assign($3, NEW_GVAR(rb_intern("$!")));
|
||||||
@ -1694,9 +1723,20 @@ rescue : kRESCUE exc_list exc_var then
|
|||||||
fixpos($$, $2?$2:$5);
|
fixpos($$, $2?$2:$5);
|
||||||
}
|
}
|
||||||
| none
|
| none
|
||||||
|
;
|
||||||
|
|
||||||
ensure : none
|
exc_list : args
|
||||||
| kENSURE compstmt
|
| none
|
||||||
|
;
|
||||||
|
|
||||||
|
exc_var : tASSOC lhs
|
||||||
|
{
|
||||||
|
$$ = $2;
|
||||||
|
}
|
||||||
|
| none
|
||||||
|
;
|
||||||
|
|
||||||
|
opt_ensure : kENSURE compstmt
|
||||||
{
|
{
|
||||||
if ($2)
|
if ($2)
|
||||||
$$ = $2;
|
$$ = $2;
|
||||||
@ -1704,6 +1744,8 @@ ensure : none
|
|||||||
/* place holder */
|
/* place holder */
|
||||||
$$ = NEW_NIL();
|
$$ = NEW_NIL();
|
||||||
}
|
}
|
||||||
|
| none
|
||||||
|
;
|
||||||
|
|
||||||
literal : numeric
|
literal : numeric
|
||||||
| symbol
|
| symbol
|
||||||
@ -1711,6 +1753,7 @@ literal : numeric
|
|||||||
$$ = ID2SYM($1);
|
$$ = ID2SYM($1);
|
||||||
}
|
}
|
||||||
| tREGEXP
|
| tREGEXP
|
||||||
|
;
|
||||||
|
|
||||||
string : tSTRING
|
string : tSTRING
|
||||||
{
|
{
|
||||||
@ -1739,20 +1782,24 @@ string : tSTRING
|
|||||||
nd_set_type($2, NODE_ARRAY);
|
nd_set_type($2, NODE_ARRAY);
|
||||||
list_concat($$, $2);
|
list_concat($$, $2);
|
||||||
}
|
}
|
||||||
|
;
|
||||||
|
|
||||||
symbol : tSYMBEG sym
|
symbol : tSYMBEG sym
|
||||||
{
|
{
|
||||||
lex_state = EXPR_END;
|
lex_state = EXPR_END;
|
||||||
$$ = $2;
|
$$ = $2;
|
||||||
}
|
}
|
||||||
|
;
|
||||||
|
|
||||||
sym : fname
|
sym : fname
|
||||||
| tIVAR
|
| tIVAR
|
||||||
| tGVAR
|
| tGVAR
|
||||||
| tCVAR
|
| tCVAR
|
||||||
|
;
|
||||||
|
|
||||||
numeric : tINTEGER
|
numeric : tINTEGER
|
||||||
| tFLOAT
|
| tFLOAT
|
||||||
|
;
|
||||||
|
|
||||||
variable : tIDENTIFIER
|
variable : tIDENTIFIER
|
||||||
| tIVAR
|
| tIVAR
|
||||||
@ -1765,19 +1812,23 @@ variable : tIDENTIFIER
|
|||||||
| kFALSE {$$ = kFALSE;}
|
| kFALSE {$$ = kFALSE;}
|
||||||
| k__FILE__ {$$ = k__FILE__;}
|
| k__FILE__ {$$ = k__FILE__;}
|
||||||
| k__LINE__ {$$ = k__LINE__;}
|
| k__LINE__ {$$ = k__LINE__;}
|
||||||
|
;
|
||||||
|
|
||||||
var_ref : variable
|
var_ref : variable
|
||||||
{
|
{
|
||||||
$$ = gettable($1);
|
$$ = gettable($1);
|
||||||
}
|
}
|
||||||
|
;
|
||||||
|
|
||||||
var_lhs : variable
|
var_lhs : variable
|
||||||
{
|
{
|
||||||
$$ = assignable($1, 0);
|
$$ = assignable($1, 0);
|
||||||
}
|
}
|
||||||
|
;
|
||||||
|
|
||||||
backref : tNTH_REF
|
backref : tNTH_REF
|
||||||
| tBACK_REF
|
| tBACK_REF
|
||||||
|
;
|
||||||
|
|
||||||
superclass : term
|
superclass : term
|
||||||
{
|
{
|
||||||
@ -1792,6 +1843,7 @@ superclass : term
|
|||||||
$$ = $3;
|
$$ = $3;
|
||||||
}
|
}
|
||||||
| error term {yyerrok; $$ = 0;}
|
| error term {yyerrok; $$ = 0;}
|
||||||
|
;
|
||||||
|
|
||||||
f_arglist : '(' f_args opt_nl ')'
|
f_arglist : '(' f_args opt_nl ')'
|
||||||
{
|
{
|
||||||
@ -1802,6 +1854,7 @@ f_arglist : '(' f_args opt_nl ')'
|
|||||||
{
|
{
|
||||||
$$ = $1;
|
$$ = $1;
|
||||||
}
|
}
|
||||||
|
;
|
||||||
|
|
||||||
f_args : f_arg ',' f_optarg ',' f_rest_arg opt_f_block_arg
|
f_args : f_arg ',' f_optarg ',' f_rest_arg opt_f_block_arg
|
||||||
{
|
{
|
||||||
@ -1839,6 +1892,7 @@ f_args : f_arg ',' f_optarg ',' f_rest_arg opt_f_block_arg
|
|||||||
{
|
{
|
||||||
$$ = NEW_ARGS(0, 0, -1);
|
$$ = NEW_ARGS(0, 0, -1);
|
||||||
}
|
}
|
||||||
|
;
|
||||||
|
|
||||||
f_norm_arg : tCONSTANT
|
f_norm_arg : tCONSTANT
|
||||||
{
|
{
|
||||||
@ -1865,12 +1919,14 @@ f_norm_arg : tCONSTANT
|
|||||||
local_cnt($1);
|
local_cnt($1);
|
||||||
$$ = 1;
|
$$ = 1;
|
||||||
}
|
}
|
||||||
|
;
|
||||||
|
|
||||||
f_arg : f_norm_arg
|
f_arg : f_norm_arg
|
||||||
| f_arg ',' f_norm_arg
|
| f_arg ',' f_norm_arg
|
||||||
{
|
{
|
||||||
$$ += 1;
|
$$ += 1;
|
||||||
}
|
}
|
||||||
|
;
|
||||||
|
|
||||||
f_opt : tIDENTIFIER '=' arg_value
|
f_opt : tIDENTIFIER '=' arg_value
|
||||||
{
|
{
|
||||||
@ -1880,6 +1936,7 @@ f_opt : tIDENTIFIER '=' arg_value
|
|||||||
yyerror("duplicate optional argument name");
|
yyerror("duplicate optional argument name");
|
||||||
$$ = assignable($1, $3);
|
$$ = assignable($1, $3);
|
||||||
}
|
}
|
||||||
|
;
|
||||||
|
|
||||||
f_optarg : f_opt
|
f_optarg : f_opt
|
||||||
{
|
{
|
||||||
@ -1890,6 +1947,7 @@ f_optarg : f_opt
|
|||||||
{
|
{
|
||||||
$$ = block_append($1, $3);
|
$$ = block_append($1, $3);
|
||||||
}
|
}
|
||||||
|
;
|
||||||
|
|
||||||
f_rest_arg : tSTAR tIDENTIFIER
|
f_rest_arg : tSTAR tIDENTIFIER
|
||||||
{
|
{
|
||||||
@ -1903,6 +1961,7 @@ f_rest_arg : tSTAR tIDENTIFIER
|
|||||||
{
|
{
|
||||||
$$ = -2;
|
$$ = -2;
|
||||||
}
|
}
|
||||||
|
;
|
||||||
|
|
||||||
f_block_arg : tAMPER tIDENTIFIER
|
f_block_arg : tAMPER tIDENTIFIER
|
||||||
{
|
{
|
||||||
@ -1912,12 +1971,14 @@ f_block_arg : tAMPER tIDENTIFIER
|
|||||||
yyerror("duplicate block argument name");
|
yyerror("duplicate block argument name");
|
||||||
$$ = NEW_BLOCK_ARG($2);
|
$$ = NEW_BLOCK_ARG($2);
|
||||||
}
|
}
|
||||||
|
;
|
||||||
|
|
||||||
opt_f_block_arg : ',' f_block_arg
|
opt_f_block_arg : ',' f_block_arg
|
||||||
{
|
{
|
||||||
$$ = $2;
|
$$ = $2;
|
||||||
}
|
}
|
||||||
| none
|
| none
|
||||||
|
;
|
||||||
|
|
||||||
singleton : var_ref
|
singleton : var_ref
|
||||||
{
|
{
|
||||||
@ -1947,6 +2008,7 @@ singleton : var_ref
|
|||||||
}
|
}
|
||||||
$$ = $3;
|
$$ = $3;
|
||||||
}
|
}
|
||||||
|
;
|
||||||
|
|
||||||
assoc_list : none
|
assoc_list : none
|
||||||
| assocs trailer
|
| assocs trailer
|
||||||
@ -1960,54 +2022,64 @@ assoc_list : none
|
|||||||
}
|
}
|
||||||
$$ = $1;
|
$$ = $1;
|
||||||
}
|
}
|
||||||
|
;
|
||||||
|
|
||||||
assocs : assoc
|
assocs : assoc
|
||||||
| assocs ',' assoc
|
| assocs ',' assoc
|
||||||
{
|
{
|
||||||
$$ = list_concat($1, $3);
|
$$ = list_concat($1, $3);
|
||||||
}
|
}
|
||||||
|
;
|
||||||
|
|
||||||
assoc : arg_value tASSOC arg_value
|
assoc : arg_value tASSOC arg_value
|
||||||
{
|
{
|
||||||
$$ = list_append(NEW_LIST($1), $3);
|
$$ = list_append(NEW_LIST($1), $3);
|
||||||
}
|
}
|
||||||
|
;
|
||||||
|
|
||||||
operation : tIDENTIFIER
|
operation : tIDENTIFIER
|
||||||
| tCONSTANT
|
| tCONSTANT
|
||||||
| tFID
|
| tFID
|
||||||
|
;
|
||||||
|
|
||||||
operation2 : tIDENTIFIER
|
operation2 : tIDENTIFIER
|
||||||
| tCONSTANT
|
| tCONSTANT
|
||||||
| tFID
|
| tFID
|
||||||
| op
|
| op
|
||||||
|
;
|
||||||
|
|
||||||
operation3 : tIDENTIFIER
|
operation3 : tIDENTIFIER
|
||||||
| tFID
|
| tFID
|
||||||
| op
|
| op
|
||||||
|
;
|
||||||
|
|
||||||
dot_or_colon : '.'
|
dot_or_colon : '.'
|
||||||
| tCOLON2
|
| tCOLON2
|
||||||
|
;
|
||||||
|
|
||||||
opt_terms : /* none */
|
opt_terms : /* none */
|
||||||
| terms
|
| terms
|
||||||
|
;
|
||||||
|
|
||||||
opt_nl : /* none */
|
opt_nl : /* none */
|
||||||
| '\n'
|
| '\n'
|
||||||
|
;
|
||||||
|
|
||||||
trailer : /* none */
|
trailer : /* none */
|
||||||
| '\n'
|
| '\n'
|
||||||
| ','
|
| ','
|
||||||
|
;
|
||||||
|
|
||||||
term : ';' {yyerrok;}
|
term : ';' {yyerrok;}
|
||||||
| '\n'
|
| '\n'
|
||||||
|
;
|
||||||
|
|
||||||
terms : term
|
terms : term
|
||||||
| terms ';' {yyerrok;}
|
| terms ';' {yyerrok;}
|
||||||
|
;
|
||||||
|
|
||||||
none : /* none */
|
none : /* none */ {$$ = 0;}
|
||||||
{
|
;
|
||||||
$$ = 0;
|
|
||||||
}
|
|
||||||
%%
|
%%
|
||||||
#include "regex.h"
|
#include "regex.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#define RUBY_VERSION "1.7.2"
|
#define RUBY_VERSION "1.7.2"
|
||||||
#define RUBY_RELEASE_DATE "2002-03-25"
|
#define RUBY_RELEASE_DATE "2002-03-26"
|
||||||
#define RUBY_VERSION_CODE 172
|
#define RUBY_VERSION_CODE 172
|
||||||
#define RUBY_RELEASE_CODE 20020325
|
#define RUBY_RELEASE_CODE 20020326
|
||||||
|
Loading…
x
Reference in New Issue
Block a user