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