on master help sign in
javascript: filter all nonascii letters from identifiers
commitfe570cb310bb2ca22811afef43d9fb0d70f1766c authorraichoo <raichoo@googlemail.com> dateMon 4 Feb 2013, 19:02 (14 years ago) parent2407cbb
1 file changed+1−28
src/IRTS/CodegenJavaScript.hs+1−28
src/IRTS/CodegenJavaScript.hs+1−28
@@ -53,36 +53,9 @@ translateIdentifier :: String -> String
5353translateIdentifier =
5454 replaceReserved . concatMap replaceBadChars
5555 where replaceBadChars :: Char -> String
56− replaceBadChars ' ' = "_"
57− replaceBadChars '_' = "__"
58− replaceBadChars '@' = "_at"
59− replaceBadChars '[' = "_OSB"
60− replaceBadChars ']' = "_CSB"
61− replaceBadChars '(' = "_OP"
62− replaceBadChars ')' = "_CP"
63− replaceBadChars '{' = "_OB"
64− replaceBadChars '}' = "_CB"
65− replaceBadChars '!' = "_bang"
66− replaceBadChars '#' = "_hash"
67− replaceBadChars '.' = "_dot"
68− replaceBadChars ',' = "_comma"
69− replaceBadChars ':' = "_colon"
70− replaceBadChars '+' = "_plus"
71− replaceBadChars '-' = "_minus"
72− replaceBadChars '*' = "_times"
73− replaceBadChars '<' = "_lt"
74− replaceBadChars '>' = "_gt"
75− replaceBadChars '=' = "_eq"
76− replaceBadChars '|' = "_pipe"
77− replaceBadChars '&' = "_amp"
78− replaceBadChars '/' = "_SL"
79− replaceBadChars '\\' = "_BSL"
80− replaceBadChars '%' = "_per"
81− replaceBadChars '?' = "_que"
82− replaceBadChars '~' = "_til"
83− replaceBadChars '\'' = "_apo"
8456 replaceBadChars c
8557 | isDigit c = "_" ++ [c] ++ "_"
58+ | not (isLetter c && isAscii c) = '_' : show (ord c)
8659 | otherwise = [c]
8760 replaceReserved s
8861 | s `elem` reserved = '_' : s