module GHC.Lexeme (
startsVarSym, startsVarId, startsConSym, startsConId,
startsVarSymASCII, isVarSymChar, okSymChar
) where
import Prelude
import Data.Char
okSymChar :: Char -> Bool
okSymChar :: Char -> Bool
okSymChar Char
c
| Char
c forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
`elem` String
"(),;[]`{}_\"'"
= Bool
False
| Bool
otherwise
= case Char -> GeneralCategory
generalCategory Char
c of
GeneralCategory
ConnectorPunctuation -> Bool
True
GeneralCategory
DashPunctuation -> Bool
True
GeneralCategory
OtherPunctuation -> Bool
True
GeneralCategory
MathSymbol -> Bool
True
GeneralCategory
CurrencySymbol -> Bool
True
GeneralCategory
ModifierSymbol -> Bool
True
GeneralCategory
OtherSymbol -> Bool
True
GeneralCategory
_ -> Bool
False
startsVarSym, startsVarId, startsConSym, startsConId :: Char -> Bool
startsVarSym :: Char -> Bool
startsVarSym Char
c = Char -> Bool
okSymChar Char
c Bool -> Bool -> Bool
&& Char
c forall a. Eq a => a -> a -> Bool
/= Char
':'
startsConSym :: Char -> Bool
startsConSym Char
c = Char
c forall a. Eq a => a -> a -> Bool
== Char
':'
startsVarId :: Char -> Bool
startsVarId Char
c = Char
c forall a. Eq a => a -> a -> Bool
== Char
'_' Bool -> Bool -> Bool
|| case Char -> GeneralCategory
generalCategory Char
c of
GeneralCategory
LowercaseLetter -> Bool
True
GeneralCategory
OtherLetter -> Bool
True
GeneralCategory
_ -> Bool
False
startsConId :: Char -> Bool
startsConId Char
c = Char -> Bool
isUpper Char
c Bool -> Bool -> Bool
|| Char
c forall a. Eq a => a -> a -> Bool
== Char
'('
startsVarSymASCII :: Char -> Bool
startsVarSymASCII :: Char -> Bool
startsVarSymASCII Char
c = Char
c forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
`elem` String
"!#$%&*+./<=>?@\\^|~-"
isVarSymChar :: Char -> Bool
isVarSymChar :: Char -> Bool
isVarSymChar Char
c = Char
c forall a. Eq a => a -> a -> Bool
== Char
':' Bool -> Bool -> Bool
|| Char -> Bool
startsVarSym Char
c