From 2fc45de8c29b6d023c548793f17f4cb55bb04b79 Mon Sep 17 00:00:00 2001 From: aarne Date: Mon, 2 Oct 2006 15:40:15 +0000 Subject: [PATCH] started documentation of gfcc --- src/GF/Canon/GFCC/doc/Eng.gf | 13 ++++++ src/GF/Canon/GFCC/doc/Ex.gf | 8 ++++ src/GF/Canon/GFCC/doc/Swe.gf | 13 ++++++ src/GF/Canon/GFCC/doc/gfcc.txt | 76 ++++++++++++++++++++++++++++++++++ 4 files changed, 110 insertions(+) create mode 100644 src/GF/Canon/GFCC/doc/Eng.gf create mode 100644 src/GF/Canon/GFCC/doc/Ex.gf create mode 100644 src/GF/Canon/GFCC/doc/Swe.gf create mode 100644 src/GF/Canon/GFCC/doc/gfcc.txt diff --git a/src/GF/Canon/GFCC/doc/Eng.gf b/src/GF/Canon/GFCC/doc/Eng.gf new file mode 100644 index 000000000..c64f46313 --- /dev/null +++ b/src/GF/Canon/GFCC/doc/Eng.gf @@ -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"}} ; +} diff --git a/src/GF/Canon/GFCC/doc/Ex.gf b/src/GF/Canon/GFCC/doc/Ex.gf new file mode 100644 index 000000000..bd0b03483 --- /dev/null +++ b/src/GF/Canon/GFCC/doc/Ex.gf @@ -0,0 +1,8 @@ +abstract Ex = { + cat + S ; NP ; VP ; + fun + Pred : NP -> VP -> S ; + She, They : NP ; + Sleep : VP ; +} diff --git a/src/GF/Canon/GFCC/doc/Swe.gf b/src/GF/Canon/GFCC/doc/Swe.gf new file mode 100644 index 000000000..1d6672371 --- /dev/null +++ b/src/GF/Canon/GFCC/doc/Swe.gf @@ -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"} ; +} diff --git a/src/GF/Canon/GFCC/doc/gfcc.txt b/src/GF/Canon/GFCC/doc/gfcc.txt new file mode 100644 index 000000000..cb38793e5 --- /dev/null +++ b/src/GF/Canon/GFCC/doc/gfcc.txt @@ -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"]; + } ; +} ; +```