{-# LANGUAGE CPP #-}
module GHC.Internal.Lexeme (
startsVarSym, startsVarId, startsConSym, startsConId,
startsVarSymASCII, isVarSymChar, okSymChar
) where
#ifdef BOOTSTRAP_TH
import Prelude
import Data.Char
#else
import GHC.Internal.Base
import GHC.Internal.Unicode
import GHC.Internal.List (elem)
#endif
okSymChar :: Char -> Bool
okSymChar :: Char -> Bool
okSymChar Char
c
| Char
c Char -> [Char] -> Bool
forall a. Eq a => a -> [a] -> Bool
`elem` [Char]
"(),;[]`{}_\"'"
= 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 Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
/= Char
':'
startsConSym :: Char -> Bool
startsConSym Char
c = Char
c Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
== Char
':'
startsVarId :: Char -> Bool
startsVarId Char
c = Char
c Char -> Char -> Bool
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 Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
== Char
'('
startsVarSymASCII :: Char -> Bool
startsVarSymASCII :: Char -> Bool
startsVarSymASCII Char
c = Char
c Char -> [Char] -> Bool
forall a. Eq a => a -> [a] -> Bool
`elem` [Char]
"!#$%&*+./<=>?@\\^|~-"
isVarSymChar :: Char -> Bool
isVarSymChar :: Char -> Bool
isVarSymChar Char
c = Char
c Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
== Char
':' Bool -> Bool -> Bool
|| Char -> Bool
startsVarSym Char
c