make identifier parsing a little more faithful
This commit is contained in:
parent
acc476d8a3
commit
cf999d19b6
1 changed files with 3 additions and 1 deletions
|
@ -98,11 +98,13 @@ chunks = reverse . go "" [] . trimEnd where
|
||||||
go acc cs (c :. rest) = go (acc <> singleton c) cs rest
|
go acc cs (c :. rest) = go (acc <> singleton c) cs rest
|
||||||
|
|
||||||
splitVar s
|
splitVar s
|
||||||
| (var, s') <- Text.span isAlphaNum s,
|
| (var, s') <- Text.span isIdChar s,
|
||||||
isLower (Text.head var)
|
isLower (Text.head var)
|
||||||
= (var, s')
|
= (var, s')
|
||||||
splitVar _ = error "invalid variable name"
|
splitVar _ = error "invalid variable name"
|
||||||
|
|
||||||
|
isIdChar c = isAlphaNum c || c `elem` ['_', '\'']
|
||||||
|
|
||||||
lit s = (Lit, toStrictText s)
|
lit s = (Lit, toStrictText s)
|
||||||
|
|
||||||
trimEnd = Text.dropWhileEnd isSpace
|
trimEnd = Text.dropWhileEnd isSpace
|
||||||
|
|
Loading…
Reference in a new issue