@@ -69,12 +69,13 @@ module Language.PureScript.Parser.Lexer
6969 , reservedPsNames
7070 , reservedTypeNames
7171 , isSymbolChar
72+ , isUnquotedKey
7273 )
7374 where
7475
7576import Prelude hiding (lex)
7677
77−import Data.Char (isSpace, isAscii, isSymbol)
78+import Data.Char (isSpace, isAscii, isSymbol, isAlphaNum)
7879
7980import Control.Monad (void, guard)
8081import Data.Functor.Identity
@@ -534,3 +535,24 @@ reservedTypeNames = [ "forall", "where" ]
534535--
535536isSymbolChar :: Char -> Bool
536537isSymbolChar c = (c `elem` ":!#$%&*+./<=>?@\\^|-~") || (not (isAscii c) && isSymbol c)
538+
539+
540+-- |
541+-- The characters allowed in the head of an unquoted record key
542+--
543+isUnquotedKeyHeadChar :: Char -> Bool
544+isUnquotedKeyHeadChar c = (c == '_') || isAlphaNum c
545+
546+-- |
547+-- The characters allowed in the tail of an unquoted record key
548+--
549+isUnquotedKeyTailChar :: Char -> Bool
550+isUnquotedKeyTailChar c = (c `elem` "_'") || isAlphaNum c
551+
552+-- |
553+-- Strings allowed to be left unquoted in a record key
554+--
555+isUnquotedKey :: String -> Bool
556+isUnquotedKey [] = False
557+isUnquotedKey (hd : tl) = isUnquotedKeyHeadChar hd &&
558+ all isUnquotedKeyTailChar tl