UNPKG

simc-ast-builder

Version:

Parser and AST generator for SimulationCraft files

26 lines 954 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.handleVariable = void 0; const SimCVisitorError_1 = require("../../errors/SimCVisitorError"); const fieldMaps_1 = require("../../utils/fieldMaps"); /** * Handler for variable access contexts */ const handleVariable = ({ ctx, parts, }) => { if (parts.length < 2) { throw new SimCVisitorError_1.SimCVisitorError("Variable access requires a name", ctx); } const name = parts[1]; // Non-null assertion since we check parts.length above // Variables don't have fields like other access types // They just return their value directly const fieldDef = (0, fieldMaps_1.getFieldDef)("value"); return { expressionType: fieldDef.type, field: "", kind: "expression", nodeType: "variable", variableName: name, }; }; exports.handleVariable = handleVariable; //# sourceMappingURL=VariableHandler.js.map