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.handleDot = void 0; const SimCVisitorError_1 = require("../../errors/SimCVisitorError"); const fieldMaps_1 = require("../../utils/fieldMaps"); /** * Handler for dot access contexts */ const handleDot = ({ ctx, parts }) => { if (parts.length < 2) { throw new SimCVisitorError_1.SimCVisitorError("Dot 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)("dot"); const field = rawField || defaultField || ""; const fieldDef = (0, fieldMaps_1.getFieldDef)(field); return { dotName: name, expressionType: fieldDef.type, field: fieldDef, kind: "expression", nodeType: "dot", }; }; exports.handleDot = handleDot; //# sourceMappingURL=DotHandler.js.map