Match a specific character.
Modulestreamly-core-0.2.2Haskell2010
Streamly.Unicode.Parser
To parse a text input, use the decode routines from Streamly.Unicode.Stream module to convert an input byte stream to a Unicode Char stream and then use these parsers on the Char stream.
- 29 values
- Packagestreamly-core-0.2.2
- Exports29
- LanguageHaskell2010
- LicenceBSD-3-Clause
- SourceParser.hs
Setup
0 declarationsTo execute the code examples provided in this module in ghci, please run the following commands first.
:mimport qualified Streamly.Data.Stream as Streamimport qualified Streamly.Unicode.Parser as Unicode
For APIs that have not been released yet.
import qualified Streamly.Internal.Unicode.Parser as Unicode (number, mkDouble)Single Chars
21 declarationsMatch a specific character ignoring case.
Match any character that satisfies isAlpha
Match any character that satisfies isAlphaNum
Match any character that satisfies isLetter
Match any character that satisfies isAscii
Match any character that satisfies isAsciiLower
Match any character that satisfies isAsciiUpper
Match any character that satisfies isLatin1
Match any character that satisfies isLower
Match any character that satisfies isUpper
Match any character that satisfies isMark
Match any character that satisfies isPrint
Match any character that satisfies isPunctuation
Match any character that satisfies isSeparator
Match any character that satisfies isSpace
Match any character that satisfies isSymbol
Match any character that satisfies isDigit
Match any character that satisfies isOctDigit
Match any character that satisfies isHexDigit
Match any character that satisfies isNumber
Char Sequences
4 declarationsMatch the input with the supplied string and return it if successful.
Match the input with the supplied string and return it if successful.
Drop zero or more white space characters.
Drop one or more white space characters.
Digit Sequences (Numbers)
3 declarationsParse and decode an unsigned integral decimal number.
Parse and decode an unsigned integral hexadecimal number. The hex digits
'a' through 'f' may be upper or lower case.
Note: This parser does not accept a leading "0x" string.
Parse a decimal Double value. This parser accepts an optional sign (+ or -) followed by at least one decimal digit. Decimal digits are optionally followed by a decimal point and at least one decimal digit after the point. This parser accepts the maximal valid input as long as it gives a valid number. Specifcally a trailing decimal point is allowed but not consumed. This function does not accept "NaN" or "Infinity" string representations of double values.
Definition:
double = uncurry Unicode.mkDouble <$> Unicode.numberExamples:
p = Stream.parse Unicode.double . Stream.fromListp "-1.23e-123"Right (-1.23e-123)
Trailing input examples:
p "1."Right 1.0
p "1.2.3"Right 1.2
p "1e"Right 1.0
p "1e2.3"Right 100.0
p "1+2"Right 1.0
Error cases:
p ""Left (ParseError "number: expecting sign or decimal digit, got end of input")
p ".1"Left (ParseError "number: expecting sign or decimal digit, got '.'")
p "+"Left (ParseError "number: expecting decimal digit, got end of input")
Modifiers
1 declarationAllow an optional leading '+' or '-' sign character before any
parser.