summaryrefslogtreecommitdiff
path: root/parse.y
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-07-15 08:29:03 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-07-15 08:29:03 +0000
commit70af8d3c9ca2a46ef1f364783125a747d9426b2b (patch)
treec1673a07e0d1ae963a963b77e221ca4724e00433 /parse.y
parenta7452a8f4f80ba12022b1bd381af17c29c1fcffd (diff)
parse.y: refine error messages
* parse.y (parser_read_escape, parser_tok_hex): refine error messages. point from the backslash up to the invalid char. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59341 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'parse.y')
-rw-r--r--parse.y7
1 files changed, 5 insertions, 2 deletions
diff --git a/parse.y b/parse.y
index 3c76d99585..c681d41a74 100644
--- a/parse.y
+++ b/parse.y
@@ -5636,6 +5636,7 @@ parser_tok_hex(struct parser_params *parser, size_t *numlen)
c = scan_hex(lex_p, 2, numlen);
if (!*numlen) {
+ parser->tokp = lex_p;
yyerror("invalid hex escape");
return 0;
}
@@ -5780,7 +5781,6 @@ parser_read_escape(struct parser_params *parser, int flags,
case 'M':
if (flags & ESCAPE_META) goto eof;
if ((c = nextc()) != '-') {
- pushback(c);
goto eof;
}
if ((c = nextc()) == '\\') {
@@ -5794,7 +5794,6 @@ parser_read_escape(struct parser_params *parser, int flags,
case 'C':
if ((c = nextc()) != '-') {
- pushback(c);
goto eof;
}
case 'c':
@@ -5811,6 +5810,7 @@ parser_read_escape(struct parser_params *parser, int flags,
eof:
case -1:
yyerror("Invalid escape character syntax");
+ pushback(c);
return '\0';
default:
@@ -6045,6 +6045,9 @@ parser_tokadd_string(struct parser_params *parser,
}
else if (c == '\\') {
const char *beg = lex_p - 1;
+#ifndef RIPPER
+ parser->tokp = beg;
+#endif
c = nextc();
switch (c) {
case '\n':