simc-ast-builder
Version:
Parser and AST generator for SimulationCraft files
22 lines • 968 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.handleParseContext = handleParseContext;
const antlr4ts_1 = require("antlr4ts");
const SimCVisitorError_1 = require("../../errors/SimCVisitorError");
/**
* Handler for the top-level parse context
*/
function handleParseContext(ctx, visitor) {
var _a;
const children = (_a = ctx.children) !== null && _a !== void 0 ? _a : [];
// The first child should be the actual content (actionLine, commentLine, or expression)
// The second child is typically the EOF token
if (Array.isArray(children) && children.length > 0) {
const contentChild = children[0];
if (contentChild && contentChild instanceof antlr4ts_1.ParserRuleContext) {
return visitor.visit(contentChild);
}
}
throw new SimCVisitorError_1.SimCVisitorError(`Unexpected parse context structure: ${ctx.text}`, ctx);
}
//# sourceMappingURL=ParseContextHandler.js.map