diff options
author | tv <tv@krebsco.de> | 2019-01-23 00:02:42 +0100 |
---|---|---|
committer | tv <tv@krebsco.de> | 2019-01-23 00:57:36 +0100 |
commit | d40815fd56bf1895af89b72b1171675a2e0ae5f7 (patch) | |
tree | 83b96a701f16b13915836c3a6c94463732a9f6d8 /src/Reaktor/Parser.hs | |
parent | a00da57346c195b1b15d1c6aca2891483901aae6 (diff) |
src: use more simple functionsv0.1.0
Diffstat (limited to 'src/Reaktor/Parser.hs')
-rw-r--r-- | src/Reaktor/Parser.hs | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/src/Reaktor/Parser.hs b/src/Reaktor/Parser.hs index 12d5ace..1b358fc 100644 --- a/src/Reaktor/Parser.hs +++ b/src/Reaktor/Parser.hs @@ -1,35 +1,37 @@ {-# LANGUAGE OverloadedStrings #-} module Reaktor.Parser where -import Control.Applicative -import Data.Attoparsec.ByteString.Char8 -import qualified Data.ByteString.Char8.Extended as BS +import Control.Applicative +import Data.ByteString (ByteString) +import Data.Attoparsec.ByteString.Char8 +--import qualified Data.ByteString.Char8.Extended as BS +import qualified Data.ByteString.Char8 as BS import qualified Data.Char -import Reaktor.Internal +import Reaktor.Internal -prefix :: Parser Prefix +prefix :: Parser ByteString prefix = BS.pack <$> many (satisfy Data.Char.isAlphaNum <|> satisfy (flip elem (":.-@/!~[]\\`_^{|}" :: String))) -command :: Parser Command +command :: Parser ByteString command = BS.pack <$> many1 (satisfy Data.Char.isAlphaNum) nospcrlfcl :: Parser Char nospcrlfcl = satisfy (flip notElem ("\NUL\CR\LF :" :: String)) <?> "nospcrlfcl" -middle :: Parser Param +middle :: Parser ByteString middle = BS.pack <$> ((:) <$> nospcrlfcl <*> many (char ':' <|> nospcrlfcl)) <?> "middle" -trailing :: Parser Param +trailing :: Parser ByteString trailing = BS.pack <$> many (char ':' <|> char ' ' <|> nospcrlfcl) <?> "trailing" -params :: Parser [Param] +params :: Parser [ByteString] params = (do a <- many (char ' ' *> middle) b <- optional (char ' ' *> char ':' *> trailing) |