Helper methods for creating and executing parsers.
public static class Parser
name | description |
---|---|
static readonly AnyChar | Parses any character; i.e. only fails at the end of the text. |
static readonly Digit | Parses any digit (as determined by char.IsDigit ). |
static readonly Letter | Parses any letter (as determined by char.IsLetter ). |
static readonly LetterOrDigit | Parses any letter or digit (as determined by char.IsLetterOrDigit ). |
static readonly WhiteSpace | Parses any whitespace character (as determined by 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<TValue,TBracketing>(…) | Succeeds if the specified parser succeeds beforehand and afterward (ignoring its results). |
static Bracketed<TValue,TPreceding,TFollowing>(…) | Succeeds if the specified parsers succeed beforehand and afterward (ignoring their results). |
static Capture<T>(…) | Captures the parsed text as a string. |
static ChainBinary<TValue,TOperator>(…) | Chains a left-associative binary operator to the parser. |
static ChainBinaryList<TValue,TOperator>(…) | Chains a left-associative binary operator to the parser. |
static ChainUnary<TValue,TOperator>(…) | Chains a left-associative unary operator to the parser. |
static ChainUnaryList<TValue,TOperator>(…) | Chains a left-associative unary operator to the parser. |
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<TValue,TDelimiter>(…) | Succeeds if the specified parser succeeds at least once, requiring and ignoring the specified delimiter between each item. |
static DelimitedAllowTrailing<TValue,TDelimiter>(…) | 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. (2 methods) |
static Failure<T>() | Always fails. |
static Failure<T>(…) | Fails even if the parser is successful. |
static FollowedBy<TValue,TFollowing>(…) | 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 Not<T>(…) | Fails if the parser succeeds, and succeeds with the default value if it 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<TValue,TPreceding>(…) | 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. (3 methods) |
static Regex(…) | Succeeds if the specified regular expression pattern matches the text. (3 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<TBefore,TAfter>(…) | Converts any successfully parsed value. |
static SelectMany<TBefore,TDuring,TAfter>(…) | Used to support LINQ query syntax. |
static SkipThen<T1,T2>(…) | Executes one parser after another, ignoring the output of the first parser. |
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<TBefore,TAfter>(…) | Succeeds with the specified value if the parser is successful. |
static Then<T1,T2>(…) | Executes one parser after another. |
static Then<TBefore,TAfter>(…) | Executes one parser after another. |
static Then<T1,T2,T3>(…) | Executes one parser after another. |
static Then<T1,T2,TAfter>(…) | Executes one parser after another. |
static Then<T1,T2,T3,T4>(…) | Executes one parser after another. |
static Then<T1,T2,T3,T4,T5>(…) | Executes one parser after another. |
static Then<T1,T2,T3,T4,T5,T6>(…) | Executes one parser after another. |
static Then<T1,T2,T3,T4,T5,T6,T7>(…) | Executes one parser after another. |
static Then<T1,T2,T3,T4,T5,T6,T7,T8>(…) | Executes one parser after another. |
static ThenSkip<T1,T2>(…) | Executes one parser after another, ignoring the output of the second parser. |
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. (4 methods) |
static Where<T>(…) | Fails if the specified predicate returns false for the successfully parsed value. (2 methods) |