git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Fix escaping for operator name props in externs
2c8abc3Gary Burgess
src/Language/PureScript/Parser/Common.hs+8−2
@@ -53,6 +53,12 @@ reservedPsNames = [ "data"
53 , "where"
53 , "where"
54 ]
54 ]
55
55
56+-- |
57+-- The characters allowed for use in operators
58+--
59+opChars :: [Char]
60+opChars = ":!#$%&*+./<=>?@\\^|-~"
61+
56-- |
62-- |
57-- A list of reserved identifiers for types
63-- A list of reserved identifiers for types
58--
64--
@@ -82,13 +88,13 @@ identLetter = P.alphaNum <|> P.oneOf "_'"
82-- Valid first characters for an operator
88-- Valid first characters for an operator
83--
89--
84opStart :: P.Parsec String u Char
90opStart :: P.Parsec String u Char
85−opStart = P.oneOf ":!#$%&*+./<=>?@\\^|-~"
91+opStart = P.oneOf opChars
86
92
87-- |
93-- |
88-- Valid operators characters
94-- Valid operators characters
89--
95--
90opLetter :: P.Parsec String u Char
96opLetter :: P.Parsec String u Char
91−opLetter = P.oneOf ":!#$%&*+./<=>?@\\^|-~"
97+opLetter = P.oneOf opChars
92
98
93-- |
99-- |
94-- The PureScript language definition
100-- The PureScript language definition
src/Language/PureScript/Pretty/Common.hs+2−1
@@ -17,7 +17,7 @@ module Language.PureScript.Pretty.Common where
17
17
18import Control.Monad.State
18import Control.Monad.State
19import Data.List (intercalate)
19import Data.List (intercalate)
20−import Language.PureScript.Parser.Common (reservedPsNames)
20+import Language.PureScript.Parser.Common (reservedPsNames, opChars)
21
21
22-- |
22-- |
23-- Wrap a string in parentheses
23-- Wrap a string in parentheses
@@ -65,4 +65,5 @@ prettyPrintMany f xs = do
65--
65--
66prettyPrintObjectKey :: String -> String
66prettyPrintObjectKey :: String -> String
67prettyPrintObjectKey s | s `elem` reservedPsNames = show s
67prettyPrintObjectKey s | s `elem` reservedPsNames = show s
68+ | head s `elem` opChars = show s
68 | otherwise = s
69 | otherwise = s