diff options
-rw-r--r-- | frontend/typesupport.dcl | 4 | ||||
-rw-r--r-- | frontend/typesupport.icl | 33 |
2 files changed, 36 insertions, 1 deletions
diff --git a/frontend/typesupport.dcl b/frontend/typesupport.dcl index 3bdf7ab..0b3c4d1 100644 --- a/frontend/typesupport.dcl +++ b/frontend/typesupport.dcl @@ -86,7 +86,9 @@ addAttrEnvInequalities :: ![AttrInequality] !*Coercions !u:AttrVarHeap -> (!.Coercions, !u:AttrVarHeap) // assertion: the attribute variables point to (AVI_Attr (TA_TempVar nr)) where // nr corresponds to the attribute variable - +optBeautifulizeIdent :: !String -> Optional (!String, !LineNr) + // convert something like "c;8;2" to Yes ("comprehension", 8) + //accCoercionTree :: !.(u:CoercionTree -> (.a,u:CoercionTree)) !Int !*{!u:CoercionTree} -> (!.a,!{!u:CoercionTree}) accCoercionTree f i coercion_trees :== acc_coercion_tree i coercion_trees diff --git a/frontend/typesupport.icl b/frontend/typesupport.icl index 11bd794..b9ee9b9 100644 --- a/frontend/typesupport.icl +++ b/frontend/typesupport.icl @@ -1492,3 +1492,36 @@ addAttrEnvInequalities st_attr_env coercions th_attrs # (AVI_Attr (TA_TempVar offered), th_attrs) = readPtr ai_offered.av_info_ptr th_attrs (AVI_Attr (TA_TempVar demanded), th_attrs) = readPtr ai_demanded.av_info_ptr th_attrs = (newInequality offered demanded coercions, th_attrs) + +optBeautifulizeIdent :: !String -> Optional (!String, !LineNr) +optBeautifulizeIdent id_name + # fst_semicolon_index = searchlArrElt ((==) ';') id_name 0 + | fst_semicolon_index < size id_name + # snd_semicolon_index = searchlArrElt ((==) ';') id_name (fst_semicolon_index+1) + prefix = id_name % (0, fst_semicolon_index-1) + line = toInt (id_name % (fst_semicolon_index+1, snd_semicolon_index-1)) + = Yes (prefix_to_readable_name prefix, line) + = No + where + prefix_to_readable_name "_c" = "case" + prefix_to_readable_name "_g" = "guard" + prefix_to_readable_name "_f" = "filter" + prefix_to_readable_name "\\" = "lambda" + prefix_to_readable_name prefix + | prefix.[0] == 'c' + = "comprehension" + | prefix.[0] == 'g' + = "generator" + prefix_to_readable_name _ = abort "fatal error 21 in type.icl" + +// search for an element in an array +searchlArrElt p s i + :== searchl s i + where + searchl s i + | i>=size s + = i + | p s.[i] + = i + = searchl s (i+1) +// ..MW4 |