forked from GitHub/gf-core
Add Phrasebook to testsuite. Move grammars into subfolders. Add run-bench script.
This commit is contained in:
12
testsuite/lpgf/unittests/Bind.gf
Normal file
12
testsuite/lpgf/unittests/Bind.gf
Normal 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 ;
|
||||
}
|
||||
20
testsuite/lpgf/unittests/Bind.treebank
Normal file
20
testsuite/lpgf/unittests/Bind.treebank
Normal 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
|
||||
7
testsuite/lpgf/unittests/Bind.trees
Normal file
7
testsuite/lpgf/unittests/Bind.trees
Normal file
@@ -0,0 +1,7 @@
|
||||
f1
|
||||
f2
|
||||
concat f1 f2
|
||||
bind f1 f2
|
||||
softbind f1 f2
|
||||
softspace f1 f2
|
||||
concat (capit f1) (allcapit f2)
|
||||
13
testsuite/lpgf/unittests/BindCnc.gf
Normal file
13
testsuite/lpgf/unittests/BindCnc.gf
Normal 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) ;
|
||||
}
|
||||
7
testsuite/lpgf/unittests/Params.gf
Normal file
7
testsuite/lpgf/unittests/Params.gf
Normal file
@@ -0,0 +1,7 @@
|
||||
abstract Params = {
|
||||
cat S ; F ;
|
||||
fun
|
||||
FtoS : F -> S ;
|
||||
f1 : F ;
|
||||
f2 : F ;
|
||||
}
|
||||
5
testsuite/lpgf/unittests/Params.treebank
Normal file
5
testsuite/lpgf/unittests/Params.treebank
Normal file
@@ -0,0 +1,5 @@
|
||||
Params: FtoS f1
|
||||
ParamsCnc: PR R1 Q1
|
||||
|
||||
Params: FtoS f2
|
||||
ParamsCnc: PR R2 _
|
||||
21
testsuite/lpgf/unittests/ParamsCnc.gf
Normal file
21
testsuite/lpgf/unittests/ParamsCnc.gf
Normal 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"
|
||||
} ;
|
||||
}
|
||||
8
testsuite/lpgf/unittests/Pre.gf
Normal file
8
testsuite/lpgf/unittests/Pre.gf
Normal 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;
|
||||
}
|
||||
17
testsuite/lpgf/unittests/Pre.treebank
Normal file
17
testsuite/lpgf/unittests/Pre.treebank
Normal 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
|
||||
6
testsuite/lpgf/unittests/Pre.trees
Normal file
6
testsuite/lpgf/unittests/Pre.trees
Normal file
@@ -0,0 +1,6 @@
|
||||
mkS a ant
|
||||
mkS the ant
|
||||
mkS a dog
|
||||
mkS the dog
|
||||
detS a
|
||||
detS the
|
||||
16
testsuite/lpgf/unittests/PreCnc.gf
Normal file
16
testsuite/lpgf/unittests/PreCnc.gf
Normal 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 } ;
|
||||
}
|
||||
8
testsuite/lpgf/unittests/Projection.gf
Normal file
8
testsuite/lpgf/unittests/Projection.gf
Normal file
@@ -0,0 +1,8 @@
|
||||
abstract Projection = {
|
||||
flags startcat = Comment ;
|
||||
cat
|
||||
Comment ; Item ;
|
||||
fun
|
||||
Pred : Item -> Comment ;
|
||||
Wine : Item ;
|
||||
}
|
||||
3
testsuite/lpgf/unittests/Projection.treebank
Normal file
3
testsuite/lpgf/unittests/Projection.treebank
Normal file
@@ -0,0 +1,3 @@
|
||||
Projection: Pred Wine
|
||||
ProjectionCnc: ce vin
|
||||
|
||||
1
testsuite/lpgf/unittests/Projection.trees
Normal file
1
testsuite/lpgf/unittests/Projection.trees
Normal file
@@ -0,0 +1 @@
|
||||
Pred Wine
|
||||
20
testsuite/lpgf/unittests/ProjectionCnc.gf
Normal file
20
testsuite/lpgf/unittests/ProjectionCnc.gf
Normal 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 } ;
|
||||
}
|
||||
6
testsuite/lpgf/unittests/Tables.gf
Normal file
6
testsuite/lpgf/unittests/Tables.gf
Normal file
@@ -0,0 +1,6 @@
|
||||
abstract Tables = {
|
||||
cat S ; F ;
|
||||
fun
|
||||
FtoS : F -> S ;
|
||||
f1, f2, f3, f4, f5, f6 : F ;
|
||||
}
|
||||
17
testsuite/lpgf/unittests/Tables.treebank
Normal file
17
testsuite/lpgf/unittests/Tables.treebank
Normal 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
|
||||
26
testsuite/lpgf/unittests/TablesCnc.gf
Normal file
26
testsuite/lpgf/unittests/TablesCnc.gf
Normal 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" ;
|
||||
_ => "_ _"
|
||||
} ;
|
||||
}
|
||||
Reference in New Issue
Block a user