microparsec/characters

    Dark Mode
Search:
Group by:

Commonly used character parsers.

Lets

space: Parser[char] = satisfy(isSpaceAscii, ["space"])
A Parser that consumes a single white space character (any character which satisfies isSpaceAscii). Returns the parsed character.   Source Edit
spaces: Parser[void] = skipMany(space) <?> "white space"
Skips zero or more white space characters. See also skipMany.   Source Edit
newline: Parser[char] = ch('\n') <?> "lf new-line"
Parses a newline character ('n'). Returns a newline character.   Source Edit
crlf: Parser[char] = ch('\c') *> ch('\n') <?> "crlf new-line"
Parses a carriage return character ('r') followed by a newline character ('n'). Returns a newline character.   Source Edit
endOfLine: Parser[char] = newline <|> crlf <?> "new-line"
Parses a CRLF (see crlf) or LF (see newline) end-of-line. Returns a newline character ('n').   Source Edit

Funcs

func inClass(cs: auto): (char -> bool)
Match any character in a set.   Source Edit
func notInClass(cs: auto): (char -> bool)
Match any character not in a set.   Source Edit
func oneOf(cs: auto): Parser[char]
A Parser that succeeds if the current character is in the supplied set of characters. Returns the parsed character. See also satisfy.

Example:

let vowel = oneOf "aeiou"
  Source Edit
func noneOf(cs: auto): Parser[char]
As the dual of oneOf, this Parser succeeds if the current character is not in the supplied set of characters. Returns the parsed character.

Example:

let consonant = noneOf "aeiou"
  Source Edit