Trait RegexParsers
A collection of parser combinators for string/character parsing using
regular expressions.
This trait defines an input sequence as an array of characters.
-
Parco\Combinator\RegexParsers
uses
Parco\Combinator\Parsers
Methods summary
protected
|
|
protected
|
|
protected
|
#
tail( $input, array $pos )
|
protected
|
|
public
Parco\Result
|
#
parse( Parco\Parser $p, string $string )
Use a character parser to parse a string.
Use a character parser to parse a string.
Parameters
- $p
- A parser.
- $string
- An input string.
Returns
|
public
Parco\Result
|
#
parseAll( Parco\Parser $p, string $string )
Use a character parser to parse a string. The entire string must be
consumed by the parser.
Use a character parser to parse a string. The entire string must be
consumed by the parser.
parseAll($p) is the same as parse(phrase($p)) .
Parameters
- $p
- A parser.
- $string
- An input string.
Returns
|
public
Parco\Parser
|
#
whitespace( )
A parser that matches any number of whitespace characters.
A parser that matches any number of whitespace characters.
The following bytes are matched: 0x09 (horizontal tab), 0x0A (line feed),
0x0B (vertical tab), 0x0C (form feed), 0x0D (carriage return), and 0x20
(space).
Returns
|
public
Parco\FuncParser
|
|
public
Parco\Parser
|
#
char( string $c )
A parser that accepts only the given character.
A parser that accepts only the given character.
char($c) is a parser that succeeds if the first character in the input
is equal to $c .
Parameters
Returns
|
public
Parco\Parser
|
#
string( string $s )
A parser that accepts only the given string.
A parser that accepts only the given string.
string($s) is a parser that succeeds if the first $n characters of the
input is equal to $s , where $n=strlen($s) .
Parameters
Returns
|
public
Parco\Parser
|
#
regex( string $regex )
A parser that matches a regular expression string.
A parser that matches a regular expression string.
The parser returns an instance of Parco\Match to store its result.
Parameters
- $regex
- A regular expression, see preg_match.
Returns
|
public
Parco\Parser
|
#
group( integer $i, Parco\Parser $p )
A parser that returns the $i th group of a regex parse result.
A parser that returns the $i th group of a regex parse result.
Parameters
Returns
Parco\Parser A parser that returns the group or null if the group is
empty.
|
Methods used from Parco\Combinator\Parsers
__get(),
acceptIf(),
alt(),
chainl(),
chainr(),
elem(),
failure(),
not(),
opt(),
phrase(),
positioned(),
rep(),
rep1(),
rep1sep(),
repN(),
repsep(),
seq(),
success()
|