1
1
mirror of https://github.com/github/semantic.git synced 2024-12-22 06:11:49 +03:00

Add a character predicate to test for word characters.

This commit is contained in:
Rob Rix 2015-12-14 15:01:38 -05:00
parent 9c1dd640f5
commit 4fae286cf0

View File

@ -22,6 +22,8 @@ rangesOfWordsFrom startIndex string = case break Char.isSpace string of
(word, rest) -> (Range startIndex $ startIndex + length word) : rangesOfWordsAfterWhitespace (startIndex + length word) rest
where
rangesOfWordsAfterWhitespace startIndex string | (whitespace, rest) <- break (not . Char.isSpace) string = rangesOfWordsFrom (startIndex + length whitespace) rest
isWord c = Char.isLetter c || Char.isNumber c || Char.isMark c || Char.generalCategory c == Char.ConnectorPunctuation
instance Ord Range where
a <= b = start a <= start b