1
1
mirror of https://github.com/github/semantic.git synced 2024-12-22 22:31:36 +03:00

Use the Alternative instance for skipping spaces too.

This commit is contained in:
Rob Rix 2015-12-14 16:34:52 -05:00
parent 645ae0b6de
commit 44c11647f8

View File

@ -18,12 +18,9 @@ offsetRange i (Range start end) = Range (i + start) (i + end)
rangesAndWordsFrom :: Int -> String -> [(Range, String)] rangesAndWordsFrom :: Int -> String -> [(Range, String)]
rangesAndWordsFrom _ "" = [] rangesAndWordsFrom _ "" = []
rangesAndWordsFrom startIndex string = rangesAndWordsFrom startIndex string =
case takeAndContinue <$> (word <|> punctuation) of case takeAndContinue <$> (word <|> punctuation) <|> skipAndContinue <$> space of
Just a -> a Just a -> a
Nothing -> Nothing -> []
case space of
Just parsed -> skipAndContinue parsed
Nothing -> []
where where
word = parse isWord string word = parse isWord string
punctuation = parse (not . isWordOrSpace) string punctuation = parse (not . isWordOrSpace) string