refactored parenthesis checking conditional

This commit is contained in:
SirPython 2016-04-02 21:10:10 -04:00
parent a44d3ff1e8
commit 3a2260c6ba

View File

@ -362,14 +362,14 @@ function tokenizer(input) {
// later be used for `CallExpressions` but for now we only care about the // later be used for `CallExpressions` but for now we only care about the
// character. // character.
// //
// We check to see if we have an open parenthesis: // We check to see if we have either an open or close parenthesis:
if (char === '(') { if (char === '(' || char === ')') {
// If we do, we push a new token with the type `paren` and set the value // If we do, we push a new token with the type `paren` and set the value
// to an open parenthesis. // to an open or close parenthesis.
tokens.push({ tokens.push({
type: 'paren', type: 'paren',
value: '(' value: char
}); });
// Then we increment `current` // Then we increment `current`
@ -379,18 +379,6 @@ function tokenizer(input) {
continue; continue;
} }
// Next we're going to check for a closing parenthesis. We do the same exact
// thing as before: Check for a closing parenthesis, add a new token,
// increment `current`, and `continue`.
if (char === ')') {
tokens.push({
type: 'paren',
value: ')'
});
current++;
continue;
}
// Moving on, we're now going to check for whitespace. This is interesting // Moving on, we're now going to check for whitespace. This is interesting
// because we care that whitespace exists to separate characters, but it // because we care that whitespace exists to separate characters, but it
// isn't actually important for us to store as a token. We would only throw // isn't actually important for us to store as a token. We would only throw