From: Nathaniel Wesley Filardo Date: Tue, 16 Feb 2016 03:25:01 +0000 (-0500) Subject: Break word parse util into two pieces X-Git-Url: https://hydra-www.ietfng.org/gitweb/?a=commitdiff_plain;h=5426c480d34415227416f920465c644ed4abcdca;p=grade Break word parse util into two pieces --- diff --git a/lib/Grade/ParseUtils.hs b/lib/Grade/ParseUtils.hs index 3a6efee..2aec5fa 100644 --- a/lib/Grade/ParseUtils.hs +++ b/lib/Grade/ParseUtils.hs @@ -1,7 +1,7 @@ -- Header -------------------------------------------------------------- {{{ module Grade.ParseUtils ( - toUtf8, sseof, word, hashComment, parseMapKeys + toUtf8, sseof, wordish, word, hashComment, parseMapKeys ) where import Control.Applicative @@ -23,8 +23,15 @@ sseof = (T.someSpace <|> T.eof) -- | Grab a word in its entirety. Note that this is a little strange as -- we check the 'notFollowedBy' condition *first*! +-- +-- Most likely you want this to be followed by space or EOF (see `word`), +-- but you may want to be more specific. +wordish :: (T.DeltaParsing f) => f Text +wordish = toUtf8 (T.sliced (many $ T.notFollowedBy T.someSpace *> T.anyChar)) + +-- | A wordish followed by some space or EOF. word :: (T.DeltaParsing f) => f Text -word = toUtf8 (T.sliced (many $ T.notFollowedBy T.someSpace *> T.anyChar)) <* sseof +word = wordish <* sseof -- | Grab a comment beginning with # and going to end of line. hashComment :: T.DeltaParsing f => f Text