Ejemplo n.º 1
0
 public static Parser <char, T> Next <T>(Parser <char, T> parser)
 {
     return
         (SkipWhitespaces
          .Then(Try(CommentParser.SkipBlockComment(String("/*"), String("*/"))
                    .Or(CommentParser.SkipLineComment(String("//")))).Optional()
                .Then(SkipWhitespaces))
          .Then(parser));
 }
Ejemplo n.º 2
0
        public void TestSkipLineComment()
        {
            var p = CommentParser.SkipLineComment(String("//")).Then(End);

            {
                var comment = "//\n";

                var result = p.Parse(comment);

                AssertSuccess(result, Unit.Value, true);
            }
            {
                var comment = "//";

                var result = p.Parse(comment);

                AssertSuccess(result, Unit.Value, true);
            }
            {
                var comment = "// here is a comment ending with an osx style newline\n";

                var result = p.Parse(comment);

                AssertSuccess(result, Unit.Value, true);
            }
            {
                var comment = "// here is a comment ending with a windows style newline\r\n";

                var result = p.Parse(comment);

                AssertSuccess(result, Unit.Value, true);
            }
            {
                var comment = "// here is a comment with a \r carriage return in the middle\r\n";

                var result = p.Parse(comment);

                AssertSuccess(result, Unit.Value, true);
            }
            {
                var comment = "// here is a comment at the end of a file";

                var result = p.Parse(comment);

                AssertSuccess(result, Unit.Value, true);
            }
        }