mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
parse.y: unterminated content token
* parse.y (parser_parse_string): defer the end token to next reading, to yield tSTRING_CONTENT with the unterminated content. [Bug #13363] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58138 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
07e4aa67e1
commit
cb64ef240b
2 changed files with 9 additions and 7 deletions
13
parse.y
13
parse.y
|
@ -6207,15 +6207,14 @@ parser_parse_string(struct parser_params *parser, NODE *quote)
|
|||
pushback(c);
|
||||
if (tokadd_string(func, term, paren, "e->nd_nest,
|
||||
&enc) == -1) {
|
||||
if (func & STR_FUNC_REGEXP) {
|
||||
if (parser->eofp)
|
||||
if (parser->eofp) {
|
||||
if (func & STR_FUNC_REGEXP) {
|
||||
compile_error(PARSER_ARG "unterminated regexp meets end of file");
|
||||
return tREGEXP_END;
|
||||
}
|
||||
else {
|
||||
if (parser->eofp)
|
||||
}
|
||||
else {
|
||||
compile_error(PARSER_ARG "unterminated string meets end of file");
|
||||
return tSTRING_END;
|
||||
}
|
||||
quote->u2.id = STR_TERM_END;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -109,6 +109,9 @@ class TestRipper::ScannerEvents < Test::Unit::TestCase
|
|||
[[3, 0], :on_heredoc_end, "EOS"]
|
||||
],
|
||||
Ripper.lex("<<~EOS\n heredoc\nEOS")
|
||||
assert_equal [[[1, 0], :on_tstring_beg, "'"],
|
||||
[[1, 1], :on_tstring_content, "foo"]],
|
||||
Ripper.lex("'foo")
|
||||
end
|
||||
|
||||
def test_location
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue