mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-04-22 19:22:50 -06:00
started documentation of gfcc
This commit is contained in:
13
src/GF/Canon/GFCC/doc/Eng.gf
Normal file
13
src/GF/Canon/GFCC/doc/Eng.gf
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
concrete Eng of Ex = {
|
||||||
|
lincat
|
||||||
|
S = {s : Str} ;
|
||||||
|
NP = {s : Str ; n : Num} ;
|
||||||
|
VP = {s : Num => Str} ;
|
||||||
|
param
|
||||||
|
Num = Sg | Pl ;
|
||||||
|
lin
|
||||||
|
Pred np vp = {s = np.s ++ vp.s ! np.n} ;
|
||||||
|
She = {s = "she" ; n = Sg} ;
|
||||||
|
They = {s = "they" ; n = Pl} ;
|
||||||
|
Sleep = {s = table {Sg => "sleeps" ; Pl => "sleep"}} ;
|
||||||
|
}
|
||||||
8
src/GF/Canon/GFCC/doc/Ex.gf
Normal file
8
src/GF/Canon/GFCC/doc/Ex.gf
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
abstract Ex = {
|
||||||
|
cat
|
||||||
|
S ; NP ; VP ;
|
||||||
|
fun
|
||||||
|
Pred : NP -> VP -> S ;
|
||||||
|
She, They : NP ;
|
||||||
|
Sleep : VP ;
|
||||||
|
}
|
||||||
13
src/GF/Canon/GFCC/doc/Swe.gf
Normal file
13
src/GF/Canon/GFCC/doc/Swe.gf
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
concrete Swe of Ex = {
|
||||||
|
lincat
|
||||||
|
S = {s : Str} ;
|
||||||
|
NP = {s : Str} ;
|
||||||
|
VP = {s : Str} ;
|
||||||
|
param
|
||||||
|
Num = Sg | Pl ;
|
||||||
|
lin
|
||||||
|
Pred np vp = {s = np.s ++ vp.s} ;
|
||||||
|
She = {s = "hon"} ;
|
||||||
|
They = {s = "de"} ;
|
||||||
|
Sleep = {s = "sover"} ;
|
||||||
|
}
|
||||||
76
src/GF/Canon/GFCC/doc/gfcc.txt
Normal file
76
src/GF/Canon/GFCC/doc/gfcc.txt
Normal file
@@ -0,0 +1,76 @@
|
|||||||
|
The GFCC Grammar Format
|
||||||
|
|
||||||
|
GFCC is a low-level format for GF grammars. Its aim is to contain the minimum
|
||||||
|
that is needed to process GF grammars at runtime. This minimality has three
|
||||||
|
advantages:
|
||||||
|
- compact grammar files and run-time objects
|
||||||
|
- efficient processing
|
||||||
|
- simple definition of interpreters
|
||||||
|
|
||||||
|
|
||||||
|
GFCC is aimed to replace GFC as the run-time grammar format. GFC is designed
|
||||||
|
to support separate compilation of grammars, to store the results of compiling
|
||||||
|
individual GF modules. But this means it has to contain extra information,
|
||||||
|
such as type information, which is only needed in compilation and not at
|
||||||
|
run-time. In particular, the pattern matching syntax and semantics of GFC is
|
||||||
|
complex and therefore difficult to implement in new platforms.
|
||||||
|
|
||||||
|
The main novelties of GFCC compared with GFC can be summarized as follows:
|
||||||
|
- a GFCC grammar is multilingual, and consists of a common abstract syntax
|
||||||
|
together with one concrete syntax per language
|
||||||
|
- there are no modules, and therefore no qualified names
|
||||||
|
- records and tables are replaced by arrays
|
||||||
|
- record projection and table selection are replaced by array indexing
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Here is an example of a GF grammar, consisting of three modules,
|
||||||
|
as translated to GFCC.
|
||||||
|
```
|
||||||
|
grammar Ex (Eng Swe);
|
||||||
|
|
||||||
|
abstract Ex = { abstract {
|
||||||
|
cat
|
||||||
|
S ; NP ; VP ;
|
||||||
|
fun
|
||||||
|
Pred : NP -> VP -> S ; Pred : NP VP -> S = (Pred);
|
||||||
|
She, They : NP ; She : -> NP = (She);
|
||||||
|
Sleep : VP ; Sleep : -> VP = (Sleep);
|
||||||
|
They : -> NP = (They);
|
||||||
|
} } ;
|
||||||
|
;
|
||||||
|
concrete Eng of Ex = { concrete Eng {
|
||||||
|
lincat
|
||||||
|
S = {s : Str} ;
|
||||||
|
NP = {s : Str ; n : Num} ;
|
||||||
|
VP = {s : Num => Str} ;
|
||||||
|
param
|
||||||
|
Num = Sg | Pl ;
|
||||||
|
lin
|
||||||
|
Pred np vp = { Pred = [($0[1], $1[0][$0[0]])] ;
|
||||||
|
s = np.s ++ vp.s ! np.n} ;
|
||||||
|
She = {s = "she" ; n = Sg} ; She = [0, "she"];
|
||||||
|
They = {s = "they" ; n = Pl} ;
|
||||||
|
Sleep = {s = table { Sleep = [("sleep" + ["s",""])];
|
||||||
|
Sg => "sleeps" ;
|
||||||
|
Pl => "sleep" They = [1, "they"];
|
||||||
|
} } ;
|
||||||
|
} ;
|
||||||
|
}
|
||||||
|
|
||||||
|
concrete Swe of Ex = { concrete Swe {
|
||||||
|
lincat
|
||||||
|
S = {s : Str} ;
|
||||||
|
NP = {s : Str} ;
|
||||||
|
VP = {s : Str} ;
|
||||||
|
param
|
||||||
|
Num = Sg | Pl ;
|
||||||
|
lin
|
||||||
|
Pred np vp = { Pred = [($0[1], $1[0])];
|
||||||
|
s = np.s ++ vp.s} ;
|
||||||
|
She = {s = "hon"} ; She = ["hon"];
|
||||||
|
They = {s = "de"} ; They = ["de"];
|
||||||
|
Sleep = {s = "sover"} ; Sleep = ["sover"];
|
||||||
|
} ;
|
||||||
|
} ;
|
||||||
|
```
|
||||||
Reference in New Issue
Block a user