diff options
Diffstat (limited to 'frontend/utilities.icl')
-rw-r--r-- | frontend/utilities.icl | 31 |
1 files changed, 21 insertions, 10 deletions
diff --git a/frontend/utilities.icl b/frontend/utilities.icl index 50dd8d2..15d1a90 100644 --- a/frontend/utilities.icl +++ b/frontend/utilities.icl @@ -38,17 +38,28 @@ revCharListToString [hd:tl] = revCharListToString tl +++ toString hd revCharListToString [] = "" */ -isUpperCaseName :: ! String -> Bool -isUpperCaseName id - = ('A' <= c && c <= 'Z') || c == '_' - where - c =: id.[0] - -isLowerCaseName :: ! String -> Bool -isLowerCaseName id +NoUnderscores :== False +UnderscoresAllowed :== True + +skipUnderscores :: !Int !Int !String -> Char +skipUnderscores i size s + | i < size + #! c = s.[i] + | c == '_' + = skipUnderscores (i+1) size s + = c + // otherwise: i >= size + = '_' + +isUpperCaseName :: ! String !Bool -> Bool +isUpperCaseName id underscoresAllowed + #! c = if underscoresAllowed (skipUnderscores 0 (size id) id) (id.[0]) + = 'A' <= c && c <= 'Z' + +isLowerCaseName :: ! String !Bool -> Bool +isLowerCaseName id underscoresAllowed + #! c = if underscoresAllowed (skipUnderscores 0 (size id) id) (id.[0]) = 'a' <= c && c <= 'z' - where - c =: id.[0] isFunnyIdName :: ! String -> Bool isFunnyIdName id |