* parse.y (parser_yylex): suppress an extra error message after
numeric literal without digits. based on a patch from ujihisa . in [ruby-dev:39811]. [ruby-dev:39798] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25962 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
c52a8112b2
commit
b19b496248
@ -1,3 +1,9 @@
|
|||||||
|
Mon Nov 30 11:00:12 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
|
* parse.y (parser_yylex): suppress an extra error message after
|
||||||
|
numeric literal without digits. based on a patch from ujihisa .
|
||||||
|
in [ruby-dev:39811]. [ruby-dev:39798]
|
||||||
|
|
||||||
Sun Nov 29 16:56:24 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
Sun Nov 29 16:56:24 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
* vm_eval.c (check_funcall_failed): pass ID. [ruby-core:26934]
|
* vm_eval.c (check_funcall_failed): pass ID. [ruby-core:26934]
|
||||||
|
9
parse.y
9
parse.y
@ -6902,6 +6902,7 @@ parser_yylex(struct parser_params *parser)
|
|||||||
c = nextc();
|
c = nextc();
|
||||||
}
|
}
|
||||||
if (c == '0') {
|
if (c == '0') {
|
||||||
|
#define no_digits() do {yyerror("numeric literal without digits"); return 0;} while (0)
|
||||||
int start = toklen();
|
int start = toklen();
|
||||||
c = nextc();
|
c = nextc();
|
||||||
if (c == 'x' || c == 'X') {
|
if (c == 'x' || c == 'X') {
|
||||||
@ -6922,7 +6923,7 @@ parser_yylex(struct parser_params *parser)
|
|||||||
pushback(c);
|
pushback(c);
|
||||||
tokfix();
|
tokfix();
|
||||||
if (toklen() == start) {
|
if (toklen() == start) {
|
||||||
yyerror("numeric literal without digits");
|
no_digits();
|
||||||
}
|
}
|
||||||
else if (nondigit) goto trailing_uc;
|
else if (nondigit) goto trailing_uc;
|
||||||
set_yylval_literal(rb_cstr_to_inum(tok(), 16, FALSE));
|
set_yylval_literal(rb_cstr_to_inum(tok(), 16, FALSE));
|
||||||
@ -6946,7 +6947,7 @@ parser_yylex(struct parser_params *parser)
|
|||||||
pushback(c);
|
pushback(c);
|
||||||
tokfix();
|
tokfix();
|
||||||
if (toklen() == start) {
|
if (toklen() == start) {
|
||||||
yyerror("numeric literal without digits");
|
no_digits();
|
||||||
}
|
}
|
||||||
else if (nondigit) goto trailing_uc;
|
else if (nondigit) goto trailing_uc;
|
||||||
set_yylval_literal(rb_cstr_to_inum(tok(), 2, FALSE));
|
set_yylval_literal(rb_cstr_to_inum(tok(), 2, FALSE));
|
||||||
@ -6970,7 +6971,7 @@ parser_yylex(struct parser_params *parser)
|
|||||||
pushback(c);
|
pushback(c);
|
||||||
tokfix();
|
tokfix();
|
||||||
if (toklen() == start) {
|
if (toklen() == start) {
|
||||||
yyerror("numeric literal without digits");
|
no_digits();
|
||||||
}
|
}
|
||||||
else if (nondigit) goto trailing_uc;
|
else if (nondigit) goto trailing_uc;
|
||||||
set_yylval_literal(rb_cstr_to_inum(tok(), 10, FALSE));
|
set_yylval_literal(rb_cstr_to_inum(tok(), 10, FALSE));
|
||||||
@ -6984,7 +6985,7 @@ parser_yylex(struct parser_params *parser)
|
|||||||
/* prefixed octal */
|
/* prefixed octal */
|
||||||
c = nextc();
|
c = nextc();
|
||||||
if (c == -1 || c == '_' || !ISDIGIT(c)) {
|
if (c == -1 || c == '_' || !ISDIGIT(c)) {
|
||||||
yyerror("numeric literal without digits");
|
no_digits();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (c >= '0' && c <= '7') {
|
if (c >= '0' && c <= '7') {
|
||||||
|
@ -211,6 +211,16 @@ class TestRubyLiteral < Test::Unit::TestCase
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
bug2407 = '[ruby-dev:39798]'
|
||||||
|
head.each {|h|
|
||||||
|
if /^0/ =~ h
|
||||||
|
begin
|
||||||
|
eval("#{h}_")
|
||||||
|
rescue SyntaxError => e
|
||||||
|
assert_match(/numeric literal without digits\Z/, e.message, bug2407)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_float
|
def test_float
|
||||||
|
Loading…
x
Reference in New Issue
Block a user