simc-ast-builder
Version:
Parser and AST generator for SimulationCraft files
74 lines • 2.46 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.handleTotem = exports.handleShaman = exports.handleLightningRod = exports.handleFeralSpirit = void 0;
const SimCVisitorError_1 = require("../../../errors/SimCVisitorError");
const fieldMaps_1 = require("../../../utils/fieldMaps");
/**
* Handler for shaman access contexts
* This handles access to shaman-specific properties
*/
const handleShaman = ({ ctx, parts, }) => {
if (parts.length < 2) {
throw new SimCVisitorError_1.SimCVisitorError("Shaman access requires a field", ctx);
}
const field = parts[1] || "";
const fieldDef = (0, fieldMaps_1.getFieldDef)(field);
return {
expressionType: fieldDef.type,
field: fieldDef,
kind: "expression",
nodeType: "shaman",
};
};
exports.handleShaman = handleShaman;
/**
* Handler for totem access contexts
* This handles access to totem properties for Shaman
*/
const handleTotem = ({ ctx, parts }) => {
if (parts.length < 2) {
throw new SimCVisitorError_1.SimCVisitorError("Totem access requires a totem name", ctx);
}
const totemName = parts[1] || "";
const field = parts.length > 2 ? parts[2] || "" : "";
const fieldDef = (0, fieldMaps_1.getFieldDef)(field || "up");
return {
expressionType: fieldDef.type,
field: fieldDef,
kind: "expression",
nodeType: "totem",
totemName,
};
};
exports.handleTotem = handleTotem;
/**
* Handler for feral_spirit access contexts
* This handles access to feral spirit properties for Enhancement Shaman
*/
const handleFeralSpirit = ({ ctx, parts, }) => {
if (parts.length < 2) {
throw new SimCVisitorError_1.SimCVisitorError("Feral Spirit access requires a field", ctx);
}
const field = parts[1] || "";
const fieldDef = (0, fieldMaps_1.getFieldDef)(field);
return {
expressionType: fieldDef.type,
field: fieldDef,
kind: "expression",
nodeType: "feral_spirit",
};
};
exports.handleFeralSpirit = handleFeralSpirit;
/**
* Handler for lightning_rod access contexts
* This handles access to the lightning_rod property for Shaman
*/
const handleLightningRod = ({ parts, }) => {
return {
expressionType: "numeric",
kind: "expression",
nodeType: "lightning_rod",
};
};
exports.handleLightningRod = handleLightningRod;
//# sourceMappingURL=ShamanHandler.js.map