@@ -201,6 +201,8 @@ data Next
201 = Keyword [Char]
201 = Keyword [Char]
202 | Operator [Char]
202 | Operator [Char]
203 | Close [Char] Char
203 | Close [Char] Char
204 | Other (Maybe Char)
206 | Other (Maybe Char)
@@ -211,25 +213,34 @@ whatIsNext (Source sourceLines) row col =
211 Other Nothing
213 Other Nothing
213 Just line ->
215 Just line ->
215− chars = drop (fromIntegral col - 1) line
216+ case drop (fromIntegral col - 1) line of
216− keywords = map Name.toChars (Set.toList reservedWords)
217+ [] ->
217− in
218+ Other Nothing
218− case List.find (startsWithKeyword chars) keywords of
219+
219− Just keyword ->
220+ c:cs
220− Keyword keyword
221+ | Char.isUpper c -> Upper c (takeWhile isInner cs)
221−
222+ | Char.isLower c -> detectKeywords c cs
228− | isSymbol c -> Operator (c : takeWhile isSymbol cs)
223+ | isSymbol c -> Operator (c : takeWhile isSymbol cs)
229− | c == ')' -> Close "parenthesis" ')'
224+ | c == ')' -> Close "parenthesis" ')'
230− | c == ']' -> Close "square bracket" ']'
225+ | c == ']' -> Close "square bracket" ']'
231− | c == '}' -> Close "curly brace" '}'
226+ | c == '}' -> Close "curly brace" '}'
232− | otherwise -> Other (Just c)
227+ | otherwise -> Other (Just c)
230+detectKeywords :: Char -> [Char] -> Next
231+detectKeywords c rest =
233+ cs = takeWhile isInner rest
236+ if Set.member (Name.fromChars name) reservedWords
241+isInner :: Char -> Bool
243+ Char.isAlphaNum char || char == '_'
235isSymbol :: Char -> Bool
246isSymbol :: Char -> Bool
@@ -246,7 +257,7 @@ startsWithKeyword restOfLine keyword =
249− not (Char.isAlphaNum c || c == '_')
260+ not (isInner c)
252nextLineStartsWithKeyword :: [Char] -> Source -> Row -> Maybe (Row, Col)
263nextLineStartsWithKeyword :: [Char] -> Source -> Row -> Maybe (Row, Col)