Beispiel #1
0
        /// <summary>
        /// Matches the current token against a certain type.
        /// </summary>
        /// <param name="source">Source enumerator.</param>
        /// <param name="type">Token type to match.</param>
        /// <param name="error">Output error string.</param>
        /// <returns>True if advanced successfully, otherwise false.</returns>
        private static bool MatchAndEat(this IEnumerator <Token> source, TokenType type, out string error)
        {
            error = null;

            if (source is null)
            {
                error = "Source enumerator is null.";
                return(false);
            }

            if (source.Current == type)
            {
                return(source.MoveNext());
            }

            error = $"Unexpected '{source.Current.Type.AsString()}', expected '{type.AsString()}'";
            return(false);
        }
 public override string ToString()
 {
     return($"JsonToken {{tokenType={TokenType.AsString()}, value={Value ?? "null"}}}");
 }