public void Named_Test()
        {
            var needle   = Fail <char>().Named("needle");
            var haystack = (Any(), Any(), Any(), needle).First();
            var result   = FindParserVisitor.Named(haystack, "needle");

            result.Success.Should().BeTrue();
            result.Value.Should().BeSameAs(needle);
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Recurse the tree searching for a parser with the given name. Returns a result with the
 /// parser if found, a failure flag otherwise.
 /// </summary>
 /// <param name="root"></param>
 /// <param name="name"></param>
 /// <returns></returns>
 public static IOption <IParser> FindNamed(this IParser root, string name) => FindParserVisitor.Named(root, name);