simc-ast-builder
Version:
Parser and AST generator for SimulationCraft files
26 lines • 1.01 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.handleStringExpr = void 0;
const SimCVisitorError_1 = require("../../errors/SimCVisitorError");
const ContextHandlerRegistry_1 = require("../ContextHandlerRegistry");
/**
* Handler for string expression contexts
*/
const handleStringExpr = (ctx, visitor) => {
if (!ctx.text) {
throw new SimCVisitorError_1.SimCVisitorError("Empty string text", ctx);
}
// Check if this string is a registered access handler (like "boss")
if (ContextHandlerRegistry_1.contextHandlerRegistry.hasAccessHandler(ctx.text)) {
// If it is, use that handler instead
return ContextHandlerRegistry_1.contextHandlerRegistry.dispatchAccess(ctx.text, ctx, visitor, [ctx.text]);
}
return {
expressionType: "neutral",
kind: "expression",
nodeType: "literal",
value: ctx.text,
};
};
exports.handleStringExpr = handleStringExpr;
//# sourceMappingURL=StringHandler.js.map