mirror of
https://github.com/jamiebuilds/the-super-tiny-compiler.git
synced 2024-10-27 20:34:08 +00:00
Fix infinite loop
Fixes infinite loop in case when number or letter appears outside of parentheses. For example: `(add 1 2)5` or `(add 2 3)abs`
This commit is contained in:
parent
3356bea996
commit
b46bfb1eba
@ -423,7 +423,7 @@ function tokenizer(input) {
|
|||||||
// Then we're going to loop through each character in the sequence until
|
// Then we're going to loop through each character in the sequence until
|
||||||
// we encounter a character that is not a number, pushing each character
|
// we encounter a character that is not a number, pushing each character
|
||||||
// that is a number to our `value` and incrementing `current` as we go.
|
// that is a number to our `value` and incrementing `current` as we go.
|
||||||
while (NUMBERS.test(char)) {
|
while (char && NUMBERS.test(char)) {
|
||||||
value += char;
|
value += char;
|
||||||
char = input[++current];
|
char = input[++current];
|
||||||
}
|
}
|
||||||
@ -447,7 +447,7 @@ function tokenizer(input) {
|
|||||||
// Name token
|
// Name token
|
||||||
//
|
//
|
||||||
var LETTERS = /[a-z]/i;
|
var LETTERS = /[a-z]/i;
|
||||||
if (LETTERS.test(char)) {
|
if (char && LETTERS.test(char)) {
|
||||||
var value = '';
|
var value = '';
|
||||||
|
|
||||||
// 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
|
||||||
|
Loading…
Reference in New Issue
Block a user