Parser class

Helper methods for creating and executing parsers.

public static class Parser

Public Members

name description
static AnyChar Parses any character; i.e. only fails at the end of the text.
static Digit Parses any digit (as determined by System.Char.IsDigit).
static Letter Parses any letter (as determined by System.Char.IsLetter).
static LetterOrDigit Parses any letter or digit (as determined by System.Char.IsLetterOrDigit).
static WhiteSpace Parses any whitespace character (as determined by System.Char.IsWhiteSpace).
static AnyCharExcept(…) Parses any character except the specified character.
static Append<T>(…) Appends a successfully parsed value to the end of a successfully parsed collection.
static AtLeast<T>(…) Succeeds if the parser succeeds at least the specified number of times. The value is a collection of as many items as can be successfully parsed.
static AtLeastOnce<T>(…) Succeeds if the parser succeeds at least once. The value is a collection of as many items as can be successfully parsed.
static AtMost<T>(…) Always succeeds. The value is a collection of at most the specified number of successfully parsed items.
static AtMostOnce<T>(…) Always succeeds. The value is a one-item collection of a single successfully parsed item; otherwise an empty collection.
static Bracketed<T,U,V>(…) Succeeds if the specified parsers succeed beforehand and afterward (ignoring their results).
static Char(…) Parses a single character if the specified predicate returns true. (2 methods)
static Chars(…) Maps a successfully parsed string into a successfully parsed collection of characters.
static Concat(…) Concatenates the successfully parsed collection of strings into a single successfully parsed string.
static Concat<T>(…) Concatenates the two successfully parsed collections.
static Create<T>(…) Creates a parser from a delegate.
static Delimited<T,U>(…) Succeeds if the specified parser succeeds at least once, requiring and ignoring the specified delimiter between each item.
static DelimitedAllowTrailing<T,U>(…) Succeeds if the specified parser succeeds at least once, requiring and ignoring the specified delimiter between each item, and allowing a single optional trailing delimiter.
static End<T>(…) Succeeds only at the end of the text.
static FollowedBy<T,U>(…) Succeeds if the specified parser also succeeds afterward (ignoring its result).
static Join(…) Joins the successfully parsed collection of strings into a single successfully parsed string using the specified separator.
static Many<T>(…) Always succeeds. The value is a collection of as many items as can be successfully parsed.
static Named<T>(…) Reports a named failure with the specified name if the parser fails.
static Once<T>(…) Succeeds if the parser succeeds. The value is a one-item collection of the successfully parsed item.
static Or<T>(…) Succeeds with a successful parser, if any. (3 methods)
static OrDefault<T>(…) Succeeds with the default value if the parser fails. (2 methods)
static OrEmpty<T>(…) Succeeds with an empty collection if the parser fails. (3 methods)
static Parse<T>(…) Parses the specified text, throwing ParseException on failure. (2 methods)
static Positioned<T>(…) Wraps the text position and length around a successfully parsed value.
static PrecededBy<T,U>(…) Succeeds if the specified parser also succeeds beforehand (ignoring its result).
static Ref<T>(…) Refers to another parser indirectly. This allows circular compile-time dependency between parsers.
static Regex(…) Succeeds if the specified regular expression pattern matches the text. (2 methods)
static Repeat<T>(…) Succeeds if the parser succeeds the specified number of times. The value is a collection of the parsed items. (2 methods)
static Select<T,U>(…) Converts any successfully parsed value.
static SelectMany<T,U,V>(…) Used to support LINQ query syntax.
static String(…) Parses the specified string using ordinal (case-sensitive) comparison. (3 methods)
static Success<T>(…) Succeeds with the specified value without advancing the text position.
static Success<T,U>(…) Succeeds with the specified value if the parser is successful.
static Then<T,U>(…) Executes one parser after another.
static Trim<T>(…) Succeeds if the specified parser succeeds, ignoring any whitespace characters beforehand or afterward.
static TrimEnd<T>(…) Succeeds if the specified parser succeeds, ignoring any whitespace characters afterward.
static TrimStart<T>(…) Succeeds if the specified parser succeeds, ignoring any whitespace characters beforehand.
static TryParse<T>(…) Attempts to parse the specified text. (2 methods)
static Where<T>(…) Fails if the specified predicate returns false for the successfully parsed value.

See Also