summaryrefslogtreecommitdiff
path: root/parse.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>1999-02-09 06:08:24 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>1999-02-09 06:08:24 +0000
commit115eb4595cea72226ec8acd357e7c403e2c4b04a (patch)
treec050f1ee16f730fc7dbc89586e09b33a23196485 /parse.c
parent9b64dfe3b8f0343ebf97ae80d3a4ec3f4bd115b3 (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.c')
-rw-r--r--parse.c37
1 files changed, 29 insertions, 8 deletions
diff --git a/parse.c b/parse.c
index e7385cd5a6..379d0328bd 100644
--- a/parse.c
+++ b/parse.c
@@ -5376,7 +5376,7 @@ retry:
for (i = 0; i < len; i++) {
c = nextc();
if (c == '\n') {
- ruby_sourceline++;
+ pushback(c);
break;
}
}
@@ -5689,23 +5689,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);