From b93fd7f051e0f3b9e5c23585b52cfd718ed6d56c Mon Sep 17 00:00:00 2001 From: Inari Listenmaa Date: Tue, 12 Aug 2025 15:13:19 +0200 Subject: [PATCH] add morphodict into Setup.hs --- Config.hs | 2 ++ Setup.hs | 26 +++++++++++++++++++------- 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/Config.hs b/Config.hs index b671eacb..07350748 100644 --- a/Config.hs +++ b/Config.hs @@ -25,6 +25,7 @@ data LangInfo = LangInfo , langSymbolic :: Bool , langCompatibility :: Bool , langSynopsis :: Bool -- ^ include in RGL synopsis + , langMorphodict :: Bool } deriving (Show,Eq) -- | Load language information from default config file @@ -55,6 +56,7 @@ loadLangsFrom configFile = do , langSymbolic = boolBit bits 8 True , langCompatibility = boolBit bits 9 False , langSynopsis = boolBit bits 10 False + , langMorphodict = boolBit bits 11 False } -- | Separate a string on a character diff --git a/Setup.hs b/Setup.hs index 2227ccb2..d1203b7f 100644 --- a/Setup.hs +++ b/Setup.hs @@ -1,4 +1,4 @@ -{-# LANGUAGE CPP #-} +{-# LANGUAGE CPP, LambdaCase #-} -- | Main build script for RGL @@ -150,11 +150,12 @@ getRGLBuildSubDir mode = case mode of Present -> "present" AllTenses -> "alltenses" + MorphoDict -> "morphodict" ------------------------------------------------------------------------------- -- Build modes -data Mode = Present | AllTenses +data Mode = Present | AllTenses | MorphoDict deriving (Show,Eq) all_modes :: [String] @@ -187,6 +188,7 @@ rglCommands = , RGLCommand "lang" False $ gfcp [l,s] , RGLCommand "api" False $ gfcp [t,sc] , RGLCommand "compat" False $ gfcp [c] + , RGLCommand "morphodict" False $ gfcp [m] -- Special command, invoked when command ends in .gf , RGLCommand "modules" False $ \modes args bi -> do @@ -223,14 +225,20 @@ rglCommands = s mode args = (symbol,optml mode langTry args) c mode args = (compat,optml AllTenses langCompatibility args) t mode args = (try,optml mode langTry args) + m mode args = (morphodict,optml mode langMorphodict args) sc mode args = (symbolic,optml mode langSymbolic args) optml :: Mode -> (LangInfo -> Bool) -> [String] -> ([LangInfo] -> [LangInfo]) optml mode pred args = \langsAll -> - let langsDefault = filter (if mode == Present then langPresent else const True) (filter pred langsAll) + let langsDefault = filter (mode2langinfo mode) (filter pred langsAll) in getOptLangs langsAll langsDefault args + mode2langinfo = \case + Present -> langPresent + MorphoDict -> langMorphodict + _ -> const True + ------------------------------------------------------------------------------- -- Getting module paths/names @@ -260,6 +268,9 @@ syntax l = sourceDir "api" ("Syntax" ++ langCode l ++ ".gf") symbolic :: LangInfo -> FilePath symbolic l = sourceDir "api" ("Symbolic" ++ langCode l ++ ".gf") +morphodict :: LangInfo -> FilePath +morphodict l = sourceDir "morphodict" ("MorphoDict" ++ langCode l ++ ".gf") + ------------------------------------------------------------------------------- -- Argument helpers @@ -302,8 +313,9 @@ getOptMode args = else explicit_modes where explicit_modes = - [Present|have "present"]++ - [AllTenses|have "alltenses"] + [Present | have "present"] ++ + [AllTenses | have "alltenses"] ++ + [MorphoDict | have "morphodict"] have mode = mode `elem` args -- | List of languages overriding the default definitions @@ -366,8 +378,8 @@ gfcn :: Info -> Mode -> String -> [FilePath] -> IO () gfcn bi mode summary files = do let dir = getRGLBuildDir bi mode preproc = case mode of - Present -> "--preproc=mkPresent" - AllTenses -> "" + Present -> "--preproc=mkPresent" + _ -> "" createDirectoryIfMissing True dir if length files > 0 then do