Functions
The following functions are available globally.
-
Sequential conjunction of two parsers while ignoring the result of lhs
See moreDeclaration
Parameters
lhs
the first parser that has to succeed
rhs
the second parser that has to succeed
Return Value
a parser that parses lhs, then rhs on the rest and returns the result of rhs
-
Sequential conjunction of two parsers while ignoring the result of rhs
See moreDeclaration
Parameters
lhs
the first parser that has to succeed
rhs
the second parser that has to succeed
Return Value
a parser that parses lhs, then rhs on the rest and returns the result of lhs
-
Sequential conjunction of lhs and rhs with combining of the results in a tuple
See moreDeclaration
Parameters
lhs
the first parser that has to succeed
rhs
the second parser that has to succeed
Return Value
a parser that parses lhs, then rhs on the rest and returns a tuple of the combined results
-
Sequential conjunction of lhs and rhs with combining of the results in a tuple
See moreDeclaration
Parameters
lhs
the first parser that has to succeed
rhs
the second parser that has to succeed
Return Value
a parser that parses lhs, then rhs on the rest and returns a tuple of the combined results
-
Sequential conjunction of lhs and rhs with combining of the results in a tuple
See moreDeclaration
Parameters
lhs
the first parser that has to succeed
rhs
the second parser that has to succeed
Return Value
a parser that parses lhs, then rhs on the rest and returns a tuple of the combined results
-
Sequential conjunction of lhs and rhs with combining of the results in a tuple
See moreDeclaration
Parameters
lhs
the first parser that has to succeed
rhs
the second parser that has to succeed
Return Value
a parser that parses lhs, then rhs on the rest and returns a tuple of the combined results
-
Sequential conjunction of lhs and rhs with combining of the results in a tuple
See moreDeclaration
Parameters
lhs
the first parser that has to succeed
rhs
the second parser that has to succeed
Return Value
a parser that parses lhs, then rhs on the rest and returns a tuple of the combined results
-
Sequential conjunction of lhs and rhs with combining of the results in a tuple
See moreDeclaration
Parameters
lhs
the first parser that has to succeed
rhs
the second parser that has to succeed
Return Value
a parser that parses lhs, then rhs on the rest and returns a tuple of the combined results
-
Sequential conjunction of lhs and rhs with combining of the results in a tuple
See moreDeclaration
Parameters
lhs
the first parser that has to succeed
rhs
the second parser that has to succeed
Return Value
a parser that parses lhs, then rhs on the rest and returns a tuple of the combined results
-
Sequential conjunction of lhs and rhs with combining of the results in a tuple
See moreDeclaration
Parameters
lhs
the first parser that has to succeed
rhs
the second parser that has to succeed
Return Value
a parser that parses lhs, then rhs on the rest and returns a tuple of the combined results
-
Sequential conjunction of lhs and rhs with combining of the results in a tuple
See moreDeclaration
Parameters
lhs
the first parser that has to succeed
rhs
the second parser that has to succeed
Return Value
a parser that parses lhs, then rhs on the rest and returns a tuple of the combined results
-
Sequential conjunction of lhs and rhs with combining of the results in a tuple
See moreDeclaration
Parameters
lhs
the first parser that has to succeed
rhs
the second parser that has to succeed
Return Value
a parser that parses lhs, then rhs on the rest and returns a tuple of the combined results
-
Sequential conjunction of lhs and rhs with combining of the results in a tuple
See moreDeclaration
Parameters
lhs
the first parser that has to succeed
rhs
the second parser that has to succeed
Return Value
a parser that parses lhs, then rhs on the rest and returns a tuple of the combined results
-
Sequential conjunction of lhs and rhs with combining of the results in a tuple
See moreDeclaration
Parameters
lhs
the first parser that has to succeed
rhs
the second parser that has to succeed
Return Value
a parser that parses lhs, then rhs on the rest and returns a tuple of the combined results
-
Sequential conjunction of lhs and rhs with combining of the results in a tuple
See moreDeclaration
Parameters
lhs
the first parser that has to succeed
rhs
the second parser that has to succeed
Return Value
a parser that parses lhs, then rhs on the rest and returns a tuple of the combined results
-
Sequential conjunction of lhs and rhs with combining of the results in a tuple
See moreDeclaration
Parameters
lhs
the first parser that has to succeed
rhs
the second parser that has to succeed
Return Value
a parser that parses lhs, then rhs on the rest and returns a tuple of the combined results
-
Sequential conjunction of lhs and rhs with combining of the results in a tuple
See moreDeclaration
Parameters
lhs
the first parser that has to succeed
rhs
the second parser that has to succeed
Return Value
a parser that parses lhs, then rhs on the rest and returns a tuple of the combined results
-
Sequential conjunction of lhs and rhs with combining of the results in a tuple
See moreDeclaration
Parameters
lhs
the first parser that has to succeed
rhs
the second parser that has to succeed
Return Value
a parser that parses lhs, then rhs on the rest and returns a tuple of the combined results
-
Sequential conjunction of lhs and rhs with combining of the results in a tuple
See moreDeclaration
Parameters
lhs
the first parser that has to succeed
rhs
the second parser that has to succeed
Return Value
a parser that parses lhs, then rhs on the rest and returns a tuple of the combined results
-
Sequential conjunction of lhs and rhs with combining of the results in a tuple
See moreDeclaration
Parameters
lhs
the first parser that has to succeed
rhs
the second parser that has to succeed
Return Value
a parser that parses lhs, then rhs on the rest and returns a tuple of the combined results
-
Sequential conjunction of lhs and rhs with combining of the results in a tuple
See moreDeclaration
Parameters
lhs
the first parser that has to succeed
rhs
the second parser that has to succeed
Return Value
a parser that parses lhs, then rhs on the rest and returns a tuple of the combined results
-
Convenience operator for ‘or’ conjunction.
See moreDeclaration
Parameters
lhs
the first parser to evaluate
rhs
the second parser to evaluate
Return Value
a parser that evaluates both, rhs and lhs, starting with lhs
-
Convenience operator for ‘then’ concatenation.
See moreDeclaration
Parameters
lhs
the first parser to evaluate
rhs
the second parser to evaluate on lhs’ rest
Return Value
a parser that evaluates lhs and on it’s rest rhs
-
Convenience operator for map operations.
See moreDeclaration
Parameters
lhs
a parser to evaluate
rhs
a mapping operation to call on lhs’ result
Return Value
a parser that calls lhs and transforms its result with rhs afterwards.
-
Convenience operator for map operation. Replaces the result of lhs with rhs if lhs succeeded.
See moreDeclaration
Parameters
lhs
the parser which result should be replaced
rhs
the value that should replace the result of lhs
Return Value
a parser that parses lhs and replaces its result with rhs if it succeeds
-
Convenience operator for fallback operation.
See moreDeclaration
Parameters
lhs
the parser that could possibly fail
rhs
the default value that should be used instead
Return Value
a parser that tries to parse self and uses rhs if parsing failed.
-
Convenience operator for fallback with parser operation.
See moreDeclaration
Parameters
lhs
the parser that could fail
rhs
the parser that should be used instead
Return Value
a parser that tries to parse self and parses rhs if self failed.
-
~= allows the usage of
Parser
s in switch-case pattern matching statements.example:
switch "a" { case L.char: print("it's a char \o/") case L.digit: print("it's a digit!") default: print("it's something unexpected :/")
NOTE: Be aware that this also checks if the rest is empty to ensure the whole input matches!
See moreDeclaration
Swift
public func ~=<T, U>(lhs: Parser<T, U>, rhs: T) -> Bool
Parameters
lhs
the pattern, in this case the parser that should succeed
rhs
the value that the pattern should be matched with
Return Value
true if the parsing succeeds, false otherwise
-
Compares two ParseResults for equality NOTE: two failed ParseResults are always equal!
Hack until extensions with protocol conformance with constraints are possible
See moreDeclaration
Swift
public func ==<T, R>(lhs: ParseResult<T, R>, rhs: ParseResult<T, R>) -> Bool where T: Equatable, R: Equatable
Parameters
lhs
first argument
rhs
second argument
Return Value
true if both are equal
-
Convenience operator overload to use fallback on fail.
See moreDeclaration
Swift
public func ??<T, R>(lhs: ParseResult<T, R>, rhs: @autoclosure () -> R) -> R
Parameters
lhs
the parse result that could fail
rhs
the fallback that should be used in that case
Return Value
either the unwrapped result or fallback