mirror of
https://github.com/jamiebuilds/the-super-tiny-compiler.git
synced 2024-10-27 20:34:08 +00:00
refactored parenthesis checking conditional
This commit is contained in:
parent
a44d3ff1e8
commit
3a2260c6ba
@ -362,14 +362,14 @@ function tokenizer(input) {
|
||||
// later be used for `CallExpressions` but for now we only care about the
|
||||
// character.
|
||||
//
|
||||
// We check to see if we have an open parenthesis:
|
||||
if (char === '(') {
|
||||
// We check to see if we have either an open or close parenthesis:
|
||||
if (char === '(' || char === ')') {
|
||||
|
||||
// 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({
|
||||
type: 'paren',
|
||||
value: '('
|
||||
value: char
|
||||
});
|
||||
|
||||
// Then we increment `current`
|
||||
@ -379,18 +379,6 @@ function tokenizer(input) {
|
||||
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
|
||||
// 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
|
||||
|
Loading…
Reference in New Issue
Block a user