summaryrefslogtreecommitdiff
path: root/src/compiler/GF/Compile
AgeCommit message (Collapse)Author
2014-09-27checked that course of value tables (table P [...]) have the correct number ↵aarne
of values w.r.t the type P. This was previously not checked, and caused hard-to-find run-time errors.
2014-09-17forgot to type check the type of a typed let expressionkr.angelov
2014-09-17the type checker for the abstract syntax now allows let expressions in def ↵kr.angelov
rules, since they are easily compilable to byte code. This fails in the Haskell runtime since let expressions are not allowed as abstract syntax expressions.
2014-09-11a major revision of the bytecode generator and JIT compiler. the effect is ↵kr.angelov
that now we can compute with lambda functions and with true tail recursion
2014-09-05the code for def rules now uses proper graph update to preserve lazynesskr.angelov
2014-09-05full support for recursive def rules in the C runtimekr.angelov
2014-09-01partial implementation for recursive def ruleskr.angelov
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-20Add lifted directory operations in GF.System.Directory to eliminate the need ↵hallgren
for liftIO in various places
2014-08-19GF.Compile.ReadFiles: a simpler & faster way to convert from Latin1 to UTF-8hallgren
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-08-11pattern matching in def rules is now supportedkr.angelov
2014-08-11a partial support for def rules in the C runtimekr.angelov
The def rules are now compiled to byte code by the compiler and then to native code by the JIT compiler in the runtime. Not all constructions are implemented yet. The partial implementation is now in the repository but it is not activated by default since this requires changes in the PGF format. I will enable it only after it is complete.
2014-07-28Convert from Text.PrettyPrint to GF.Text.Prettyhallgren
All compiler modules now use GF.Text.Pretty instead of Text.PrettyPrint
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-17Compute/ConcreteNew.hs: eliminate selections from wildcard tableshallgren
This patch also includes some commented out code that was used to search for the source of code size explosions and an eta expansion bug.
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-24now we compile context-free grammars directly to PGF without going via GF ↵kr.angelov
source code. This makes it quick and lightweight to compile big grammars such as the Berkley grammar
2014-05-16Compute/ConcreteNew.hs: adding a Prawitz rewritehallgren
(table { p_i => t_i } ! x).l ==> table { p_i => t_i.l } ! x This was used in the old partial evaluator and can significantly reduce term sizes in some cases.
2014-05-16Fix an eta expansion bug in the grammar compilerhallgren
Eta expansion is applied between partial evaluation and PMCFG generation. The buggy version generated type incorrect terms, but PMCFG generation apparently worked anyway.
2014-04-04TypeCheck.RConcrete: contravariance in table typeshallgren
2014-04-04Removed imports of TypeCheck.Concrete, fixed problems in TypeCheck.RConcretehallgren
+ The current type checker for concrete syntax is in GF.Compile.TypeCheck.RConcrete, but GF.Compile.TypeCheck.Concrete was still imported in GFI. + Fixed a bug that allowed Ints n as a subtype of Ints m, regardless of m and n. It now requires n<=m. Note: the type checker still allows Int as a subtype of Ints m, regardless of m. + Fixed a potential efficiency problem with large record types, by reducing the number of recursive calls from |R|*|S| to |R| when checking if R<=S. + Fixed a misleading comment: "alpha g t u" checks that u is a subtype of t, the other way around. Similarly, "checkIfEqLType gr g t u trm" checks that u is a subtype of t, not the other way around, and not that t is equal to u.
2014-04-01Bug fix for pattern macros in pre{}hallgren
This bug was introduced sometime between 2013-08-21 and 2013-11-01 and caused the function convertTerm in GF.Compile.GeneratePMCFG to encounter a EPatt where it expected Strs. I fixed it by applying the function getPatts (from the old partial evaluator) to the pattern.
2014-03-21refactor the compilation of CFG and EBNF grammars. Now they are parsed by ↵kr.angelov
using GF.Grammar.Parser just like the ordinary GF grammars. Furthermore now GF.Speech.CFG is moved to GF.Grammar.CFG. The new module is used by both the speech conversion utils and by the compiler for CFG grammars. The parser for CFG now consumes a lot less memory and can be used with grammars with more than 4 000 000 productions.
2014-03-17show the value in the error message when failing to get Str from valueaarne
2014-03-15bugfix in the compiler for linref of empty recordkr.angelov
2014-02-17fix in GF.Compile.Compute.ConcreteNew which makes it possible to compile ↵kr.angelov
DocumentationBul.gf
2014-02-09disabled ad hoc overloading, as it still causes mysterious errors. It is ↵aarne
just a few lines in Rename.hs
2014-02-01new overload resolution, taking care of ad hoc overloading.aarne
2014-02-01ad hoc overloading: a new way to deal with name resolution conflicts. ↵aarne
Previously the renamer warned if there was e.g. an unqualified reference to mkAdv, which could come from either Syntax or Paradigms. The renamer picked randomly one of the alternatives, which then often failed in type checking. Now, all candidates are collected into a new structure AdHocOverload [Term], which is accessed by the type checker to make the choice based on the type of the constant. This eliminates some of the warnings and some of the error due to wrong choices. In some rare cases, the inherited constants have the same type, which cannot be resolved by overloading. In such cases, the type checker does the same as the renamer did before: pick the "first" option (i.e. the one that happens to be the first in the list returned by the renamer) and issues a warning. In this patch, only a couple of lines are changed. The typechecker (RConcrete) has more substantial changes, and will be recorded as the next patch.
2014-01-31typo in Concrete type checker: when type checking <e : t>, return annotated ↵aarne
e and not e itself. Fixed in RConcrete, which should soon replace Concrete; and hopefully will be replaced by some cleaner code soon, such as ConcreteNew which has been under construction for quite some time.
2014-01-31experimental type checker module GF.Compile.TypeCheck.RConcrete.hs with ↵aarne
record updates enabled by ** expressions. Can be changed back to Concrete.hs by just changing one import command in GF.Compile.CheckGrammar.hs. The worst thing that *should* happen with the new type checker is that some old code is detected to be invalid, which happens if it contains a type-incompatible record extension, e.g. {x = "foo"} ** {x = 1}. Previously such errors were silently ignored. A set of test runs detected one such error in the RGL, which was corrected. On the positive side, the new type checker now enables record updates in the natural way: R ** {x = 1} will give value x = 1 overshadowing any value of x in R (provided the expected type of x is Int). lib/src/experimental/PredicationSwe.gf illustrates this, as opposed to PredicationSwO.gf which has to use old-style copying of even the unchanged record fields.
2013-12-18PGFtoPython: add Python translations for nonExist, BIND and SOFT_BINDhallgren
Someone who is familiar with the Python translation should check this.
2013-12-16GF.Compile.ReadFiles: reduced code duplicationhallgren
2013-12-06Show relative file paths in error messageshallgren
This is to avoid one trivial reason for failures in the test suite.
2013-12-06GF.Compile.CheckGrammar: add source path to error message for circular ↵hallgren
definitions
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-29Move typePredefined from GF.Compile.Compute.AppPredefined to ↵hallgren
GF.Compile.TypeCheck.Primitives Also move the list of primitives
2013-11-29Move checkPredefError from GF.Compile.Compute.ConcreteLazy to GF.Grammar.Macroshallgren
Also simplified its type.
2013-11-28GFI: adapt to character encoding changeshallgren
GF.Compile.Coding is not used any more.
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 refactoring in GF.Compile and GF.Compile.GetGrammarhallgren
Move source transcoding function GF.Compile to GF.Compile.GetGrammar, in preparation for doing transcoding before lexing.
2013-11-21Some more monadic lifting changeshallgren
2013-11-20Removed some code duplication in GF.Compile.Updatehallgren
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-12Fix Issue 68: Cannot use an overloaded operator in table defined using ↵hallgren
square brackets Add proper type checking of course-of-values tables: + Make sure that all subterms have the same type. + Resolve overloaded operators. Note though that the GF book states in C.4.12 that the "course-of-values table [...] format is not recommended for GF source code, since the ordering of parameter values is not specified and therefore a compiler-internal decision."
2013-11-12added Predef.SOFT_BIND. This special token allows zero or more spaces ↵kr.angelov
between ordinary tokens. It is also used in the English RGL to attach the commas to the previous word.