diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 1999-02-09 06:08:24 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 1999-02-09 06:08:24 +0000 |
commit | 115eb4595cea72226ec8acd357e7c403e2c4b04a (patch) | |
tree | c050f1ee16f730fc7dbc89586e09b33a23196485 /parse.y | |
parent | 9b64dfe3b8f0343ebf97ae80d3a4ec3f4bd115b3 (diff) |
990209
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_3@394 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'parse.y')
-rw-r--r-- | parse.y | 37 |
1 files changed, 29 insertions, 8 deletions
@@ -2465,7 +2465,7 @@ retry: for (i = 0; i < len; i++) { c = nextc(); if (c == '\n') { - ruby_sourceline++; + pushback(c); break; } } @@ -2778,23 +2778,44 @@ retry: c = nextc(); if (c == 'x' || c == 'X') { /* hexadecimal */ - while (c = nextc()) { + c = nextc(); + if (!ISXDIGIT(c)) { + yyerror("hexadecimal number without hex-digits"); + } + do { if (c == '_') continue; if (!ISXDIGIT(c)) break; tokadd(c); - } + } while (c = nextc()); pushback(c); tokfix(); yylval.val = rb_str2inum(tok(), 16); return tINTEGER; } - else if (c >= '0' && c <= '7') { - /* octal */ + if (c == 'b' || c == 'B') { + /* binary */ + c = nextc(); + if (c != '0' && c != '1') { + yyerror("numeric constant with no digits"); + } do { + if (c == '_') continue; + if (c != '0'&& c != '1') break; + tokadd(c); + } while (c = nextc()); + pushback(c); + tokfix(); + yylval.val = rb_str2inum(tok(), 2); + return tINTEGER; + } + else if (c >= '0' && c <= '7' || c == '_') { + /* octal */ + tokadd(c); + do { + if (c == '_') continue; + if (c < '0' || c > '7') break; tokadd(c); - while ((c = nextc()) == '_') - ; - } while (c >= '0' && c <= '9'); + } while (c = nextc()); pushback(c); tokfix(); yylval.val = rb_str2inum(tok(), 8); |