ts-fusion-parser
Version:
Parser for Neos Fusion Files
82 lines (81 loc) • 2.47 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.Token = void 0;
class Token {
constructor(type, value) {
this.type = type;
this.value = value;
this.name = Token.typeToString(type);
}
getType() {
return this.type;
}
getValue() {
return this.value;
}
static typeToString(type) {
const stringRepresentation = Token.getConstants()[type];
if (stringRepresentation === undefined) {
throw Error(`Token of type '{type}' does not exist`);
// throw new \LogicException("Token of type 'type' does not exist", 1637307344);
}
return stringRepresentation;
}
static getConstants() {
if (this.ConstantsMap === undefined) {
const propertyNames = Object.getOwnPropertyNames(this).filter(name => !['length', 'prototype', 'name',].includes(name));
const descriptors = Object.getOwnPropertyDescriptors(this);
this.ConstantsMap = {};
for (const propertyName of propertyNames) {
this.ConstantsMap[descriptors[propertyName].value] = propertyName;
}
}
return this.ConstantsMap;
}
}
exports.Token = Token;
Token.EOF = 1;
Token.SLASH_COMMENT = 2;
Token.HASH_COMMENT = 3;
Token.MULTILINE_COMMENT = 4;
Token.SPACE = 5;
Token.NEWLINE = 6;
Token.INCLUDE = 7;
Token.NAMESPACE = 8;
Token.META_PATH_START = 9;
Token.OBJECT_PATH_PART = 10;
Token.PROTOTYPE_START = 11;
Token.ASSIGNMENT = 12;
Token.COPY = 13;
Token.UNSET = 14;
Token.FUSION_OBJECT_NAME = 15;
Token.TRUE_VALUE = 16;
Token.FALSE_VALUE = 17;
Token.NULL_VALUE = 18;
Token.INTEGER = 19;
Token.FLOAT = 20;
Token.STRING_DOUBLE_QUOTED = 21;
Token.STRING_SINGLE_QUOTED = 22;
Token.EEL_EXPRESSION = 23;
Token.DSL_EXPRESSION_START = 24;
Token.DSL_EXPRESSION_CONTENT = 25;
Token.FILE_PATTERN = 26;
Token.DOT = 27;
Token.COLON = 28;
Token.RPAREN = 29;
Token.LBRACE = 30;
Token.RBRACE = 31;
Token.PROPERTY_DOCUMENTATION_DEFINITION = 650;
Token.PROTOTYPE_DOCUMENTATION_DEFINITION = 651;
Token.EEL_EXPRESSION_START = 691;
Token.STRING_DOUBLE_QUOTED_START = 692;
Token.STRING_SINGLE_QUOTED_START = 693;
Token.EEL_EXPRESSION_FUNCTION_PATH = 694;
Token.LPAREN = 695;
Token.COMMA = 696;
Token.EEL_EXPRESSION_OBJECT_PATH = 697;
Token.EEL_EXPRESSION_OBJECT_PATH_PART = 698;
Token.LBRACKET = 699;
Token.RBRACKET = 700;
Token.EEL_EXPRESSION_CALLBACK = 701;
Token.ConstantsMap = undefined;