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

* parse.y (parser_yylex): check EOF explicitly.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@20000 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
mame 2008-10-28 12:34:13 +00:00
parent 45ea81a492
commit d563f1680c
2 changed files with 15 additions and 11 deletions

View file

@ -1,3 +1,7 @@
Tue Oct 28 21:31:55 2008 Yusuke Endoh <mame@tsg.ne.jp>
* parse.y (parser_yylex): check EOF explicitly.
Tue Oct 28 20:59:12 2008 NAKAMURA Usaku <usa@ruby-lang.org>
* io.c (extract_binmode): new function to extract binmode/textmode

22
parse.y
View file

@ -6790,7 +6790,7 @@ parser_yylex(struct parser_params *parser)
if (IS_ARG()) arg_ambiguous();
lex_state = EXPR_BEG;
pushback(c);
if (ISDIGIT(c)) {
if (c != -1 && ISDIGIT(c)) {
c = '+';
goto start_num;
}
@ -6824,7 +6824,7 @@ parser_yylex(struct parser_params *parser)
if (IS_ARG()) arg_ambiguous();
lex_state = EXPR_BEG;
pushback(c);
if (ISDIGIT(c)) {
if (c != -1 && ISDIGIT(c)) {
return tUMINUS_NUM;
}
return tUMINUS;
@ -6843,7 +6843,7 @@ parser_yylex(struct parser_params *parser)
return tDOT2;
}
pushback(c);
if (ISDIGIT(c)) {
if (c != -1 && ISDIGIT(c)) {
yyerror("no .<digit> floating literal anymore; put 0 before dot");
}
lex_state = EXPR_DOT;
@ -6868,7 +6868,7 @@ parser_yylex(struct parser_params *parser)
if (c == 'x' || c == 'X') {
/* hexadecimal */
c = nextc();
if (ISXDIGIT(c)) {
if (c != -1 && ISXDIGIT(c)) {
do {
if (c == '_') {
if (nondigit) break;
@ -6916,7 +6916,7 @@ parser_yylex(struct parser_params *parser)
if (c == 'd' || c == 'D') {
/* decimal */
c = nextc();
if (ISDIGIT(c)) {
if (c != -1 && ISDIGIT(c)) {
do {
if (c == '_') {
if (nondigit) break;
@ -6944,7 +6944,7 @@ parser_yylex(struct parser_params *parser)
if (c == 'o' || c == 'O') {
/* prefixed octal */
c = nextc();
if (c == '_' || !ISDIGIT(c)) {
if (c == -1 || c == '_' || !ISDIGIT(c)) {
yyerror("numeric literal without digits");
}
}
@ -7003,7 +7003,7 @@ parser_yylex(struct parser_params *parser)
}
else {
int c0 = nextc();
if (!ISDIGIT(c0)) {
if (c == -1 || !ISDIGIT(c0)) {
pushback(c0);
goto decode_num;
}
@ -7092,7 +7092,7 @@ parser_yylex(struct parser_params *parser)
lex_state = EXPR_DOT;
return tCOLON2;
}
if (lex_state == EXPR_END || lex_state == EXPR_ENDARG || ISSPACE(c)) {
if (lex_state == EXPR_END || lex_state == EXPR_ENDARG || (c != -1 && ISSPACE(c))) {
pushback(c);
lex_state = EXPR_BEG;
return ':';
@ -7251,7 +7251,7 @@ parser_yylex(struct parser_params *parser)
c = nextc();
quotation:
if (!ISALNUM(c)) {
if (c == -1 || !ISALNUM(c)) {
term = c;
c = 'Q';
}
@ -7401,7 +7401,7 @@ parser_yylex(struct parser_params *parser)
do {
tokadd(c);
c = nextc();
} while (ISDIGIT(c));
} while (c != -1 && ISDIGIT(c));
pushback(c);
if (last_state == EXPR_FNAME) goto gvar;
tokfix();
@ -7426,7 +7426,7 @@ parser_yylex(struct parser_params *parser)
tokadd('@');
c = nextc();
}
if (ISDIGIT(c)) {
if (c != -1 && ISDIGIT(c)) {
if (tokidx == 1) {
compile_error(PARSER_ARG "`@%c' is not allowed as an instance variable name", c);
}