aboutsummaryrefslogtreecommitdiff
path: root/frontend/utilities.icl
diff options
context:
space:
mode:
authorronny2001-07-18 11:22:43 +0000
committerronny2001-07-18 11:22:43 +0000
commit2d637512067926a9217e281041ba7eb3fec1bd52 (patch)
tree8f8c7281a7f884403e9fbec47c5f38bf90d69ee1 /frontend/utilities.icl
parentwork around for caching / attribute heap bug (diff)
assorted scanner/parser bug fixes by Pieter (tested by Ronny)
(bug_incomplete_instance_def, bug_layout_rule, bug_nested_guard_in_otherwise, parse-bug-18, parse_bug_Real_as_class_name, parse_bug_case, parse_bug_constructor_with_name_of_basic_type, parse_bug_lost_brackets_in_pattern, parse_bug_no_layout_rule) git-svn-id: https://svn.cs.ru.nl/repos/clean-compiler/trunk@550 1f8540f1-abd5-4d5b-9d24-4c5ce8603e2d
Diffstat (limited to 'frontend/utilities.icl')
-rw-r--r--frontend/utilities.icl31
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