UNPKG

mframejs

Version:
35 lines (24 loc) 1.15 kB
/** * class that holds all typoes of char types tokenizer need to know * */ export class CharCodes { public readonly WHITESPACE: Set<number>; public readonly OPERATOR: Set<number>; public readonly STRING_START_END: Set<number>; public readonly NUMBER: Set<number>; public readonly OPERATOR_COMBO: Set<string>; constructor() { this.WHITESPACE = new Set(); [32, 10, 13].map(a => this.WHITESPACE.add(a)); this.STRING_START_END = new Set(); ["'", '"', '`'].map(a => this.STRING_START_END.add(a.charCodeAt(0))); this.OPERATOR = new Set(); ['=', '!', '>', '<', '+', '-', '*', '/', '%', '@', '^', '(', ')', '|', '&', '?', ':', ',', '{', , '}', '[', ']', '$', '.'].map(a => this.OPERATOR.add(a.charCodeAt(0))); this.NUMBER = new Set(); ['1', '2', '3', '4', '5', '6', '7', '8', '9', '0'].map(a => this.NUMBER.add(a.charCodeAt(0))); this.OPERATOR_COMBO = new Set(); ['===', '==', '+=', '-=', '*=', '/=', '!=', '&&', '||', '!==', '>=', '<=', '${', '@{'].map(a => this.OPERATOR_COMBO.add(a)); } }