UNPKG

simc-ast-builder

Version:

Parser and AST generator for SimulationCraft files

43 lines 1.64 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.handleDeathKnight = exports.handleDeathAndDecay = void 0; const SimCVisitorError_1 = require("../../../errors/SimCVisitorError"); const fieldMaps_1 = require("../../../utils/fieldMaps"); /** * Handler for death_and_decay access contexts */ const handleDeathAndDecay = ({ ctx, parts, }) => { const rawField = parts.length > 1 ? parts[1] : null; const defaultField = (0, fieldMaps_1.getDefaultField)("death_and_decay"); const field = rawField || defaultField || ""; const fieldDef = (0, fieldMaps_1.getFieldDef)(field); return { expressionType: fieldDef.type, field: fieldDef, kind: "expression", nodeType: "death_and_decay", }; }; exports.handleDeathAndDecay = handleDeathAndDecay; /** * Handler for death_knight access contexts * This is the main class handler that can be extended to handle * class-specific expressions */ const handleDeathKnight = ({ ctx, parts, }) => { if (parts.length < 2) { throw new SimCVisitorError_1.SimCVisitorError("Death Knight access requires a field", ctx); } const rawField = parts.length > 1 ? parts[1] : null; const defaultField = (0, fieldMaps_1.getDefaultField)("death_knight"); const field = rawField || defaultField || ""; const fieldDef = (0, fieldMaps_1.getFieldDef)(field); return { expressionType: fieldDef.type, field: fieldDef, kind: "expression", nodeType: "death_knight", }; }; exports.handleDeathKnight = handleDeathKnight; //# sourceMappingURL=DeathKnightHandler.js.map