From a82095d11765e7b801a904c5b67f2845daaff1b6 Mon Sep 17 00:00:00 2001 From: Krasimir Angelov Date: Thu, 18 Jan 2024 20:58:10 +0100 Subject: [PATCH] reintroduce the compiler API --- src/compiler/GF.hs | 42 ----- src/compiler/GF/Main.hs | 55 ------- src/compiler/GF/Scribe.hs | 2 - src/compiler/{ => api}/Data/Binary.hs | 0 src/compiler/{ => api}/Data/Binary/Builder.hs | 0 src/compiler/{ => api}/Data/Binary/Get.hs | 0 .../{ => api}/Data/Binary/IEEE754.lhs | 0 src/compiler/{ => api}/Data/Binary/Put.hs | 0 src/compiler/{ => api}/GF/Command/Abstract.hs | 0 .../{ => api}/GF/Command/CommandInfo.hs | 0 src/compiler/{ => api}/GF/Command/Commands.hs | 0 .../{ => api}/GF/Command/CommonCommands.hs | 0 src/compiler/{ => api}/GF/Command/Help.hs | 0 .../{ => api}/GF/Command/Importing.hs | 0 .../{ => api}/GF/Command/Interpreter.hs | 0 src/compiler/{ => api}/GF/Command/Messages.hs | 0 src/compiler/{ => api}/GF/Command/Parse.hs | 0 .../{ => api}/GF/Command/SourceCommands.hs | 0 .../{ => api}/GF/Command/TreeOperations.hs | 0 src/compiler/{ => api}/GF/Compile.hs | 0 src/compiler/{ => api}/GF/Compile/CFGtoPGF.hs | 0 .../{ => api}/GF/Compile/CheckGrammar.hs | 0 .../{ => api}/GF/Compile/Compute/Abstract.hs | 0 .../{ => api}/GF/Compile/Compute/Concrete.hs | 0 .../{ => api}/GF/Compile/ConcreteToHaskell.hs | 0 .../{ => api}/GF/Compile/ExampleBased.hs | 0 src/compiler/{ => api}/GF/Compile/Export.hs | 0 .../{ => api}/GF/Compile/GenerateBC.hs | 0 .../{ => api}/GF/Compile/GeneratePMCFG.hs | 0 .../{ => api}/GF/Compile/GetGrammar.hs | 0 .../GF/Compile/GrammarToCanonical.hs | 0 .../{ => api}/GF/Compile/GrammarToPGF.hs | 0 src/compiler/{ => api}/GF/Compile/ModDeps.hs | 0 src/compiler/{ => api}/GF/Compile/Multi.hs | 0 .../{ => api}/GF/Compile/OptimizePGF.hs | 0 .../{ => api}/GF/Compile/PGFtoHaskell.hs | 0 .../{ => api}/GF/Compile/PGFtoJava.hs | 0 .../{ => api}/GF/Compile/ReadFiles.hs | 0 src/compiler/{ => api}/GF/Compile/Rename.hs | 0 src/compiler/{ => api}/GF/Compile/SubExOpt.hs | 0 src/compiler/{ => api}/GF/Compile/Tags.hs | 0 src/compiler/{ => api}/GF/Compile/ToAPI.hs | 0 .../GF/Compile/TypeCheck/Abstract.hs | 0 .../GF/Compile/TypeCheck/Concrete.hs | 0 .../GF/Compile/TypeCheck/ConcreteNew.hs | 0 .../GF/Compile/TypeCheck/Primitives.hs | 0 .../{ => api}/GF/Compile/TypeCheck/TC.hs | 0 src/compiler/{ => api}/GF/Compile/Update.hs | 0 .../{ => api}/GF/Compile/pgf.schema.json | 0 .../{ => api}/GF/CompileInParallel.hs | 0 src/compiler/{ => api}/GF/CompileOne.hs | 0 src/compiler/{ => api}/GF/Compiler.hs | 0 src/compiler/{ => api}/GF/CompilerAPI.hs | 0 src/compiler/{ => api}/GF/Data/BacktrackM.hs | 0 src/compiler/{ => api}/GF/Data/ErrM.hs | 0 src/compiler/{ => api}/GF/Data/Graph.hs | 0 src/compiler/{ => api}/GF/Data/Graphviz.hs | 0 src/compiler/{ => api}/GF/Data/Operations.hs | 0 src/compiler/{ => api}/GF/Data/Relation.hs | 0 src/compiler/{ => api}/GF/Data/SortedList.hs | 0 src/compiler/{ => api}/GF/Data/Str.hs | 0 src/compiler/{ => api}/GF/Data/Utilities.hs | 0 src/compiler/{ => api}/GF/Data/XML.hs | 0 src/compiler/{ => api}/GF/Data/Zipper.hs | 0 src/compiler/{ => api}/GF/Grammar.hs | 2 + src/compiler/{ => api}/GF/Grammar/Analyse.hs | 0 src/compiler/{ => api}/GF/Grammar/BNFC.hs | 0 src/compiler/{ => api}/GF/Grammar/Binary.hs | 0 src/compiler/{ => api}/GF/Grammar/CFG.hs | 0 .../{ => api}/GF/Grammar/Canonical.hs | 0 .../{ => api}/GF/Grammar/CanonicalJSON.hs | 0 src/compiler/{ => api}/GF/Grammar/EBNF.hs | 0 src/compiler/{ => api}/GF/Grammar/Grammar.hs | 0 src/compiler/{ => api}/GF/Grammar/Lexer.x | 0 .../{ => api}/GF/Grammar/Lockfield.hs | 0 src/compiler/{ => api}/GF/Grammar/Lookup.hs | 0 src/compiler/{ => api}/GF/Grammar/Macros.hs | 0 src/compiler/{ => api}/GF/Grammar/Parser.y | 0 .../{ => api}/GF/Grammar/PatternMatch.hs | 0 src/compiler/{ => api}/GF/Grammar/Predef.hs | 0 src/compiler/{ => api}/GF/Grammar/Printer.hs | 0 src/compiler/{ => api}/GF/Grammar/ShowTerm.hs | 0 src/compiler/{ => api}/GF/Grammar/Unify.hs | 0 src/compiler/{ => api}/GF/Grammar/Values.hs | 0 src/compiler/{ => api}/GF/Haskell.hs | 0 src/compiler/{ => api}/GF/Infra/BuildInfo.hs | 0 src/compiler/{ => api}/GF/Infra/CheckM.hs | 0 .../{ => api}/GF/Infra/Concurrency.hs | 0 .../{ => api}/GF/Infra/Dependencies.hs | 0 src/compiler/{ => api}/GF/Infra/GetOpt.hs | 0 src/compiler/{ => api}/GF/Infra/Ident.hs | 0 src/compiler/{ => api}/GF/Infra/Location.hs | 0 src/compiler/{ => api}/GF/Infra/Option.hs | 0 src/compiler/{ => api}/GF/Infra/SIO.hs | 0 src/compiler/{ => api}/GF/Infra/UseIO.hs | 0 src/compiler/{ => api}/GF/Interactive.hs | 0 src/compiler/{ => api}/GF/JavaScript/AbsJS.hs | 0 src/compiler/{ => api}/GF/JavaScript/JS.cf | 0 src/compiler/{ => api}/GF/JavaScript/LexJS.x | 0 src/compiler/{ => api}/GF/JavaScript/Makefile | 0 src/compiler/{ => api}/GF/JavaScript/ParJS.y | 0 .../{ => api}/GF/JavaScript/PrintJS.hs | 0 src/compiler/{ => api}/GF/Quiz.hs | 0 src/compiler/{ => api}/GF/Server.hs | 0 .../GF/Server/SimpleEditor/Convert.hs | 0 .../{ => api}/GF/Server/SimpleEditor/JSON.hs | 0 .../GF/Server/SimpleEditor/Syntax.hs | 0 src/compiler/{ => api}/GF/Speech/CFGToFA.hs | 0 .../{ => api}/GF/Speech/FiniteState.hs | 0 src/compiler/{ => api}/GF/Speech/GSL.hs | 0 src/compiler/{ => api}/GF/Speech/JSGF.hs | 0 src/compiler/{ => api}/GF/Speech/PGFToCFG.hs | 0 src/compiler/{ => api}/GF/Speech/PrRegExp.hs | 0 src/compiler/{ => api}/GF/Speech/RegExp.hs | 0 src/compiler/{ => api}/GF/Speech/SISR.hs | 0 src/compiler/{ => api}/GF/Speech/SLF.hs | 0 src/compiler/{ => api}/GF/Speech/SRG.hs | 0 src/compiler/{ => api}/GF/Speech/SRGS_ABNF.hs | 0 src/compiler/{ => api}/GF/Speech/SRGS_XML.hs | 0 src/compiler/{ => api}/GF/Speech/VoiceXML.hs | 0 src/compiler/{ => api}/GF/Support.hs | 0 src/compiler/{ => api}/GF/System/Catch.hs | 0 .../{ => api}/GF/System/Concurrency.hs | 0 src/compiler/{ => api}/GF/System/Console.hs | 0 src/compiler/{ => api}/GF/System/Directory.hs | 0 src/compiler/{ => api}/GF/System/NoSignal.hs | 0 src/compiler/{ => api}/GF/System/Process.hs | 0 src/compiler/{ => api}/GF/System/Signal.hs | 0 src/compiler/{ => api}/GF/System/UseSignal.hs | 0 src/compiler/api/GF/Term.hs | 5 + src/compiler/{ => api}/GF/Text/Clitics.hs | 0 src/compiler/{ => api}/GF/Text/Coding.hs | 0 src/compiler/{ => api}/GF/Text/Lexing.hs | 0 src/compiler/{ => api}/GF/Text/Pretty.hs | 0 .../{ => api}/GF/Text/Transliterations.hs | 0 src/compiler/gf-main.hs | 55 ++++++- src/compiler/gf-scribe.hs | 144 ------------------ src/compiler/gf.cabal | 121 +++------------ 138 files changed, 84 insertions(+), 342 deletions(-) delete mode 100644 src/compiler/GF.hs delete mode 100644 src/compiler/GF/Main.hs delete mode 100644 src/compiler/GF/Scribe.hs rename src/compiler/{ => api}/Data/Binary.hs (100%) rename src/compiler/{ => api}/Data/Binary/Builder.hs (100%) rename src/compiler/{ => api}/Data/Binary/Get.hs (100%) rename src/compiler/{ => api}/Data/Binary/IEEE754.lhs (100%) rename src/compiler/{ => api}/Data/Binary/Put.hs (100%) rename src/compiler/{ => api}/GF/Command/Abstract.hs (100%) rename src/compiler/{ => api}/GF/Command/CommandInfo.hs (100%) rename src/compiler/{ => api}/GF/Command/Commands.hs (100%) rename src/compiler/{ => api}/GF/Command/CommonCommands.hs (100%) rename src/compiler/{ => api}/GF/Command/Help.hs (100%) rename src/compiler/{ => api}/GF/Command/Importing.hs (100%) rename src/compiler/{ => api}/GF/Command/Interpreter.hs (100%) rename src/compiler/{ => api}/GF/Command/Messages.hs (100%) rename src/compiler/{ => api}/GF/Command/Parse.hs (100%) rename src/compiler/{ => api}/GF/Command/SourceCommands.hs (100%) rename src/compiler/{ => api}/GF/Command/TreeOperations.hs (100%) rename src/compiler/{ => api}/GF/Compile.hs (100%) rename src/compiler/{ => api}/GF/Compile/CFGtoPGF.hs (100%) rename src/compiler/{ => api}/GF/Compile/CheckGrammar.hs (100%) rename src/compiler/{ => api}/GF/Compile/Compute/Abstract.hs (100%) rename src/compiler/{ => api}/GF/Compile/Compute/Concrete.hs (100%) rename src/compiler/{ => api}/GF/Compile/ConcreteToHaskell.hs (100%) rename src/compiler/{ => api}/GF/Compile/ExampleBased.hs (100%) rename src/compiler/{ => api}/GF/Compile/Export.hs (100%) rename src/compiler/{ => api}/GF/Compile/GenerateBC.hs (100%) rename src/compiler/{ => api}/GF/Compile/GeneratePMCFG.hs (100%) rename src/compiler/{ => api}/GF/Compile/GetGrammar.hs (100%) rename src/compiler/{ => api}/GF/Compile/GrammarToCanonical.hs (100%) rename src/compiler/{ => api}/GF/Compile/GrammarToPGF.hs (100%) rename src/compiler/{ => api}/GF/Compile/ModDeps.hs (100%) rename src/compiler/{ => api}/GF/Compile/Multi.hs (100%) rename src/compiler/{ => api}/GF/Compile/OptimizePGF.hs (100%) rename src/compiler/{ => api}/GF/Compile/PGFtoHaskell.hs (100%) rename src/compiler/{ => api}/GF/Compile/PGFtoJava.hs (100%) rename src/compiler/{ => api}/GF/Compile/ReadFiles.hs (100%) rename src/compiler/{ => api}/GF/Compile/Rename.hs (100%) rename src/compiler/{ => api}/GF/Compile/SubExOpt.hs (100%) rename src/compiler/{ => api}/GF/Compile/Tags.hs (100%) rename src/compiler/{ => api}/GF/Compile/ToAPI.hs (100%) rename src/compiler/{ => api}/GF/Compile/TypeCheck/Abstract.hs (100%) rename src/compiler/{ => api}/GF/Compile/TypeCheck/Concrete.hs (100%) rename src/compiler/{ => api}/GF/Compile/TypeCheck/ConcreteNew.hs (100%) rename src/compiler/{ => api}/GF/Compile/TypeCheck/Primitives.hs (100%) rename src/compiler/{ => api}/GF/Compile/TypeCheck/TC.hs (100%) rename src/compiler/{ => api}/GF/Compile/Update.hs (100%) rename src/compiler/{ => api}/GF/Compile/pgf.schema.json (100%) rename src/compiler/{ => api}/GF/CompileInParallel.hs (100%) rename src/compiler/{ => api}/GF/CompileOne.hs (100%) rename src/compiler/{ => api}/GF/Compiler.hs (100%) rename src/compiler/{ => api}/GF/CompilerAPI.hs (100%) rename src/compiler/{ => api}/GF/Data/BacktrackM.hs (100%) rename src/compiler/{ => api}/GF/Data/ErrM.hs (100%) rename src/compiler/{ => api}/GF/Data/Graph.hs (100%) rename src/compiler/{ => api}/GF/Data/Graphviz.hs (100%) rename src/compiler/{ => api}/GF/Data/Operations.hs (100%) rename src/compiler/{ => api}/GF/Data/Relation.hs (100%) rename src/compiler/{ => api}/GF/Data/SortedList.hs (100%) rename src/compiler/{ => api}/GF/Data/Str.hs (100%) rename src/compiler/{ => api}/GF/Data/Utilities.hs (100%) rename src/compiler/{ => api}/GF/Data/XML.hs (100%) rename src/compiler/{ => api}/GF/Data/Zipper.hs (100%) rename src/compiler/{ => api}/GF/Grammar.hs (92%) rename src/compiler/{ => api}/GF/Grammar/Analyse.hs (100%) rename src/compiler/{ => api}/GF/Grammar/BNFC.hs (100%) rename src/compiler/{ => api}/GF/Grammar/Binary.hs (100%) rename src/compiler/{ => api}/GF/Grammar/CFG.hs (100%) rename src/compiler/{ => api}/GF/Grammar/Canonical.hs (100%) rename src/compiler/{ => api}/GF/Grammar/CanonicalJSON.hs (100%) rename src/compiler/{ => api}/GF/Grammar/EBNF.hs (100%) rename src/compiler/{ => api}/GF/Grammar/Grammar.hs (100%) rename src/compiler/{ => api}/GF/Grammar/Lexer.x (100%) rename src/compiler/{ => api}/GF/Grammar/Lockfield.hs (100%) rename src/compiler/{ => api}/GF/Grammar/Lookup.hs (100%) rename src/compiler/{ => api}/GF/Grammar/Macros.hs (100%) rename src/compiler/{ => api}/GF/Grammar/Parser.y (100%) rename src/compiler/{ => api}/GF/Grammar/PatternMatch.hs (100%) rename src/compiler/{ => api}/GF/Grammar/Predef.hs (100%) rename src/compiler/{ => api}/GF/Grammar/Printer.hs (100%) rename src/compiler/{ => api}/GF/Grammar/ShowTerm.hs (100%) rename src/compiler/{ => api}/GF/Grammar/Unify.hs (100%) rename src/compiler/{ => api}/GF/Grammar/Values.hs (100%) rename src/compiler/{ => api}/GF/Haskell.hs (100%) rename src/compiler/{ => api}/GF/Infra/BuildInfo.hs (100%) rename src/compiler/{ => api}/GF/Infra/CheckM.hs (100%) rename src/compiler/{ => api}/GF/Infra/Concurrency.hs (100%) rename src/compiler/{ => api}/GF/Infra/Dependencies.hs (100%) rename src/compiler/{ => api}/GF/Infra/GetOpt.hs (100%) rename src/compiler/{ => api}/GF/Infra/Ident.hs (100%) rename src/compiler/{ => api}/GF/Infra/Location.hs (100%) rename src/compiler/{ => api}/GF/Infra/Option.hs (100%) rename src/compiler/{ => api}/GF/Infra/SIO.hs (100%) rename src/compiler/{ => api}/GF/Infra/UseIO.hs (100%) rename src/compiler/{ => api}/GF/Interactive.hs (100%) rename src/compiler/{ => api}/GF/JavaScript/AbsJS.hs (100%) rename src/compiler/{ => api}/GF/JavaScript/JS.cf (100%) rename src/compiler/{ => api}/GF/JavaScript/LexJS.x (100%) rename src/compiler/{ => api}/GF/JavaScript/Makefile (100%) rename src/compiler/{ => api}/GF/JavaScript/ParJS.y (100%) rename src/compiler/{ => api}/GF/JavaScript/PrintJS.hs (100%) rename src/compiler/{ => api}/GF/Quiz.hs (100%) rename src/compiler/{ => api}/GF/Server.hs (100%) rename src/compiler/{ => api}/GF/Server/SimpleEditor/Convert.hs (100%) rename src/compiler/{ => api}/GF/Server/SimpleEditor/JSON.hs (100%) rename src/compiler/{ => api}/GF/Server/SimpleEditor/Syntax.hs (100%) rename src/compiler/{ => api}/GF/Speech/CFGToFA.hs (100%) rename src/compiler/{ => api}/GF/Speech/FiniteState.hs (100%) rename src/compiler/{ => api}/GF/Speech/GSL.hs (100%) rename src/compiler/{ => api}/GF/Speech/JSGF.hs (100%) rename src/compiler/{ => api}/GF/Speech/PGFToCFG.hs (100%) rename src/compiler/{ => api}/GF/Speech/PrRegExp.hs (100%) rename src/compiler/{ => api}/GF/Speech/RegExp.hs (100%) rename src/compiler/{ => api}/GF/Speech/SISR.hs (100%) rename src/compiler/{ => api}/GF/Speech/SLF.hs (100%) rename src/compiler/{ => api}/GF/Speech/SRG.hs (100%) rename src/compiler/{ => api}/GF/Speech/SRGS_ABNF.hs (100%) rename src/compiler/{ => api}/GF/Speech/SRGS_XML.hs (100%) rename src/compiler/{ => api}/GF/Speech/VoiceXML.hs (100%) rename src/compiler/{ => api}/GF/Support.hs (100%) rename src/compiler/{ => api}/GF/System/Catch.hs (100%) rename src/compiler/{ => api}/GF/System/Concurrency.hs (100%) rename src/compiler/{ => api}/GF/System/Console.hs (100%) rename src/compiler/{ => api}/GF/System/Directory.hs (100%) rename src/compiler/{ => api}/GF/System/NoSignal.hs (100%) rename src/compiler/{ => api}/GF/System/Process.hs (100%) rename src/compiler/{ => api}/GF/System/Signal.hs (100%) rename src/compiler/{ => api}/GF/System/UseSignal.hs (100%) create mode 100644 src/compiler/api/GF/Term.hs rename src/compiler/{ => api}/GF/Text/Clitics.hs (100%) rename src/compiler/{ => api}/GF/Text/Coding.hs (100%) rename src/compiler/{ => api}/GF/Text/Lexing.hs (100%) rename src/compiler/{ => api}/GF/Text/Pretty.hs (100%) rename src/compiler/{ => api}/GF/Text/Transliterations.hs (100%) delete mode 100644 src/compiler/gf-scribe.hs diff --git a/src/compiler/GF.hs b/src/compiler/GF.hs deleted file mode 100644 index a99970a57..000000000 --- a/src/compiler/GF.hs +++ /dev/null @@ -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 diff --git a/src/compiler/GF/Main.hs b/src/compiler/GF/Main.hs deleted file mode 100644 index 83c453782..000000000 --- a/src/compiler/GF/Main.hs +++ /dev/null @@ -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 diff --git a/src/compiler/GF/Scribe.hs b/src/compiler/GF/Scribe.hs deleted file mode 100644 index 300325cfc..000000000 --- a/src/compiler/GF/Scribe.hs +++ /dev/null @@ -1,2 +0,0 @@ -module GF.Scribe where - diff --git a/src/compiler/Data/Binary.hs b/src/compiler/api/Data/Binary.hs similarity index 100% rename from src/compiler/Data/Binary.hs rename to src/compiler/api/Data/Binary.hs diff --git a/src/compiler/Data/Binary/Builder.hs b/src/compiler/api/Data/Binary/Builder.hs similarity index 100% rename from src/compiler/Data/Binary/Builder.hs rename to src/compiler/api/Data/Binary/Builder.hs diff --git a/src/compiler/Data/Binary/Get.hs b/src/compiler/api/Data/Binary/Get.hs similarity index 100% rename from src/compiler/Data/Binary/Get.hs rename to src/compiler/api/Data/Binary/Get.hs diff --git a/src/compiler/Data/Binary/IEEE754.lhs b/src/compiler/api/Data/Binary/IEEE754.lhs similarity index 100% rename from src/compiler/Data/Binary/IEEE754.lhs rename to src/compiler/api/Data/Binary/IEEE754.lhs diff --git a/src/compiler/Data/Binary/Put.hs b/src/compiler/api/Data/Binary/Put.hs similarity index 100% rename from src/compiler/Data/Binary/Put.hs rename to src/compiler/api/Data/Binary/Put.hs diff --git a/src/compiler/GF/Command/Abstract.hs b/src/compiler/api/GF/Command/Abstract.hs similarity index 100% rename from src/compiler/GF/Command/Abstract.hs rename to src/compiler/api/GF/Command/Abstract.hs diff --git a/src/compiler/GF/Command/CommandInfo.hs b/src/compiler/api/GF/Command/CommandInfo.hs similarity index 100% rename from src/compiler/GF/Command/CommandInfo.hs rename to src/compiler/api/GF/Command/CommandInfo.hs diff --git a/src/compiler/GF/Command/Commands.hs b/src/compiler/api/GF/Command/Commands.hs similarity index 100% rename from src/compiler/GF/Command/Commands.hs rename to src/compiler/api/GF/Command/Commands.hs diff --git a/src/compiler/GF/Command/CommonCommands.hs b/src/compiler/api/GF/Command/CommonCommands.hs similarity index 100% rename from src/compiler/GF/Command/CommonCommands.hs rename to src/compiler/api/GF/Command/CommonCommands.hs diff --git a/src/compiler/GF/Command/Help.hs b/src/compiler/api/GF/Command/Help.hs similarity index 100% rename from src/compiler/GF/Command/Help.hs rename to src/compiler/api/GF/Command/Help.hs diff --git a/src/compiler/GF/Command/Importing.hs b/src/compiler/api/GF/Command/Importing.hs similarity index 100% rename from src/compiler/GF/Command/Importing.hs rename to src/compiler/api/GF/Command/Importing.hs diff --git a/src/compiler/GF/Command/Interpreter.hs b/src/compiler/api/GF/Command/Interpreter.hs similarity index 100% rename from src/compiler/GF/Command/Interpreter.hs rename to src/compiler/api/GF/Command/Interpreter.hs diff --git a/src/compiler/GF/Command/Messages.hs b/src/compiler/api/GF/Command/Messages.hs similarity index 100% rename from src/compiler/GF/Command/Messages.hs rename to src/compiler/api/GF/Command/Messages.hs diff --git a/src/compiler/GF/Command/Parse.hs b/src/compiler/api/GF/Command/Parse.hs similarity index 100% rename from src/compiler/GF/Command/Parse.hs rename to src/compiler/api/GF/Command/Parse.hs diff --git a/src/compiler/GF/Command/SourceCommands.hs b/src/compiler/api/GF/Command/SourceCommands.hs similarity index 100% rename from src/compiler/GF/Command/SourceCommands.hs rename to src/compiler/api/GF/Command/SourceCommands.hs diff --git a/src/compiler/GF/Command/TreeOperations.hs b/src/compiler/api/GF/Command/TreeOperations.hs similarity index 100% rename from src/compiler/GF/Command/TreeOperations.hs rename to src/compiler/api/GF/Command/TreeOperations.hs diff --git a/src/compiler/GF/Compile.hs b/src/compiler/api/GF/Compile.hs similarity index 100% rename from src/compiler/GF/Compile.hs rename to src/compiler/api/GF/Compile.hs diff --git a/src/compiler/GF/Compile/CFGtoPGF.hs b/src/compiler/api/GF/Compile/CFGtoPGF.hs similarity index 100% rename from src/compiler/GF/Compile/CFGtoPGF.hs rename to src/compiler/api/GF/Compile/CFGtoPGF.hs diff --git a/src/compiler/GF/Compile/CheckGrammar.hs b/src/compiler/api/GF/Compile/CheckGrammar.hs similarity index 100% rename from src/compiler/GF/Compile/CheckGrammar.hs rename to src/compiler/api/GF/Compile/CheckGrammar.hs diff --git a/src/compiler/GF/Compile/Compute/Abstract.hs b/src/compiler/api/GF/Compile/Compute/Abstract.hs similarity index 100% rename from src/compiler/GF/Compile/Compute/Abstract.hs rename to src/compiler/api/GF/Compile/Compute/Abstract.hs diff --git a/src/compiler/GF/Compile/Compute/Concrete.hs b/src/compiler/api/GF/Compile/Compute/Concrete.hs similarity index 100% rename from src/compiler/GF/Compile/Compute/Concrete.hs rename to src/compiler/api/GF/Compile/Compute/Concrete.hs diff --git a/src/compiler/GF/Compile/ConcreteToHaskell.hs b/src/compiler/api/GF/Compile/ConcreteToHaskell.hs similarity index 100% rename from src/compiler/GF/Compile/ConcreteToHaskell.hs rename to src/compiler/api/GF/Compile/ConcreteToHaskell.hs diff --git a/src/compiler/GF/Compile/ExampleBased.hs b/src/compiler/api/GF/Compile/ExampleBased.hs similarity index 100% rename from src/compiler/GF/Compile/ExampleBased.hs rename to src/compiler/api/GF/Compile/ExampleBased.hs diff --git a/src/compiler/GF/Compile/Export.hs b/src/compiler/api/GF/Compile/Export.hs similarity index 100% rename from src/compiler/GF/Compile/Export.hs rename to src/compiler/api/GF/Compile/Export.hs diff --git a/src/compiler/GF/Compile/GenerateBC.hs b/src/compiler/api/GF/Compile/GenerateBC.hs similarity index 100% rename from src/compiler/GF/Compile/GenerateBC.hs rename to src/compiler/api/GF/Compile/GenerateBC.hs diff --git a/src/compiler/GF/Compile/GeneratePMCFG.hs b/src/compiler/api/GF/Compile/GeneratePMCFG.hs similarity index 100% rename from src/compiler/GF/Compile/GeneratePMCFG.hs rename to src/compiler/api/GF/Compile/GeneratePMCFG.hs diff --git a/src/compiler/GF/Compile/GetGrammar.hs b/src/compiler/api/GF/Compile/GetGrammar.hs similarity index 100% rename from src/compiler/GF/Compile/GetGrammar.hs rename to src/compiler/api/GF/Compile/GetGrammar.hs diff --git a/src/compiler/GF/Compile/GrammarToCanonical.hs b/src/compiler/api/GF/Compile/GrammarToCanonical.hs similarity index 100% rename from src/compiler/GF/Compile/GrammarToCanonical.hs rename to src/compiler/api/GF/Compile/GrammarToCanonical.hs diff --git a/src/compiler/GF/Compile/GrammarToPGF.hs b/src/compiler/api/GF/Compile/GrammarToPGF.hs similarity index 100% rename from src/compiler/GF/Compile/GrammarToPGF.hs rename to src/compiler/api/GF/Compile/GrammarToPGF.hs diff --git a/src/compiler/GF/Compile/ModDeps.hs b/src/compiler/api/GF/Compile/ModDeps.hs similarity index 100% rename from src/compiler/GF/Compile/ModDeps.hs rename to src/compiler/api/GF/Compile/ModDeps.hs diff --git a/src/compiler/GF/Compile/Multi.hs b/src/compiler/api/GF/Compile/Multi.hs similarity index 100% rename from src/compiler/GF/Compile/Multi.hs rename to src/compiler/api/GF/Compile/Multi.hs diff --git a/src/compiler/GF/Compile/OptimizePGF.hs b/src/compiler/api/GF/Compile/OptimizePGF.hs similarity index 100% rename from src/compiler/GF/Compile/OptimizePGF.hs rename to src/compiler/api/GF/Compile/OptimizePGF.hs diff --git a/src/compiler/GF/Compile/PGFtoHaskell.hs b/src/compiler/api/GF/Compile/PGFtoHaskell.hs similarity index 100% rename from src/compiler/GF/Compile/PGFtoHaskell.hs rename to src/compiler/api/GF/Compile/PGFtoHaskell.hs diff --git a/src/compiler/GF/Compile/PGFtoJava.hs b/src/compiler/api/GF/Compile/PGFtoJava.hs similarity index 100% rename from src/compiler/GF/Compile/PGFtoJava.hs rename to src/compiler/api/GF/Compile/PGFtoJava.hs diff --git a/src/compiler/GF/Compile/ReadFiles.hs b/src/compiler/api/GF/Compile/ReadFiles.hs similarity index 100% rename from src/compiler/GF/Compile/ReadFiles.hs rename to src/compiler/api/GF/Compile/ReadFiles.hs diff --git a/src/compiler/GF/Compile/Rename.hs b/src/compiler/api/GF/Compile/Rename.hs similarity index 100% rename from src/compiler/GF/Compile/Rename.hs rename to src/compiler/api/GF/Compile/Rename.hs diff --git a/src/compiler/GF/Compile/SubExOpt.hs b/src/compiler/api/GF/Compile/SubExOpt.hs similarity index 100% rename from src/compiler/GF/Compile/SubExOpt.hs rename to src/compiler/api/GF/Compile/SubExOpt.hs diff --git a/src/compiler/GF/Compile/Tags.hs b/src/compiler/api/GF/Compile/Tags.hs similarity index 100% rename from src/compiler/GF/Compile/Tags.hs rename to src/compiler/api/GF/Compile/Tags.hs diff --git a/src/compiler/GF/Compile/ToAPI.hs b/src/compiler/api/GF/Compile/ToAPI.hs similarity index 100% rename from src/compiler/GF/Compile/ToAPI.hs rename to src/compiler/api/GF/Compile/ToAPI.hs diff --git a/src/compiler/GF/Compile/TypeCheck/Abstract.hs b/src/compiler/api/GF/Compile/TypeCheck/Abstract.hs similarity index 100% rename from src/compiler/GF/Compile/TypeCheck/Abstract.hs rename to src/compiler/api/GF/Compile/TypeCheck/Abstract.hs diff --git a/src/compiler/GF/Compile/TypeCheck/Concrete.hs b/src/compiler/api/GF/Compile/TypeCheck/Concrete.hs similarity index 100% rename from src/compiler/GF/Compile/TypeCheck/Concrete.hs rename to src/compiler/api/GF/Compile/TypeCheck/Concrete.hs diff --git a/src/compiler/GF/Compile/TypeCheck/ConcreteNew.hs b/src/compiler/api/GF/Compile/TypeCheck/ConcreteNew.hs similarity index 100% rename from src/compiler/GF/Compile/TypeCheck/ConcreteNew.hs rename to src/compiler/api/GF/Compile/TypeCheck/ConcreteNew.hs diff --git a/src/compiler/GF/Compile/TypeCheck/Primitives.hs b/src/compiler/api/GF/Compile/TypeCheck/Primitives.hs similarity index 100% rename from src/compiler/GF/Compile/TypeCheck/Primitives.hs rename to src/compiler/api/GF/Compile/TypeCheck/Primitives.hs diff --git a/src/compiler/GF/Compile/TypeCheck/TC.hs b/src/compiler/api/GF/Compile/TypeCheck/TC.hs similarity index 100% rename from src/compiler/GF/Compile/TypeCheck/TC.hs rename to src/compiler/api/GF/Compile/TypeCheck/TC.hs diff --git a/src/compiler/GF/Compile/Update.hs b/src/compiler/api/GF/Compile/Update.hs similarity index 100% rename from src/compiler/GF/Compile/Update.hs rename to src/compiler/api/GF/Compile/Update.hs diff --git a/src/compiler/GF/Compile/pgf.schema.json b/src/compiler/api/GF/Compile/pgf.schema.json similarity index 100% rename from src/compiler/GF/Compile/pgf.schema.json rename to src/compiler/api/GF/Compile/pgf.schema.json diff --git a/src/compiler/GF/CompileInParallel.hs b/src/compiler/api/GF/CompileInParallel.hs similarity index 100% rename from src/compiler/GF/CompileInParallel.hs rename to src/compiler/api/GF/CompileInParallel.hs diff --git a/src/compiler/GF/CompileOne.hs b/src/compiler/api/GF/CompileOne.hs similarity index 100% rename from src/compiler/GF/CompileOne.hs rename to src/compiler/api/GF/CompileOne.hs diff --git a/src/compiler/GF/Compiler.hs b/src/compiler/api/GF/Compiler.hs similarity index 100% rename from src/compiler/GF/Compiler.hs rename to src/compiler/api/GF/Compiler.hs diff --git a/src/compiler/GF/CompilerAPI.hs b/src/compiler/api/GF/CompilerAPI.hs similarity index 100% rename from src/compiler/GF/CompilerAPI.hs rename to src/compiler/api/GF/CompilerAPI.hs diff --git a/src/compiler/GF/Data/BacktrackM.hs b/src/compiler/api/GF/Data/BacktrackM.hs similarity index 100% rename from src/compiler/GF/Data/BacktrackM.hs rename to src/compiler/api/GF/Data/BacktrackM.hs diff --git a/src/compiler/GF/Data/ErrM.hs b/src/compiler/api/GF/Data/ErrM.hs similarity index 100% rename from src/compiler/GF/Data/ErrM.hs rename to src/compiler/api/GF/Data/ErrM.hs diff --git a/src/compiler/GF/Data/Graph.hs b/src/compiler/api/GF/Data/Graph.hs similarity index 100% rename from src/compiler/GF/Data/Graph.hs rename to src/compiler/api/GF/Data/Graph.hs diff --git a/src/compiler/GF/Data/Graphviz.hs b/src/compiler/api/GF/Data/Graphviz.hs similarity index 100% rename from src/compiler/GF/Data/Graphviz.hs rename to src/compiler/api/GF/Data/Graphviz.hs diff --git a/src/compiler/GF/Data/Operations.hs b/src/compiler/api/GF/Data/Operations.hs similarity index 100% rename from src/compiler/GF/Data/Operations.hs rename to src/compiler/api/GF/Data/Operations.hs diff --git a/src/compiler/GF/Data/Relation.hs b/src/compiler/api/GF/Data/Relation.hs similarity index 100% rename from src/compiler/GF/Data/Relation.hs rename to src/compiler/api/GF/Data/Relation.hs diff --git a/src/compiler/GF/Data/SortedList.hs b/src/compiler/api/GF/Data/SortedList.hs similarity index 100% rename from src/compiler/GF/Data/SortedList.hs rename to src/compiler/api/GF/Data/SortedList.hs diff --git a/src/compiler/GF/Data/Str.hs b/src/compiler/api/GF/Data/Str.hs similarity index 100% rename from src/compiler/GF/Data/Str.hs rename to src/compiler/api/GF/Data/Str.hs diff --git a/src/compiler/GF/Data/Utilities.hs b/src/compiler/api/GF/Data/Utilities.hs similarity index 100% rename from src/compiler/GF/Data/Utilities.hs rename to src/compiler/api/GF/Data/Utilities.hs diff --git a/src/compiler/GF/Data/XML.hs b/src/compiler/api/GF/Data/XML.hs similarity index 100% rename from src/compiler/GF/Data/XML.hs rename to src/compiler/api/GF/Data/XML.hs diff --git a/src/compiler/GF/Data/Zipper.hs b/src/compiler/api/GF/Data/Zipper.hs similarity index 100% rename from src/compiler/GF/Data/Zipper.hs rename to src/compiler/api/GF/Data/Zipper.hs diff --git a/src/compiler/GF/Grammar.hs b/src/compiler/api/GF/Grammar.hs similarity index 92% rename from src/compiler/GF/Grammar.hs rename to src/compiler/api/GF/Grammar.hs index 92bf60c9f..0733ecc58 100644 --- a/src/compiler/GF/Grammar.hs +++ b/src/compiler/api/GF/Grammar.hs @@ -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 diff --git a/src/compiler/GF/Grammar/Analyse.hs b/src/compiler/api/GF/Grammar/Analyse.hs similarity index 100% rename from src/compiler/GF/Grammar/Analyse.hs rename to src/compiler/api/GF/Grammar/Analyse.hs diff --git a/src/compiler/GF/Grammar/BNFC.hs b/src/compiler/api/GF/Grammar/BNFC.hs similarity index 100% rename from src/compiler/GF/Grammar/BNFC.hs rename to src/compiler/api/GF/Grammar/BNFC.hs diff --git a/src/compiler/GF/Grammar/Binary.hs b/src/compiler/api/GF/Grammar/Binary.hs similarity index 100% rename from src/compiler/GF/Grammar/Binary.hs rename to src/compiler/api/GF/Grammar/Binary.hs diff --git a/src/compiler/GF/Grammar/CFG.hs b/src/compiler/api/GF/Grammar/CFG.hs similarity index 100% rename from src/compiler/GF/Grammar/CFG.hs rename to src/compiler/api/GF/Grammar/CFG.hs diff --git a/src/compiler/GF/Grammar/Canonical.hs b/src/compiler/api/GF/Grammar/Canonical.hs similarity index 100% rename from src/compiler/GF/Grammar/Canonical.hs rename to src/compiler/api/GF/Grammar/Canonical.hs diff --git a/src/compiler/GF/Grammar/CanonicalJSON.hs b/src/compiler/api/GF/Grammar/CanonicalJSON.hs similarity index 100% rename from src/compiler/GF/Grammar/CanonicalJSON.hs rename to src/compiler/api/GF/Grammar/CanonicalJSON.hs diff --git a/src/compiler/GF/Grammar/EBNF.hs b/src/compiler/api/GF/Grammar/EBNF.hs similarity index 100% rename from src/compiler/GF/Grammar/EBNF.hs rename to src/compiler/api/GF/Grammar/EBNF.hs diff --git a/src/compiler/GF/Grammar/Grammar.hs b/src/compiler/api/GF/Grammar/Grammar.hs similarity index 100% rename from src/compiler/GF/Grammar/Grammar.hs rename to src/compiler/api/GF/Grammar/Grammar.hs diff --git a/src/compiler/GF/Grammar/Lexer.x b/src/compiler/api/GF/Grammar/Lexer.x similarity index 100% rename from src/compiler/GF/Grammar/Lexer.x rename to src/compiler/api/GF/Grammar/Lexer.x diff --git a/src/compiler/GF/Grammar/Lockfield.hs b/src/compiler/api/GF/Grammar/Lockfield.hs similarity index 100% rename from src/compiler/GF/Grammar/Lockfield.hs rename to src/compiler/api/GF/Grammar/Lockfield.hs diff --git a/src/compiler/GF/Grammar/Lookup.hs b/src/compiler/api/GF/Grammar/Lookup.hs similarity index 100% rename from src/compiler/GF/Grammar/Lookup.hs rename to src/compiler/api/GF/Grammar/Lookup.hs diff --git a/src/compiler/GF/Grammar/Macros.hs b/src/compiler/api/GF/Grammar/Macros.hs similarity index 100% rename from src/compiler/GF/Grammar/Macros.hs rename to src/compiler/api/GF/Grammar/Macros.hs diff --git a/src/compiler/GF/Grammar/Parser.y b/src/compiler/api/GF/Grammar/Parser.y similarity index 100% rename from src/compiler/GF/Grammar/Parser.y rename to src/compiler/api/GF/Grammar/Parser.y diff --git a/src/compiler/GF/Grammar/PatternMatch.hs b/src/compiler/api/GF/Grammar/PatternMatch.hs similarity index 100% rename from src/compiler/GF/Grammar/PatternMatch.hs rename to src/compiler/api/GF/Grammar/PatternMatch.hs diff --git a/src/compiler/GF/Grammar/Predef.hs b/src/compiler/api/GF/Grammar/Predef.hs similarity index 100% rename from src/compiler/GF/Grammar/Predef.hs rename to src/compiler/api/GF/Grammar/Predef.hs diff --git a/src/compiler/GF/Grammar/Printer.hs b/src/compiler/api/GF/Grammar/Printer.hs similarity index 100% rename from src/compiler/GF/Grammar/Printer.hs rename to src/compiler/api/GF/Grammar/Printer.hs diff --git a/src/compiler/GF/Grammar/ShowTerm.hs b/src/compiler/api/GF/Grammar/ShowTerm.hs similarity index 100% rename from src/compiler/GF/Grammar/ShowTerm.hs rename to src/compiler/api/GF/Grammar/ShowTerm.hs diff --git a/src/compiler/GF/Grammar/Unify.hs b/src/compiler/api/GF/Grammar/Unify.hs similarity index 100% rename from src/compiler/GF/Grammar/Unify.hs rename to src/compiler/api/GF/Grammar/Unify.hs diff --git a/src/compiler/GF/Grammar/Values.hs b/src/compiler/api/GF/Grammar/Values.hs similarity index 100% rename from src/compiler/GF/Grammar/Values.hs rename to src/compiler/api/GF/Grammar/Values.hs diff --git a/src/compiler/GF/Haskell.hs b/src/compiler/api/GF/Haskell.hs similarity index 100% rename from src/compiler/GF/Haskell.hs rename to src/compiler/api/GF/Haskell.hs diff --git a/src/compiler/GF/Infra/BuildInfo.hs b/src/compiler/api/GF/Infra/BuildInfo.hs similarity index 100% rename from src/compiler/GF/Infra/BuildInfo.hs rename to src/compiler/api/GF/Infra/BuildInfo.hs diff --git a/src/compiler/GF/Infra/CheckM.hs b/src/compiler/api/GF/Infra/CheckM.hs similarity index 100% rename from src/compiler/GF/Infra/CheckM.hs rename to src/compiler/api/GF/Infra/CheckM.hs diff --git a/src/compiler/GF/Infra/Concurrency.hs b/src/compiler/api/GF/Infra/Concurrency.hs similarity index 100% rename from src/compiler/GF/Infra/Concurrency.hs rename to src/compiler/api/GF/Infra/Concurrency.hs diff --git a/src/compiler/GF/Infra/Dependencies.hs b/src/compiler/api/GF/Infra/Dependencies.hs similarity index 100% rename from src/compiler/GF/Infra/Dependencies.hs rename to src/compiler/api/GF/Infra/Dependencies.hs diff --git a/src/compiler/GF/Infra/GetOpt.hs b/src/compiler/api/GF/Infra/GetOpt.hs similarity index 100% rename from src/compiler/GF/Infra/GetOpt.hs rename to src/compiler/api/GF/Infra/GetOpt.hs diff --git a/src/compiler/GF/Infra/Ident.hs b/src/compiler/api/GF/Infra/Ident.hs similarity index 100% rename from src/compiler/GF/Infra/Ident.hs rename to src/compiler/api/GF/Infra/Ident.hs diff --git a/src/compiler/GF/Infra/Location.hs b/src/compiler/api/GF/Infra/Location.hs similarity index 100% rename from src/compiler/GF/Infra/Location.hs rename to src/compiler/api/GF/Infra/Location.hs diff --git a/src/compiler/GF/Infra/Option.hs b/src/compiler/api/GF/Infra/Option.hs similarity index 100% rename from src/compiler/GF/Infra/Option.hs rename to src/compiler/api/GF/Infra/Option.hs diff --git a/src/compiler/GF/Infra/SIO.hs b/src/compiler/api/GF/Infra/SIO.hs similarity index 100% rename from src/compiler/GF/Infra/SIO.hs rename to src/compiler/api/GF/Infra/SIO.hs diff --git a/src/compiler/GF/Infra/UseIO.hs b/src/compiler/api/GF/Infra/UseIO.hs similarity index 100% rename from src/compiler/GF/Infra/UseIO.hs rename to src/compiler/api/GF/Infra/UseIO.hs diff --git a/src/compiler/GF/Interactive.hs b/src/compiler/api/GF/Interactive.hs similarity index 100% rename from src/compiler/GF/Interactive.hs rename to src/compiler/api/GF/Interactive.hs diff --git a/src/compiler/GF/JavaScript/AbsJS.hs b/src/compiler/api/GF/JavaScript/AbsJS.hs similarity index 100% rename from src/compiler/GF/JavaScript/AbsJS.hs rename to src/compiler/api/GF/JavaScript/AbsJS.hs diff --git a/src/compiler/GF/JavaScript/JS.cf b/src/compiler/api/GF/JavaScript/JS.cf similarity index 100% rename from src/compiler/GF/JavaScript/JS.cf rename to src/compiler/api/GF/JavaScript/JS.cf diff --git a/src/compiler/GF/JavaScript/LexJS.x b/src/compiler/api/GF/JavaScript/LexJS.x similarity index 100% rename from src/compiler/GF/JavaScript/LexJS.x rename to src/compiler/api/GF/JavaScript/LexJS.x diff --git a/src/compiler/GF/JavaScript/Makefile b/src/compiler/api/GF/JavaScript/Makefile similarity index 100% rename from src/compiler/GF/JavaScript/Makefile rename to src/compiler/api/GF/JavaScript/Makefile diff --git a/src/compiler/GF/JavaScript/ParJS.y b/src/compiler/api/GF/JavaScript/ParJS.y similarity index 100% rename from src/compiler/GF/JavaScript/ParJS.y rename to src/compiler/api/GF/JavaScript/ParJS.y diff --git a/src/compiler/GF/JavaScript/PrintJS.hs b/src/compiler/api/GF/JavaScript/PrintJS.hs similarity index 100% rename from src/compiler/GF/JavaScript/PrintJS.hs rename to src/compiler/api/GF/JavaScript/PrintJS.hs diff --git a/src/compiler/GF/Quiz.hs b/src/compiler/api/GF/Quiz.hs similarity index 100% rename from src/compiler/GF/Quiz.hs rename to src/compiler/api/GF/Quiz.hs diff --git a/src/compiler/GF/Server.hs b/src/compiler/api/GF/Server.hs similarity index 100% rename from src/compiler/GF/Server.hs rename to src/compiler/api/GF/Server.hs diff --git a/src/compiler/GF/Server/SimpleEditor/Convert.hs b/src/compiler/api/GF/Server/SimpleEditor/Convert.hs similarity index 100% rename from src/compiler/GF/Server/SimpleEditor/Convert.hs rename to src/compiler/api/GF/Server/SimpleEditor/Convert.hs diff --git a/src/compiler/GF/Server/SimpleEditor/JSON.hs b/src/compiler/api/GF/Server/SimpleEditor/JSON.hs similarity index 100% rename from src/compiler/GF/Server/SimpleEditor/JSON.hs rename to src/compiler/api/GF/Server/SimpleEditor/JSON.hs diff --git a/src/compiler/GF/Server/SimpleEditor/Syntax.hs b/src/compiler/api/GF/Server/SimpleEditor/Syntax.hs similarity index 100% rename from src/compiler/GF/Server/SimpleEditor/Syntax.hs rename to src/compiler/api/GF/Server/SimpleEditor/Syntax.hs diff --git a/src/compiler/GF/Speech/CFGToFA.hs b/src/compiler/api/GF/Speech/CFGToFA.hs similarity index 100% rename from src/compiler/GF/Speech/CFGToFA.hs rename to src/compiler/api/GF/Speech/CFGToFA.hs diff --git a/src/compiler/GF/Speech/FiniteState.hs b/src/compiler/api/GF/Speech/FiniteState.hs similarity index 100% rename from src/compiler/GF/Speech/FiniteState.hs rename to src/compiler/api/GF/Speech/FiniteState.hs diff --git a/src/compiler/GF/Speech/GSL.hs b/src/compiler/api/GF/Speech/GSL.hs similarity index 100% rename from src/compiler/GF/Speech/GSL.hs rename to src/compiler/api/GF/Speech/GSL.hs diff --git a/src/compiler/GF/Speech/JSGF.hs b/src/compiler/api/GF/Speech/JSGF.hs similarity index 100% rename from src/compiler/GF/Speech/JSGF.hs rename to src/compiler/api/GF/Speech/JSGF.hs diff --git a/src/compiler/GF/Speech/PGFToCFG.hs b/src/compiler/api/GF/Speech/PGFToCFG.hs similarity index 100% rename from src/compiler/GF/Speech/PGFToCFG.hs rename to src/compiler/api/GF/Speech/PGFToCFG.hs diff --git a/src/compiler/GF/Speech/PrRegExp.hs b/src/compiler/api/GF/Speech/PrRegExp.hs similarity index 100% rename from src/compiler/GF/Speech/PrRegExp.hs rename to src/compiler/api/GF/Speech/PrRegExp.hs diff --git a/src/compiler/GF/Speech/RegExp.hs b/src/compiler/api/GF/Speech/RegExp.hs similarity index 100% rename from src/compiler/GF/Speech/RegExp.hs rename to src/compiler/api/GF/Speech/RegExp.hs diff --git a/src/compiler/GF/Speech/SISR.hs b/src/compiler/api/GF/Speech/SISR.hs similarity index 100% rename from src/compiler/GF/Speech/SISR.hs rename to src/compiler/api/GF/Speech/SISR.hs diff --git a/src/compiler/GF/Speech/SLF.hs b/src/compiler/api/GF/Speech/SLF.hs similarity index 100% rename from src/compiler/GF/Speech/SLF.hs rename to src/compiler/api/GF/Speech/SLF.hs diff --git a/src/compiler/GF/Speech/SRG.hs b/src/compiler/api/GF/Speech/SRG.hs similarity index 100% rename from src/compiler/GF/Speech/SRG.hs rename to src/compiler/api/GF/Speech/SRG.hs diff --git a/src/compiler/GF/Speech/SRGS_ABNF.hs b/src/compiler/api/GF/Speech/SRGS_ABNF.hs similarity index 100% rename from src/compiler/GF/Speech/SRGS_ABNF.hs rename to src/compiler/api/GF/Speech/SRGS_ABNF.hs diff --git a/src/compiler/GF/Speech/SRGS_XML.hs b/src/compiler/api/GF/Speech/SRGS_XML.hs similarity index 100% rename from src/compiler/GF/Speech/SRGS_XML.hs rename to src/compiler/api/GF/Speech/SRGS_XML.hs diff --git a/src/compiler/GF/Speech/VoiceXML.hs b/src/compiler/api/GF/Speech/VoiceXML.hs similarity index 100% rename from src/compiler/GF/Speech/VoiceXML.hs rename to src/compiler/api/GF/Speech/VoiceXML.hs diff --git a/src/compiler/GF/Support.hs b/src/compiler/api/GF/Support.hs similarity index 100% rename from src/compiler/GF/Support.hs rename to src/compiler/api/GF/Support.hs diff --git a/src/compiler/GF/System/Catch.hs b/src/compiler/api/GF/System/Catch.hs similarity index 100% rename from src/compiler/GF/System/Catch.hs rename to src/compiler/api/GF/System/Catch.hs diff --git a/src/compiler/GF/System/Concurrency.hs b/src/compiler/api/GF/System/Concurrency.hs similarity index 100% rename from src/compiler/GF/System/Concurrency.hs rename to src/compiler/api/GF/System/Concurrency.hs diff --git a/src/compiler/GF/System/Console.hs b/src/compiler/api/GF/System/Console.hs similarity index 100% rename from src/compiler/GF/System/Console.hs rename to src/compiler/api/GF/System/Console.hs diff --git a/src/compiler/GF/System/Directory.hs b/src/compiler/api/GF/System/Directory.hs similarity index 100% rename from src/compiler/GF/System/Directory.hs rename to src/compiler/api/GF/System/Directory.hs diff --git a/src/compiler/GF/System/NoSignal.hs b/src/compiler/api/GF/System/NoSignal.hs similarity index 100% rename from src/compiler/GF/System/NoSignal.hs rename to src/compiler/api/GF/System/NoSignal.hs diff --git a/src/compiler/GF/System/Process.hs b/src/compiler/api/GF/System/Process.hs similarity index 100% rename from src/compiler/GF/System/Process.hs rename to src/compiler/api/GF/System/Process.hs diff --git a/src/compiler/GF/System/Signal.hs b/src/compiler/api/GF/System/Signal.hs similarity index 100% rename from src/compiler/GF/System/Signal.hs rename to src/compiler/api/GF/System/Signal.hs diff --git a/src/compiler/GF/System/UseSignal.hs b/src/compiler/api/GF/System/UseSignal.hs similarity index 100% rename from src/compiler/GF/System/UseSignal.hs rename to src/compiler/api/GF/System/UseSignal.hs diff --git a/src/compiler/api/GF/Term.hs b/src/compiler/api/GF/Term.hs new file mode 100644 index 000000000..de47d243d --- /dev/null +++ b/src/compiler/api/GF/Term.hs @@ -0,0 +1,5 @@ +module GF.Term (renameSourceTerm, inferLType, checkLType, normalForm) where + +import GF.Compile.Rename +import GF.Compile.Compute.Concrete +import GF.Compile.TypeCheck.ConcreteNew diff --git a/src/compiler/GF/Text/Clitics.hs b/src/compiler/api/GF/Text/Clitics.hs similarity index 100% rename from src/compiler/GF/Text/Clitics.hs rename to src/compiler/api/GF/Text/Clitics.hs diff --git a/src/compiler/GF/Text/Coding.hs b/src/compiler/api/GF/Text/Coding.hs similarity index 100% rename from src/compiler/GF/Text/Coding.hs rename to src/compiler/api/GF/Text/Coding.hs diff --git a/src/compiler/GF/Text/Lexing.hs b/src/compiler/api/GF/Text/Lexing.hs similarity index 100% rename from src/compiler/GF/Text/Lexing.hs rename to src/compiler/api/GF/Text/Lexing.hs diff --git a/src/compiler/GF/Text/Pretty.hs b/src/compiler/api/GF/Text/Pretty.hs similarity index 100% rename from src/compiler/GF/Text/Pretty.hs rename to src/compiler/api/GF/Text/Pretty.hs diff --git a/src/compiler/GF/Text/Transliterations.hs b/src/compiler/api/GF/Text/Transliterations.hs similarity index 100% rename from src/compiler/GF/Text/Transliterations.hs rename to src/compiler/api/GF/Text/Transliterations.hs diff --git a/src/compiler/gf-main.hs b/src/compiler/gf-main.hs index cf387d2fa..c9e977159 100644 --- a/src/compiler/gf-main.hs +++ b/src/compiler/gf-main.hs @@ -1,5 +1,54 @@ -module Main where +-- | GF main program (grammar compiler, interactive shell, http server) -import qualified GF +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 -main = GF.main +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 diff --git a/src/compiler/gf-scribe.hs b/src/compiler/gf-scribe.hs deleted file mode 100644 index 1589f29bc..000000000 --- a/src/compiler/gf-scribe.hs +++ /dev/null @@ -1,144 +0,0 @@ -import PGF2 -import Data.Char (toUpper) -import GF.Scribe -import GF.Infra.Ident -import GF.Infra.CheckM -import GF.Infra.Option -import GF.Grammar.Grammar -import GF.Grammar.Parser -import GF.Grammar.Printer -import GF.Grammar.Macros -import qualified GF.Data.Operations as O -import GF.Compile.Rename -import GF.Compile.Compute.Concrete -import GF.Compile.TypeCheck.ConcreteNew -import GF.Compile -import qualified Data.Map as Map -import qualified Data.ByteString.Char8 as BS -import System.Environment(getArgs) -import System.Console.Haskeline -import Network.HTTP -import Control.Monad -import Control.Monad.IO.Class -import Text.JSON -import Text.PrettyPrint - -main = do - (qid:lang:args) <- getArgs - gr <- readNGF "/usr/local/share/x86_64-linux-ghc-8.8.4/gf-4.0.0/www/robust/Parse.ngf" - let Just cnc = Map.lookup (toCnc lang) (languages gr) - rsp <- simpleHTTP (getRequest ("https://www.wikidata.org/wiki/Special:EntityData/"++qid++".json")) - case decode (rspBody rsp) >>= valFromObj "entities" >>= valFromObj qid >>= valFromObj "claims" of - Ok obj -> do do (_,(mo,sgr)) <- batchCompile noOptions ["RGL.gf"] - interactive (item2term obj) () mo sgr gr cnc qid - Error msg -> fail msg - where - toCnc (c:cs) = "Parse"++(toUpper c:cs) - toCnc s = s - -item2term obj = - R [assign (LIdent (rawIdentS prop)) - (mkFV [term | value <- values, - Ok term <- [claim2term value]]) - | (prop,values) <- fromJSObject obj] - where - mkFV [t] = t - mkFV ts = FV ts - - claim2term value = do - t1 <- valFromObj "mainsnak" value >>= snak2term - t2 <- (valFromObj "qualifiers" value >>= mods2term) - `mplus` - return [] - t3 <- (valFromObj "references" value >>= mods2term) - `mplus` - return [] - return (R (t1++t2++t3)) - - mods2term obj = - return [assign (LIdent (rawIdentS prop)) - (mkFV [R term | value <- values, - Ok term <- [snak2term value]]) - | (prop,values) <- fromJSObject obj] - - snak2term value = valFromObj "datavalue" value >>= datavalue2term - - datavalue2term dv = - do s <- valFromObj "value" dv -- string - return [assign (LIdent (rawIdentS "s")) (K s)] - `mplus` - do value <- valFromObj "value" dv -- wikibase-entityid - id <- valFromObj "id" value - return [assign (LIdent (rawIdentS "id")) (K id)] - `mplus` - do value <- valFromObj "value" dv -- globecoordinate - latitude <- valFromObj "latitude" value - longitude <- valFromObj "longitude" value - precision <- valFromObj "precision" value - return [assign (LIdent (rawIdentS "latitude")) (EFloat latitude) - ,assign (LIdent (rawIdentS "longitude")) (EFloat longitude) - ,assign (LIdent (rawIdentS "longitude")) (EFloat precision)] - `mplus` - do value <- valFromObj "value" dv -- quantity - amount <- valFromObj "amount" value >>= decimal - unit <- fmap dropURL (valFromObj "unit" value) - return [assign (LIdent (rawIdentS "amount")) amount - ,assign (LIdent (rawIdentS "unit")) (K unit)] - `mplus` - do value <- valFromObj "value" dv -- time - time <- valFromObj "time" value - model <- fmap dropURL (valFromObj "calendarmodel" value) - precision <- valFromObj "precision" value - return [assign (LIdent (rawIdentS "time")) (K time) - ,assign (LIdent (rawIdentS "calendarmodel")) (K model) - ,assign (LIdent (rawIdentS "precision")) (EInt precision)] - `mplus` - do value <- valFromObj "value" dv - text <- valFromObj "text" value - language <- valFromObj "language" value - return [assign (LIdent (rawIdentS "text")) (K text) - ,assign (LIdent (rawIdentS "language")) (K language)] - `mplus` - Error "Cannot parse a datavalue" - - dropURL s = match "http://www.wikidata.org/entity/" s - where - match [] ys = ys - match (x:xs) (y:ys) - | x == y = match xs ys - match _ _ = s - - decimal ('+':s) = decimal s - decimal s = - case reads s of - [(n,"")] -> return (EInt n) - _ -> case reads s of - [(d,"")] -> return (EFloat d) - _ -> Error "Not a decimal" - -interactive entity db mo sgr gr cnc qid = runInputT defaultSettings loop - where - loop :: InputT IO () - loop = do - minput <- getInputLine (qid++"> ") - case minput of - Nothing -> return () - Just input -> case runP pTerm (BS.pack input) of - Right term -> do case runCheck (checkComputeTerm term) of - O.Ok (res,msg) -> do outputStr msg - mapM_ (\(term,typ) -> outputStrLn (render (ppTerm Unqualified 0 term)) >> outputStrLn (render (ppTerm Unqualified 0 typ))) res - O.Bad msg -> do outputStrLn msg - loop - Left (pos,msg) -> do outputStrLn (show pos ++ msg) - loop - - checkComputeTerm term = do - let term' = Abs Explicit (identS "entity") term - term' <- renameSourceTerm sgr mo term' - (term',typ) <- inferLType sgr term' - runEvalM sgr $ do - tnk <- newThunk [] entity - -- val <- eval [(identS "entity",tnk)] term [] - --res <- value2term [] val - let res = term - return (res, typ) diff --git a/src/compiler/gf.cabal b/src/compiler/gf.cabal index 1bcf5f37f..d3f1f9eae 100644 --- a/src/compiler/gf.cabal +++ b/src/compiler/gf.cabal @@ -55,9 +55,9 @@ flag network-uri description: Get Network.URI from the network-uri package default: True -executable gf - main-is: gf-main.hs +library default-language: Haskell2010 + hs-source-dirs: api build-depends: pgf2 >= 4.0.0, base >= 4.6 && <5, array, @@ -70,20 +70,28 @@ executable gf ghc-prim, filepath, directory>=1.2, time, process, haskeline, parallel>=3, json - ghc-options: -threaded + exposed-modules: + GF.Interactive + GF.Compiler + GF.Grammar + GF.Term + GF.Compile + GF.CompileInParallel + GF.Data.ErrM + GF.Infra.CheckM + GF.Infra.Option + GF.Infra.UseIO + GF.Infra.BuildInfo + other-modules: - GF GF.Support GF.Text.Pretty GF.Text.Lexing GF.Grammar.Canonical - GF.Main GF.Compiler GF.Interactive + GF.CompileOne GF.Compile.GetGrammar - GF.Compile GF.CompileInParallel GF.CompileOne GF.Compile.GetGrammar - GF.Grammar - - GF.Data.Operations GF.Infra.Option GF.Infra.UseIO + GF.Data.Operations GF.Command.Abstract GF.Command.CommandInfo @@ -124,7 +132,6 @@ executable gf GF.Compile.TypeCheck.TC GF.Compile.Update GF.Data.BacktrackM - GF.Data.ErrM GF.Data.Graph GF.Data.Graphviz GF.Data.Relation @@ -148,8 +155,6 @@ executable gf GF.Grammar.ShowTerm GF.Grammar.Unify GF.Grammar.Values - GF.Infra.BuildInfo - GF.Infra.CheckM GF.Infra.Concurrency GF.Infra.Dependencies GF.Infra.GetOpt @@ -226,6 +231,14 @@ executable gf else other-modules: GF.System.NoSignal +executable gf + main-is: gf-main.hs + other-modules: + Paths_gf + default-language: Haskell2010 + build-depends: base >= 4.6 && <5, directory>=1.2, gf + ghc-options: -threaded + test-suite gf-tests type: exitcode-stdio-1.0 main-is: run.hs @@ -238,87 +251,3 @@ test-suite gf-tests process >= 1.4.3 && < 1.7 build-tool-depends: gf:gf default-language: Haskell2010 - -executable gf-scribe - main-is: gf-scribe.hs - default-language: Haskell2010 - build-depends: pgf2 >= 4.0.0, - base >= 4.6 && <5, - array, - containers, - bytestring, - utf8-string, - random, - pretty, - mtl, - ghc-prim, - filepath, directory>=1.2, time, - http-slim, - process, haskeline, parallel>=3, json - if os(windows) - build-depends: - Win32 >= 2.3.1.1 && < 2.7 - else - build-depends: - terminfo >=0.4.0 && < 0.5, - unix >= 2.7.2 && < 2.8 - ghc-options: -threaded - other-modules: - GF.Scribe - Data.Binary - Data.Binary.Builder - Data.Binary.Get - Data.Binary.IEEE754 - Data.Binary.Put - GF.Compile.Update - GF.Compile.Compute.Concrete - GF.Compile.CheckGrammar - GF.Compile.GenerateBC - GF.Compile.GeneratePMCFG - GF.Compile.GetGrammar - GF.Compile.GrammarToPGF - GF.Compile.OptimizePGF - GF.Compile.ReadFiles - GF.Compile.Rename - GF.Compile.SubExOpt - GF.Compile.Tags - GF.Compile.TypeCheck.Abstract - GF.Compile.TypeCheck.Concrete - GF.Compile.TypeCheck.ConcreteNew - GF.Compile.TypeCheck.Primitives - GF.Compile.TypeCheck.TC - GF.Compile - GF.CompileOne - GF.Data.ErrM - GF.Data.Operations - GF.Data.Relation - GF.Data.Str - GF.Data.Utilities - GF.Grammar - GF.Grammar.Lexer - GF.Grammar.Parser - GF.Grammar.BNFC - GF.Grammar.CFG - GF.Grammar.EBNF - GF.Grammar.Grammar - GF.Grammar.Lockfield - GF.Grammar.Lookup - GF.Grammar.Macros - GF.Grammar.Predef - GF.Grammar.Printer - GF.Grammar.Values - GF.Grammar.Binary - GF.Grammar.PatternMatch - GF.Grammar.Unify - GF.Infra.CheckM - GF.Infra.GetOpt - GF.Infra.Ident - GF.Infra.Location - GF.Infra.Option - GF.Infra.UseIO - GF.System.Catch - GF.System.Console - GF.System.Directory - GF.Text.Pretty - GF.Text.Coding - Paths_gf