summaryrefslogtreecommitdiff
path: root/parse.y
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-04-09 11:09:30 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-04-09 11:09:30 +0000
commit6a571272227b0093a1b0fa82225ebde04ce1a69b (patch)
tree9f09c421a36b160d14e92d28137a59e71ee14715 /parse.y
parent066af25b58af97cc0b07773dd11b9a3aa55d40bf (diff)
parse.y: extra error message after no digits
* parse.y (no_digits): return tINTEGER instead of unexpected end-of-input, to get rid of extra error messages. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63126 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'parse.y')
-rw-r--r--parse.y18
1 files changed, 13 insertions, 5 deletions
diff --git a/parse.y b/parse.y
index e4e82516d2..383b5ef03b 100644
--- a/parse.y
+++ b/parse.y
@@ -6841,6 +6841,15 @@ parse_rational(struct parser_params *p, char *str, int len, int seen_point)
}
static enum yytokentype
+no_digits(struct parser_params *p)
+{
+ yyerror0("numeric literal without digits");
+ if (peek(p, '_')) nextc(p);
+ /* dummy 0, for tUMINUS_NUM at numeric */
+ return set_integer_literal(p, INT2FIX(0), 0);
+}
+
+static enum yytokentype
parse_numeric(struct parser_params *p, int c)
{
int is_float, seen_point, seen_e, nondigit;
@@ -6854,7 +6863,6 @@ parse_numeric(struct parser_params *p, int c)
c = nextc(p);
}
if (c == '0') {
-#define no_digits() do {yyerror0("numeric literal without digits"); return 0;} while (0)
int start = toklen(p);
c = nextc(p);
if (c == 'x' || c == 'X') {
@@ -6875,7 +6883,7 @@ parse_numeric(struct parser_params *p, int c)
pushback(p, c);
tokfix(p);
if (toklen(p) == start) {
- no_digits();
+ return no_digits(p);
}
else if (nondigit) goto trailing_uc;
suffix = number_literal_suffix(p, NUM_SUFFIX_ALL);
@@ -6899,7 +6907,7 @@ parse_numeric(struct parser_params *p, int c)
pushback(p, c);
tokfix(p);
if (toklen(p) == start) {
- no_digits();
+ return no_digits(p);
}
else if (nondigit) goto trailing_uc;
suffix = number_literal_suffix(p, NUM_SUFFIX_ALL);
@@ -6923,7 +6931,7 @@ parse_numeric(struct parser_params *p, int c)
pushback(p, c);
tokfix(p);
if (toklen(p) == start) {
- no_digits();
+ return no_digits(p);
}
else if (nondigit) goto trailing_uc;
suffix = number_literal_suffix(p, NUM_SUFFIX_ALL);
@@ -6937,7 +6945,7 @@ parse_numeric(struct parser_params *p, int c)
/* prefixed octal */
c = nextc(p);
if (c == -1 || c == '_' || !ISDIGIT(c)) {
- no_digits();
+ return no_digits(p);
}
}
if (c >= '0' && c <= '7') {