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

ruby-changes:14145

From: nobu <ko1@a...>
Date: Mon, 30 Nov 2009 11:00:35 +0900 (JST)
Subject: [ruby-changes:14145] Ruby:r25962 (trunk): * parse.y (parser_yylex): suppress an extra error message after

nobu	2009-11-30 11:00:14 +0900 (Mon, 30 Nov 2009)

  New Revision: 25962

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=25962

  Log:
    * parse.y (parser_yylex): suppress an extra error message after
      numeric literal without digits.  based on a patch from ujihisa .
      in [ruby-dev:39811].  [ruby-dev:39798]

  Modified files:
    trunk/ChangeLog
    trunk/parse.y
    trunk/test/ruby/test_literal.rb

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 25961)
+++ ChangeLog	(revision 25962)
@@ -1,3 +1,9 @@
+Mon Nov 30 11:00:12 2009  Nobuyoshi Nakada  <nobu@r...>
+
+	* parse.y (parser_yylex): suppress an extra error message after
+	  numeric literal without digits.  based on a patch from ujihisa .
+	  in [ruby-dev:39811].  [ruby-dev:39798]
+
 Sun Nov 29 16:56:24 2009  Nobuyoshi Nakada  <nobu@r...>
 
 	* vm_eval.c (check_funcall_failed): pass ID.  [ruby-core:26934]
Index: parse.y
===================================================================
--- parse.y	(revision 25961)
+++ parse.y	(revision 25962)
@@ -6902,6 +6902,7 @@
 		c = nextc();
 	    }
 	    if (c == '0') {
+#define no_digits() do {yyerror("numeric literal without digits"); return 0;} while (0)
 		int start = toklen();
 		c = nextc();
 		if (c == 'x' || c == 'X') {
@@ -6922,7 +6923,7 @@
 		    pushback(c);
 		    tokfix();
 		    if (toklen() == start) {
-			yyerror("numeric literal without digits");
+			no_digits();
 		    }
 		    else if (nondigit) goto trailing_uc;
 		    set_yylval_literal(rb_cstr_to_inum(tok(), 16, FALSE));
@@ -6946,7 +6947,7 @@
 		    pushback(c);
 		    tokfix();
 		    if (toklen() == start) {
-			yyerror("numeric literal without digits");
+			no_digits();
 		    }
 		    else if (nondigit) goto trailing_uc;
 		    set_yylval_literal(rb_cstr_to_inum(tok(), 2, FALSE));
@@ -6970,7 +6971,7 @@
 		    pushback(c);
 		    tokfix();
 		    if (toklen() == start) {
-			yyerror("numeric literal without digits");
+			no_digits();
 		    }
 		    else if (nondigit) goto trailing_uc;
 		    set_yylval_literal(rb_cstr_to_inum(tok(), 10, FALSE));
@@ -6984,7 +6985,7 @@
 		    /* prefixed octal */
 		    c = nextc();
 		    if (c == -1 || c == '_' || !ISDIGIT(c)) {
-			yyerror("numeric literal without digits");
+			no_digits();
 		    }
 		}
 		if (c >= '0' && c <= '7') {
Index: test/ruby/test_literal.rb
===================================================================
--- test/ruby/test_literal.rb	(revision 25961)
+++ test/ruby/test_literal.rb	(revision 25962)
@@ -211,6 +211,16 @@
         }
       }
     }
+    bug2407 = '[ruby-dev:39798]'
+    head.each {|h|
+      if /^0/ =~ h
+        begin
+          eval("#{h}_")
+        rescue SyntaxError => e
+          assert_match(/numeric literal without digits\Z/, e.message, bug2407)
+        end
+      end
+    }
   end
 
   def test_float

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

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