From d40815fd56bf1895af89b72b1171675a2e0ae5f7 Mon Sep 17 00:00:00 2001 From: tv Date: Wed, 23 Jan 2019 00:02:42 +0100 Subject: src: use more simple functions --- src/Reaktor/Parser.hs | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'src/Reaktor/Parser.hs') 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) -- cgit v1.2.3