Exemple #1
0
        /// <summary> scanner for non-nested block comment.</summary>
        /// <param name="start">the start string of a block comment.
        /// </param>
        /// <param name="end">the end string of a block comment.
        /// </param>
        /// <returns> the scanner.
        /// </returns>
        public static Scanner IsBlockComment(string start, string end)
        {
            CharPattern opening = Patterns.IsString(start).Seq(Patterns.NotString(end).Many());

            return(IsPattern("block comment before the end", opening, start).Seq(IsString(end))
                   .Rename("block comment"));
        }
Exemple #2
0
        /// <summary> Scans a non-nestable block comment.</summary>
        /// <param name="open">the opening string.
        /// </param>
        /// <param name="close">the closing string.
        /// </param>
        /// <param name="commented">the commented pattern.
        /// </param>
        /// <returns> the Scanner for the block comment.
        /// </returns>
        public static Scanner IsBlockComment(string open, string close, CharPattern commented)
        {
            CharPattern opening = Patterns.IsString(open)
                                  .Seq(Patterns.IsString(close).Not().Seq(commented).Many());

            return(IsPattern("block comment before the end", opening, open).Seq(IsString(close)));
        }
Exemple #3
0
 /// <summary> Scans the input for an occurrence of a string pattern.</summary>
 /// <param name="name">the name of the result parser. It should be a meaningful name that speaks out the pattern.</param>
 /// <param name="pp">the CharPattern object.
 /// </param>
 /// <param name="expected_name">the expected message when fails.
 /// </param>
 /// <returns> the Scanner object.
 /// </returns>
 public static Scanner IsPattern(string name, CharPattern pp, string expected_name)
 {
     return(new PatternScanner(name, pp, expected_name));
 }
Exemple #4
0
 /// <summary> Scans the input for an occurrence of a string pattern.</summary>
 /// <param name="pp">the CharPattern object.
 /// </param>
 /// <param name="expected_name">the expected message when fails.
 /// </param>
 /// <returns> the Scanner object.
 /// </returns>
 public static Scanner IsPattern(CharPattern pp, string expected_name)
 {
     return(IsPattern(expected_name, pp, expected_name));
 }
Exemple #5
0
 internal PatternScanner(string name, CharPattern pp, string expected_name)
     : base(name)
 {
     this.pp            = pp;
     this.expected_name = expected_name;
 }
Exemple #6
0
 /// <summary> Scans greedily for 0 or more occurrences of the given pattern.</summary>
 /// <param name="pp">the CharPattern object.
 /// </param>
 /// <returns> the Scanner object.
 /// </returns>
 public static Scanner Many(CharPattern pp)
 {
     return(IsPattern("many patterns", pp.Many(), "many"));
 }
Exemple #7
0
 /// <summary> Scans a non-nestable block comment.</summary>
 /// <param name="open">the opening string.
 /// </param>
 /// <param name="close">the closing string.
 /// </param>
 /// <param name="commented">the commented pattern.
 /// </param>
 /// <returns> the Scanner for the block comment.
 /// </returns>
 public static Scanner IsBlockComment(string open, string close, CharPattern commented)
 {
     CharPattern opening = Patterns.IsString(open)
       .Seq(Patterns.IsString(close).Not().Seq(commented).Many());
     return IsPattern("block comment before the end", opening, open).Seq(IsString(close));
 }
Exemple #8
0
 /// <summary> Scans the input for an occurrence of a string pattern.</summary>
 /// <param name="pp">the CharPattern object.
 /// </param>
 /// <param name="expected_name">the expected message when fails.
 /// </param>
 /// <returns> the Scanner object.
 /// </returns>
 public static Scanner IsPattern(CharPattern pp, string expected_name)
 {
     return IsPattern(expected_name, pp, expected_name);
 }
Exemple #9
0
 /// <summary> Scans the input for an occurrence of a string pattern.</summary>
 /// <param name="name">the name of the result parser. It should be a meaningful name that speaks out the pattern.</param>
 /// <param name="pp">the CharPattern object.
 /// </param>
 /// <param name="expected_name">the expected message when fails.
 /// </param>
 /// <returns> the Scanner object.
 /// </returns>
 public static Scanner IsPattern(string name, CharPattern pp, string expected_name)
 {
     return new PatternScanner(name, pp, expected_name);
 }
Exemple #10
0
 /// <summary> Scans greedily for 0 or more occurrences of the given pattern.</summary>
 /// <param name="pp">the CharPattern object.
 /// </param>
 /// <returns> the Scanner object.
 /// </returns>
 public static Scanner Many(CharPattern pp)
 {
     return IsPattern("many patterns", pp.Many(), "many");
 }
Exemple #11
0
 internal PatternScanner(string name, CharPattern pp, string expected_name)
     : base(name)
 {
     this.pp = pp;
     this.expected_name = expected_name;
 }