UNPKG

antlr-ng

Version:

Next generation ANTLR Tool

36 lines (35 loc) 885 B
var __defProp = Object.defineProperty; var __name = (target, value) => __defProp(target, "name", { value, configurable: true }); import { CommonToken } from "antlr4ng"; import { GrammarASTWithOptions } from "./GrammarASTWithOptions.js"; class RuleRefAST extends GrammarASTWithOptions { static { __name(this, "RuleRefAST"); } constructor(...args) { if (typeof args[0] === "number") { const [type, t] = args; super(type, t); } else { const [node] = args; super(node); } } /** * Duplicates token too since we overwrite during LR rule transform. * * @returns A new RuleRefAST node with the same token and type. */ dupNode() { const r = new RuleRefAST(this); r.token = this.token; this.token = CommonToken.fromToken(r.token); return r; } visit(v) { return v.visit(this); } } export { RuleRefAST };