File tree Expand file tree Collapse file tree 1 file changed +9
-19
lines changed Expand file tree Collapse file tree 1 file changed +9
-19
lines changed Original file line number Diff line number Diff line change 197
197
"!" : true
198
198
} ;
199
199
200
- var numbers = {
201
- 0 : true ,
202
- 1 : true ,
203
- 2 : true ,
204
- 3 : true ,
205
- 4 : true ,
206
- 5 : true ,
207
- 6 : true ,
208
- 7 : true ,
209
- 8 : true ,
210
- 9 : true ,
211
- "-" : true
212
- } ;
213
-
214
200
var skipChars = {
215
201
" " : true ,
216
202
"\t" : true ,
217
203
"\n" : true
218
204
} ;
219
205
220
206
221
- function isAlpha ( ch ) {
207
+ function isAlpha ( ch ) {
222
208
return ( ch >= "a" && ch <= "z" ) ||
223
209
( ch >= "A" && ch <= "Z" ) ||
224
- ch === "_"
210
+ ch === "_" ;
225
211
}
226
212
213
+ function isNum ( ch ) {
214
+ return ( ch >= "0" && ch <= "9" ) ||
215
+ ch === "-" ;
216
+ }
227
217
function isAlphaNum ( ch ) {
228
218
return ( ch >= "a" && ch <= "z" ) ||
229
219
( ch >= "A" && ch <= "Z" ) ||
230
220
( ch >= "0" && ch <= "9" ) ||
231
- ch === "_"
221
+ ch === "_" ;
232
222
}
233
223
234
224
function Lexer ( ) {
252
242
value : stream [ this . current ] ,
253
243
start : this . current } ) ;
254
244
this . current ++ ;
255
- } else if ( numbers [ stream [ this . current ] ] !== undefined ) {
245
+ } else if ( isNum ( stream [ this . current ] ) ) {
256
246
token = this . consumeNumber ( stream ) ;
257
247
tokens . push ( token ) ;
258
248
} else if ( stream [ this . current ] === "[" ) {
362
352
var start = this . current ;
363
353
this . current ++ ;
364
354
var maxLength = stream . length ;
365
- while ( numbers [ stream [ this . current ] ] !== undefined && this . current < maxLength ) {
355
+ while ( isNum ( stream [ this . current ] ) && this . current < maxLength ) {
366
356
this . current ++ ;
367
357
}
368
358
var value = parseInt ( stream . slice ( start , this . current ) ) ;
You can’t perform that action at this time.
0 commit comments