git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Fix escaping for operator name props in externs
commit2c8abc3c54875d6d63114202ba8eb314da34b92e authorGary Burgess <gary.burgess@gmail.com> dateThu 1 May 2014, 21:58 (13 years ago) parent5183422
2 files changed+10−3
src/Language/PureScript/Parser/Common.hs+8−2 src/Language/PureScript/Pretty/Common.hs+2−1
src/Language/PureScript/Parser/Common.hs+8−2
@@ -53,6 +53,12 @@ reservedPsNames = [ "data"
5353 , "where"
5454 ]
5555
56+-- |
57+-- The characters allowed for use in operators
58+--
59+opChars :: [Char]
60+opChars = ":!#$%&*+./<=>?@\\^|-~"
61+
5662-- |
5763-- A list of reserved identifiers for types
5864--
@@ -82,13 +88,13 @@ identLetter = P.alphaNum <|> P.oneOf "_'"
8288-- Valid first characters for an operator
8389--
8490opStart :: P.Parsec String u Char
85−opStart = P.oneOf ":!#$%&*+./<=>?@\\^|-~"
91+opStart = P.oneOf opChars
8692
8793-- |
8894-- Valid operators characters
8995--
9096opLetter :: P.Parsec String u Char
91−opLetter = P.oneOf ":!#$%&*+./<=>?@\\^|-~"
97+opLetter = P.oneOf opChars
9298
9399-- |
94100-- The PureScript language definition
src/Language/PureScript/Pretty/Common.hs+2−1
@@ -17,7 +17,7 @@ module Language.PureScript.Pretty.Common where
1717
1818import Control.Monad.State
1919import Data.List (intercalate)
20−import Language.PureScript.Parser.Common (reservedPsNames)
20+import Language.PureScript.Parser.Common (reservedPsNames, opChars)
2121
2222-- |
2323-- Wrap a string in parentheses
@@ -65,4 +65,5 @@ prettyPrintMany f xs = do
6565--
6666prettyPrintObjectKey :: String -> String
6767prettyPrintObjectKey s | s `elem` reservedPsNames = show s
68+ | head s `elem` opChars = show s
6869 | otherwise = s