mirror of
https://github.com/github/semantic.git
synced 2024-12-22 14:21:31 +03:00
Use Alternative to combine our non-skipped parsers.
This commit is contained in:
parent
835a3a0245
commit
e9f21668a1
@ -1,5 +1,6 @@
|
||||
module Range where
|
||||
|
||||
import Control.Applicative ((<|>))
|
||||
import qualified Data.Char as Char
|
||||
|
||||
data Range = Range { start :: Int, end :: Int }
|
||||
@ -17,10 +18,7 @@ offsetRange i (Range start end) = Range (i + start) (i + end)
|
||||
rangesAndWordsFrom :: Int -> String -> [(Range, String)]
|
||||
rangesAndWordsFrom _ "" = []
|
||||
rangesAndWordsFrom startIndex string =
|
||||
case parse isWord string of
|
||||
Just parsed -> takeAndContinue parsed
|
||||
Nothing ->
|
||||
case parse (not . isWordOrSeparator) string of
|
||||
case (parse isWord string <|> parse (not . isWordOrSeparator) string) of
|
||||
Just parsed -> takeAndContinue parsed
|
||||
Nothing ->
|
||||
case parse Char.isSeparator string of
|
||||
|
Loading…
Reference in New Issue
Block a user