13/10/2003 - 25/11
GF1 grammars can be automatically translated to GF2 (although result not as good as manual, since indentation and comments are destroyed). The results can be saved in GF2 files, but this is not necessary.
Example grammars and resource libraries are in the process of being converted. There will be a new API with many new constructions. The new versions lie in grammars/newresource. English and Swedish resources are up-to-date. In the old API version, grammars/resource, the other languages are up-to-date.
A make facility works, finding out which modules have to be recompiled.
There is some room for improvement.
Bug.
Sometimes the grammar compiler gets confused if there are many
grammars open simultaneously. Then the advice is to empty
the environment (using e) and compile grammar one by one.
When read from gfc versions, there should be no problems
to have several grammars simultaneously.
The module type grammar (to build multilingual grammars) not yet implemented. transfer modules have to be called by flags
Abstract modules (interface, instance, and incomplete) have not been stress-tested, but work in the examples in resource/romance and resource/french.
Soundness checking of module depencencies and completeness is not complete.
i -old tut1.Eng.g2This generates, internally, three modules:
abstract tut1 = ... resource ResEng = ... concrete Eng of tut1 = open ResEng in ...(The names are different if the file name has fewer parts.)
The option -o causes GF2 to write these modules into files.
The flags -abs, -cnc, and -res can be used to give custom names to the modules. In particular, it is good to use the -abs flag to guarantee that the abstract syntax module has the same name for all grammars in a multilingual environmens:
i -old -abs=Numerals hungarian.gf i -old -abs=Numerals tamil.gf i -old -abs=Numerals sanskrit.gf
The same flags as in the import command can be used when invoking GF2 from the system shell. Many grammars can be imported on the same command line, e.g.
% gf2 -old -abs=Tutorial tut1.Eng.gf tut1.Fin.gf tut1.Fra.gf
GF2 has more reserved words than GF 1.2. When old files are read, a preprocessor replaces every identifier that has the shape of a new reserved word with a variant where the last letter is replaced by Z, e.g. instance is replaced by instancZ. This method is of course unsafe and should be replaced by something better.
abstract Sums = {
cat
Exp ;
fun
One : Exp ;
plus : Exp -> Exp -> Exp ;
}
concrete EnglishSums of Sums = open ResEng in {
lincat
Exp = {s : Str ; n : Number} ;
lin
One = expSg "one" ;
sum x y = expSg ("the" ++ "sum" ++ "of" ++ x.s ++ "and" ++ y.s) ;
}
resource ResEng = {
param
Number = Sg | Pl ;
oper
expSG : Str -> {s : Str ; n : Number} = \s -> {s = s ; n = Sg} ;
}
abstract Products = Sums ** {
fun times : Exp -> Exp -> Exp ;
}
-- names exported: Exp, plus, times
concrete English of Products = EnglishSums ** open ResEng in {
lin times x y = expSg ("the" ++ "product" ++ "of" ++ x.s ++ "and" ++ y.s) ;
}
Another important difference:
Moreover:
Example of qualified opening:
concrete NumberSystems of Systems = open (Bin = Binary), (Dec = Decimal) in {
lin
BZero = Bin.Zero ;
DZero = Dec.Zero
}
The module header is the beginning of the module code up to the first left bracket ({). The header gives
filename = modulename . extension
File name extensions:
What the make facility does when compiling Foo.gf