/** <summary> * For every node in this subtree, make sure it's start/stop token's * are set. Walk depth first, visit bottom up. Only updates nodes * with at least one token index < 0. * </summary> */ public virtual void SetUnknownTokenBoundaries() { if (Children == null) { if (startIndex < 0 || stopIndex < 0) { startIndex = stopIndex = Token.TokenIndex; } return; } foreach (ITree childTree in Children) { CommonTree commonTree = childTree as CommonTree; if (commonTree == null) { continue; } commonTree.SetUnknownTokenBoundaries(); } if (startIndex >= 0 && stopIndex >= 0) { return; // already set } if (Children.Count > 0) { ITree firstChild = Children[0]; ITree lastChild = Children[Children.Count - 1]; startIndex = firstChild.TokenStartIndex; stopIndex = lastChild.TokenStopIndex; } }