From 3a2260c6baf131382aa64c8f4fe05ce6766f51f3 Mon Sep 17 00:00:00 2001 From: SirPython Date: Sat, 2 Apr 2016 21:10:10 -0400 Subject: [PATCH] refactored parenthesis checking conditional --- super-tiny-compiler.js | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/super-tiny-compiler.js b/super-tiny-compiler.js index e4e214d..fb3085b 100644 --- a/super-tiny-compiler.js +++ b/super-tiny-compiler.js @@ -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