simc-ast-builder
Version:
Parser and AST generator for SimulationCraft files
33 lines • 1.33 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.BaseVisitor = void 0;
const AbstractParseTreeVisitor_1 = require("antlr4ts/tree/AbstractParseTreeVisitor");
/**
* Base visitor class
*/
class BaseVisitor extends AbstractParseTreeVisitor_1.AbstractParseTreeVisitor {
defaultResult() {
// Get the caller information to identify which context is missing a visitor
const stack = new Error().stack;
const callerInfo = stack ? stack.split("\n")[2] : "unknown";
// Extract context type from the stack trace if possible
const contextTypeMatch = typeof callerInfo === "string" ? callerInfo.match(/at\s+(\w+)\./) : null;
const contextType = contextTypeMatch
? contextTypeMatch[1]
: "unknown context";
/*
console.warn(
`Missing visitor method for ${contextType}. Add a visit${contextType} method to handle this context type.\nStack trace: ${callerInfo}`,
);
*/
return {
callerInfo: callerInfo,
expressionType: "neutral",
kind: "expression",
missingVisitorFor: contextType,
nodeType: `missing_visitor_${contextType}`,
};
}
}
exports.BaseVisitor = BaseVisitor;
//# sourceMappingURL=common-types.js.map