C# Class Sprache.Parse

Exibir arquivo Open project: sprache/Sprache

Public Methods

Method Description
Regex ( Regex regex, string description = null ) : Parser

Construct a parser from the given regular expression.

Regex ( string pattern, string description = null ) : Parser

Construct a parser from the given regular expression.

RegexMatch ( Regex regex, string description = null ) : Parser

Construct a parser from the given regular expression, returning a parser of type Match.

RegexMatch ( string pattern, string description = null ) : Parser

Construct a parser from the given regular expression, returning a parser of type Match.

Private Methods

Method Description
OptimizeRegex ( Regex regex ) : Regex

Optimize the regex by only matching successfully at the start of the input. Do this by wrapping the whole regex in non-capturing parentheses preceded by a `^'.

This method is invoked via reflection in unit tests. If renamed, the tests will need to be modified or they will fail.

Method Details

Regex() public static method

Construct a parser from the given regular expression.
public static Regex ( Regex regex, string description = null ) : Parser
regex System.Text.RegularExpressions.Regex The regex expression.
description string Description of characters that don't match.
return Parser

Regex() public static method

Construct a parser from the given regular expression.
public static Regex ( string pattern, string description = null ) : Parser
pattern string The regex expression.
description string Description of characters that don't match.
return Parser

RegexMatch() public static method

Construct a parser from the given regular expression, returning a parser of type Match.
public static RegexMatch ( Regex regex, string description = null ) : Parser
regex System.Text.RegularExpressions.Regex The regex expression.
description string Description of characters that don't match.
return Parser

RegexMatch() public static method

Construct a parser from the given regular expression, returning a parser of type Match.
public static RegexMatch ( string pattern, string description = null ) : Parser
pattern string The regex expression.
description string Description of characters that don't match.
return Parser