зеркало из https://github.com/github/ruby.git
parse.y: refine error message
* parse.y (parser_number_literal_suffix): refine error message for extra dot and digits. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46179 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
3356c312cd
Коммит
fe780f2997
|
@ -1,3 +1,8 @@
|
|||
Tue May 27 23:06:46 2014 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* parse.y (parser_number_literal_suffix): refine error message for
|
||||
extra dot and digits.
|
||||
|
||||
Tue May 27 22:44:20 2014 Tanaka Akira <akr@fsij.org>
|
||||
|
||||
* test/rexml: Avoid fd leaks.
|
||||
|
|
10
parse.y
10
parse.y
|
@ -5594,6 +5594,8 @@ parser_str_new(const char *p, long n, rb_encoding *enc, int func, rb_encoding *e
|
|||
#define lex_eol_p() (lex_p >= lex_pend)
|
||||
#define peek(c) peek_n((c), 0)
|
||||
#define peek_n(c,n) (lex_p+(n) < lex_pend && (c) == (unsigned char)lex_p[n])
|
||||
#define peekc() peekc_n(0)
|
||||
#define peekc_n(n) (lex_p+(n) < lex_pend ? (unsigned char)lex_p[n] : -1)
|
||||
|
||||
static inline int
|
||||
parser_nextc(struct parser_params *parser)
|
||||
|
@ -6453,6 +6455,14 @@ parser_number_literal_suffix(struct parser_params *parser, int mask)
|
|||
return 0;
|
||||
}
|
||||
pushback(c);
|
||||
if (c == '.') {
|
||||
c = peekc_n(1);
|
||||
if (ISDIGIT(c)) {
|
||||
yyerror("unexpected fraction part after numeric literal");
|
||||
lex_p += 2;
|
||||
while (parser_is_identchar()) nextc();
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
return result;
|
||||
|
|
|
@ -426,6 +426,15 @@ eom
|
|||
end
|
||||
end
|
||||
|
||||
def test_unexpected_fraction
|
||||
msg = /unexpected fraction/
|
||||
assert_syntax_error("0x0.0", msg)
|
||||
assert_syntax_error("0b0.0", msg)
|
||||
assert_syntax_error("0d0.0", msg)
|
||||
assert_syntax_error("0o0.0", msg)
|
||||
assert_syntax_error("0.0.0", msg)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def not_label(x) @result = x; @not_label ||= nil end
|
||||
|
|
Загрузка…
Ссылка в новой задаче