[#13161] hacking on the "heap" implementation in gc.c — Lloyd Hilaiel <lloyd@...>

Hi all,

16 messages 2007/11/01

[#13182] Thinking of dropping YAML from 1.8 — Urabe Shyouhei <shyouhei@...>

Hello all.

14 messages 2007/11/03

[#13315] primary encoding and source encoding — David Flanagan <david@...>

I've got a couple of questions about the handling of primary encoding.

29 messages 2007/11/08
[#13331] Re: primary encoding and source encoding — Yukihiro Matsumoto <matz@...> 2007/11/09

Hi,

[#13368] method names in 1.9 — "David A. Black" <dblack@...>

Hi --

61 messages 2007/11/10
[#13369] Re: method names in 1.9 — Yukihiro Matsumoto <matz@...> 2007/11/10

Hi,

[#13388] Re: method names in 1.9 — Charles Oliver Nutter <charles.nutter@...> 2007/11/11

Yukihiro Matsumoto wrote:

[#13403] Re: method names in 1.9 — "Austin Ziegler" <halostatue@...> 2007/11/11

On 11/11/07, Charles Oliver Nutter <charles.nutter@sun.com> wrote:

[#13410] Re: method names in 1.9 — David Flanagan <david@...> 2007/11/11

Austin Ziegler wrote:

[#13413] Re: method names in 1.9 — Charles Oliver Nutter <charles.nutter@...> 2007/11/11

David Flanagan wrote:

[#13423] Re: method names in 1.9 — Jordi <mumismo@...> 2007/11/12

Summing it up:

[#13386] Re: method names in 1.9 — Trans <transfire@...> 2007/11/11

[#13391] Re: method names in 1.9 — Matthew Boeh <mboeh@...> 2007/11/11

On Sun, Nov 11, 2007 at 05:50:18PM +0900, Trans wrote:

[#13457] mingw rename — "Roger Pack" <rogerpack2005@...>

Currently for different windows' builds, the names for RUBY_PLATFORM

13 messages 2007/11/13

[#13485] Proposal: Array#walker — Wolfgang Nádasi-Donner <ed.odanow@...>

Good morning all together!

23 messages 2007/11/14
[#13486] Re: Proposal: Array#walker — Wolfgang Nádasi-Donner <ed.odanow@...> 2007/11/14

A nicer version may be...

[#13488] Re: Proposal: Array#walker — Trans <transfire@...> 2007/11/14

[#13495] Re: Proposal: Array#walker — Trans <transfire@...> 2007/11/14

[#13498] state of threads in 1.9 — Jordi <mumismo@...>

Are Threads mapped to threads on the underlying operating system in

30 messages 2007/11/14
[#13519] Re: state of threads in 1.9 — "Bill Kelly" <billk@...> 2007/11/14

[#13526] Re: state of threads in 1.9 — Eric Hodel <drbrain@...7.net> 2007/11/14

On Nov 14, 2007, at 11:18 , Bill Kelly wrote:

[#13528] test/unit and miniunit — Ryan Davis <ryand-ruby@...>

When is the 1.9 freeze?

17 messages 2007/11/14

[#13564] Thoughts about Array#compact!, Array#flatten!, Array#reject!, String#strip!, String#capitalize!, String#gsub!, etc. — Wolfgang Nádasi-Donner <ed.odanow@...>

Good evening all together!

53 messages 2007/11/15
[#13575] Re: Thoughts about Array#compact!, Array#flatten!, Array#reject!, String#strip!, String#capitalize!, String#gsub!, etc. — "Nikolai Weibull" <now@...> 2007/11/15

On Nov 15, 2007 8:14 PM, Wolfgang N=E1dasi-Donner <ed.odanow@wonado.de> wro=

[#13578] Re: Thoughts about Array#compact!, Array#flatten!, Array#reject!, String#strip!, String#capitalize!, String#gsub!, etc. — Michael Neumann <mneumann@...> 2007/11/16

Nikolai Weibull schrieb:

[#13598] wondering about #tap (was: Re: Thoughts about Array#compact!, Array#flatten!, Array#reject!, String#strip!, String#capitalize!, String#gsub!, etc.) — "David A. Black" <dblack@...> 2007/11/16

Hi --

[#13605] Re: wondering about #tap (was: Re: Thoughts about Array#compact!, Array#flatten!, Array#reject!, String#strip!, String#capitalize!, String#gsub!, etc.) — Trans <transfire@...> 2007/11/16

[#13612] Re: wondering about #tap (was: Re: Thoughts about Array#compact!, Array#flatten!, Array#reject!, String#strip!, String#capitalize!, String#gsub!, etc.) — "David A. Black" <dblack@...> 2007/11/16

Hi --

[#13624] Re: wondering about #tap (was: Re: Thoughts about Array#compact!, Array#flatten!, Array#reject!, String#strip!, String#capitalize!, String#gsub!, etc.) — "Nikolai Weibull" <now@...> 2007/11/16

On Nov 16, 2007 12:40 PM, David A. Black <dblack@rubypal.com> wrote:

[#13632] Re: wondering about #tap — David Flanagan <david@...> 2007/11/16

David A. Black wrote:

[#13634] Re: wondering about #tap — "David A. Black" <dblack@...> 2007/11/16

Hi --

[#13636] Re: wondering about #tap — "Rick DeNatale" <rick.denatale@...> 2007/11/16

On Nov 16, 2007 12:40 PM, David A. Black <dblack@rubypal.com> wrote:

[#13637] Re: wondering about #tap — murphy <murphy@...> 2007/11/16

Rick DeNatale wrote:

[#13640] Re: wondering about #tap — Wolfgang Nádasi-Donner <ed.odanow@...> 2007/11/16

murphy schrieb:

[#13614] Suggestion for native thread tests — "Eust痃uio Rangel" <eustaquiorangel@...>

Hi!

12 messages 2007/11/16

[#13685] Problems with \M-x in utf-8 encoded strings — Wolfgang Nádasi-Donner <ed.odanow@...>

Hi!

11 messages 2007/11/18

[#13741] retry semantics changed — Dave Thomas <dave@...>

In 1.8, I could write:

46 messages 2007/11/23
[#13742] Re: retry semantics changed — "Brian Mitchell" <binary42@...> 2007/11/23

On Nov 23, 2007 12:06 PM, Dave Thomas <dave@pragprog.com> wrote:

[#13743] Re: retry semantics changed — Dave Thomas <dave@...> 2007/11/23

[#13746] Re: retry semantics changed — Yukihiro Matsumoto <matz@...> 2007/11/23

Hi,

[#13747] Re: retry semantics changed — Dave Thomas <dave@...> 2007/11/23

[#13748] Re: retry semantics changed — Yukihiro Matsumoto <matz@...> 2007/11/23

Hi,

[#13749] Re: retry semantics changed — Dave Thomas <dave@...> 2007/11/23

[PATCH]: Parse floating point literals that start with a dot

From: Brent Roman <brent@...>
Date: 2007-11-06 20:34:48 UTC
List: ruby-core #13244
The attached patch to 1.8.6-p110 yyparse.c allows Ruby's parser
to accept floating point literals that start with a decimal point.  e.g.

  x = .1
  y = -.86

Ruby 1.6.8 accepts these, later versions do not.

Folks, like myself, who use Ruby as a "domain specific" command parser
(and/or are porting from Ruby 1.6.8) may find it useful.
I can create a similar patch for Ruby 1.9 if there is interest. 

Note that the patch is much smaller than it looks.  I factored a  new
function parse_float() out of the code in the {very long} yylex() function
to avoid the need to repeat it.

- brent

Attachments (1)

decimal.patch (5.83 KB, text/x-patch)
--- ruby-1.8.6-p110/parse.y	2007-08-21 17:40:49.000000000 -0700
+++ ruby-1.8.6-mbari/parse.y	2007-11-05 23:55:27.000000000 -0800
@@ -2,8 +2,8 @@
 
   parse.y -
 
-  $Author: shyouhei $
-  $Date: 2007-08-22 09:40:49 +0900 (Wed, 22 Aug 2007) $
+  $Author: brent $
+  $Date: 2007/11/06 07:55:27 $
   created at: Fri May 28 18:02:42 JST 1993
 
   Copyright (C) 1993-2003 Yukihiro Matsumoto
@@ -3166,6 +3166,99 @@
     return tSTRING_CONTENT;
 }
 
+
+static int
+trailing_uc(int nondigit)
+{
+   char tmp[30];
+   sprintf(tmp, "trailing `%c' in number", nondigit);
+   yyerror(tmp);
+}
+
+static int
+parse_decimal(int c)
+{
+    int is_float, seen_point, seen_e, nondigit;
+
+    is_float = seen_point = seen_e = nondigit = 0;
+    for (;;) {
+	switch (c) {
+	  case '0': case '1': case '2': case '3': case '4':
+	  case '5': case '6': case '7': case '8': case '9':
+	    nondigit = 0;
+	    tokadd(c);
+	    break;
+
+	  case '.':
+	    if (nondigit)
+              trailing_uc(nondigit);
+	    if (seen_point || seen_e) {
+		goto decode_num;
+	    }
+	    else {
+		int c0 = nextc();
+		if (!ISDIGIT(c0)) {
+		    pushback(c0);
+		    goto decode_num;
+		}
+		c = c0;
+	    }
+	    tokadd('.');
+	    tokadd(c);
+	    is_float++;
+	    seen_point++;
+	    nondigit = 0;
+	    break;
+
+	  case 'e':
+	  case 'E':
+	    if (nondigit) {
+		pushback(c);
+		c = nondigit;
+		goto decode_num;
+	    }
+	    if (seen_e) {
+		goto decode_num;
+	    }
+	    tokadd(c);
+	    seen_e++;
+	    is_float++;
+	    nondigit = c;
+	    c = nextc();
+	    if (c != '-' && c != '+') continue;
+	    tokadd(c);
+	    nondigit = c;
+	    break;
+
+	  case '_':	/* `_' in number just ignored */
+	    if (nondigit) goto decode_num;
+	    nondigit = c;
+	    break;
+
+	  default:
+	    goto decode_num;
+	}
+	c = nextc();
+    }
+
+  decode_num:
+    pushback(c);
+    tokfix();
+    if (nondigit) 
+      trailing_uc(nondigit);
+    if (is_float) {
+	double d = strtod(tok(), 0);
+	if (errno == ERANGE) {
+	    rb_warn("Float %s out of range", tok());
+	    errno = 0;
+	}
+	yylval.node = NEW_LIT(rb_float_new(d));
+	return tFLOAT;
+    }
+    yylval.node = NEW_LIT(rb_cstr_to_inum(tok(), 10, Qfalse));
+    return tINTEGER;
+}
+
 static int
 heredoc_identifier()
 {
@@ -3772,7 +3865,8 @@
 	}
 	pushback(c);
 	if (ISDIGIT(c)) {
-	    yyerror("no .<digit> floating literal anymore; put 0 before dot");
+	    newtok();
+            return parse_decimal('.');
 	}
 	lex_state = EXPR_DOT;
 	return '.';
@@ -3781,9 +3875,8 @@
       case '0': case '1': case '2': case '3': case '4':
       case '5': case '6': case '7': case '8': case '9':
 	{
-	    int is_float, seen_point, seen_e, nondigit;
+	    int nondigit = 0;
 
-	    is_float = seen_point = seen_e = nondigit = 0;
 	    lex_state = EXPR_END;
 	    newtok();
 	    if (c == '-' || c == '+') {
@@ -3813,7 +3906,8 @@
 		    if (toklen() == start) {
 			yyerror("numeric literal without digits");
 		    }
-		    else if (nondigit) goto trailing_uc;
+		    else if (nondigit)
+                      trailing_uc(nondigit);
 		    yylval.node = NEW_LIT(rb_cstr_to_inum(tok(), 16, Qfalse));
 		    return tINTEGER;
 		}
@@ -3837,7 +3931,8 @@
 		    if (toklen() == start) {
 			yyerror("numeric literal without digits");
 		    }
-		    else if (nondigit) goto trailing_uc;
+		    else if (nondigit)
+                      trailing_uc(nondigit);
 		    yylval.node = NEW_LIT(rb_cstr_to_inum(tok(), 2, Qfalse));
 		    return tINTEGER;
 		}
@@ -3861,7 +3956,8 @@
 		    if (toklen() == start) {
 			yyerror("numeric literal without digits");
 		    }
-		    else if (nondigit) goto trailing_uc;
+		    else if (nondigit)
+                      trailing_uc(nondigit);
 		    yylval.node = NEW_LIT(rb_cstr_to_inum(tok(), 10, Qfalse));
 		    return tINTEGER;
 		}
@@ -3892,13 +3988,14 @@
 		    if (toklen() > start) {
 			pushback(c);
 			tokfix();
-			if (nondigit) goto trailing_uc;
+			if (nondigit)
+                          trailing_uc(nondigit);
 			yylval.node = NEW_LIT(rb_cstr_to_inum(tok(), 8, Qfalse));
 			return tINTEGER;
 		    }
 		    if (nondigit) {
 			pushback(c);
-			goto trailing_uc;
+			trailing_uc(nondigit);
 		    }
 		}
 		if (c > '7' && c <= '9') {
@@ -3913,87 +4010,8 @@
 		    return tINTEGER;
 		}
 	    }
-
-	    for (;;) {
-		switch (c) {
-		  case '0': case '1': case '2': case '3': case '4':
-		  case '5': case '6': case '7': case '8': case '9':
-		    nondigit = 0;
-		    tokadd(c);
-		    break;
-
-		  case '.':
-		    if (nondigit) goto trailing_uc;
-		    if (seen_point || seen_e) {
-			goto decode_num;
-		    }
-		    else {
-			int c0 = nextc();
-			if (!ISDIGIT(c0)) {
-			    pushback(c0);
-			    goto decode_num;
-			}
-			c = c0;
-		    }
-		    tokadd('.');
-		    tokadd(c);
-		    is_float++;
-		    seen_point++;
-		    nondigit = 0;
-		    break;
-
-		  case 'e':
-		  case 'E':
-		    if (nondigit) {
-			pushback(c);
-			c = nondigit;
-			goto decode_num;
-		    }
-		    if (seen_e) {
-			goto decode_num;
-		    }
-		    tokadd(c);
-		    seen_e++;
-		    is_float++;
-		    nondigit = c;
-		    c = nextc();
-		    if (c != '-' && c != '+') continue;
-		    tokadd(c);
-		    nondigit = c;
-		    break;
-
-		  case '_':	/* `_' in number just ignored */
-		    if (nondigit) goto decode_num;
-		    nondigit = c;
-		    break;
-
-		  default:
-		    goto decode_num;
-		}
-		c = nextc();
-	    }
-
-	  decode_num:
-	    pushback(c);
-	    tokfix();
-	    if (nondigit) {
-		char tmp[30];
-	      trailing_uc:
-		sprintf(tmp, "trailing `%c' in number", nondigit);
-		yyerror(tmp);
-	    }
-	    if (is_float) {
-		double d = strtod(tok(), 0);
-		if (errno == ERANGE) {
-		    rb_warn("Float %s out of range", tok());
-		    errno = 0;
-		}
-		yylval.node = NEW_LIT(rb_float_new(d));
-		return tFLOAT;
-	    }
-	    yylval.node = NEW_LIT(rb_cstr_to_inum(tok(), 10, Qfalse));
-	    return tINTEGER;
-	}
+            return parse_decimal(c);
+         }
 
       case ']':
       case '}':

In This Thread

Prev Next