summaryrefslogtreecommitdiff
path: root/src/compiler/GF/Infra
AgeCommit message (Collapse)Author
2014-10-08GF.Infra.Options: change from String to Int in the type of optJobshallgren
2014-09-08(1) Refactor concurrency, (2) write to .gfo.tmp then rename to .gfohallgren
(1) introduces the module GF.Infra.Concurreny with lifted concurrency operators (to reduce uses of liftIO) and some additional concurrency utilities, e.g. a function for sequential logging that is used in both GF.CompileInParallel and GFServer. (2) avoids leaving broken .gfo files behind if compilation is aborted.
2014-08-25Experimental: parallel batch compilation of grammarshallgren
On my laptop these changes speed up the full build of the RGL and example grammars with 'cabal build' from ~95s to ~43s and the zero build from ~18s to ~5s. The main change is the introduction of the module GF.CompileInParallel that replaces GF.Compile and the function GF.Compile.ReadFiles.getAllFiles. At present, it is activated with the new -j flag, and it is only used when combined with --make or --batch. In addition, to get parallel computations, you need to add GHC run-time flags, e.g., +RTS -N -A20M -RTS, to the command line. The Setup.hs script has been modified to pass the appropriate flags to GF for parallel compilation when compiling the RGL and example grammars, but you need a recent version of Cabal for this to work (probably >=1.20). Some additonal refactoring were made during this work. A new monad is used to avoid warnings/error messages from different modules to be intertwined when compiling in parallel, so some functios that were hardiwred to the IO or IOE monads have been lifted to work in arbitrary monads that are instances in the appropriate classes.
2014-08-22Command line flag -s/-q now silences all warningshallgren
These flags now do what the say.
2014-08-13Fix warnings in 16 modules, mostly forward compatibility warnings from GHC 7.8hallgren
2014-08-13Refactoring in GF.Compile and GF.ReadFiles with an eye to parallel compilationhallgren
In particular, the function compileOne has been moved to the new module GF.CompileOne and its type has been changed from compileOne :: ... -> CompileEnv -> FilePath -> IOE CompileEnv to compileOne :: ... -> SourceGrammar -> FilePath -> IOE OneCompiledModule making it more suitable for use in a parallel compiler.
2014-07-27Adding GF.Infra.Location and GF.Text.Pretty (forgot to 'darcs add' them before)hallgren
2014-07-27Introducing GF.Text.Pretty for more concise pretty printers and ↵hallgren
GF.Infra.Location for modularity GF.Text.Pretty provides the class Pretty and overloaded versions of the pretty printing combinators in Text.PrettyPrint, allowing pretty printable values to be used directly instead of first having to convert them to Doc with functions like text, int, char and ppIdent. Some modules have been converted to use GF.Text.Pretty, but not all. Precedences could be added to simplify the pretty printers for terms and patterns. GF.Infra.Location contains the types Location and L, factored out from GF.Grammar.Grammar, and the class HasSourcePath. This allowed the import of GF.Grammar.Grammar to be removed from GF.Infra.CheckM, making it more like a pure library module.
2014-06-24minibar: include the grammar's last modification in the grammar info shown ↵hallgren
by the "i" button Also bumped version number in gf.cabal to 3.6-darcs. Also removed some unecessary use of CPP.
2014-06-12PGF library: expose only PGF and PGF.Internal instead of all moduleshallgren
PGF exports the public, stable API. PGF.Internal exports additional things needed in the GF compiler & shell, including the nonstardard version of Data.Binary.
2014-05-21in verbosity mode the compiler warns about missing pathskr.angelov
2014-01-20Optionally include C run-time supporthallgren
If the C run-time library is compiled and installed on your system, you can now do 'cabal configure -fc-runtime' to get the following extras: + The haskell binding to the C run-time library will be included in the PGF library (so you can import it in Haskell applications). Documentation on the new modules will be included when you run 'cabal haddock'. + The new command 'pgf-shell', implemented on top of haskell binding to the C run-time system. + Three new commands in the web API: c-parse, c-linearize and c-translate. Their interfaces are similar to the corresponding commands without the "c-" prefix, but they should be considered preliminary.
2013-12-16GF.Compile.ReadFiles: reduced code duplicationhallgren
2013-12-10option --split-pgf replaces option --mk-index. This splits the PGF into one ↵kr.angelov
file for the abstract and one more for each concrete syntax. This is a preparation for being able to load only specific languages from the whole grammar.
2013-12-06Show relative file paths in error messageshallgren
This is to avoid one trivial reason for failures in the test suite.
2013-11-29Commment code and options relating to the old partial evaluatorhallgren
This means that the -old-comp and -new-comp flags are not recognized anymore. The only functional difference is that printnames were still normalized with the old partial evaluator. Now that is done with the new partial evaluator.
2013-11-26Represent identifiers as UTF-8-encoded ByteStringshallgren
This was a fairly simple change thanks to previous work on making the Ident type abstract and the fact that PGF.CId already uses UTF-8-encoded ByteStrings. One potential pitfall is that Data.ByteString.UTF8 uses the same type for ByteStrings as Data.ByteString. I renamed ident2bs to ident2utf8 and bsCId to utf8CId, to make it clearer that they work with UTF-8-encoded ByteStrings. Since both the compiler input and identifiers are now UTF-8-encoded ByteStrings, the lexer now creates identifiers without copying any characters. **END OF DESCRIPTION*** Place the long patch description above the ***END OF DESCRIPTION*** marker. The first line of this file will be the patch name. This patch contains the following changes: M ./src/compiler/GF/Compile/CheckGrammar.hs -3 +3 M ./src/compiler/GF/Compile/GrammarToPGF.hs -2 +2 M ./src/compiler/GF/Grammar/Binary.hs -5 +1 M ./src/compiler/GF/Grammar/Lexer.x -11 +13 M ./src/compiler/GF/Infra/Ident.hs -19 +36 M ./src/runtime/haskell/PGF.hs -1 +1 M ./src/runtime/haskell/PGF/CId.hs -2 +3
2013-11-25Change how GF deals with character encodings in grammar fileshallgren
1. The default encoding is changed from Latin-1 to UTF-8. 2. Alternate encodings should be specified as "--# -coding=enc", the old "flags coding=enc" declarations have no effect but are still checked for consistency. 3. A transitional warning is generated for files that contain non-ASCII characters without specifying a character encoding: "Warning: default encoding has changed from Latin-1 to UTF-8" 4. Conversion to Unicode is now done *before* lexing. This makes it possible to allow arbitrary Unicode characters in identifiers. But identifiers are still stored as ByteStrings, so they are limited to Latin-1 characters for now. 5. Lexer.hs is no longer part of the repository. We now generate the lexer from Lexer.x with alex>=3. Some workarounds for bugs in alex-3.0 were needed. These bugs might already be fixed in newer versions of alex, but we should be compatible with what is shipped in the Haskell Platform.
2013-11-21Some more monadic lifting changeshallgren
2013-11-20Reduced clutter in monadic codehallgren
+ Eliminated vairous ad-hoc coersion functions between specific monads (IO, Err, IOE, Check) in favor of more general lifting functions (liftIO, liftErr). + Generalized many basic monadic operations from specific monads to arbitrary monads in the appropriate class (MonadIO and/or ErrorMonad), thereby completely eliminating the need for lifting functions in lots of places. This can be considered a small step forward towards a cleaner compiler API and more malleable compiler code in general.
2013-11-06the content of ParseEngAbs3.probs is now merged with ParseEngAbs.probs. The ↵kr.angelov
later is now retrained. Once the grammar is compiled with the .probs file now it doesn't need anything more to do robust parsing. The robustness itself is controlled by the flags 'heuristic_search_factor', 'meta_prob' and 'meta_token_prob' in ParseEngAbs.gf
2013-11-05Eliminate mutual dependencies between the GF compiler and the PGF libraryhallgren
+ References to modules under src/compiler have been eliminated from the PGF library (under src/runtime/haskell). Only two functions had to be moved (from GF.Data.Utilities to PGF.Utilities) to make this possible, other apparent dependencies turned out to be vacuous. + In gf.cabal, the GF executable no longer directly depends on the PGF library source directory, but only on the exposed library modules. This means that there is less duplication in gf.cabal and that the 30 modules in the PGF library will no longer be compiled twice while building GF. To make this possible, additional PGF library modules have been exposed, even though they should probably be considered for internal use only. They could be collected in a PGF.Internal module, or marked as "unstable", to make this explicit. + Also, by using the -fwarn-unused-imports flag, ~220 redundant imports were found and removed, reducing the total number of imports by ~15%.
2013-09-20Comment out identifier refreshing code only used by the removed refresh passhallgren
2013-09-19Introduce type RawIdent; only 9 imports of Data.ByteString.Char8 remainhallgren
The fact that identifiers are represented as ByteStrings is now an internal implentation detail in module GF.Infra.Ident. Conversion between ByteString and identifiers is only needed in the lexer and the Binary instances.
2013-09-19Make Ident abstract; imports of Data.ByteString.Char8 down from 29 to 16 moduleshallgren
Most of the explicit uses of ByteStrings were eliminated by using identS, identS = identC . BS.pack which was found in GF.Grammar.CF and moved to GF.Infra.Ident. The function prefixIdent :: String -> Ident -> Ident allowed one additional import of ByteString to be eliminated. The functions isArgIdent :: Ident -> Bool getArgIndex :: Ident -> Maybe Int were needed to eliminate explicit pattern matching on Ident from two modules.
2013-06-10Update the usage text for the --output-format optionhallgren
It needs to be updated manually when the list of available output format changes.
2013-02-12now the beam size for the statistical parser can be configured by using the ↵kr.angelov
flag beam_size in the top-level concrete module
2013-01-28Better error message for Predef.errorhallgren
+ Instead of "Internal error in ...", you now get a proper error message with a source location and a function name. + Also added some missing error value propagation in the partial evaluator. + Also some other minor cleanup and error handling fixes.
2012-12-20added alltenses to the default search path (just like prelude)aarne
2012-11-14Add flag --document-root for user with gf --serverhallgren
This can make it easier to test cloud service updates before installing them.
2012-11-14GF usage message fixeshallgren
Change the command name from gfc to gf in the usage message header. Correct spelling of "overide" to "override" in -gf-lib-path description.
2012-11-13Adding a new experimental partial evalutatorhallgren
GF.Compile.Compute.ConcreteNew + two new modules contain a new partial evaluator intended to solve some performance problems with the old partial evalutator in GF.Compile.Compute.ConcreteLazy. It has been around for a while, but is now complete enough to compile the RGL and the Phrasebook. The old partial evaluator is still used by default. The new one can be activated in two ways: - by using the command line option -new-comp when invoking GF. - by using cabal configure -fnew-comp to make -new-comp the default. In this case you can also use the command line option -old-comp to revert to the old partial evaluator. In the GF shell, the cc command uses the old evaluator regardless of -new-comp for now, but you can use "cc -new ..." to invoke the new evaluator. With -new-comp, computations happen in GF.Compile.GeneratePMCFG instead of GF.Compile.Optimize. This is implemented by testing the flag optNewComp in both modules, to omit calls to the old partial evaluator from GF.Compile.Optimize and add calls to the new partial evaluator in GF.Compile.GeneratePMCFG. This also means that -new-comp effectively implies -noexpand. In GF.Compile.CheckGrammar, there is a check that restricted inheritance is used correctly. However, when -noexpand is used, this check causes unexpected errors, so it has been converted to generate warnings, for now. -new-comp no longer enables the new type checker in GF.Compile.Typeckeck.ConcreteNew. The GF version number has been bumped to 3.3.10-darcs
2012-11-08Eliminate warnings about deprecated use of catch and tryhallgren
This is also needed for compatibility with GHC 7.6.
2012-10-23cleanuphallgren
Simplify the implementation of writeUTF8File and use it in one more place. Remove unused imports left over after a previous change.
2012-10-19Refactor compileSourceModulehallgren
There was 55 lines of rather repetitive code with calls to 6 compiler passes. They have been replaced with 19 lines that call the 6 compiler passes plus 26 lines of helper functions.
2012-10-18Use NOINLINE for build info and darcs version infohallgren
... to avoid unnecessary recompilation of other modules.
2012-09-26SIO bug fixhallgren
Line breaks were missing when capturing stdout. (putStrLn acted like putStr.)
2012-09-25Use the SIO monad in the GF shellhallgren
+ The restrictions on arbitrary IO when GF is running in restricted mode is now enforced in the types. + This hopefully also solves an intermittent problem when accessing the GF shell through the web API provided by gf -server. This was visible in the Simple Translation Tool and probably caused by some low-level bug in the GHC IO libraries.
2012-09-25GF.Infra.SIO.hs: adding the SIO monad (where S = Shell or Safe)hallgren
The SIO monad is a restriction of the IO monad with two purposes: + Access to arbitrary IO operations can be turned off by setting the environment variable GF_RESTRICTED. There is a limited set of IO operations that are considered safe and always allowed. + It allows output to stdout to be captured. This can be used in gf -server mode, where output of GF shell commands is made part of HTTP responses returned to clients.
2012-08-29Use nub' instead of nub in some places, remove some unused nub importspeter.ljunglof
2012-08-29A basic infrastructure for generating Teyjus bytecode from the GF abstract ↵kr.angelov
syntax
2012-06-27major changes to the prolog exportpeter.ljunglof
2012-06-26Experiment with parallel grammar checkshallgren
Introduced the function parallelCheck :: [Check a] -> Check [a] that runs independent checks in parallel, potentially allowing faster grammar compilation on multi-core computers, if you run gf with +RTS -N. However, on my dual core laptop, this seems to slow down compilation somewhat even though CPU utilization goes up as high as 170% at times. (This is with GF compiled with GHC 7.0.4.)
2012-06-26GF.Infra.CheckM: comment out unused Context argumenthallgren
2012-06-26Report many type errors instead of stopping after the first onehallgren
In GF.Compile.CheckGrammar, use a new topological sorting function that groups independent judgements, allowing them all to be checked before continuing or reporting errors.
2012-06-25Fix for warning messages from checkMapRecoverhallgren
Reimplemented it with the new function accumulateError. Also keeping the formatting of errors and warnings unchanged for now, to avoid potentially causing problems in the GF Eclipse Plugin.
2012-06-25removed spurious empty warningsaarne
2012-06-25Check monad: support for accumulated errorshallgren
In addition to warnings, the Check monad in GF.Infra.CheckM can now accumulate errors. There are two new functions checkAccumError: Message -> Check () accumulateError :: (a -> Check a) -> a -> Check a The former (with the same type as checkWarn) is used to report an accumulated (nonfatal) error. The latter converts fatal errors into accumulated errors. Accumulated errors are reported as regular errors by runCheck. Also, the Check monad type has been made abstract.
2012-06-25Export PGF in Python formatpeter.ljunglof
2012-06-25warnings shown in checkMapRecoveraarne