@@ -10,6 +10,7 @@ const spaceChars = [' ', '\t'];
1010const lineBreakChars = [ '\r' , '\n' ] ;
1111const digit = / ^ [ 0 - 9 ] $ / ;
1212const wordChar = / ^ [ A - Z a - z 0 - 9 _ ] $ / ;
13+ const exponentIndicatorPattern = / ^ [ e E ] $ / ;
1314
1415/**
1516 * 入力文字列からトークンを読み取るクラス
@@ -436,12 +437,38 @@ export class Scanner implements ITokenStream {
436437 throw new AiScriptSyntaxError ( 'digit expected' , pos ) ;
437438 }
438439 }
440+
441+ let exponentIndicator = '' ;
442+ let exponentSign = '' ;
443+ let exponentAbsolute = '' ;
444+ if ( ! this . stream . eof && exponentIndicatorPattern . test ( this . stream . char as string ) ) {
445+ exponentIndicator = this . stream . char as string ;
446+ this . stream . next ( ) ;
447+ if ( ! this . stream . eof && ( this . stream . char as string ) === '-' ) {
448+ exponentSign = '-' ;
449+ this . stream . next ( ) ;
450+ } else if ( ! this . stream . eof && ( this . stream . char as string ) === '+' ) {
451+ exponentSign = '+' ;
452+ this . stream . next ( ) ;
453+ }
454+ while ( ! this . stream . eof && digit . test ( this . stream . char ) ) {
455+ exponentAbsolute += this . stream . char ;
456+ this . stream . next ( ) ;
457+ }
458+ if ( exponentAbsolute . length === 0 ) {
459+ throw new AiScriptSyntaxError ( 'exponent expected' , pos ) ;
460+ }
461+ }
462+
439463 let value : string ;
440464 if ( fractional . length > 0 ) {
441465 value = wholeNumber + '.' + fractional ;
442466 } else {
443467 value = wholeNumber ;
444468 }
469+ if ( exponentIndicator . length > 0 ) {
470+ value += exponentIndicator + exponentSign + exponentAbsolute ;
471+ }
445472 return TOKEN ( TokenKind . NumberLiteral , pos , { hasLeftSpacing, value } ) ;
446473 }
447474
0 commit comments