1
0
forked from GitHub/gf-core
Commit Graph

545 Commits

Author SHA1 Message Date
hallgren
831be9393a Documentation improvements and cleanup relating to the IOE monad
Renamed appIOE to tryIOE (it is analogous to 'try' in the standard libraries).
Removed unused IOE operations & documented the remaining ones.
Removed/simplified superfluous uses of IOE operations.
2014-11-10 16:20:01 +00:00
hallgren
c02fef9b6a Some work to improve the structure of the haddock documenation 2014-11-10 15:23:02 +00:00
kr.angelov
2bde418b15 now (+) in the abstract syntax works, i.e. it knows how to deal with partial sums 2014-10-31 14:16:11 +00:00
kr.angelov
4db6e30b54 a more efficient tail call by using the new TUCK instruction 2014-10-30 13:09:50 +00:00
hallgren
fd1c6a0a17 Use terminfo to highlight warnings and errors in blue and red
This replaces the hardwired ANSI escape codes that were accidentally included
in a previous patch.

This adds a dependency on terminfo, but this should be unproblematic, since
haskeline already depends on the same underlying C library.

The color highlighting is omitted on Windows.
2014-10-28 19:04:48 +00:00
hallgren
14850cd7f4 Show paths relative to the current directory in progress reports
It is much nicer to see something like

- compiling FoodsSwe.gf...   write file FoodsSwe.gfo
- compiling FoodsTha.gf...   write file FoodsTha.gfo
- compiling FoodsTsn.gf...   write file FoodsTsn.gfo
- compiling FoodsTur.gf...   write file FoodsTur.gfo
- compiling FoodsUrd.gf...   write file FoodsUrd.gfo
linking ... OK
Writing Foods.pgf...

instead of

- compiling /Users/hallgren/src/GF/gf/examples/foods/FoodsSwe.gf...   write file /Users/hallgren/src/GF/gf/examples/foods/FoodsSwe.gfo
- compiling /Users/hallgren/src/GF/gf/examples/foods/FoodsTha.gf...   write file /Users/hallgren/src/GF/gf/examples/foods/FoodsTha.gfo
- compiling /Users/hallgren/src/GF/gf/examples/foods/FoodsTsn.gf...   write file /Users/hallgren/src/GF/gf/examples/foods/FoodsTsn.gfo
- compiling /Users/hallgren/src/GF/gf/examples/foods/FoodsTur.gf...   write file /Users/hallgren/src/GF/gf/examples/foods/FoodsTur.gfo
- compiling /Users/hallgren/src/GF/gf/examples/foods/FoodsUrd.gf...   write file /Users/hallgren/src/GF/gf/examples/foods/FoodsUrd.gfo
linking ... OK
Writing Foods.pgf...
2014-10-28 15:02:29 +00:00
hallgren
5480c9b4dc A couple of haddock documentation improvements 2014-10-28 14:58:43 +00:00
kr.angelov
77d3775385 an explicit SAVE instruction 2014-10-26 11:40:12 +00:00
hallgren
11ec4bc655 Various small changes for improved documentation 2014-10-22 15:45:52 +00:00
kr.angelov
0da379f97b an explicit PUSH_FRAME instruction 2014-10-22 14:11:41 +00:00
hallgren
1048a89ca7 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
491e8b2bb8 Renaming SourceGrammar to Grammar and similarly for some related types
Included renamings:

	SourceGrammar -> Grammar
	SourceModule -> Module
	SourceModInfo -> ModuleInfo
	emptySourceGrammar -> emptyGrammar

Also introduces a type synonym (which might be good to turn into a newtype):

	type ModuleName = Ident

The reason is to make types like the following more self documenting:

	type Module = (ModuleName,ModuleInfo)
	type QIdent = (ModuleName,Ident)
2014-10-21 14:42:31 +00:00
aarne
fe6d2738a0 use of 'head' in TypeCheck/RConcrete created an uncomprehensible error message. Now checking for the emptiness of the list concerned, so that the error can be found. 2014-10-20 20:06:46 +00:00
hallgren
1e0d078ae2 Some small documentation improvements 2014-10-20 19:45:43 +00:00
hallgren
add8f9285b type IOE a = IO a
IOE used to be a monad with extra error handling built on top of the IO monad,
But the IO monad already supports error handling, so this construction was a
superfluous.

The new 'instance ErrorMonad IOE' is defined to preserve the previous error
handling behaviour, i.e. the function 'handle' only catches errors thrown with
'raise' (or 'fail') and not other errors in the IO monad.
2014-10-20 19:32:46 +00:00
hallgren
46e18b9291 Remove some dead code
* The following modules are no longer used and have been removed completely:

	GF.Compile.Compute.ConcreteLazy
	GF.Compile.Compute.ConcreteStrict
	GF.Compile.Refresh

* The STM monad has been commented out. It was only used in
  GF.Compile.SubExpOpt, where could be replaced with a plain State monad,
  since no error handling was needed. One of the functions was hardwired to
  the Err monad, but did in fact not use error handling, so it was turned
  into a pure function.

* The function errVal has been renamed to fromErr (since it is analogous to
  fromMaybe).

* Replaced 'fail' with 'raise' and 'return ()' with 'done' in a few places.

* Some additional old code that was already commented out has been removed.
2014-10-20 15:05:43 +00:00
aarne
0025e078ea (un)lexmixed: added the other math environments than $ used in latex 2014-10-19 17:43:39 +00:00
aarne
2cda0ea770 ps -lines preserves line-by-line structure when preprocessing files for parsing line by line 2014-10-17 15:50:03 +00:00
hallgren
c3e1d65fc1 Some work on the haddock documentation 2014-10-16 16:28:54 +00:00
hallgren
ede4a5a4c2 Turn the GF compiler into a library. Main program is now in src/programs/gf.hs
The module src/compiler/GF.hs now serves as a prelimiary compiler API. It just
exports a selection of functions and types from the compiler.

Haddock documentation can be generated with

	cabal haddock --hyperlink-source

Also bumbed the version number to 3.6.10.
2014-10-16 15:00:49 +00:00
hallgren
f109b44c97 More haddock documentation improvements 2014-10-16 14:03:57 +00:00
kr.angelov
76a448e26f finally proper stack unwind in the evaluator 2014-10-16 10:00:32 +00:00
hallgren
1d4215b822 Rename modules GFI, GFC & GFServer...
... to GF.Interactive, GF.Compiler & GF.Server, respectively.
2014-10-15 21:04:29 +00:00
hallgren
e0c0ff0020 Fixes for the haddock documentation 2014-10-15 20:42:36 +00:00
kr.angelov
6aa0fd2590 the compiler now allows + to be used as a floating point addition in the abstract syntax 2014-10-14 11:15:18 +00:00
kr.angelov
d42ffaa546 yet another bugfix in the byte code 2014-10-14 10:39:28 +00:00
kr.angelov
bc8cb8e9d7 another bugfix in the byte code generation 2014-10-14 09:43:43 +00:00
kr.angelov
e8b81c145b bugfix in the bytecode generator 2014-10-14 09:27:24 +00:00
kr.angelov
4efb2d5a22 Prelude.CAPIT is now a built-in primitive. It still generates &| in the Haskell runtime but will be intepreted in the C runtime 2014-10-09 19:34:12 +00:00
hallgren
d0441cf847 GF.Infra.Options: change from String to Int in the type of optJobs 2014-10-08 16:57:04 +00:00
kr.angelov
23642fbb90 now we statically allocate closures for all top-level functions and all nullary constructors. closures are dynamically allocated only for CAFs. this reduces memory use and time to allocate dynamic closures 2014-10-08 12:57:29 +00:00
kr.angelov
297403b350 bugfix in the byte code compiler 2014-10-07 20:03:54 +00:00
kr.angelov
8d09f62efc using instruction RET was wrong; now use EVAL 2014-10-06 15:57:42 +00:00
kr.angelov
2f7bd0306f minor stylistic change in GenerateBC 2014-09-29 15:08:00 +00:00
kr.angelov
698329f469 bugfix in the pattern matching compiler and a number of other fixes that I somehow did not push before 2014-09-29 15:00:04 +00:00
aarne
a757798656 checked that course of value tables (table P [...]) have the correct number of values w.r.t the type P. This was previously not checked, and caused hard-to-find run-time errors. 2014-09-27 17:14:35 +00:00
kr.angelov
4d6994ffde forgot to type check the type of a typed let expression 2014-09-17 22:25:08 +00:00
kr.angelov
4f23ed2289 appForm now skips over Typed expressions 2014-09-17 22:02:36 +00:00
kr.angelov
ff45e7dd3a the type checker for the abstract syntax now allows let expressions in def 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-17 21:59:45 +00:00
kr.angelov
923ad6b3c0 a major revision of the bytecode generator and JIT compiler. the effect is that now we can compute with lambda functions and with true tail recursion 2014-09-11 15:39:39 +00:00
hallgren
782bdf3a52 (1) Refactor concurrency, (2) write to .gfo.tmp then rename to .gfo
(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-09-08 15:43:20 +00:00
kr.angelov
d7dc541f74 the code for def rules now uses proper graph update to preserve lazyness 2014-09-05 11:53:02 +00:00
kr.angelov
5e5ad8f2db full support for recursive def rules in the C runtime 2014-09-05 10:09:43 +00:00
hallgren
0e87a88f4b src/server: refactoring to isolate dependencies on the cgi/fastcgi packages
* Introducing the module CGI, re-exporting a subset of the cgi package. It
  might complete replace the cgi package in the future.
* Introducing the module CGIUtils, containing functions from FastCGIUtils that
  have nothing to do with fastcgi.

Some low level hackery with unsafePerformIO and global variables was left
in FastCGIUtils, but it is actually not used, neither for gf -server nor
exec/pgf-fcgi.hs.
2014-09-02 12:27:47 +00:00
kr.angelov
442dadf100 partial implementation for recursive def rules 2014-09-01 14:51:20 +00:00
hallgren
20d5a89664 Fix GHC 7.4 compatibility issue caused by previous patch 2014-08-25 11:26:58 +00:00
hallgren
c0eb79b403 Experimental: parallel batch compilation of grammars
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-25 09:56:00 +00:00
hallgren
11105f81cd 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
e1644ef319 Add lifted directory operations in GF.System.Directory to eliminate the need for liftIO in various places 2014-08-20 17:47:08 +00:00
hallgren
ff960a27b8 GF.CompileOne: refactoring to reduce code duplication and improve readability
I prefer small functions with descriptive names over large monilithic chunks
of code, so I grouped the compiler passes called from compileSourceModule
into funcitons named frontend, middle and backend. This also makes decisions
about which passes to run clearly visible up front.

Also made some small changes in GF.Compile.
2014-08-20 17:04:15 +00:00