-
-
Notifications
You must be signed in to change notification settings - Fork 240
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
perf: introduce AST to avoid reparse
- Loading branch information
Showing
96 changed files
with
1,557 additions
and
1,172 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#!/usr/bin/env node | ||
|
||
const isQuote = c => c === '"' || c === "'" | ||
const isOperator = c => '!=<>'.includes(c) | ||
const isNumber = c => c >= '0' && c <= '9' | ||
const isCharacter = c => (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') | ||
const isVariable = c => '_-?'.includes(c) || isCharacter(c) || isNumber(c) | ||
const isBlank = c => c === '\n' || c === '\t' || c === ' ' || c === '\r' | ||
const isInlineBlank = c => c === '\t' || c === ' ' || c === '\r' | ||
const isSign = c => c === '-' || c === '+' | ||
|
||
const types = [] | ||
for (let i = 0; i < 128; i++) { | ||
const c = String.fromCharCode(i) | ||
let n = 0 | ||
if (isVariable(c)) n |= 1 | ||
if (isOperator(c)) n |= 2 | ||
if (isBlank(c)) n |= 4 | ||
if (isQuote(c)) n |= 8 | ||
if (isInlineBlank(c)) n |= 16 | ||
if (isNumber(c)) n |= 32 | ||
if (isSign(c)) n |= 64 | ||
types.push(n) | ||
} | ||
console.log(` | ||
// bitmask character types to boost performance | ||
// generated by bin/character-gen.js | ||
export const TYPES = [${types.join(', ')}] | ||
export const VARIABLE = 1 | ||
export const OPERATOR = 2 | ||
export const BLANK = 4 | ||
export const QUOTE = 8 | ||
export const INLINE_BLANK = 16 | ||
export const NUMBER = 32 | ||
export const SIGN = 64 | ||
`.trim()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.