Consume the next character, failing if it does not match the expected value or if there is no more input.
Modulebytesmith-0.3.11.1Haskell2010
Data.Bytes.Parser.Ascii
Parse input as ASCII-encoded text. Some parsers in this module,
like any and peek, fail if they encounter a byte above 0x7F.
Others, like numeric parsers and skipping parsers, leave the cursor
at the position of the offending byte without failing.
- 23 values
- Packagebytesmith-0.3.11.1
- Exports23
- LanguageHaskell2010
- LicenceBSD-3-Clause
- SourceAscii.hs
Matching
4 declarationsConsume the next two characters, failing if they do not match the expected values.
char2 e a b === char e a *> char e bConsume three characters, failing if they do not match the expected values.
char3 e a b c === char e a *> char e b *> char e cConsume four characters, failing if they do not match the expected values.
char4 e a b c d === char e a *> char e b *> char e c *> char e dCase-Insensitive Matching
1 declarationConsume the next character, failing if it does not match the expected value or if there is no more input. This check for equality is case insensitive.
Precondition: The argument must be a letter ([a-zA-Z]). Behavior is
undefined if it is not.
Get Character
4 declarationsConsumes and returns the next character in the input.
Variant of any with unboxed result.
Examine the next byte without consuming it, interpret it as an
ASCII-encoded character. This fails if the byte is above 0x7F or
if the end of input has been reached.
Consume the next byte, interpreting it as an ASCII-encoded character.
Fails if the byte is above 0x7F. Returns Nothing if the
end of the input has been reached.
Match Many
2 declarationsConsume input through the next occurrence of the target
character and return the consumed input, excluding the
target character, as a ShortText. This fails if it
encounters any bytes above 0x7F.
Consume characters matching the predicate. The stops when it
encounters a non-matching character or when it encounters a byte
above 0x7F. This never fails.
Skip
8 declarationsSkip the characters 0-9 until a non-digit is encountered.
This parser does not fail.
Variant of skipDigits that requires at least one digit to be present.
Skip the character any number of times. This succeeds even if the character was not present.
Skip the character any number of times. It must occur at least once or else this will fail.
Skip uppercase and lowercase letters until a non-alpha character is encountered.
Skip uppercase and lowercase letters until a non-alpha character is encountered.
Consume input until the trailer is found. Then, consume the trailer as well. This fails if the trailer is not found or if any non-ASCII characters are encountered.
Consume characters matching the predicate. The stops when it
encounters a non-matching character or when it encounters a byte
above 0x7F. This never fails.
Numbers
4 declarationsParse a decimal-encoded number. If the number is too large to be represented by a machine word, this fails with the provided error message. This accepts any number of leading zeroes.
Parse a decimal-encoded 8-bit word. If the number is larger than 255, this parser fails.
Parse a decimal-encoded 16-bit word. If the number is larger than 65535, this parser fails.
Parse a decimal-encoded 32-bit word. If the number is larger than 4294967295, this parser fails.