module Text.InterpolatedString.QM.Internal.Parsers
( qm, qn
, qmb, qnb
, qms, qns
) where
import qualified "template-haskell" Language.Haskell.TH as TH
import Text.InterpolatedString.QM.Internal.Parsers.TH (parserTpl)
import Text.InterpolatedString.QM.Internal.Parsers.Types ( Parser
, StringPart (..)
, LineBreaks (..)
)
import Text.InterpolatedString.QM.Internal.Parsers.Helpers
( unQX
, clearIndentAtStart
, clearIndentAtSOF
, clearIndentTillEOF
, clearFirstQXXLineBreak
, clearLastQXXLineBreak
, makeExpr
)
$(parserTpl "parseQM" True IgnoreLineBreaks)
$(parserTpl "parseQN" False IgnoreLineBreaks)
$(parserTpl "parseQMB" True KeepLineBreaks)
$(parserTpl "parseQNB" False KeepLineBreaks)
$(parserTpl "parseQMS" True ReplaceLineBreaksWithSpaces)
$(parserTpl "parseQNS" False ReplaceLineBreaksWithSpaces)
qm :: String -> TH.ExpQ
qm = makeExpr . parseQM "" . clearIndentAtStart . filter (/= '\r')
qn :: String -> TH.ExpQ
qn = makeExpr . parseQN "" . clearIndentAtStart . filter (/= '\r')
qmb :: String -> TH.ExpQ
qmb = makeExpr
. parseQMB ""
. clearFirstQXXLineBreak
. clearIndentAtStart
. filter (/= '\r')
qnb :: String -> TH.ExpQ
qnb = makeExpr
. parseQNB ""
. clearFirstQXXLineBreak
. clearIndentAtStart
. filter (/= '\r')
qms :: String -> TH.ExpQ
qms = makeExpr
. parseQMS ""
. clearFirstQXXLineBreak
. clearIndentAtStart
. filter (/= '\r')
qns :: String -> TH.ExpQ
qns = makeExpr
. parseQNS ""
. clearFirstQXXLineBreak
. clearIndentAtStart
. filter (/= '\r')