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