UNPKG

antlr-ng

Version:

Next generation ANTLR Tool

48 lines (47 loc) 1.2 kB
var __defProp = Object.defineProperty; var __name = (target, value) => __defProp(target, "name", { value, configurable: true }); import { GrammarASTWithOptions } from "./GrammarASTWithOptions.js"; class AltAST extends GrammarASTWithOptions { static { __name(this, "AltAST"); } astType = "AltAST"; alt; /** If we transformed this alt from a left-recursive one, need info on it */ leftRecursiveAltInfo; /** * If someone specified an outermost alternative label with #foo. Token type will be ID. */ altLabel; constructor(...args) { if (args.length === 1) { const [param] = args; if (typeof param === "number") { super(param); } else if (param instanceof AltAST) { super(param); this.alt = param.alt; this.altLabel = param.altLabel; this.leftRecursiveAltInfo = param.leftRecursiveAltInfo; } else { super(param); } } else { const [type, t, text] = args; if (text !== void 0) { super(type, t, text); } else { super(type, t); } } } dupNode() { return new AltAST(this); } visit(v) { return v.visit(this); } } export { AltAST };