Common code has been lifted out from the generated Haskell modules to
an auxiliary module PGF.Haskell, which is currently included in the
regular PGF library, although it is independent of it and probably belongs
in a separate library.
The type Str used by linearization functions is now based on a token
type Tok, which is defined in PGF.Haskell.
PGF.Haskell.Tok is similar to the type GF.Data.Str.Tok, but it has
constructors for the special tokens BIND, SOFT_BIND and CAPIT, and there is
a function
fromStr :: Str -> String
that computes the effects of these special tokens.
+ Instead of including lists of parameter values generated by GF, generate
code to enumerate parameter values (in the same order as GF). This seems
to give a factor of 2-3 code size reduction in the Phrasebook (e.g.
from 84MB to 25MB for Hin, from 338MB to 154MB for Fre).
+ Deduplicate table entries, i.e. convert "table [..,E,..,E,..,E,..]" into
"let x = E in table [..,x,..,x,..,x,..]". This gives even more significant
code size reduction in some cases, e.g. from 569MB to 15MB for
PhrasebookFin.
All phrasebook languages can now be converted to compilable Haskell code,
except PhrasebookPes, which still has the name clash problem.
Many Phrasebook languages can now be converted to compilable Haskell code.
Some languages (Fre, Hin, Snd, Urd) generate too much Haskell code to be
practically useful (e.g. 338MB for Fre). One language (Fin) took too long
to convert to Haskell. One language (Pes) has problems with name clashes in
the generated Haskell code.
STILL TODO:
- variants
- pre { ... }
- reduce code duplication for large tables
- generate qualified names to avoid name clashes
The API in the C runtime as well as in the Haskell, Python and Java binding
is changed. Now instead of adding the literal callbacks to the concrete syntax
you need to supply them every time when you need to parse. The main reason is:
- referentially transparent API for Haskell
- when we start using memory mapped files we will not be allowed to change
anything in the grammar data structures. At that point the old API would
be impossible to use.
When mkPresent (or another preprocessor) is used, error messages from GF will
show the file name _gf_preproc.tmp instead of the name of the file where
the error occurred. By compiling Alltenses first, the real file name will
appear in error messages (unless the error only happens then mkPresent is
used).
The translation is currently good enough to translate all concrete syntaxes
of the Foods and Letter grammars, and some concrete syntaxes of the Phrasebook
grammar (e.g. PhrasebookEng & PhrasebookSpa works, but there are problems with
e.g. PhrasebookSwe and PhrasebookChi)
This functionality is enabled by running
gf -make -output-format=haskell -haskell=concrete ...
TODO:
- variants
- pre { ... }
- eta expansion of linearization functions
- record subtyping can still cause type errors in the Haskell code
in some cases
- reduce code large tables
It was used only in cases where a lock field needed to be added to a
run-time variable, like e.g. in examples/phrasebook/SentencesTha.gf:
lin
PGreetingMale g = mkText (lin Text g) (lin Text (ss "ครับ")) | g ;
PGreetingFemale g = mkText (lin Text g) (lin Text (ss "ค่ะ")) | g ;
But lock fields are only meaningful during type checking and can safely be
ignored in later passes.