simc-ast-builder
Version:
Parser and AST generator for SimulationCraft files
62 lines (61 loc) • 1.89 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.handleActionLine = handleActionLine;
/**
* Handler for action line contexts
*/
function handleActionLine(ctx, visitor) {
var _a;
// Get the parameter contexts
const paramContexts = ctx.actionParam();
// Process each parameter context to get the expression and parameter name
const conditions = paramContexts.map((paramCtx) => {
// Get the parameter name (identifier before the equals sign)
const paramName = paramCtx.identifier().text;
// Get the expression
const expression = visitor.visit(paramCtx.expression());
return {
expression,
kind: "condition",
type: paramName,
};
});
let subList = (_a = ctx.sublistName()) === null || _a === void 0 ? void 0 : _a.text;
if (!subList) {
subList = "default";
}
// Build parameters object for the action
const parameters = {};
const parameterNodes = {};
paramContexts.forEach((paramCtx) => {
const paramName = paramCtx.identifier().text;
parameters[paramName] = paramCtx.expression().text;
parameterNodes[paramName] = visitor.visit(paramCtx.expression());
});
/*
const action: SimCAction = {
actionList: subList,
actionName: ctx.actionName().text,
conditions: conditions.map((c) => c.expression),
originalLine: ctx.text,
parameterNodes,
parameters,
rawNode: {
conditions,
kind: "actionLine",
name: ctx.actionName().text,
rawLine: ctx.text,
subList,
},
};
simcStore.addAction(action);
*/
return {
conditions,
kind: "actionLine",
name: ctx.actionName().text,
rawLine: ctx.text,
subList,
};
}
//# sourceMappingURL=ActionLineHandler.js.map