private void UpdateCacheOnTheFly(UnparsableAst self, State state)
{
if (state == State.Before)
{
if (self.SyntaxParent == null)
topAncestorCacheForLeft = null; // self is root node
else if (self.IsLeftSiblingCalculated && self.LeftSibling != null)
topAncestorCacheForLeft = self;
else
topAncestorCacheForLeft = UnparsableAst.NonCalculated;
}
else if (state == State.After)
{
if (direction == Unparser.Direction.LeftToRight && self.BnfTerm is Terminal)
leftTerminalLeaveCache = self;
else if (direction == Unparser.Direction.RightToLeft && self == topAncestorCacheForLeft)
leftTerminalLeaveCache = UnparsableAst.NonCalculated;
}
}