primitives.php
This file is part of the Parsica library.
Copyright (c) 2020 Mathias Verraes mathias@verraes.net
For the full copyright and license information, please view the LICENSE file that was distributed with this source code.
Table of Contents
Functions
- satisfy() : Parser
- A parser that satisfies a predicate on a single token. Useful as a building block for writing things like char(), digit().
- skipWhile() : Parser
- Skip 0 or more characters as long as the predicate holds.
- skipWhile1() : Parser
- Skip 1 or more characters as long as the predicate holds.
- takeWhile() : Parser
- Keep parsing 0 or more characters as long as the predicate holds.
- takeWhile1() : Parser
- Keep parsing 1 or more characters as long as the predicate holds.
- anySingle() : Parser
- Parse and return a single character of anything.
- anything() : Parser
- Parse and return a single character of anything.
- anySingleBut() : Parser
- Match any character but the given one.
- oneOf() : Parser
- Succeeds if the current character is in the supplied list of characters. Returns the parsed character.
- oneOfS() : Parser
- A compact form of 'oneOf'.
- noneOf() : Parser
- The dual of 'oneOf'. Succeeds if the current character is not in the supplied list of characters. Returns the parsed character.
- noneOfS() : Parser
- A compact form of 'noneOf'.
- takeRest() : Parser
- Consume the rest of the input and return it as a string. This parser never fails, but may return the empty string.
- nothing() : Parser
- Parse nothing, but still succeed.
- everything() : Parser
- Parse everything; that is, consume the rest of the input until the end.
- succeed() : Parser
- Always succeed, no matter what the input was.
- fail() : Parser
- Always fail, no matter what the input was.
- eof() : Parser
- Parse the end of the input
Functions
satisfy()
A parser that satisfies a predicate on a single token. Useful as a building block for writing things like char(), digit().
satisfy(callable $predicate) : Parser
..
Parameters
- $predicate : callable
Tags
Return values
ParserskipWhile()
Skip 0 or more characters as long as the predicate holds.
skipWhile(callable $predicate) : Parser
Parameters
- $predicate : callable
Tags
Return values
ParserskipWhile1()
Skip 1 or more characters as long as the predicate holds.
skipWhile1(callable $predicate) : Parser
Parameters
- $predicate : callable
Tags
Return values
ParsertakeWhile()
Keep parsing 0 or more characters as long as the predicate holds.
takeWhile(callable $predicate) : Parser
Parameters
- $predicate : callable
Tags
Return values
ParsertakeWhile1()
Keep parsing 1 or more characters as long as the predicate holds.
takeWhile1(callable $predicate) : Parser
Parameters
- $predicate : callable
Tags
Return values
ParseranySingle()
Parse and return a single character of anything.
anySingle() : Parser
Tags
Return values
Parseranything()
Parse and return a single character of anything.
anything() : Parser
Tags
Return values
ParseranySingleBut()
Match any character but the given one.
anySingleBut(string $x) : Parser
Parameters
- $x : string
Tags
Return values
ParseroneOf()
Succeeds if the current character is in the supplied list of characters. Returns the parsed character.
oneOf(array<string|int, mixed> $chars) : Parser
Parameters
- $chars : array<string|int, mixed>
Tags
Return values
ParseroneOfS()
A compact form of 'oneOf'.
oneOfS(string $chars) : Parser
oneOfS("abc") == oneOf(['a', 'b', 'c'])
Parameters
- $chars : string
Tags
Return values
ParsernoneOf()
The dual of 'oneOf'. Succeeds if the current character is not in the supplied list of characters. Returns the parsed character.
noneOf(array<string|int, mixed> $chars) : Parser
Parameters
- $chars : array<string|int, mixed>
Tags
Return values
ParsernoneOfS()
A compact form of 'noneOf'.
noneOfS(string $chars) : Parser
noneOfS("abc") == noneOf(['a', 'b', 'c'])
Parameters
- $chars : string
Tags
Return values
ParsertakeRest()
Consume the rest of the input and return it as a string. This parser never fails, but may return the empty string.
takeRest() : Parser
Tags
Return values
Parsernothing()
Parse nothing, but still succeed.
nothing() : Parser
This serves as the zero parser in append() operations.
Tags
Return values
Parsereverything()
Parse everything; that is, consume the rest of the input until the end.
everything() : Parser
Tags
Return values
Parsersucceed()
Always succeed, no matter what the input was.
succeed() : Parser
Tags
Return values
Parserfail()
Always fail, no matter what the input was.
fail(string $label) : Parser
Parameters
- $label : string
Tags
Return values
Parsereof()
Parse the end of the input
eof() : Parser