示例#1
0
        /// <summary>
        /// Don't override this method, implement VisitNode on child
        /// </summary>
        /// <param name="astVisitor"></param>
        /// <returns></returns>
        public bool AcceptASTVisitor(IASTVisitor astVisitor) {
            bool continueVisit = astVisitor.BeginNode(this) && VisitNode(astVisitor);

            if (continueVisit && CodeElement != null)
            {
                CodeElement.AcceptASTVisitor(astVisitor);
            }

            if (continueVisit) {
                //To Handle concurrent modifications during traverse.
                //Get the array of Children that must be traverse.
                Node[] childrenNodes = children.ToArray();
                foreach (Node child in childrenNodes)
                {
                    if (!continueVisit) {
                        break;
                    }
                    continueVisit = child.AcceptASTVisitor(astVisitor);
                }
            }

            astVisitor.EndNode(this);
            return continueVisit;
        }