Пример #1
0
        /// <summary>
        /// Folds a numbered capture node.
        /// </summary>
        /// <param name="numberedCapture"></param>
        /// <param name="argument">The argument to be passed to the visitor method.</param>
        /// <returns>
        /// <list type="number">
        /// <item>The original node if it's to be kept</item>
        /// <item>A different node to replace the original node with</item>
        /// <item>Null if the node is to be removed</item>
        /// </list>
        /// </returns>
        protected override GrammarNode <Char>?VisitNumberedCapture(NumberedCapture numberedCapture, TArgument argument)
        {
            if (numberedCapture is null)
            {
                throw new ArgumentNullException(nameof(numberedCapture));
            }

            GrammarNode <Char>?innerNode = this.Visit(numberedCapture.InnerNode, argument);

            if (innerNode is null)
            {
                return(null);
            }
            else if (innerNode == numberedCapture.InnerNode)
            {
                return(numberedCapture);
            }
            else
            {
                return(new NumberedCapture(numberedCapture.Position, innerNode));
            }
        }
 protected override String?VisitNumberedCapture(NumberedCapture numberedCapture, Unit argument) =>
 this.Visit(numberedCapture.InnerNode, default);
Пример #3
0
 /// <summary>
 /// Visits a numbered capture.
 /// </summary>
 /// <param name="numberedCapture"></param>
 /// <param name="argument">The argument data passed by the caller.</param>
 /// <returns>The result of visiting this node.</returns>
 protected abstract TReturn VisitNumberedCapture(NumberedCapture numberedCapture, TArgument argument);