UNPKG

simc-ast-builder

Version:

Parser and AST generator for SimulationCraft files

27 lines 981 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.handlePet = void 0; const SimCVisitorError_1 = require("../../errors/SimCVisitorError"); const fieldMaps_1 = require("../../utils/fieldMaps"); /** * Handler for pet access contexts */ const handlePet = ({ ctx, parts }) => { if (parts.length < 2) { throw new SimCVisitorError_1.SimCVisitorError("Pet access requires a name", ctx); } const name = parts[1]; // Non-null assertion since we check parts.length above const rawField = parts.length > 2 ? parts[2] : null; const defaultField = (0, fieldMaps_1.getDefaultField)("pet"); const field = rawField || defaultField || ""; const fieldDef = (0, fieldMaps_1.getFieldDef)(field); return { expressionType: fieldDef.type, field: fieldDef, kind: "expression", nodeType: "pet", petName: name, }; }; exports.handlePet = handlePet; //# sourceMappingURL=PetHandler.js.map