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