Inheritance: SyntaxTreeNode
        protected internal virtual SyntaxTreeNode Visit(SequenceNode node)
        {
            if (node == null) return null;

            var modifiedSubNodes = GetModifiedSubNodes(node);

            if (modifiedSubNodes == null)
                return node; //unmodified
            else
                return node.SetSubNodes(modifiedSubNodes); //subnodes were modified
        }
        protected internal virtual SyntaxTreeNode Visit(SequenceNode node)
        {
            if (node == null)
            {
                return(null);
            }

            var modifiedSubNodes = GetModifiedSubNodes(node);

            if (modifiedSubNodes == null)
            {
                return(node); //unmodified
            }
            else
            {
                return(node.SetSubNodes(modifiedSubNodes)); //subnodes were modified
            }
        }
        public virtual SequenceNode ParseSyntaxTree(string bbCode)
        {
            if (bbCode == null) throw new ArgumentNullException("bbCode");

            Stack<SyntaxTreeNode> stack = new Stack<SyntaxTreeNode>();
            var rootNode = new SequenceNode();
            stack.Push(rootNode);

            int end = 0;
            while (end < bbCode.Length)
            {
                if (MatchTagEnd(bbCode, ref end, stack))
                    continue;

                if (MatchStartTag(bbCode, ref end, stack))
                    continue;

                if (MatchTextNode(bbCode, ref end, stack))
                    continue;

                if (ErrorMode != ErrorMode.ErrorFree)
                    throw new BBCodeParsingException(""); //there is no possible match at the current position

                AppendText(bbCode[end].ToString(), stack); //if the error free mode is enabled force interpretation as text if no other match could be made
                end++;
            }

            Debug.Assert(end == bbCode.Length); //assert bbCode was matched entirely

            while (stack.Count > 1) //close all tags that are still open and can be closed implicitly
            {
                var node = (TagNode)stack.Pop();
                if (node.Tag.RequiresClosingTag && ErrorMode == ErrorMode.Strict) throw new BBCodeParsingException(MessagesHelper.GetString("TagNotClosed", node.Tag.Name));
            }

            if (stack.Count != 1)
            {
                Debug.Assert(ErrorMode != ErrorMode.ErrorFree);
                throw new BBCodeParsingException(""); //only the root node may be left
            }

            return rootNode;
        }
 protected internal override SyntaxTreeNode Visit(SequenceNode node)
 {
     var baseResult = base.Visit(node);
     return baseResult.SetSubNodes(baseResult.SubNodes.Concat(new[] { new TextNode("y") }));
 }
 protected internal override SyntaxTreeNode Visit(SequenceNode node)
 {
     var baseResult = base.Visit(node);
     if (!PexChoose.Value<bool>("x")) return baseResult;
     return baseResult.SetSubNodes(baseResult.SubNodes.ToList());
 }
 public static SequenceNode CreateRootNode(BBTag[] allowedTags)
 {
     var node = new SequenceNode();
     AddSubnodes(allowedTags, node);
     return node;
 }