Skip to content

Commit

Permalink
Lexer: simplify char/string regex
Browse files Browse the repository at this point in the history
  • Loading branch information
ivanjermakov committed Mar 19, 2024
1 parent 9e2706d commit b271751
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/lexer/lexer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,13 +125,13 @@ export const boolMap: [TokenKind, string][] = [
]

const floatRegex = /^((\d+(\.\d*)?e[+-]?\d+)|(\d+\.\d*)|(\d*\.\d+))/
const escapeCharReg = /(\\[btnvfr\\'"])/
const escapeCharReg = /(\\[tnr\\])/
const unicodeCharReg = /(\\u{[0-9a-fA-F]{1,4}})/
const charRegex = new RegExp(
`^'(${["(\\\\')", /[^\\\n\r']/.source, escapeCharReg.source, unicodeCharReg.source].join('|')})'`
`^'(${["(\\\\')", /[^\\\t\n\r']/.source, escapeCharReg.source, unicodeCharReg.source].join('|')})'`
)
const stringRegex = new RegExp(
`^"(${['(\\\\")', /[^\\\n\r"]/.source, escapeCharReg.source, unicodeCharReg.source].join('|')})*"`
`^"(${['(\\\\")', /[^\\\t\n\r"]/.source, escapeCharReg.source, unicodeCharReg.source].join('|')})*"`
)

/**
Expand Down

0 comments on commit b271751

Please sign in to comment.