UNPKG

simc-ast-builder

Version:

Parser and AST generator for SimulationCraft files

27 lines 1.02 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.handleAction = void 0; const SimCVisitorError_1 = require("../../errors/SimCVisitorError"); const fieldMaps_1 = require("../../utils/fieldMaps"); /** * Handler for action access contexts */ const handleAction = ({ ctx, parts, }) => { if (parts.length < 2) { throw new SimCVisitorError_1.SimCVisitorError("Action access requires an action name", ctx); } const actionName = 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)("action"); const field = rawField || defaultField || ""; const fieldDef = (0, fieldMaps_1.getFieldDef)(field); return { actionName, expressionType: fieldDef.type, field: fieldDef, kind: "expression", nodeType: "action", }; }; exports.handleAction = handleAction; //# sourceMappingURL=ActionHandler.js.map