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:
parent
3356c312cd
commit
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>
|
Tue May 27 22:44:20 2014 Tanaka Akira <akr@fsij.org>
|
||||||
|
|
||||||
* test/rexml: Avoid fd leaks.
|
* 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 lex_eol_p() (lex_p >= lex_pend)
|
||||||
#define peek(c) peek_n((c), 0)
|
#define peek(c) peek_n((c), 0)
|
||||||
#define peek_n(c,n) (lex_p+(n) < lex_pend && (c) == (unsigned char)lex_p[n])
|
#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
|
static inline int
|
||||||
parser_nextc(struct parser_params *parser)
|
parser_nextc(struct parser_params *parser)
|
||||||
@ -6453,6 +6455,14 @@ parser_number_literal_suffix(struct parser_params *parser, int mask)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
pushback(c);
|
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;
|
break;
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
@ -426,6 +426,15 @@ eom
|
|||||||
end
|
end
|
||||||
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
|
private
|
||||||
|
|
||||||
def not_label(x) @result = x; @not_label ||= nil end
|
def not_label(x) @result = x; @not_label ||= nil end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user