mirror of
https://github.com/joshuaclayton/unused.git
synced 2024-09-11 04:45:28 +03:00
Use applicative style in Parsec
This commit also moves `eol` into the `parseTermMatch` parser, which should be safe since `parseTermMatches` is the only place that `parseTermMatch` is used.
This commit is contained in:
parent
3ff26fceea
commit
985d876ff5
@ -21,15 +21,7 @@ responseFromParse =
|
|||||||
fmap $ Map.fromList . map (second $ calculateLikelihood . resultsFromMatches) . groupBy tmTerm
|
fmap $ Map.fromList . map (second $ calculateLikelihood . resultsFromMatches) . groupBy tmTerm
|
||||||
|
|
||||||
parseTermMatches :: Parser [TermMatch]
|
parseTermMatches :: Parser [TermMatch]
|
||||||
parseTermMatches = do
|
parseTermMatches = many1 parseTermMatch <* eof
|
||||||
tm <- many1 $ do
|
|
||||||
m <- parseTermMatch
|
|
||||||
void eol
|
|
||||||
|
|
||||||
return m
|
|
||||||
eof
|
|
||||||
|
|
||||||
return tm
|
|
||||||
|
|
||||||
parseTermMatch :: Parser TermMatch
|
parseTermMatch :: Parser TermMatch
|
||||||
parseTermMatch = do
|
parseTermMatch = do
|
||||||
@ -38,6 +30,7 @@ parseTermMatch = do
|
|||||||
path' <- pathParser
|
path' <- pathParser
|
||||||
colonSep
|
colonSep
|
||||||
occurrences' <- occurrenceParser
|
occurrences' <- occurrenceParser
|
||||||
|
void eol
|
||||||
|
|
||||||
return $ TermMatch term' path' $ toInt occurrences'
|
return $ TermMatch term' path' $ toInt occurrences'
|
||||||
where
|
where
|
||||||
|
Loading…
Reference in New Issue
Block a user