Commit Graph

36 Commits

Author SHA1 Message Date
hallgren
ece3e33c52 partial evaluator bug fix
It failed to delay table selection when the selector contains a run-time
variable, causing "gf: Prelude.(!!): index too large" instead.

Also:
  + Show better source locations on unexpected errors, to aid bug hunting.
  + Removed unused SourceGrammar argument to value2term.
2012-12-19 23:12:37 +00:00
hallgren
b4207d1b00 GF.Grammar.Lookup: new function lookupResDefLoc
It's like lookupResDef but it includes a source location in the output.
2012-12-19 23:08:56 +00:00
hallgren
c3beefba47 partial evaluator bug fix
Int was missing from the list of predefined canonical constants.
2012-12-18 13:03:20 +00:00
hallgren
9ab3a6034d Add language extension for ghc<7.4
FlexibleInstances does not imply TypeSynonymInstances, apparently.
2012-12-14 14:21:46 +00:00
hallgren
d7e3c869c2 More work on the new partial evaluator
The work done by the partial evaluator is now divied in two stages:
 - A static "term traversal" stage that happens only once per term and uses
   only statically known information. In particular, the values of lambda bound
   variables are unknown during this stage. Some tables are transformed to
   reduce the cost of pattern matching.
 - A dynamic "function application" stage, where function bodies can be
   evaluated repeatedly with different arguments, without the term traversal
   overhead and without recomputing statically known information.

Also the treatment of predefined functions has been reworked to take advantage
of the staging and better handle partial applications.
2012-12-14 14:00:21 +00:00
hallgren
5e091d2e3d partial evaluator work
* Evaluate operators once, not every time they are looked up
* Remember the list of parameter values instead of recomputing it from the
  pattern type every time a table selection is made.
* Quick fix for partial application of some predefined functions.
2012-12-11 15:37:41 +00:00
hallgren
621291a575 Compute.ConcreteNew: add missing case for variant functions
Also adding a test case in the test suite for this.
2012-12-10 13:25:32 +00:00
hallgren
81f843ac06 Compute.ConcreteNew: bug fix for indirectly defined pattern macros
More changes are probably needed to make pattern macros first class values.
Also includes minor changes related to variants and error messages.
2012-12-06 16:44:03 +00:00
hallgren
7d616c01b4 new-comp: rewrite f (x|y) into (f x|f y)
With this change, all languages in molto/mgl/mixture except German and Polish
can be compiled.
2012-11-16 13:47:10 +00:00
hallgren
27e675910a Adding a new experimental partial evalutator
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-13 14:09:15 +00:00
hallgren
9f8c0f86f1 Compute.ConcreteNew: support variants
Also add a missing check for Predef values in apply.
2012-10-24 17:49:20 +00:00
aarne
a2bae03824 missing case in partial evaluation of + fixed 2012-05-15 11:48:30 +00:00
aarne
69f84defb0 bug fix in AppPredefined: don't compare values that contain variables. this should be checked even more generally. 2012-02-28 15:13:32 +00:00
aarne
aa7668ef75 the Predef function eqVal to compare equality of parameter values 2012-02-24 10:00:27 +00:00
kr.angelov
c52f05ed46 The typechecker is still unfinished but at least it can typecheck the English resource grammar 2011-12-02 12:33:26 +00:00
kr.angelov
b859edee38 Hopefully complete Value type and a little bit more on computations. 2011-11-30 20:56:31 +00:00
kr.angelov
7863b21c1a more stuff in the new type checker 2011-11-30 14:55:52 +00:00
kr.angelov
fffc5f2507 Sketch of the new type checker for the concrete syntax. Enabled only with -new-comp 2011-11-29 12:12:51 +00:00
kr.angelov
416d231c5e Now PMCFG is compiled per module and at the end we only link it. The new compilation schema is few times faster. 2011-11-10 14:09:41 +00:00
kr.angelov
734c66710e merge GF.Infra.Modules and GF.Grammar.Grammar. This is a preparation for the separate PGF building 2011-11-02 13:57:11 +00:00
kr.angelov
5fe49ed9f7 Now the compiler maintains more precise information for the source locations of the different definitions. There is a --tags option which generates a list of all identifiers with their source locations. 2011-11-02 11:44:59 +00:00
hallgren
f8665c7213 Remove configuration flag cclazy 2011-11-01 13:45:12 +00:00
hallgren
c4ee13abac Recording an alternative version of look in Compute/ConcreteLazy.hs
Commented out, causes problems in the greek example.
2011-10-25 18:50:07 +00:00
aarne
7372da3d7f use associativity to force more precompilation of pre expressions 2011-10-24 12:52:20 +00:00
hallgren
ed451653bd Introduce an explicit error value in the Term type
This makes it easier to treat run-time errors (e.g. caused by calls to
Predef.error) in a way that is more typical for a lazy functional language.
2011-10-20 14:36:30 +00:00
hallgren
ef4fac9d82 Compute/ConcreteLazy.hs: no need to reverse when looking up labels in records 2011-10-20 14:19:33 +00:00
hallgren
d8d60adb15 AppPredefined.hs: more readable notation for the types of primitives 2011-10-20 14:17:37 +00:00
hallgren
42ea96a5ca Remove unused function computeConcreteRec.
This also allows the parameter rec to be removed from function computeTermOpt.
(The change is made in GF.Compile.Compute.ConcreteLazy, but not in 
GF.Compile.Compute.ConcreteStrict.)
2011-09-09 12:25:27 +00:00
hallgren
875df01dc6 Add lazy version of GF.Compile.Compute.Concrete
This patch adds GF.Compile.Compute.ConcreteLazy, which replaces the Err monad
with the Identity monad. While the Err monad makes the interpreter
(hyper)strict, the Identity monad let's the interpreter inherit Haskell's
laziness.  This can give big speedups: from 50s to 1s in one example,
from ~4 minutes to ~2 minutes for the RGL.

This is still experimental and might be buggy, so it is off by default.
You can turn it on by configuring with the -fcclazy flag, e.g.

	cabal configure -fcclazy

Let me know if anything breaks.
2011-09-01 16:39:41 +00:00
aarne
6757ab2b41 reload command in shell 2011-08-25 15:58:38 +00:00
aarne
3afefb0ac9 commented Compute/Concrete with explanations 2011-08-22 17:08:07 +00:00
aarne
a3924abece Predef functions toUpper, toLower, isUpper 2011-06-02 16:10:46 +00:00
aarne
445a3aafeb Predef.error surfaces as error message in compilation and cc command 2011-02-25 17:01:10 +00:00
aarne
9b5223a06b fixed the failure to partial-evaluate pre in right-associative context 2010-12-11 16:27:35 +00:00
krasimir
710b8f1bf7 the abstract syntax for Predef.gf is now hard-coded in AppPredefined.hs 2010-07-01 15:38:16 +00:00
krasimir
e0231cbf5b reorganize the modules in GF.Compile.* 2010-07-01 14:19:32 +00:00