Skip to content

Commit

Permalink
Do not try being clever in case fold mapping
Browse files Browse the repository at this point in the history
  • Loading branch information
Bodigrim authored and Lysxia committed Jan 2, 2022
1 parent 81d178c commit 02ee677
Show file tree
Hide file tree
Showing 2 changed files with 1,743 additions and 518 deletions.
9 changes: 1 addition & 8 deletions scripts/CaseFolding.hs
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,12 @@ parseCF :: FilePath -> IO (Either ParseError CaseFolding)
parseCF name = parse entries name <$> readFile name

mapCF :: CaseFolding -> [String]
mapCF (CF _ ms) = typ ++ map printUnusual ms' ++ map printUsual usual ++ [last]
mapCF (CF _ ms) = typ ++ map printUnusual (filter (\f -> status f `elem` "CF") ms) ++ [last]
where
ms' = filter p ms
p f = status f `elem` "CF" &&
mapping f /= [toLower (code f)]
unusual = map code ms'
usual = filter (\c -> toLower c /= c && c `notElem` unusual) [minBound..maxBound]

typ = ["foldMapping :: Char# -> _ {- unboxed Int64 -}"
,"{-# NOINLINE foldMapping #-}"
,"foldMapping = \\case"]
last = " _ -> unI64 0"
printUnusual c = " -- " ++ name c ++ "\n" ++
" " ++ showC (code c) ++ "# -> unI64 " ++ show (ord x + (ord y `shiftL` 21) + (ord z `shiftL` 42))
where x:y:z:_ = mapping c ++ repeat '\0'
printUsual c = " " ++ showC c ++ "# -> unI64 " ++ show (ord (toLower c))
Loading

0 comments on commit 02ee677

Please sign in to comment.