mirror of
https://github.com/jamiebuilds/the-super-tiny-compiler.git
synced 2024-10-27 20:34:08 +00:00
Fix lexer issue with name, update tokens to const
/undefined/.test() returns true, so ```parser('test');``` will infinite loop. Tokens is never redefined, so const is preferred.
This commit is contained in:
parent
4f7a85a9f8
commit
10884cbb4d
@ -384,7 +384,7 @@ function tokenizer(input) {
|
|||||||
let current = 0;
|
let current = 0;
|
||||||
|
|
||||||
// And a `tokens` array for pushing our tokens to.
|
// And a `tokens` array for pushing our tokens to.
|
||||||
let tokens = [];
|
const tokens = [];
|
||||||
|
|
||||||
// We start by creating a `while` loop where we are setting up our `current`
|
// We start by creating a `while` loop where we are setting up our `current`
|
||||||
// variable to be incremented as much as we want `inside` the loop.
|
// variable to be incremented as much as we want `inside` the loop.
|
||||||
@ -517,7 +517,7 @@ function tokenizer(input) {
|
|||||||
|
|
||||||
// Again we're just going to loop through all the letters pushing them to
|
// Again we're just going to loop through all the letters pushing them to
|
||||||
// a value.
|
// a value.
|
||||||
while (LETTERS.test(char)) {
|
while (char && LETTERS.test(char)) {
|
||||||
value += char;
|
value += char;
|
||||||
char = input[++current];
|
char = input[++current];
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user