@@ -69,12 +69,13 @@ module Language.PureScript.Parser.Lexer
69 , reservedPsNames
69 , reservedPsNames
70 , reservedTypeNames
70 , reservedTypeNames
71 , isSymbolChar
71 , isSymbolChar
75import Prelude hiding (lex)
76import Prelude hiding (lex)
77−import Data.Char (isSpace, isAscii, isSymbol)
78+import Data.Char (isSpace, isAscii, isSymbol, isAlphaNum)
79import Control.Monad (void, guard)
80import Control.Monad (void, guard)
80import Data.Functor.Identity
81import Data.Functor.Identity
@@ -534,3 +535,24 @@ reservedTypeNames = [ "forall", "where" ]
535isSymbolChar :: Char -> Bool
536isSymbolChar :: Char -> Bool
536isSymbolChar c = (c `elem` ":!#$%&*+./<=>?@\\^|-~") || (not (isAscii c) && isSymbol c)
537isSymbolChar c = (c `elem` ":!#$%&*+./<=>?@\\^|-~") || (not (isAscii c) && isSymbol c)
541+-- The characters allowed in the head of an unquoted record key
543+isUnquotedKeyHeadChar :: Char -> Bool
544+isUnquotedKeyHeadChar c = (c == '_') || isAlphaNum c
547+-- The characters allowed in the tail of an unquoted record key
549+isUnquotedKeyTailChar :: Char -> Bool
550+isUnquotedKeyTailChar c = (c `elem` "_'") || isAlphaNum c
553+-- Strings allowed to be left unquoted in a record key
555+isUnquotedKey :: String -> Bool
556+isUnquotedKey [] = False
557+isUnquotedKey (hd : tl) = isUnquotedKeyHeadChar hd &&
558+ all isUnquotedKeyTailChar tl