mirror of
https://github.com/GrammaticalFramework/gf-rgl.git
synced 2026-05-27 08:58:55 -06:00
add morphodict into Setup.hs
This commit is contained in:
@@ -25,6 +25,7 @@ data LangInfo = LangInfo
|
|||||||
, langSymbolic :: Bool
|
, langSymbolic :: Bool
|
||||||
, langCompatibility :: Bool
|
, langCompatibility :: Bool
|
||||||
, langSynopsis :: Bool -- ^ include in RGL synopsis
|
, langSynopsis :: Bool -- ^ include in RGL synopsis
|
||||||
|
, langMorphodict :: Bool
|
||||||
} deriving (Show,Eq)
|
} deriving (Show,Eq)
|
||||||
|
|
||||||
-- | Load language information from default config file
|
-- | Load language information from default config file
|
||||||
@@ -55,6 +56,7 @@ loadLangsFrom configFile = do
|
|||||||
, langSymbolic = boolBit bits 8 True
|
, langSymbolic = boolBit bits 8 True
|
||||||
, langCompatibility = boolBit bits 9 False
|
, langCompatibility = boolBit bits 9 False
|
||||||
, langSynopsis = boolBit bits 10 False
|
, langSynopsis = boolBit bits 10 False
|
||||||
|
, langMorphodict = boolBit bits 11 False
|
||||||
}
|
}
|
||||||
|
|
||||||
-- | Separate a string on a character
|
-- | Separate a string on a character
|
||||||
|
|||||||
26
Setup.hs
26
Setup.hs
@@ -1,4 +1,4 @@
|
|||||||
{-# LANGUAGE CPP #-}
|
{-# LANGUAGE CPP, LambdaCase #-}
|
||||||
|
|
||||||
-- | Main build script for RGL
|
-- | Main build script for RGL
|
||||||
|
|
||||||
@@ -150,11 +150,12 @@ getRGLBuildSubDir mode =
|
|||||||
case mode of
|
case mode of
|
||||||
Present -> "present"
|
Present -> "present"
|
||||||
AllTenses -> "alltenses"
|
AllTenses -> "alltenses"
|
||||||
|
MorphoDict -> "morphodict"
|
||||||
|
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
-- Build modes
|
-- Build modes
|
||||||
|
|
||||||
data Mode = Present | AllTenses
|
data Mode = Present | AllTenses | MorphoDict
|
||||||
deriving (Show,Eq)
|
deriving (Show,Eq)
|
||||||
|
|
||||||
all_modes :: [String]
|
all_modes :: [String]
|
||||||
@@ -187,6 +188,7 @@ rglCommands =
|
|||||||
, RGLCommand "lang" False $ gfcp [l,s]
|
, RGLCommand "lang" False $ gfcp [l,s]
|
||||||
, RGLCommand "api" False $ gfcp [t,sc]
|
, RGLCommand "api" False $ gfcp [t,sc]
|
||||||
, RGLCommand "compat" False $ gfcp [c]
|
, RGLCommand "compat" False $ gfcp [c]
|
||||||
|
, RGLCommand "morphodict" False $ gfcp [m]
|
||||||
|
|
||||||
-- Special command, invoked when command ends in .gf
|
-- Special command, invoked when command ends in .gf
|
||||||
, RGLCommand "modules" False $ \modes args bi -> do
|
, RGLCommand "modules" False $ \modes args bi -> do
|
||||||
@@ -223,14 +225,20 @@ rglCommands =
|
|||||||
s mode args = (symbol,optml mode langTry args)
|
s mode args = (symbol,optml mode langTry args)
|
||||||
c mode args = (compat,optml AllTenses langCompatibility args)
|
c mode args = (compat,optml AllTenses langCompatibility args)
|
||||||
t mode args = (try,optml mode langTry 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)
|
sc mode args = (symbolic,optml mode langSymbolic args)
|
||||||
|
|
||||||
optml :: Mode -> (LangInfo -> Bool) -> [String] -> ([LangInfo] -> [LangInfo])
|
optml :: Mode -> (LangInfo -> Bool) -> [String] -> ([LangInfo] -> [LangInfo])
|
||||||
optml mode pred args =
|
optml mode pred args =
|
||||||
\langsAll ->
|
\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
|
in getOptLangs langsAll langsDefault args
|
||||||
|
|
||||||
|
mode2langinfo = \case
|
||||||
|
Present -> langPresent
|
||||||
|
MorphoDict -> langMorphodict
|
||||||
|
_ -> const True
|
||||||
|
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
-- Getting module paths/names
|
-- Getting module paths/names
|
||||||
|
|
||||||
@@ -260,6 +268,9 @@ syntax l = sourceDir </> "api" </> ("Syntax" ++ langCode l ++ ".gf")
|
|||||||
symbolic :: LangInfo -> FilePath
|
symbolic :: LangInfo -> FilePath
|
||||||
symbolic l = sourceDir </> "api" </> ("Symbolic" ++ langCode l ++ ".gf")
|
symbolic l = sourceDir </> "api" </> ("Symbolic" ++ langCode l ++ ".gf")
|
||||||
|
|
||||||
|
morphodict :: LangInfo -> FilePath
|
||||||
|
morphodict l = sourceDir </> "morphodict" </> ("MorphoDict" ++ langCode l ++ ".gf")
|
||||||
|
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
-- Argument helpers
|
-- Argument helpers
|
||||||
|
|
||||||
@@ -302,8 +313,9 @@ getOptMode args =
|
|||||||
else explicit_modes
|
else explicit_modes
|
||||||
where
|
where
|
||||||
explicit_modes =
|
explicit_modes =
|
||||||
[Present|have "present"]++
|
[Present | have "present"] ++
|
||||||
[AllTenses|have "alltenses"]
|
[AllTenses | have "alltenses"] ++
|
||||||
|
[MorphoDict | have "morphodict"]
|
||||||
have mode = mode `elem` args
|
have mode = mode `elem` args
|
||||||
|
|
||||||
-- | List of languages overriding the default definitions
|
-- | List of languages overriding the default definitions
|
||||||
@@ -366,8 +378,8 @@ gfcn :: Info -> Mode -> String -> [FilePath] -> IO ()
|
|||||||
gfcn bi mode summary files = do
|
gfcn bi mode summary files = do
|
||||||
let dir = getRGLBuildDir bi mode
|
let dir = getRGLBuildDir bi mode
|
||||||
preproc = case mode of
|
preproc = case mode of
|
||||||
Present -> "--preproc=mkPresent"
|
Present -> "--preproc=mkPresent"
|
||||||
AllTenses -> ""
|
_ -> ""
|
||||||
createDirectoryIfMissing True dir
|
createDirectoryIfMissing True dir
|
||||||
if length files > 0
|
if length files > 0
|
||||||
then do
|
then do
|
||||||
|
|||||||
Reference in New Issue
Block a user