1
0
forked from GitHub/gf-core

Add Phrasebook to testsuite. Move grammars into subfolders. Add run-bench script.

This commit is contained in:
John J. Camilleri
2021-02-20 13:22:29 +01:00
parent 5ad5789b31
commit dca2ebaf72
179 changed files with 20169 additions and 26 deletions

View File

@@ -0,0 +1,12 @@
abstract Bind = {
cat S ;
fun
f1 : S ;
f2 : S ;
concat : S -> S -> S ;
bind : S -> S -> S ;
softbind : S -> S -> S ;
softspace : S -> S -> S ;
capit : S -> S ;
allcapit : S -> S ;
}

View File

@@ -0,0 +1,20 @@
Bind: f1
BindCnc: hello there
Bind: f2
BindCnc: goodbye
Bind: concat f1 f2
BindCnc: hello there goodbye
Bind: bind f1 f2
BindCnc: hello theregoodbye
Bind: softbind f1 f2
BindCnc: hello theregoodbye
Bind: softspace f1 f2
BindCnc: hello there goodbye
Bind: concat (capit f1) (allcapit f2)
BindCnc: Hello there GOODBYE

View File

@@ -0,0 +1,7 @@
f1
f2
concat f1 f2
bind f1 f2
softbind f1 f2
softspace f1 f2
concat (capit f1) (allcapit f2)

View File

@@ -0,0 +1,13 @@
concrete BindCnc of Bind = open Prelude in {
lincat
S = SS ;
lin
f1 = ss ("hello the" ++ BIND ++ "re") ;
f2 = ss ("good" ++ SOFT_BIND ++ "bye") ;
concat a b = ss (a.s ++ b.s) ;
bind a b = ss (a.s ++ BIND ++ b.s) ;
softbind a b = ss (a.s ++ SOFT_BIND ++ b.s) ;
softspace a b = ss (a.s ++ SOFT_SPACE ++ b.s) ;
capit a = ss (CAPIT ++ a.s) ;
allcapit a = ss (ALL_CAPIT ++ a.s) ;
}

View File

@@ -0,0 +1,7 @@
abstract Params = {
cat S ; F ;
fun
FtoS : F -> S ;
f1 : F ;
f2 : F ;
}

View File

@@ -0,0 +1,5 @@
Params: FtoS f1
ParamsCnc: PR R1 Q1
Params: FtoS f2
ParamsCnc: PR R2 _

View File

@@ -0,0 +1,21 @@
concrete ParamsCnc of Params = {
param
R = R1 | R2 ;
P = PR R Q | PP ;
Q = Q3 | Q2 | Q1 ;
lincat
S = Str ;
F = { r : R } ;
lin
f1 = { r = R1 } ;
f2 = { r = R2 } ;
FtoS f = tbl ! PR f.r Q1 ;
oper
tbl = table {
PR R1 Q2 => "PR R1 Q2" ;
PR R1 Q1 => "PR R1 Q1" ;
PR R1 Q3 => "PR R1 Q3" ;
PR R2 _ => "PR R2 _" ;
PP => "PP"
} ;
}

View File

@@ -0,0 +1,8 @@
abstract Pre = {
cat S; N; Det;
fun
ant, dog: N ;
a, the: Det ;
mkS : Det -> N -> S;
detS : Det -> S;
}

View File

@@ -0,0 +1,17 @@
Pre: mkS a ant
PreCnc: an ant
Pre: mkS the ant
PreCnc: the ant
Pre: mkS a dog
PreCnc: a dog
Pre: mkS the dog
PreCnc: the dog
Pre: detS a
PreCnc: a
Pre: detS the
PreCnc: the

View File

@@ -0,0 +1,6 @@
mkS a ant
mkS the ant
mkS a dog
mkS the dog
detS a
detS the

View File

@@ -0,0 +1,16 @@
concrete PreCnc of Pre = {
lincat
S = { s : Str } ;
N = { s : Str } ;
Det = { s : Str } ;
lin
ant = { s = "ant" } ;
dog = { s = "dog" } ;
a = { s = pre {
"a"|"e"|"i"|"o"|"u" => "an" ;
_ => "a"
} } ;
the = { s = "the" } ;
mkS det n = { s = det.s ++ n.s } ;
detS det = { s = det.s } ;
}

View File

@@ -0,0 +1,8 @@
abstract Projection = {
flags startcat = Comment ;
cat
Comment ; Item ;
fun
Pred : Item -> Comment ;
Wine : Item ;
}

View File

@@ -0,0 +1,3 @@
Projection: Pred Wine
ProjectionCnc: ce vin

View File

@@ -0,0 +1 @@
Pred Wine

View File

@@ -0,0 +1,20 @@
concrete ProjectionCnc of Projection = {
-- param Case = Nom | Acc ;
lincat
Comment = {s : Str} ;
Item = {
-- s : Case => {comp : Str} ;
nom : {comp: Str}
} ;
lin
Wine = {
-- s = table {
-- Nom => {comp = "ce" ++ "vin"} ;
-- Acc => {comp = "ce" ++ "vin"}
-- } ;
nom = {comp = "ce" ++ "vin"} ;
} ;
-- Pred item = { s = ((item.s)!Nom).comp } ;
Pred item = { s = (item.nom).comp } ;
}

View File

@@ -0,0 +1,6 @@
abstract Tables = {
cat S ; F ;
fun
FtoS : F -> S ;
f1, f2, f3, f4, f5, f6 : F ;
}

View File

@@ -0,0 +1,17 @@
Tables: FtoS f1
TablesCnc: R1 _
Tables: FtoS f2
TablesCnc: R1 _
Tables: FtoS f3
TablesCnc: R1 _
Tables: FtoS f4
TablesCnc: _ _
Tables: FtoS f5
TablesCnc: _ Q2
Tables: FtoS f6
TablesCnc: R2 Q3

View File

@@ -0,0 +1,26 @@
concrete TablesCnc of Tables = {
param
R = R1 | R2 ;
Q = Q3 | Q2 | Q1 ;
oper
ParamRec: Type = { r: R; q: Q } ;
lincat
S = Str ;
F = { pr : ParamRec } ;
lin
f1 = { pr = { r = R1; q = Q1 } } ;
f2 = { pr = { r = R1; q = Q2 } } ;
f3 = { pr = { r = R1; q = Q3 } } ;
f4 = { pr = { r = R2; q = Q1 } } ;
f5 = { pr = { r = R2; q = Q2 } } ;
f6 = { pr = { r = R2; q = Q3 } } ;
FtoS f = tbl ! f.pr ;
oper
tbl = table {
{ r = R1 ; q = _ } => "R1 _" ;
{ r = _ ; q = Q2 } => "_ Q2" ;
{ r = R2 ; q = Q3 } => "R2 Q3" ;
_ => "_ _"
} ;
}