RFC5234: return what was parsed (except for \r\n in lwsp).
parent
b77f219c40
commit
45f867f3c5
|
@ -2,11 +2,12 @@
|
||||||
-- | This module implements core rules found in appendix B.1.
|
-- | This module implements core rules found in appendix B.1.
|
||||||
module GenericParser.RFC5234 where
|
module GenericParser.RFC5234 where
|
||||||
|
|
||||||
import Prelude (Unit, between, (<<<), (||), (==), bind, void, ($))
|
import Prelude (between, pure, (<$>), (<<<), (||), (==), bind, ($))
|
||||||
|
|
||||||
import Control.Alt ((<|>))
|
import Control.Alt ((<|>))
|
||||||
import Data.Array as A
|
import Data.Array as A
|
||||||
import Data.Char as C
|
import Data.Char as C
|
||||||
|
import Data.String.CodeUnits as CU
|
||||||
|
|
||||||
import GenericParser.BaseFunctions (isAlpha, isDigit, isHexaDecimal)
|
import GenericParser.BaseFunctions (isAlpha, isDigit, isHexaDecimal)
|
||||||
|
|
||||||
|
@ -40,9 +41,10 @@ cr = char '\r'
|
||||||
-- | CRLF: Internet standard newline.
|
-- | CRLF: Internet standard newline.
|
||||||
-- |
|
-- |
|
||||||
-- | CRLF = CR LF
|
-- | CRLF = CR LF
|
||||||
crlf :: forall e. Parser e Unit
|
crlf :: forall e. Parser e String
|
||||||
crlf = do _ <- char '\r'
|
crlf = do _ <- char '\r'
|
||||||
void $ char '\n'
|
_ <- char '\n'
|
||||||
|
pure "\r\n"
|
||||||
|
|
||||||
-- | CTL: control characters.
|
-- | CTL: control characters.
|
||||||
-- |
|
-- |
|
||||||
|
@ -87,11 +89,10 @@ lf = char '\n'
|
||||||
-- | Do not use when defining mail headers and use with caution in other contexts.
|
-- | Do not use when defining mail headers and use with caution in other contexts.
|
||||||
-- |
|
-- |
|
||||||
-- | LWSP = *(WSP / CRLF WSP)
|
-- | LWSP = *(WSP / CRLF WSP)
|
||||||
lwsp :: forall e. Parser e Unit
|
lwsp :: forall e. Parser e String
|
||||||
lwsp = void $ A.many (wsp <|> (do _ <- crlf
|
lwsp = CU.fromCharArray <$> A.many (wsp <|> (do _ <- crlf
|
||||||
wsp))
|
wsp))
|
||||||
|
|
||||||
|
|
||||||
-- | OCTET: any data on a single byte.
|
-- | OCTET: any data on a single byte.
|
||||||
-- |
|
-- |
|
||||||
-- | OCTET = %x00-FF
|
-- | OCTET = %x00-FF
|
||||||
|
|
Loading…
Reference in New Issue