mirror of
https://github.com/GrammaticalFramework/gf-rgl.git
synced 2026-05-28 09:28:54 -06:00
Simplify specifying languages in Make.hs
This commit is contained in:
50
Make.hs
50
Make.hs
@@ -129,7 +129,7 @@ getRGLBuildSubDir mode =
|
|||||||
-- Build modes
|
-- Build modes
|
||||||
|
|
||||||
data Mode = AllTenses | Present
|
data Mode = AllTenses | Present
|
||||||
deriving (Show)
|
deriving (Show,Eq)
|
||||||
|
|
||||||
all_modes :: [String]
|
all_modes :: [String]
|
||||||
all_modes = ["alltenses","present"]
|
all_modes = ["alltenses","present"]
|
||||||
@@ -173,6 +173,7 @@ rglCommands =
|
|||||||
|
|
||||||
, RGLCommand "parse" False $ \modes args bi -> do
|
, RGLCommand "parse" False $ \modes args bi -> do
|
||||||
langs <- loadLangs
|
langs <- loadLangs
|
||||||
|
let langsParse = \l -> langCode l `elem` ["Eng"]
|
||||||
let mylangs = (optml AllTenses langsParse args) langs
|
let mylangs = (optml AllTenses langsParse args) langs
|
||||||
gfc bi modes (summary parse) (map parse mylangs)
|
gfc bi modes (summary parse) (map parse mylangs)
|
||||||
]
|
]
|
||||||
@@ -189,18 +190,17 @@ rglCommands =
|
|||||||
summary :: (LangInfo -> FilePath) -> FilePath
|
summary :: (LangInfo -> FilePath) -> FilePath
|
||||||
summary f = f (LangInfo "*" "*" Nothing Nothing False False False False)
|
summary f = f (LangInfo "*" "*" Nothing Nothing False False False False)
|
||||||
|
|
||||||
l mode args = (lang,optml mode langsLang args)
|
l mode args = (lang,optml mode (const True) args)
|
||||||
s mode args = (symbol,optml mode langsAPI args)
|
s mode args = (symbol,optml mode langAPI args)
|
||||||
c mode args = (compat,optml AllTenses langsCompat args)
|
c mode args = (compat,optml AllTenses langCompatibility args)
|
||||||
t mode args = (try,optml mode langsAPI args)
|
t mode args = (try,optml mode langAPI args)
|
||||||
sc mode args = (symbolic,optml mode langsSymbolic args)
|
sc mode args = (symbolic,optml mode langSymbolic args)
|
||||||
|
|
||||||
optml :: Mode -> ([LangInfo] -> [LangInfo]) -> [String] -> ([LangInfo] -> [LangInfo])
|
optml :: Mode -> (LangInfo -> Bool) -> [String] -> ([LangInfo] -> [LangInfo])
|
||||||
optml mode ls args = \langs -> getOptLangs langs (shrink langs) args
|
optml mode ls args =
|
||||||
where
|
\langs ->
|
||||||
shrink langs = case mode of
|
let defLangs = filter (if mode == Present then langPresent else const True) (filter ls langs)
|
||||||
Present -> langsPresent langs
|
in getOptLangs langs defLangs args
|
||||||
_ -> langs
|
|
||||||
|
|
||||||
-- | Search all language dirs for module name
|
-- | Search all language dirs for module name
|
||||||
findModule :: String -> IO (Maybe FilePath)
|
findModule :: String -> IO (Maybe FilePath)
|
||||||
@@ -345,32 +345,6 @@ separateBy chr = unfoldr sep where
|
|||||||
sep [] = Nothing
|
sep [] = Nothing
|
||||||
sep l = Just . fmap (drop 1) . break (== chr) $ l
|
sep l = Just . fmap (drop 1) . break (== chr) $ l
|
||||||
|
|
||||||
-- -- | Exclude langs from list by code
|
|
||||||
-- exceptLangs :: [LangInfo] -> [String] -> [LangInfo]
|
|
||||||
-- exceptLangs ls es = filter (flip notElem es . langCode) ls
|
|
||||||
|
|
||||||
-- | Only specified langs by code
|
|
||||||
only :: [LangInfo] -> [String] -> [LangInfo]
|
|
||||||
only ls es = filter (flip elem es . langCode) ls
|
|
||||||
|
|
||||||
langsLang :: [LangInfo] -> [LangInfo]
|
|
||||||
langsLang = id
|
|
||||||
|
|
||||||
langsPresent :: [LangInfo] -> [LangInfo]
|
|
||||||
langsPresent = filter langPresent
|
|
||||||
|
|
||||||
langsAPI :: [LangInfo] -> [LangInfo]
|
|
||||||
langsAPI = filter langAPI
|
|
||||||
|
|
||||||
langsSymbolic :: [LangInfo] -> [LangInfo]
|
|
||||||
langsSymbolic = filter langSymbolic
|
|
||||||
|
|
||||||
langsCompat :: [LangInfo] -> [LangInfo]
|
|
||||||
langsCompat = filter langCompatibility
|
|
||||||
|
|
||||||
langsParse :: [LangInfo] -> [LangInfo]
|
|
||||||
langsParse = flip only ["Eng"]
|
|
||||||
|
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
-- Getting module paths/names
|
-- Getting module paths/names
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user