From 5426c480d34415227416f920465c644ed4abcdca Mon Sep 17 00:00:00 2001 From: Nathaniel Wesley Filardo Date: Mon, 15 Feb 2016 22:25:01 -0500 Subject: [PATCH] Break word parse util into two pieces --- lib/Grade/ParseUtils.hs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) 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 -- 2.50.1