Commit Graph

53 Commits

Author SHA1 Message Date
krangelov
c3eb6973f4 working PMCFG generation 2021-10-13 19:14:56 +02:00
krangelov
62d5ed5b42 small progress on PMCFG 2021-10-08 19:25:21 +02:00
krangelov
2a2d7269cf remove the Term(Error) constructor. Better propagation of errors. 2021-10-05 19:31:12 +02:00
krangelov
3dc2af61a6 done with partial evaluation for records and variants 2021-09-24 15:00:34 +02:00
krangelov
155657709a Merge branch 'master' into c-runtime 2021-07-30 11:20:04 +02:00
John J. Camilleri
f2e52d6f2c Replace tabs for whitespace in source code 2021-07-07 09:40:41 +02:00
John J. Camilleri
5d7c687cb7 Make imports in CheckGrammar a little more explicit 2021-07-01 14:32:39 +02:00
John J. Camilleri
376b1234a2 Rename GF.Compile.TypeCheck.RConcrete to GF.Compile.TypeCheck.Concrete 2021-07-01 14:27:11 +02:00
John J. Camilleri
71d99b9ecb Rename GF.Compile.Compute.ConcreteNew to GF.Compile.Compute.Concrete 2021-07-01 14:21:29 +02:00
krangelov
eece3e86b3 Merge branch 'master' into c-runtime 2019-09-20 16:19:08 +02:00
krangelov
30eef61f0a more dead code 2019-09-20 16:15:28 +02:00
krangelov
a27bcb8092 Merge branch 'master' into c-runtime 2019-09-20 10:42:50 +02:00
krangelov
4d79aa8b19 remove obsolete code 2019-09-20 10:37:50 +02:00
krangelov
4a71464ca7 Merge with master and drop the Haskell runtime completely 2019-09-19 22:01:57 +02:00
Thomas Hallgren
bea6aa1d2d GF.Compile.CheckGrammar: discard bad 'lincat C = …' with a warning
e.g. if C is a fun and not a cat in the abstract syntax.
Discarding bad lincats prevents GF from generating malformed PGFs that
are rejected by the C run-time system.
I also added code to reject bad lincats with an error, but I left it
commented out since it seems a bit pedantic compared to GF's otherwise
rather sloppy grammar checking.
2019-04-25 17:02:42 +02:00
Krasimir Angelov
5a2b200948 manually copy the "c-runtime" branch from the old repository. 2018-11-02 14:38:44 +01:00
Thomas Hallgren
820d2d503f Fixes for GHC 8.4.1 compatibility
* In GHC 8.4.1, the operator <> has become a method of the Semigroup class
  and is exported from the Prelude. This is unfortunate, since <> is also
  exported from the standard library module Text.PrettyPrint, so in any
  module that defines a pretty printer, there is likely to be an ambiguity.

  This affects ~18 modules in GF. Solution:

    import Prelude hiding (<>)

  This works also in older versions of GHC, since GHC does't complain if
  you hide something that doesn't exists.

* In GHC 8.4.1, Semigroup has become a superclass of Monoid. This means
  that anywhere you define an instance of the Monoid class you also have to
  define an instance in the Semigroup class.

  This affects Data.Binary.Builder in GF. Solution: conditionally define
  a Semigroup instance if compiling with base>=4.11 (ghc>=8.4.1)
2018-04-18 19:18:10 +02:00
krasimir
47eb774cdf the experimental type checker in GF.Compile.TypeCheck.ConcreteNew is now rewriten to use the complete evaluator in GF.Compile.Compute.ConcreteNew. The old sketchy implementation in GF.Compile.Compute.ConcreteNew1 is now removed. 2016-03-02 13:38:02 +00:00
krasimir
f848857519 added option -plus-as-bind which treats (+) as a bind when used with runtime variables 2015-02-20 13:26:12 +00:00
hallgren
391b301881 ModuleName and Ident are now distinct types
This makes the documentation clearer, and can potentially catch more
programming mistakes.
2014-10-21 19:20:31 +00:00
hallgren
8dfaf2ef65 Command line flag -s/-q now silences all warnings
These flags now do what the say.
2014-08-22 00:30:33 +00:00
hallgren
30cda51516 Introducing GF.Text.Pretty for more concise pretty printers and 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-07-27 22:06:23 +00:00
aarne
6f03e517c8 experimental type checker module GF.Compile.TypeCheck.RConcrete.hs with 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. 2014-01-31 20:28:25 +00:00
hallgren
a98f4aa4be Show relative file paths in error messages
This is to avoid one trivial reason for failures in the test suite.
2013-12-06 15:43:34 +00:00
hallgren
71c1741046 GF.Compile.CheckGrammar: add source path to error message for circular definitions 2013-12-06 13:46:59 +00:00
hallgren
3f57151cc3 Represent identifiers as UTF-8-encoded ByteStrings
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-26 16:12:03 +00:00
hallgren
018c9838ed Reduced clutter in monadic code
+ 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-20 00:45:33 +00:00
hallgren
3814841d7d Eliminate mutual dependencies between the GF compiler and the PGF library
+ 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-11-05 13:11:10 +00:00
kr.angelov
042243f08a added the linref construction in GF. The PGF version number is now bumped 2013-10-30 12:53:36 +00:00
hallgren
5bce1d7a16 gf -s/-q now silences "no linearization of" warnings 2013-04-10 23:00:01 +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
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
1195db1da3 Consistenly use SourceGrammar instead of [SourceModule] when calling compiler passes 2012-10-19 19:56:00 +00:00
hallgren
241bef8a51 Experiment with parallel grammar checks
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-26 17:01:15 +00:00
hallgren
b094274c0e Report many type errors instead of stopping after the first one
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-26 14:46:18 +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
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
4f95b5656b bugfix in the overload resolution. It was accidentally introduced as part of the per module PMCFG generation 2011-11-17 21:36:45 +00:00
kr.angelov
61c16f2eb2 more structured format for errors and warnings from the compiler 2011-11-15 13:33:44 +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
ba10b5b0ca GF.Infra.Modules: keep the modules of a grammar in a finite map instead of a list
This speeds up the compilation of PhrasebookFin.pgf by 12%, mosly by speeding
up calls to lookupModule in calls from lookupParamValues, in calls
from allParamValues.

The invariant "modules are stored in dependency order" is no longer respected!
But the type MGrammar is now abstract, making it easier to maintain this or
other invariants in the future.
2011-08-30 18:54:50 +00:00
krasimir
115b4213d5 operations in the abstract syntax 2010-11-12 19:37:19 +00:00
krasimir
e0231cbf5b reorganize the modules in GF.Compile.* 2010-07-01 14:19:32 +00:00
krasimir
c3f4c3eba7 refactoring in GF.Grammar.Grammar 2010-05-28 14:15:15 +00:00
krasimir
76d155af0e typo in CheckGrammar 2010-03-23 15:35:32 +00:00
krasimir
c80c403da2 use the new more accurate location information for some error messages 2010-03-23 15:24:48 +00:00