@@ -2,10 +2,10 @@ import StringUtils from "../utils/string_utils";
22
33/**
44 * Utility class for walking through a string character by character during tokenization.
5- *
5+ *
66 * Provides methods to check for specific character patterns, move through the string,
77 * and extract substrings. Used by the Tokenizer to process input text.
8- *
8+ *
99 * @example
1010 * ```typescript
1111 * const walker = new StringWalker("WITH x as variable");
@@ -20,7 +20,7 @@ class StringWalker {
2020
2121 /**
2222 * Creates a new StringWalker for the given text.
23- *
23+ *
2424 * @param text - The input text to walk through
2525 */
2626 constructor ( text : string ) {
@@ -81,42 +81,45 @@ class StringWalker {
8181 }
8282
8383 public singleLineCommentStart ( ) : boolean {
84- return this . currentChar === '/' && this . nextChar === '/' ;
84+ return this . currentChar === "/" && this . nextChar === "/" ;
8585 }
8686
8787 public multiLineCommentStart ( ) : boolean {
88- return this . currentChar === '/' && this . nextChar === '*' ;
88+ return this . currentChar === "/" && this . nextChar === "*" ;
8989 }
9090
9191 public multiLineCommentEnd ( ) : boolean {
92- return this . currentChar === '*' && this . nextChar === '/' ;
92+ return this . currentChar === "*" && this . nextChar === "/" ;
9393 }
9494
9595 public newLine ( ) : boolean {
96- if ( this . currentChar === '\n' ) {
96+ if ( this . currentChar === "\n" ) {
9797 return true ;
9898 }
9999 return false ;
100100 }
101101
102102 public escaped ( char : string ) : boolean {
103- return this . currentChar === '\\' && this . nextChar === char ;
103+ return this . currentChar === "\\" && this . nextChar === char ;
104104 }
105105
106106 public escapedBrace ( ) : boolean {
107- return ( this . currentChar === '{' && this . nextChar === '{' ) || ( this . currentChar === '}' && this . nextChar === '}' ) ;
107+ return (
108+ ( this . currentChar === "{" && this . nextChar === "{" ) ||
109+ ( this . currentChar === "}" && this . nextChar === "}" )
110+ ) ;
108111 }
109112
110113 public openingBrace ( ) : boolean {
111- return this . currentChar === '{' ;
114+ return this . currentChar === "{" ;
112115 }
113116
114117 public closingBrace ( ) : boolean {
115- return this . currentChar === '}' ;
118+ return this . currentChar === "}" ;
116119 }
117120
118121 public checkForUnderScore ( ) : boolean {
119- const foundUnderScore = this . currentChar === '_' ;
122+ const foundUnderScore = this . currentChar === "_" ;
120123 if ( foundUnderScore ) {
121124 this . _position ++ ;
122125 }
@@ -141,7 +144,7 @@ class StringWalker {
141144
142145 public checkForQuote ( ) : string | null {
143146 const quoteChar = this . currentChar ;
144- if ( quoteChar === '"' || quoteChar === "'" || quoteChar === '`' ) {
147+ if ( quoteChar === '"' || quoteChar === "'" || quoteChar === "`" ) {
145148 this . _position ++ ;
146149 return quoteChar ;
147150 }
@@ -163,7 +166,7 @@ class StringWalker {
163166 }
164167
165168 public checkForFStringStart ( ) : boolean {
166- return this . currentChar . toLowerCase ( ) === 'f' && [ '\'' , '"' , '`' ] . includes ( this . nextChar ) ;
169+ return this . currentChar . toLowerCase ( ) === "f" && [ "'" , '"' , "`" ] . includes ( this . nextChar ) ;
167170 }
168171
169172 public moveNext ( ) : void {
@@ -187,8 +190,8 @@ class StringWalker {
187190
188191 public word_continuation ( word : string ) : boolean {
189192 const next = this . text [ this . position + word . length ] ;
190- return StringUtils . word_valid_chars . includes ( next ) ;
193+ return next !== undefined && StringUtils . word_valid_chars . includes ( next . toLowerCase ( ) ) ;
191194 }
192195}
193196
194- export default StringWalker ;
197+ export default StringWalker ;
0 commit comments