make identifier parsing a little more faithful

This commit is contained in:
Rhiannon Morris 2020-07-15 11:33:12 +02:00
parent acc476d8a3
commit cf999d19b6

View file

@ -98,11 +98,13 @@ chunks = reverse . go "" [] . trimEnd where
go acc cs (c :. rest) = go (acc <> singleton c) cs rest
splitVar s
| (var, s') <- Text.span isAlphaNum s,
| (var, s') <- Text.span isIdChar s,
isLower (Text.head var)
= (var, s')
splitVar _ = error "invalid variable name"
isIdChar c = isAlphaNum c || c `elem` ['_', '\'']
lit s = (Lit, toStrictText s)
trimEnd = Text.dropWhileEnd isSpace