reintroduce the compiler API

This commit is contained in:
Krasimir Angelov
2024-01-18 20:58:10 +01:00
parent 282c6fc50f
commit a82095d117
138 changed files with 84 additions and 342 deletions
-42
View File
@@ -1,42 +0,0 @@
-- | GF, the Grammatical Framework, as a library
module GF(
-- * Command line interface
module GF.Main,
module GF.Interactive,
module GF.Compiler,
-- * Compiling GF grammars
module GF.Compile,
module GF.CompileInParallel,
-- module PF.Compile.Export, -- haddock does the wrong thing with this
exportPGF,
module GF.CompileOne,
-- * Abstract syntax, parsing, pretty printing and serialisation
module GF.Compile.GetGrammar,
module GF.Grammar.Grammar,
module GF.Grammar.Macros,
module GF.Grammar.Printer,
module GF.Infra.Ident,
-- ** Binary serialisation
module GF.Grammar.Binary,
-- * Canonical GF
module GF.Compile.GrammarToCanonical
) where
import GF.Main
import GF.Compiler
import GF.Interactive
import GF.Compile
import GF.CompileInParallel
import GF.CompileOne
import GF.Compile.Export(exportPGF)
import GF.Compile.GetGrammar
import GF.Grammar.Grammar
import GF.Grammar.Macros
import GF.Grammar.Printer
import GF.Infra.Ident
import GF.Grammar.Binary
import GF.Compile.GrammarToCanonical
-55
View File
@@ -1,55 +0,0 @@
-- | GF main program (grammar compiler, interactive shell, http server)
{-# LANGUAGE CPP #-}
module GF.Main where
import GF.Compiler
import GF.Interactive
import GF.Data.ErrM
import GF.Infra.Option
import GF.Infra.UseIO
import GF.Infra.BuildInfo (buildInfo)
import Paths_gf
import Data.Version
import System.Directory
import System.Environment (getArgs)
import System.Exit
import GHC.IO.Encoding
-- | Run the GF main program, taking arguments from the command line.
-- (It calls 'setConsoleEncoding' and 'getOptions', then 'mainOpts'.)
-- Run @gf --help@ for usage info.
main :: IO ()
main = do
setLocaleEncoding utf8
-- setConsoleEncoding
uncurry mainOpts =<< getOptions
-- | Get and parse GF command line arguments. Fix relative paths.
-- Calls 'getArgs' and 'parseOptions'.
getOptions :: IO (Options, [FilePath])
getOptions = do
args <- getArgs
case parseOptions args of
Ok (opts,files) -> do curr_dir <- getCurrentDirectory
lib_dir <- getLibraryDirectory opts
return (fixRelativeLibPaths curr_dir lib_dir opts, files)
Bad err -> do ePutStrLn err
ePutStrLn "You may want to try --help."
exitFailure
-- | Run the GF main program with the given options and files. Depending on
-- the options it invokes 'mainGFC', 'mainGFI', 'mainRunGFI', 'mainServerGFI',
-- or it just prints version/usage info.
mainOpts :: Options -> [FilePath] -> IO ()
mainOpts opts files =
case flag optMode opts of
ModeVersion -> do datadir <- getDataDir
putStrLn $ "Grammatical Framework (GF) version " ++ showVersion version ++ "\n" ++
buildInfo ++ "\n" ++
"Shared folder: " ++ datadir
ModeHelp -> putStrLn helpMessage
ModeServer port -> mainServerGFI opts port files
ModeCompiler -> mainGFC opts files
ModeInteractive -> mainGFI opts files
ModeRun -> mainRunGFI opts files
-2
View File
@@ -1,2 +0,0 @@
module GF.Scribe where
@@ -16,6 +16,7 @@ module GF.Grammar
( module GF.Grammar.Grammar,
module GF.Grammar.Values,
module GF.Grammar.Macros,
module GF.Grammar.Parser,
module GF.Grammar.Printer,
module GF.Infra.Ident
) where
@@ -23,5 +24,6 @@ module GF.Grammar
import GF.Grammar.Grammar
import GF.Grammar.Values
import GF.Grammar.Macros
import GF.Grammar.Parser
import GF.Grammar.Printer
import GF.Infra.Ident

Some files were not shown because too many files have changed in this diff Show More