javascript: special handling for space and underscore in identifiers
commitd02610a9080061eead5753a5d8ff4da2beedbeb3
authorraichoo <raichoo@googlemail.com>
dateMon 4 Feb 2013, 19:15 (14 years ago)
parentfe570cb
src/IRTS/CodegenJavaScript.hs+2
@@ -54,6 +54,8 @@ translateIdentifier =
5454 replaceReserved . concatMap replaceBadChars
5555 where replaceBadChars :: Char -> String
5656 replaceBadChars c
57+ | ' ' <- c = "_"
58+ | '_' <- c = "__"
5759 | isDigit c = "_" ++ [c] ++ "_"
5860 | not (isLetter c && isAscii c) = '_' : show (ord c)
5961 | otherwise = [c]