Skip to content

Commit d12bb85

Browse files
committed
disable exponential-notation for now
#954 (comment)
1 parent a58e85b commit d12bb85

File tree

3 files changed

+28
-29
lines changed

3 files changed

+28
-29
lines changed

src/parser/scanner.ts

Lines changed: 26 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const digit = /^[0-9]$/;
1313
const identifierStart = /^[A-Za-z_]$/u;
1414
const identifierPart = /^[A-Za-z0-9_]$/u;
1515
const hexDigit = /^[0-9a-fA-F]$/;
16-
const exponentIndicatorPattern = /^[eE]$/;
16+
//const exponentIndicatorPattern = /^[eE]$/;
1717

1818
/**
1919
* 入力文字列からトークンを読み取るクラス
@@ -330,9 +330,6 @@ export class Scanner implements ITokenStream {
330330
throw new AiScriptSyntaxError(`invalid character: "${this.stream.char}"`, pos);
331331
}
332332
}
333-
// Use `return` or `continue` before reaching this line.
334-
// Do not add any more code here. This line should be unreachable.
335-
break;
336333
}
337334
// Use `return` or `continue` before reaching this line.
338335
// Do not add any more code here. This line should be unreachable.
@@ -508,37 +505,38 @@ export class Scanner implements ITokenStream {
508505
}
509506
}
510507

511-
let exponentIndicator = '';
512-
let exponentSign = '';
513-
let exponentAbsolute = '';
514-
if (!this.stream.eof && exponentIndicatorPattern.test(this.stream.char as string)) {
515-
exponentIndicator = this.stream.char as string;
516-
this.stream.next();
517-
if (!this.stream.eof && (this.stream.char as string) === '-') {
518-
exponentSign = '-';
519-
this.stream.next();
520-
} else if (!this.stream.eof && (this.stream.char as string) === '+') {
521-
exponentSign = '+';
522-
this.stream.next();
523-
}
524-
while (!this.stream.eof && digit.test(this.stream.char)) {
525-
exponentAbsolute += this.stream.char;
526-
this.stream.next();
527-
}
528-
if (exponentAbsolute.length === 0) {
529-
throw new AiScriptSyntaxError('exponent expected', pos);
530-
}
531-
}
508+
// 指数表記仕様が必要になった段階で有効化する
509+
//let exponentIndicator = '';
510+
//let exponentSign = '';
511+
//let exponentAbsolute = '';
512+
//if (!this.stream.eof && exponentIndicatorPattern.test(this.stream.char as string)) {
513+
// exponentIndicator = this.stream.char as string;
514+
// this.stream.next();
515+
// if (!this.stream.eof && (this.stream.char as string) === '-') {
516+
// exponentSign = '-';
517+
// this.stream.next();
518+
// } else if (!this.stream.eof && (this.stream.char as string) === '+') {
519+
// exponentSign = '+';
520+
// this.stream.next();
521+
// }
522+
// while (!this.stream.eof && digit.test(this.stream.char)) {
523+
// exponentAbsolute += this.stream.char;
524+
// this.stream.next();
525+
// }
526+
// if (exponentAbsolute.length === 0) {
527+
// throw new AiScriptSyntaxError('exponent expected', pos);
528+
// }
529+
//}
532530

533531
let value: string;
534532
if (fractional.length > 0) {
535533
value = wholeNumber + '.' + fractional;
536534
} else {
537535
value = wholeNumber;
538536
}
539-
if (exponentIndicator.length > 0) {
540-
value += exponentIndicator + exponentSign + exponentAbsolute;
541-
}
537+
//if (exponentIndicator.length > 0) {
538+
// value += exponentIndicator + exponentSign + exponentAbsolute;
539+
//}
542540
return TOKEN(TokenKind.NumberLiteral, pos, { hasLeftSpacing, value });
543541
}
544542

test/literals.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ describe('literal', () => {
5858
eq(res, NUM(0.5));
5959
});
6060

61+
/* 指数表記仕様が必要になった段階で有効化する
6162
test.concurrent('number (positive exponent without plus sign)', async () => {
6263
const res = await exe(`
6364
<: 1.2e3
@@ -84,6 +85,7 @@ describe('literal', () => {
8485
<: 1.2e+
8586
`), 'exponent expected');
8687
});
88+
*/
8789

8890
test.concurrent('arr (separated by comma)', async () => {
8991
const res = await exe(`

unreleased/exponential-notation.md

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)