public void CompositeVisitor_CapturingGroup_SandBoxTest_PriorityChoice3() { var prefix = new PrioritizedChoice( new CapturingGroup("AndPredicate", new Literal { MatchText = "&" }), new CapturingGroup("NotPredicate", new Literal { MatchText = "!" }) ); PrioritizedChoice suffix = new PrioritizedChoice( new CapturingGroup("ZeroOrMore", new Literal { MatchText = "*" }), new CapturingGroup("OneOrMore", new Literal { MatchText = "+" }) ) .Or(new CapturingGroup("Optional", new Literal { MatchText = "?" })); var terminal = new CapturingGroup("AnyCharacter", new Literal { MatchText = "." }); var expression = new CapturingGroup("Expression", new PrioritizedChoice( // match prefixes first prefix.Plus() .Sequence(terminal) , // match suffixes next terminal .Sequence( suffix.Plus() ) ) .Or(terminal) .Plus() ); var input = "."; var bytes = Encoding.UTF8.GetBytes(input); var iterator = new ByteInputIterator(bytes); var visitor = new NpegParserVisitor(iterator); expression.Accept(visitor); Assert.IsTrue(visitor.IsMatch); AstNode node = visitor.AST; Assert.IsTrue(node.Children.Count == 1); Assert.IsTrue(node.Token.Name == "Expression"); Assert.IsTrue(node.Token.ValueAsString(iterator) == "."); Assert.IsTrue(node.Children[0].Token.Name == "AnyCharacter"); }