Esempio n. 1
0
 private protected override ImmutableSortedSet <Expected <TToken> > CalculateExpected()
 => ImmutableSortedSet.Create(new Expected <TToken>(Rope.Create(_token)));
Esempio n. 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))))));
        }
Esempio n. 3
0
 public CIStringParser(string value)
     : base(ImmutableSortedSet.Create(new Expected <char>(Rope.CreateRange(value))))
 {
     _value = value.ToLowerInvariant();
 }
Esempio n. 4
0
 public TokenParser(TToken token)
     : base(ImmutableSortedSet.Create(new Expected <TToken>(Rope.Create(token))))
 {
     _token = token;
 }
Esempio n. 5
0
 internal Expected(Rope <TToken> tokens)
 {
     Label          = null;
     InternalTokens = tokens;
 }
Esempio n. 6
0
 internal Expected(string label)
 {
     Label          = label;
     InternalTokens = null;
 }
Esempio n. 7
0
 public SequenceTokenParser(TEnumerable value)
     : base(ImmutableSortedSet.Create(new Expected <TToken>(Rope.CreateRange(value))))
 {
     _value       = value;
     _valueTokens = value.ToArray();
 }
Esempio n. 8
0
 private protected override ImmutableSortedSet <Expected <char> > CalculateExpected()
 => ImmutableSortedSet.Create(new Expected <char>(Rope.CreateRange(_value)));