コード例 #1
0
        public void Should_support_a_single_parser()
        {
            var parser = new ConstantStringParser("Hello");

            var visualizer = new ParserVisualizer();
            parser.Accept(visualizer);
            string text = visualizer.ToString();

            string expected = @"(String) == ""Hello""";
            Assert.AreEqual(expected, text);
        }
コード例 #2
0
        public void Should_support_a_single_parser()
        {
            var parser = new ConstantStringParser("Hello");

            var visualizer = new ParserVisualizer();

            parser.Accept(visualizer);
            string text = visualizer.ToString();

            string expected = @"(String) == ""Hello""";

            Assert.AreEqual(expected, text);
        }
コード例 #3
0
        public void Should_support_a_combined_parser()
        {
            var anyParser = new AnyParser<int>();

            Parser<int[], int> parser = from x in anyParser
                                        where x == 1
                                        select x;

            var visualizer = new ParserVisualizer();
            parser.Accept(visualizer);
            string text = visualizer.ToString();

            Console.WriteLine(text);

            string expected = @"  (Int32) *
            (Int32) Where x => (x == 1)";
            Assert.AreEqual(expected, text);
        }
コード例 #4
0
        public void Should_support_a_combined_parser()
        {
            var anyParser = new AnyParser <int>();

            Parser <int[], int> parser = from x in anyParser
                                         where x == 1
                                         select x;

            var visualizer = new ParserVisualizer();

            parser.Accept(visualizer);
            string text = visualizer.ToString();

            Console.WriteLine(text);

            string expected = @"  (Int32) *
(Int32) Where x => (x == 1)";

            Assert.AreEqual(expected, text);
        }