* parse.y (yylex): remove EXPR_CMDARG according to the RHG book.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3425 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
e13bfb1509
commit
f758195486
@ -82,6 +82,10 @@ Sun Jan 26 03:37:18 2003 Akinori MUSHA <knu@iDaemons.org>
|
||||
is used with extra arguments given. Tested with FreeBSD and
|
||||
Linux by me and mswin32, bccwin32 and mingw by usa.
|
||||
|
||||
Sat Jan 25 21:04:57 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
* parse.y (yylex): remove EXPR_CMDARG according to the RHG book.
|
||||
|
||||
Fri Jan 24 18:15:33 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
* parse.y: tMINUS should have lower precedence than tPOW.
|
||||
|
3
error.c
3
error.c
@ -490,7 +490,8 @@ set_syserr(n, name)
|
||||
}
|
||||
|
||||
static VALUE
|
||||
get_syserr(int n)
|
||||
get_syserr(n)
|
||||
int n;
|
||||
{
|
||||
VALUE error;
|
||||
|
||||
|
25
parse.y
25
parse.y
@ -68,7 +68,6 @@ static enum lex_state {
|
||||
EXPR_BEG, /* ignore newline, +/- is a sign. */
|
||||
EXPR_END, /* newline significant, +/- is a operator. */
|
||||
EXPR_ARG, /* newline significant, +/- is a operator. */
|
||||
EXPR_CMDARG, /* newline significant, +/- is a operator. */
|
||||
EXPR_ENDARG, /* newline significant, +/- is a operator. */
|
||||
EXPR_MID, /* newline significant, +/- is a operator. */
|
||||
EXPR_FNAME, /* ignore newline, no reserved words. */
|
||||
@ -3240,7 +3239,7 @@ arg_ambiguous()
|
||||
rb_warning("ambiguous first argument; make sure");
|
||||
}
|
||||
|
||||
#define IS_ARG() (lex_state == EXPR_ARG || lex_state == EXPR_CMDARG)
|
||||
#define IS_ARG() (lex_state == EXPR_ARG)
|
||||
|
||||
static int
|
||||
yylex()
|
||||
@ -3464,10 +3463,7 @@ yylex()
|
||||
return c;
|
||||
}
|
||||
if (lex_state == EXPR_DOT) {
|
||||
if (cmd_state)
|
||||
lex_state = EXPR_CMDARG;
|
||||
else
|
||||
lex_state = EXPR_ARG;
|
||||
lex_state = EXPR_ARG;
|
||||
return c;
|
||||
}
|
||||
lex_strterm = NEW_STRTERM(str_xquote, '`', 0);
|
||||
@ -3998,10 +3994,7 @@ yylex()
|
||||
c = tLPAREN;
|
||||
}
|
||||
else if (space_seen) {
|
||||
if (lex_state == EXPR_CMDARG) {
|
||||
c = tLPAREN_ARG;
|
||||
}
|
||||
else if (lex_state == EXPR_ARG) {
|
||||
if (lex_state == EXPR_ARG) {
|
||||
c = tLPAREN_ARG;
|
||||
yylval.id = last_id;
|
||||
}
|
||||
@ -4350,7 +4343,7 @@ yylex()
|
||||
}
|
||||
if (kw->id[0] == kDO) {
|
||||
if (COND_P()) return kDO_COND;
|
||||
if (CMDARG_P() && state != EXPR_CMDARG)
|
||||
if (CMDARG_P())
|
||||
return kDO_BLOCK;
|
||||
if (state == EXPR_ENDARG)
|
||||
return kDO_BLOCK;
|
||||
@ -4369,14 +4362,8 @@ yylex()
|
||||
if (lex_state == EXPR_BEG ||
|
||||
lex_state == EXPR_MID ||
|
||||
lex_state == EXPR_DOT ||
|
||||
lex_state == EXPR_ARG ||
|
||||
lex_state == EXPR_CMDARG) {
|
||||
if (cmd_state) {
|
||||
lex_state = EXPR_CMDARG;
|
||||
}
|
||||
else {
|
||||
lex_state = EXPR_ARG;
|
||||
}
|
||||
lex_state == EXPR_ARG) {
|
||||
lex_state = EXPR_ARG;
|
||||
}
|
||||
else {
|
||||
lex_state = EXPR_END;
|
||||
|
5
random.c
5
random.c
@ -214,6 +214,8 @@ rb_f_rand(argc, argv, obj)
|
||||
}
|
||||
vmax = rb_dbl2big(RFLOAT(vmax)->value);
|
||||
/* fall through */
|
||||
case T_BIGNUM:
|
||||
bignum:
|
||||
{
|
||||
long len = RBIGNUM(vmax)->len;
|
||||
double *buf = ALLOCA_N(double, len);
|
||||
@ -227,6 +229,9 @@ rb_f_rand(argc, argv, obj)
|
||||
max = 0;
|
||||
break;
|
||||
default:
|
||||
vmax = rb_Integer(vmax);
|
||||
if (TYPE(vmax) == T_BIGNUM) goto bignum:
|
||||
case T_FIXNUM:
|
||||
max = NUM2LONG(vmax);
|
||||
break;
|
||||
}
|
||||
|
21
string.c
21
string.c
@ -892,10 +892,6 @@ rb_str_index_m(argc, argv, str)
|
||||
pos = rb_reg_search(sub, str, pos, 0);
|
||||
break;
|
||||
|
||||
case T_STRING:
|
||||
pos = rb_str_index(str, sub, pos);
|
||||
break;
|
||||
|
||||
case T_FIXNUM:
|
||||
{
|
||||
int c = FIX2INT(sub);
|
||||
@ -908,9 +904,20 @@ rb_str_index_m(argc, argv, str)
|
||||
return Qnil;
|
||||
}
|
||||
|
||||
default:
|
||||
rb_raise(rb_eTypeError, "type mismatch: %s given",
|
||||
rb_class2name(CLASS_OF(sub)));
|
||||
default: {
|
||||
VALUE tmp;
|
||||
|
||||
tmp = rb_check_string_type(sub);
|
||||
if (NIL_P(tmp)) {
|
||||
rb_raise(rb_eTypeError, "type mismatch: %s given",
|
||||
rb_class2name(CLASS_OF(sub)));
|
||||
}
|
||||
sub = tmp;
|
||||
}
|
||||
/* fall through */
|
||||
case T_STRING:
|
||||
pos = rb_str_index(str, sub, pos);
|
||||
break;
|
||||
}
|
||||
|
||||
if (pos == -1) return Qnil;
|
||||
|
Loading…
x
Reference in New Issue
Block a user