[前][次][番号順一覧][スレッド一覧]

ruby-changes:46067

From: nobu <ko1@a...>
Date: Sun, 26 Mar 2017 16:13:53 +0900 (JST)
Subject: [ruby-changes:46067] nobu:r58138 (trunk): parse.y: unterminated content token

nobu	2017-03-26 16:13:43 +0900 (Sun, 26 Mar 2017)

  New Revision: 58138

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=58138

  Log:
    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]

  Modified files:
    trunk/parse.y
    trunk/test/ripper/test_scanner_events.rb
Index: parse.y
===================================================================
--- parse.y	(revision 58137)
+++ parse.y	(revision 58138)
@@ -6207,15 +6207,14 @@ parser_parse_string(struct parser_params https://github.com/ruby/ruby/blob/trunk/parse.y#L6207
     pushback(c);
     if (tokadd_string(func, term, paren, &quote->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;
 	}
     }
 
Index: test/ripper/test_scanner_events.rb
===================================================================
--- test/ripper/test_scanner_events.rb	(revision 58137)
+++ test/ripper/test_scanner_events.rb	(revision 58138)
@@ -109,6 +109,9 @@ class TestRipper::ScannerEvents < Test:: https://github.com/ruby/ruby/blob/trunk/test/ripper/test_scanner_events.rb#L109
                    [[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

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]