packages feed

unicode-data-security-0.3.0: lib/Unicode/Internal/Char/Security/IdentifierStatus.hs

-- autogenerated from https://www.unicode.org/Public/15.0.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 c = c >= '\x0027' && c <= '\x323AF' && lookupIsAllowedInIdentifierBitMap (ord c)

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

isAllowedInIdentifierDataBitMap :: Ptr Int8
isAllowedInIdentifierDataBitMap = Ptr
    "\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\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\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\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\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\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\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\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\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\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\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\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\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\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\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\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\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\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\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\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\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\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
    "\228\2\13\7\228\2\228\2\22\0\86\2\86\2\9\5\86\2\86\2\188\1\86\2\86\2\34\1\86\2\86\2\86\2\228\1\34\1\86\2\86\2\86\2\252\0\224\2\228\2\228\2\228\2\112\6\224\2\228\2\228\2\228\2\0\0\229\3\86\2\86\2\86\2\114\4\183\7\229\3\86\2\86\2\86\2\16\6\86\2\58\4\86\2\228\2\228\2\228\2\
    \\228\2\152\6\81\5\143\1\228\2\228\2\228\2\228\2\236\2\228\2\86\2\9\5\86\2\86\2\86\2\86\2\83\1\86\2\188\1\86\2\86\2\86\2\228\1\228\2\13\7\228\2\228\2\228\2\80\6\40\3\103\3\202\4\83\0\205\6\167\3\119\7\145\5\220\0\36\2\86\2\250\3\138\0\86\2\86\2\156\0"#

isAllowedInIdentifierOffsets2BitMap :: Ptr Word8
isAllowedInIdentifierOffsets2BitMap = Ptr
    "\79\83\87\35\33\41\45\47\47\56\47\47\47\47\47\47\47\47\47\47\63\52\47\47\47\47\48\62\62\62\62\6\62\62\9\62\62\62\62\62\62\62\62\62\62\14\62\62\62\62\
    \\62\62\62\62\13\62\62\62\62\19\91\62\62\62\47\47\47\47\47\47\47\47\47\47\47\47\47\47\47\47\47\47\47\47\75\47\24\23\47\29\47\47\47\3\62\62\47\47\0\47\
    \\75"#