jscript: Added support for octal literals.

This commit is contained in:
Jacek Caban 2013-11-06 17:18:28 +01:00 committed by Alexandre Julliard
parent de9e1cdcae
commit 4d9ea4b563
2 changed files with 37 additions and 4 deletions

View File

@ -484,15 +484,37 @@ static int parse_numeric_literal(parser_ctx_t *ctx, literal_t **literal)
return tNumericLiteral;
}
if(isdigitW(*ctx->ptr)) {
unsigned base = 8;
const WCHAR *ptr;
double val = 0;
for(ptr = ctx->ptr; ptr < ctx->end && isdigitW(*ptr); ptr++) {
if(*ptr > '7') {
base = 10;
break;
}
}
do {
val = val*base + *ctx->ptr-'0';
}while(++ctx->ptr < ctx->end && isdigitW(*ctx->ptr));
/* FIXME: Do we need it here? */
if(ctx->ptr < ctx->end && (is_identifier_char(*ctx->ptr) || *ctx->ptr == '.')) {
WARN("wrong char after octal literal: '%c'\n", *ctx->ptr);
return lex_error(ctx, JS_E_MISSING_SEMICOLON);
}
*literal = new_double_literal(ctx, val);
return tNumericLiteral;
}
if(is_identifier_char(*ctx->ptr)) {
WARN("wrong char after zero\n");
return lex_error(ctx, E_FAIL);
}
if(isdigitW(*ctx->ptr)) {
FIXME("octal literals not implemented\n");
return lex_error(ctx, E_NOTIMPL);
}
}
return parse_double_literal(ctx, l, literal);

View File

@ -38,6 +38,17 @@ ok(1000000*1000000 === 1000000000000, "1000000*1000000 === 1000000000000 is fals
ok(8.64e15 === 8640000000000000, "8.64e15 !== 8640000000000000");
ok(1e2147483648 === Infinity, "1e2147483648 !== Infinity");
ok(00 === 0, "00 != 0");
ok(010 === 8, "010 != 8");
ok(077 === 63, "077 != 63");
ok(080 === 80, "080 != 80");
ok(090 === 90, "090 != 90");
ok(018 === 18, "018 != 18");
tmp = 07777777777777777777777;
ok(typeof(tmp) === "number" && tmp > 0xffffffff, "tmp = " + tmp);
tmp = 07777777779777777777777;
ok(typeof(tmp) === "number" && tmp > 0xffffffff, "tmp = " + tmp);
ok(1 !== 2, "1 !== 2 is false");
ok(null !== undefined, "null !== undefined is false");