on master help sign in
javascript: special handling for space and underscore in identifiers
d02610araichoo
src/IRTS/CodegenJavaScript.hs+2
@@ -54,6 +54,8 @@ translateIdentifier =
54 replaceReserved . concatMap replaceBadChars
54 replaceReserved . concatMap replaceBadChars
55 where replaceBadChars :: Char -> String
55 where replaceBadChars :: Char -> String
56 replaceBadChars c
56 replaceBadChars c
57+ | ' ' <- c = "_"
58+ | '_' <- c = "__"
57 | isDigit c = "_" ++ [c] ++ "_"
59 | isDigit c = "_" ++ [c] ++ "_"
58 | not (isLetter c && isAscii c) = '_' : show (ord c)
60 | not (isLetter c && isAscii c) = '_' : show (ord c)
59 | otherwise = [c]
61 | otherwise = [c]