summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKevin Newton <kddnewton@gmail.com>2023-08-01 11:11:40 -0400
committerTakashi Kokubun <takashikkbn@gmail.com>2023-08-16 17:47:32 -0700
commitcededf73dca8986aec44e01647be8bef8cb85579 (patch)
treecc9fcbd9f6c3d47e36d6833986bbfee840fe76e9
parent242f3c3a77007c260d7d868cff3fd5f293e8aaa1 (diff)
[ruby/yarp] For errored % characters, use TOKEN_PERCENT and not TOKEN_STRING_BEGIN
https://github.com/ruby/yarp/commit/2ec671fe1e
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/8226
-rw-r--r--yarp/yarp.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/yarp/yarp.c b/yarp/yarp.c
index 9aa4e264c6..ee9aa1b172 100644
--- a/yarp/yarp.c
+++ b/yarp/yarp.c
@@ -6325,12 +6325,14 @@ parser_lex(yp_parser_t *parser) {
// % %= %i %I %q %Q %w %W
case '%': {
- // In a BEG state, if you encounter a % then you must be starting
- // something. In this case if there is no subsequent character then
- // we have an invalid token.
+ // In a BEG state, if you encounter a % then you must be
+ // starting something. In this case if there is no
+ // subsequent character then we have an invalid token. We're
+ // going to say it's the percent operator because we don't
+ // want to move into the string lex mode unnecessarily.
if (lex_state_beg_p(parser) && (parser->current.end >= parser->end)) {
yp_diagnostic_list_append(&parser->error_list, parser->current.start, parser->current.end, "unexpected end of input");
- LEX(YP_TOKEN_STRING_BEGIN);
+ LEX(YP_TOKEN_PERCENT);
}
if (!lex_state_beg_p(parser) && match(parser, '=')) {