Skip to content

Commit

Permalink
fix: update lexer to work with no whitespace string assignment
Browse files Browse the repository at this point in the history
  • Loading branch information
jorenrui committed Nov 7, 2023
1 parent 0c7d7bc commit 5098f23
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions lib/lexer.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,22 +61,23 @@ export default class Lexer {

// Check if char is the start / end of string
if (['\'', '"', '`'].includes(char)) {
if (type == null || type !== TOKEN.string) {
this._pushToken(TOKEN.separator, char, i)
if (char === '`')
isStringTemplate = true
}

if (type == null) {
type = TOKEN.string
index = i
} else if (type === TOKEN.string) {
if (type === TOKEN.string) {
this._pushToken(type, currentToken, index)
this._pushToken(TOKEN.separator, char, i)

type = null
currentToken = ''
isStringTemplate = false
} else {
this._pushToken(type, currentToken, index)
this._pushToken(TOKEN.separator, char, i)

type = TOKEN.string
currentToken = ''
index = i

if (char === '`')
isStringTemplate = true
}

// Check if type is string
Expand Down

0 comments on commit 5098f23

Please sign in to comment.