@@ -214,8 +214,9 @@ whatIsNext (Source sourceLines) row col =
214 Just line ->
214 Just line ->
216 chars = drop (fromIntegral col - 1) line
216 chars = drop (fromIntegral col - 1) line
217+ keywords = map Name.toChars (Set.toList reservedWords)
218− case List.find (\kwd -> startsWith kwd chars) (map Name.toChars (Set.toList reservedWords)) of
219+ case List.find (startsWithKeyword chars) keywords of
219 Just keyword ->
220 Just keyword ->
220 Keyword keyword
221 Keyword keyword
@@ -225,12 +226,12 @@ whatIsNext (Source sourceLines) row col =
225 Operator op
226 Operator op
228− | null chars -> Spaces
229+ | null chars -> Spaces
229− | startsWith " " chars -> Spaces
230+ | isNext ' ' chars -> Spaces
230− | startsWith ")" chars -> CloseParen
231+ | isNext ')' chars -> CloseParen
231− | startsWith "]" chars -> CloseSquare
232+ | isNext ']' chars -> CloseSquare
232− | startsWith "}" chars -> CloseCurly
233+ | isNext '}' chars -> CloseCurly
233− | otherwise -> Other
234+ | otherwise -> Other
236isSymbol :: Char -> Bool
237isSymbol :: Char -> Bool
@@ -238,6 +239,23 @@ isSymbol char =
238 IntSet.member (Char.ord char) binopCharSet
239 IntSet.member (Char.ord char) binopCharSet
241−startsWith :: [Char] -> [Char] -> Bool
242+isNext :: Char -> [Char] -> Bool
242−startsWith =
243+isNext expected chars =
252+startsWithKeyword :: [Char] -> [Char] -> Bool
253+startsWithKeyword restOfLine keyword =
243− List.isPrefixOf
254+ List.isPrefixOf keyword restOfLine
256+ case drop (length keyword) restOfLine of
261+ not (Char.isAlphaNum c || c == '_')