示例#1
0
 private protected override ImmutableSortedSet <Expected <TToken> > CalculateExpected()
 => ImmutableSortedSet.Create(new Expected <TToken>(Rope.Create(_token)));
示例#2
0
        /// <summary>
        /// Creates a parser which parses and returns one of the specified characters.
        /// </summary>
        /// <param name="chars">A sequence of characters to choose between</param>
        /// <returns>A parser which parses and returns one of the specified characters</returns>
        public static Parser <char, char> OneOf(IEnumerable <char> chars)
        {
            if (chars == null)
            {
                throw new ArgumentNullException(nameof(chars));
            }
            var cs = chars.ToArray();

            return(Parser <char>
                   .Token(c => Array.IndexOf(cs, c) != -1)
                   .WithExpected(ImmutableSortedSet.CreateRange(cs.Select(c => new Expected <char>(Rope.Create(c))))));
        }
示例#3
0
 public CIStringParser(string value)
     : base(ImmutableSortedSet.Create(new Expected <char>(Rope.CreateRange(value))))
 {
     _value = value.ToLowerInvariant();
 }
示例#4
0
 public TokenParser(TToken token)
     : base(ImmutableSortedSet.Create(new Expected <TToken>(Rope.Create(token))))
 {
     _token = token;
 }
示例#5
0
 internal Expected(Rope <TToken> tokens)
 {
     Label          = null;
     InternalTokens = tokens;
 }
示例#6
0
 internal Expected(string label)
 {
     Label          = label;
     InternalTokens = null;
 }
示例#7
0
 public SequenceTokenParser(TEnumerable value)
     : base(ImmutableSortedSet.Create(new Expected <TToken>(Rope.CreateRange(value))))
 {
     _value       = value;
     _valueTokens = value.ToArray();
 }
示例#8
0
 private protected override ImmutableSortedSet <Expected <char> > CalculateExpected()
 => ImmutableSortedSet.Create(new Expected <char>(Rope.CreateRange(_value)));