public virtual string ToString(IList <string> ruleNames, Antlr4.Runtime.RuleContext stop) { StringBuilder buf = new StringBuilder(); Antlr4.Runtime.RuleContext p = this; buf.Append("["); while (p != null && p != stop) { if (ruleNames == null) { if (!p.IsEmpty()) { buf.Append(p.invokingState); } } else { int ruleIndex = p.GetRuleIndex(); string ruleName = ruleIndex >= 0 && ruleIndex < ruleNames.Count ? ruleNames[ruleIndex ] : ruleIndex.ToString(); buf.Append(ruleName); } if (p.parent != null && (ruleNames != null || !p.parent.IsEmpty())) { buf.Append(" "); } p = p.parent; } buf.Append("]"); return(buf.ToString()); }
public virtual IList<string> GetRuleInvocationStack(RuleContext p) { string[] ruleNames = RuleNames; IList<string> stack = new List<string>(); while (p != null) { // compute what follows who invoked us int ruleIndex = p.GetRuleIndex(); if (ruleIndex < 0) { stack.Add("n/a"); } else { stack.Add(ruleNames[ruleIndex]); } p = p.parent; } return stack; }