| Copyright | (c) Dennis Gosnell 2016 |
|---|---|
| License | BSD-style (see LICENSE file) |
| Maintainer | cdep.illabout@gmail.com |
| Stability | experimental |
| Portability | POSIX |
| Safe Haskell | None |
| Language | Haskell2010 |
Text.Pretty.Simple.Internal.ExprParser
Description
Synopsis
- testString1 :: String
- testString2 :: String
- expressionParse :: String -> [Expr]
- parseExpr :: String -> (Expr, String)
- parseExprs :: String -> ([Expr], String)
- parseCSep :: Char -> String -> ([[Expr]], String)
- parseStringLit :: String -> (String, String)
- parseNumberLit :: Char -> String -> (String, String)
- parseOther :: String -> (String, String)
Documentation
testString1 :: String Source #
testString1 and testString2 are convenient to use in GHCi when playing
around with how parsing works.
testString2 :: String Source #
See testString1.
expressionParse :: String -> [Expr] Source #
parseExprs :: String -> ([Expr], String) Source #
Handle escaped characters correctly
>>>parseExprs $ "Foo \"hello \\\"world!\""([Other "Foo ",StringLit "hello \\\"world!"],"")
parseNumberLit :: Char -> String -> (String, String) Source #
Parses integers and reals, like 123 and 45.67.
To be more precise, any numbers matching the regex \d+(\.\d+)? should
get parsed by this function.
>>>parseNumberLit '3' "456hello world []"("3456","hello world []")>>>parseNumberLit '0' ".12399880 foobar"("0.12399880"," foobar")
parseOther :: String -> (String, String) Source #
This function consumes input, stopping only when it hits a special
character or a digit. However, if the digit is in the middle of a
Haskell-style identifier (e.g. foo123), then keep going
anyway.
This is almost the same as the function
parseOtherSimple = span $ \c ->
notElem c ("{[()]}\"," :: String) && not (isDigit c)except parseOther ignores digits that appear in Haskell-like identifiers.
>>>parseOther "hello world []"("hello world ","[]")>>>parseOther "hello234 world"("hello234 world","")>>>parseOther "hello 234 world"("hello ","234 world")>>>parseOther "hello{[ 234 world"("hello","{[ 234 world")>>>parseOther "H3110 World"("H3110 World","")