Char package:megaparsec
Commonly used character parsers.
A type-constrained version of
single.
newline = char 10
A type-constrained version of
single.
semicolon = char ';'
The same as
char but case-insensitive. This parser returns the
actually parsed character preserving its case.
>>> parseTest (char' 101) "E"
69 -- 'E'
>>> parseTest (char' 101) "G"
1:1:
unexpected 'G'
expecting 'E' or 'e'
The same as
char but case-insensitive. This parser returns the
actually parsed character preserving its case.
>>> parseTest (char' 'e') "E"
'E'
>>> parseTest (char' 'e') "G"
1:1:
unexpected 'G'
expecting 'E' or 'e'
The lexeme parser parses a single literal character without quotes.
The purpose of this parser is to help with parsing of conventional
escape sequences. It's your responsibility to take care of character
literal syntax in your language (by surrounding it with single quotes
or similar).
The literal character is parsed according to the grammar rules defined
in the Haskell report.
Note that you can use this parser as a building block to parse various
string literals:
stringLiteral = char '"' >> manyTill L.charLiteral (char '"')
Performance note: the parser is not particularly efficient at
the moment.
Return length of an individual
Char.
Parse an alphabetic or digit characters.
Parse a character from the first 128 characters of the Unicode
character set, corresponding to the ASCII character set.
Parse a binary digit, i.e. “0” or “1”.
Parse a control character.
Parse an ASCII digit, i.e between “0” and “9”.
Parse a hexadecimal digit, i.e. between “0” and “9”, or “a” and “f”,
or “A” and “F”.
Parse an alphabetic character: lower-case or upper-case.
Parse a lower-case alphabetic character.
Parse an octal digit, i.e. between “0” and “7”.
Parse a printable character: letter, number, mark, punctuation, symbol
or space.
Parse a space character, and the control characters: tab, newline,
carriage return, form feed, and vertical tab.
Parse an upper-case character.
Parse an alphabetic or numeric digit Unicode characters.
Note that the numeric digits outside the ASCII range are parsed by
this parser but not by
digitChar. Such digits may be part of
identifiers but are not used by the printer and reader to represent
numbers.
Parse a character from the first 128 characters of the Unicode
character set, corresponding to the ASCII character set.
Parse a binary digit, i.e. "0" or "1".
Parse a control character (a non-printing character of the Latin-1
subset of Unicode).
Parse an ASCII digit, i.e between “0” and “9”.