-- autogenerated from https://www.unicode.org/Public/15.1.0/ucd/IdentifierStatus.txt
-- |
-- Module      : Unicode.Internal.Char.Security.IdentifierStatus
-- Copyright   : (c) 2022 Composewell Technologies and Contributors
-- License     : Apache-2.0
-- Maintainer  : streamly@composewell.com
-- Stability   : experimental

{-# OPTIONS_HADDOCK hide #-}

module Unicode.Internal.Char.Security.IdentifierStatus
(isAllowedInIdentifier)
where

import Data.Bits (Bits(..))
import Data.Char (ord)
import Data.Int (Int8)
import Data.Word (Word16, Word8)
import GHC.Exts (Ptr(..))
import Unicode.Internal.Bits (lookupBit, lookupWord16AsInt, lookupWord8AsInt)

{-# INLINE isAllowedInIdentifier #-}
isAllowedInIdentifier :: Char -> Bool
isAllowedInIdentifier :: Char -> Bool
isAllowedInIdentifier Char
c = Char
c Char -> Char -> Bool
forall a. Ord a => a -> a -> Bool
>= Char
'\x0027' Bool -> Bool -> Bool
&& Char
c Char -> Char -> Bool
forall a. Ord a => a -> a -> Bool
<= Char
'\x323AF' Bool -> Bool -> Bool
&& Int -> Bool
lookupIsAllowedInIdentifierBitMap (Char -> Int
ord Char
c)

{-# INLINE lookupIsAllowedInIdentifierBitMap #-}
lookupIsAllowedInIdentifierBitMap :: Int -> Bool
lookupIsAllowedInIdentifierBitMap :: Int -> Bool
lookupIsAllowedInIdentifierBitMap Int
n =
    Addr# -> Int -> Int -> Bool
lookupBit Addr#
data# (
        Addr# -> Int -> Int
lookupWord16AsInt Addr#
offsets1# (
            Addr# -> Int -> Int
lookupWord8AsInt Addr#
offsets2# (
                Int
n Int -> Int -> Int
forall a. Bits a => a -> Int -> a
`shiftR` Int
11
            ) Int -> Int -> Int
forall a. Num a => a -> a -> a
+ ((Int
n Int -> Int -> Int
forall a. Bits a => a -> Int -> a
`shiftR` Int
9) Int -> Int -> Int
forall a. Bits a => a -> a -> a
.&. Int
maskOffsets)
        ) Int -> Int -> Int
forall a. Num a => a -> a -> a
+ ((Int
n Int -> Int -> Int
forall a. Bits a => a -> Int -> a
`shiftR` Int
3) Int -> Int -> Int
forall a. Bits a => a -> a -> a
.&. Int
maskData)
    ) (Int
n Int -> Int -> Int
forall a. Bits a => a -> a -> a
.&. Int
7)
    where
    maskData :: Int
maskData = (Int
1 Int -> Int -> Int
forall a. Bits a => a -> Int -> a
`shiftL` Int
6) Int -> Int -> Int
forall a. Num a => a -> a -> a
- Int
1
    maskOffsets :: Int
maskOffsets = (Int
1 Int -> Int -> Int
forall a. Bits a => a -> Int -> a
`shiftL` Int
2) Int -> Int -> Int
forall a. Num a => a -> a -> a
- Int
1
    !(Ptr Addr#
data#) = Ptr Int8
isAllowedInIdentifierDataBitMap
    !(Ptr Addr#
offsets1#) = Ptr Word16
isAllowedInIdentifierOffsets1BitMap
    !(Ptr Addr#
offsets2#) = Ptr Word8
isAllowedInIdentifierOffsets2BitMap

isAllowedInIdentifierDataBitMap :: Ptr Int8
isAllowedInIdentifierDataBitMap :: Ptr Int8
isAllowedInIdentifierDataBitMap = Addr# -> Ptr Int8
forall a. Addr# -> Ptr a
Ptr
    Addr#
"\238\135\249\255\255\253\37\211\135\57\0\16\192\255\31\0\238\191\251\255\255\253\237\243\191\59\1\0\207\255\0\252\238\159\249\255\255\253\237\243\143\57\224\128\195\255\2\0\236\199\
    \\61\214\24\199\255\195\199\61\129\0\192\255\0\0\1\2\128\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\
    \\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\255\255\255\255\231\254\207\255\255\63\133\16\255\3\0\0\0\0\255\
    \\255\255\255\254\255\63\0\255\3\23\254\255\191\255\255\253\255\255\255\255\255\47\0\96\192\255\255\0\0\0\0\0\0\0\0\0\0\255\255\255\255\255\255\255\255\255\255\255\255\3\
    \\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\128\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\
    \\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\127\111\255\127\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\
    \\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\7\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\
    \\255\255\0\0\0\0\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\3\255\255\255\255\
    \\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\15\0\
    \\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\128\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\
    \\0\0\0\0\0\0\0\0\0\0\0\0\0\255\255\255\127\224\7\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\
    \\0\0\0\0\0\128\32\0\0\0\0\0\0\0\0\0\0\255\255\127\0\127\127\127\127\127\127\127\127\0\0\0\0\128\96\255\7\254\255\255\135\254\255\255\7\0\0\0\0\0\
    \\0\128\0\255\255\127\255\255\255\127\255\255\255\255\255\255\255\243\127\254\253\255\255\255\255\255\127\0\128\0\0\3\128\1\0\0\224\255\223\207\255\49\255\255\255\255\255\255\255\255\
    \\255\255\255\255\0\0\0\0\0\252\255\255\255\255\255\255\255\255\255\255\255\255\255\255\0\0\255\255\255\195\254\255\255\255\127\2\254\255\255\255\127\4\0\0\0\0\16\0\0\0\
    \\255\255\255\135\31\0\255\255\255\63\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\
    \\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\0\0\0\0\0\0\0\0\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\
    \\255\255\3\0\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\
    \\255\255\255\255\255\255\255\255\255\255\255\255\255\255\1\0\255\255\255\207\192\255\15\0\0\0\0\2\0\0\0\0\0\0\0\0\0\0\0\24\0\0\0\0\0\16\0\0\223\159\
    \\27\8\248\97\35\3\36\0\0\0\0\0\32\56\64\215\255\255\251\255\255\255\255\127\0\0\0\0\0\240\224\0\0\0\0\0\0\0\254\255\255\255\255\255\255\255\255\255\127\102\
    \\255\255\255\255\255\255\255\255\255\255\255\127\224\255\255\255\255\191\0\0\0\0\0\0\0\0\0\0\0\0\0\0\255\255\255\255\0\0\0\0\0\0\0\0\0\0\0\0\0\0\
    \\0\0\0\0\255\255\255\255\255\231\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\
    \\0\0\0\0\0\0\0\0\255\255\255\255\231\254\207\255\255\63\133\16\255\3\0\0\254\223\253\255\255\253\239\243\223\61\96\32\195\255\0\0\237\223\253\255\255\253\239\243\223\61\
    \\96\32\207\255\14\0\237\223\253\255\255\255\255\231\207\125\240\0\195\255\0\252\236\127\126\252\191\255\251\47\127\132\95\127\0\0\4\0\192\26\128\154\3\0\0\0\0\0\0\0\
    \\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\
    \\0\10\0\0\0\0\0\0\24\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\
    \\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\128\255\255\127\255\255\255\255\255\255\255\255\255\3\255\255\255\255\255\255\255\255\255\63\0\0\0\0\128\32\255\
    \\255\255\255\129\231\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\255\255\255\127\224\7\0\0\0\0\0\0\0\
    \\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\128\7\0\4\0\0\0\39\0\240\0\0\0\0\0\0\0\0\0\0\0\0\
    \\0\0\0\0\0\0\0\128\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\128\255\0\0\0\0\0\0\0\0\0\0\0\0\0\33\12\0\0\4\0\0\255\7\
    \\235\3\0\0\0\0\255\255\255\255\255\255\255\255\255\255\255\63\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\
    \\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\10\0\0\0\0\0\0\24\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\
    \\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\3\0\254\255\255\255\255\255\247\7\
    \\255\127\255\3\0\0\0\0\214\247\255\255\175\255\247\63\95\127\255\195\0\0\0\0\1\8\0\0\255\3\160\192\247\222\123\239\255\29\22\252\221\255\247\222\123\239\255\29\64\0\
    \\0\0\0\0\0\0\0\0\0\0\0\255\255\127\252\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\126\126\126\0\127\127\0\0\0\0\0\0\192\0\0\0\0\0\0\
    \\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\128\7\0\4\0\0\0\39\0\240\0\0\0\0\0\0\0\0\0\0\0\
    \\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\
    \\0\3\0\255\255\255\255\255\255\255\255\255\61\127\61\255\255\255\255\255\61\255\255\255\255\61\127\61\255\127\255\255\255\255\255\255\255\61\255\255\255\255\255\255\255\255\231\0\0\0\
    \\0\255\255\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\
    \\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\255\255\255\126\0\0\255\31\228\255\255\3\0\0\0\0\0\0\254\255\255\255\255\255\255\255\255\191\193\0\207\255\254\
    \\254\238\159\249\255\255\253\197\243\159\121\128\0\207\255\3\64\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\255\67\255\255\255\255\255\255\255\255\255\255\255\3\255\
    \\255\63\63\255\255\255\255\63\63\255\170\255\255\85\21\255\255\255\255\255\255\223\23\220\21\199\7\247\23\220\21"#

isAllowedInIdentifierOffsets1BitMap :: Ptr Word16
isAllowedInIdentifierOffsets1BitMap :: Ptr Word16
isAllowedInIdentifierOffsets1BitMap = Addr# -> Ptr Word16
forall a. Addr# -> Ptr a
Ptr
    Addr#
"\63\5\67\0\67\0\67\0\248\5\63\5\67\0\67\0\67\0\225\1\194\2\198\2\198\2\198\2\100\1\194\2\198\2\198\2\198\2\14\3\62\0\67\0\67\0\67\0\218\3\175\7\62\0\67\0\67\0\67\0\7\2\67\0\162\3\67\0\198\2\198\2\198\2\198\2\140\1\185\4\113\6\198\2\198\2\198\2\198\2\206\2\198\2\67\0\113\4\67\0\
    \\67\0\67\0\67\0\112\5\67\0\145\4\67\0\67\0\67\0\248\5\198\2\26\1\198\2\198\2\198\2\68\1\67\0\113\4\67\0\67\0\145\4\67\0\67\0\198\2\26\1\198\2\198\2\36\3\198\2\176\5\67\2\98\3\130\2\145\0\111\7\0\0\50\4\56\6\249\4\11\7\67\0\83\0\200\0\67\0\67\0\218\0"#

isAllowedInIdentifierOffsets2BitMap :: Ptr Word8
isAllowedInIdentifierOffsets2BitMap :: Ptr Word8
isAllowedInIdentifierOffsets2BitMap = Addr# -> Ptr Word8
forall a. Addr# -> Ptr a
Ptr
    Addr#
"\80\84\88\22\20\28\32\34\34\43\34\34\34\34\34\34\34\34\34\34\50\39\34\34\34\34\35\49\49\49\49\47\49\49\54\49\49\49\49\49\49\49\49\49\49\1\49\49\49\49\
    \\49\49\49\49\0\49\49\49\49\6\92\49\49\49\34\34\34\34\34\34\34\34\34\34\34\34\34\34\34\34\34\34\34\34\62\34\11\10\34\16\34\34\34\76\49\49\34\34\60\34\
    \\62"#