@@ -5,6 +5,7 @@ import type { TokenKindEnum } from './tokenKind';
5
5
import { Token } from './ast' ;
6
6
import { TokenKind } from './tokenKind' ;
7
7
import { dedentBlockStringValue } from './blockString' ;
8
+ import { isDigit , isNameStart , isNameContinue } from './characterClasses' ;
8
9
9
10
/**
10
11
* Given a Source object, creates a Lexer for that source.
@@ -836,15 +837,6 @@ function readBlockString(lexer: Lexer, start: number): Token {
836
837
* ```
837
838
* Name ::
838
839
* - NameStart NameContinue* [lookahead != NameContinue]
839
- *
840
- * NameStart ::
841
- * - Letter
842
- * - `_`
843
- *
844
- * NameContinue ::
845
- * - Letter
846
- * - Digit
847
- * - `_`
848
840
* ```
849
841
*/
850
842
function readName ( lexer : Lexer , start : number ) : Token {
@@ -854,8 +846,7 @@ function readName(lexer: Lexer, start: number): Token {
854
846
855
847
while ( position < bodyLength ) {
856
848
const code = body . charCodeAt ( position ) ;
857
- // NameContinue
858
- if ( isLetter ( code ) || isDigit ( code ) || code === 0x005f ) {
849
+ if ( isNameContinue ( code ) ) {
859
850
++ position ;
860
851
} else {
861
852
break ;
@@ -870,33 +861,3 @@ function readName(lexer: Lexer, start: number): Token {
870
861
body . slice ( start , position ) ,
871
862
) ;
872
863
}
873
-
874
- function isNameStart ( code : number ) : boolean {
875
- return isLetter ( code ) || code === 0x005f ;
876
- }
877
-
878
- /**
879
- * ```
880
- * Digit :: one of
881
- * - `0` `1` `2` `3` `4` `5` `6` `7` `8` `9`
882
- * ```
883
- */
884
- function isDigit ( code : number ) : boolean {
885
- return code >= 0x0030 && code <= 0x0039 ;
886
- }
887
-
888
- /**
889
- * ```
890
- * Letter :: one of
891
- * - `A` `B` `C` `D` `E` `F` `G` `H` `I` `J` `K` `L` `M`
892
- * - `N` `O` `P` `Q` `R` `S` `T` `U` `V` `W` `X` `Y` `Z`
893
- * - `a` `b` `c` `d` `e` `f` `g` `h` `i` `j` `k` `l` `m`
894
- * - `n` `o` `p` `q` `r` `s` `t` `u` `v` `w` `x` `y` `z`
895
- * ```
896
- */
897
- function isLetter ( code : number ) : boolean {
898
- return (
899
- ( code >= 0x0061 && code <= 0x007a ) || // A-Z
900
- ( code >= 0x0041 && code <= 0x005a ) // a-z
901
- ) ;
902
- }
0 commit comments