diff options
author | nagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-03-22 14:26:42 +0000 |
---|---|---|
committer | nagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-03-22 14:26:42 +0000 |
commit | ddd7dd0f8cb255f81603de6e0656f0fd0c245804 (patch) | |
tree | 465af15ea1bab2cf418073e74cbfa5ddb70c8e29 /parse.y | |
parent | 10e0fc1b6c8fdc8d275653052e129a2d7569e58b (diff) |
merge revision(s) 56020,57717: [Backport #13253]
parse.y: heredoc token
* parse.y (parser_heredoc_identifier): gather branches by quote
char.
parse.y: indent at invalid identifier
* parse.y (parser_heredoc_identifier): set indent only when valid
identifier, not to dedent non-existent contents later.
[ruby-core:79772] [Bug #13253]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_3@58061 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'parse.y')
-rw-r--r-- | parse.y | 16 |
1 files changed, 10 insertions, 6 deletions
@@ -6526,7 +6526,9 @@ static int parser_heredoc_identifier(struct parser_params *parser) { int c = nextc(), term, func = 0; + int token = tSTRING_BEG; long len; + int indent = 0; if (c == '-') { c = nextc(); @@ -6535,8 +6537,7 @@ parser_heredoc_identifier(struct parser_params *parser) else if (c == '~') { c = nextc(); func = STR_FUNC_INDENT; - heredoc_indent = INT_MAX; - heredoc_line_indent = 0; + indent = INT_MAX; } switch (c) { case '\'': @@ -6544,7 +6545,9 @@ parser_heredoc_identifier(struct parser_params *parser) case '"': func |= str_dquote; goto quoted; case '`': - func |= str_xquote; + token = tXSTRING_BEG; + func |= str_xquote; goto quoted; + quoted: newtok(); tokadd(func); @@ -6562,12 +6565,11 @@ parser_heredoc_identifier(struct parser_params *parser) if (!parser_is_identchar()) { pushback(c); if (func & STR_FUNC_INDENT) { - pushback(heredoc_indent > 0 ? '~' : '-'); + pushback(indent > 0 ? '~' : '-'); } return 0; } newtok(); - term = '"'; tokadd(func |= str_dquote); do { if (tokadd_mbchar(c) == -1) return 0; @@ -6586,7 +6588,9 @@ parser_heredoc_identifier(struct parser_params *parser) lex_lastline); /* nd_orig */ nd_set_line(lex_strterm, ruby_sourceline); ripper_flush(parser); - return term == '`' ? tXSTRING_BEG : tSTRING_BEG; + heredoc_indent = indent; + heredoc_line_indent = 0; + return token; } static void |