Skip to content

Commit

Permalink
Merge cases (#1188)
Browse files Browse the repository at this point in the history
Merged cases that do the same job
Returning a single token that matches with case
Can be solved easily by converting the ASCII back to a character using String.fromCharCode
  • Loading branch information
theahmadzai authored and ai committed Sep 24, 2018
1 parent 3809582 commit c009b4a
Showing 1 changed file with 3 additions and 20 deletions.
23 changes: 3 additions & 20 deletions lib/tokenize.es6
Expand Up @@ -85,27 +85,14 @@ export default function tokenizer (input, options = {}) {
break

case OPEN_SQUARE:
currentToken = ['[', '[', line, pos - offset]
break

case CLOSE_SQUARE:
currentToken = [']', ']', line, pos - offset]
break

case OPEN_CURLY:
currentToken = ['{', '{', line, pos - offset]
break

case CLOSE_CURLY:
currentToken = ['}', '}', line, pos - offset]
break

case COLON:
currentToken = [':', ':', line, pos - offset]
break

case SEMICOLON:
currentToken = [';', ';', line, pos - offset]
case CLOSE_PARENTHESES:
let controlChar = String.fromCharCode(code)
currentToken = [controlChar, controlChar, line, pos - offset]
break

case OPEN_PARENTHESES:
Expand Down Expand Up @@ -159,10 +146,6 @@ export default function tokenizer (input, options = {}) {

break

case CLOSE_PARENTHESES:
currentToken = [')', ')', line, pos - offset]
break

case SINGLE_QUOTE:
case DOUBLE_QUOTE:
quote = code === SINGLE_QUOTE ? '\'' : '"'
Expand Down

0 comments on commit c009b4a

Please sign in to comment.