From: nobu.nokada@... Date: 2002-01-04T22:12:40+09:00 Subject: [ruby-talk:30211] Re: Bug? At Fri, 4 Jan 2002 20:37:04 +0900, Hi, Martin Kahlert wrote: > I came across this strangeness in 1.6.6: > irb(main):001:0> p 1e0 > 1.0 > nil > irb(main):002:0> p 0e0 > SyntaxError: compile error > (irb):2: parse error > from (irb):2 > > Is this a bug? I think so, and guess 0x_0 and 0b_0 should be error oppositely. Index: parse.y =================================================================== RCS file: /cvs/ruby/src/ruby/parse.y,v retrieving revision 1.138 diff -u -2 -p -r1.138 parse.y --- parse.y 2001/12/31 05:23:53 1.138 +++ parse.y 2002/01/04 12:47:53 @@ -3329,13 +3329,15 @@ yylex() /* hexadecimal */ c = nextc(); - do { - if (c == '_') { - seen_uc = 1; - continue; - } - if (!ISXDIGIT(c)) break; - seen_uc = 0; - tokadd(c); - } while (c = nextc()); + if (ISXDIGIT(c)) { + do { + if (c == '_') { + seen_uc = 1; + continue; + } + if (!ISXDIGIT(c)) break; + seen_uc = 0; + tokadd(c); + } while (c = nextc()); + } pushback(c); tokfix(); @@ -3350,13 +3352,15 @@ yylex() /* binary */ c = nextc(); - do { - if (c == '_') { - seen_uc = 1; - continue; - } - if (c != '0'&& c != '1') break; - seen_uc = 0; - tokadd(c); - } while (c = nextc()); + if (c == '0' || c != '1') { + do { + if (c == '_') { + seen_uc = 1; + continue; + } + if (c != '0' && c != '1') break; + seen_uc = 0; + tokadd(c); + } while (c = nextc()); + } pushback(c); tokfix(); @@ -3388,5 +3392,5 @@ yylex() yyerror("Illegal octal digit"); } - else if (c == '.') { + else if (c == '.' || c == 'e' || c == 'E' || c == 'f' || c == 'F') { tokadd('0'); } -- Nobu Nakada