Skip to content

Commit

Permalink
Small tokenizer refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
lahmatiy committed Jul 25, 2019
1 parent d15bea9 commit 17dd0bc
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions utils/tokenize.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,24 +184,21 @@ module.exports = (input) => {
const tokens = [];

while (index < input.length) {
const matched = (
const token = (
parseWhitespace(input, index) ||
parseDelim(input, index) ||
parseKeyword(input, index) ||
parseString(input, index) ||
parseNumber(input, index)
);

if (!matched) {
if (!token) {
break;
}

tokens.push({
type: matched.type,
value: matched.value
});
tokens.push(token);

index += matched.value.length;
index += token.value.length;
}

return tokens;
Expand Down

0 comments on commit 17dd0bc

Please sign in to comment.