forked from GitHub/gf-core
started a subdir for the book
This commit is contained in:
7
book/examples/chapter2/Copy.gf
Normal file
7
book/examples/chapter2/Copy.gf
Normal file
@@ -0,0 +1,7 @@
|
||||
concrete Copy of CopyAbs = {
|
||||
lincat S, AB = Str ;
|
||||
lin s x = x ++ x ;
|
||||
end = [] ;
|
||||
a x = "a" ++ x ;
|
||||
b x = "b" ++ x ;
|
||||
}
|
||||
6
book/examples/chapter2/CopyAbs.gf
Normal file
6
book/examples/chapter2/CopyAbs.gf
Normal file
@@ -0,0 +1,6 @@
|
||||
abstract CopyAbs = {
|
||||
cat S ; AB ;
|
||||
fun s : AB -> S ;
|
||||
end : AB ;
|
||||
a,b : AB -> AB ;
|
||||
}
|
||||
13
book/examples/chapter2/Food.gf
Normal file
13
book/examples/chapter2/Food.gf
Normal file
@@ -0,0 +1,13 @@
|
||||
abstract Food = {
|
||||
flags startcat = Comment ;
|
||||
cat
|
||||
Comment ; Item ; Kind ; Quality ;
|
||||
fun
|
||||
Pred : Item -> Quality -> Comment ;
|
||||
This, That : Kind -> Item ;
|
||||
Mod : Quality -> Kind -> Kind ;
|
||||
Wine, Cheese, Fish : Kind ;
|
||||
Very : Quality -> Quality ;
|
||||
Fresh, Warm, Italian,
|
||||
Expensive, Delicious, Boring : Quality ;
|
||||
}
|
||||
19
book/examples/chapter2/FoodEng.gf
Normal file
19
book/examples/chapter2/FoodEng.gf
Normal file
@@ -0,0 +1,19 @@
|
||||
concrete FoodEng of Food = {
|
||||
lincat
|
||||
Comment, Item, Kind, Quality = Str ;
|
||||
lin
|
||||
Pred item quality = item ++ "is" ++ quality ;
|
||||
This kind = "this" ++ kind ;
|
||||
That kind = "that" ++ kind ;
|
||||
Mod quality kind = quality ++ kind ;
|
||||
Wine = "wine" ;
|
||||
Cheese = "cheese" ;
|
||||
Fish = "fish" ;
|
||||
Very quality = "very" ++ quality ;
|
||||
Fresh = "fresh" ;
|
||||
Warm = "warm" ;
|
||||
Italian = "Italian" ;
|
||||
Expensive = "expensive" ;
|
||||
Delicious = "delicious" ;
|
||||
Boring = "boring" ;
|
||||
}
|
||||
24
book/examples/chapter2/FoodHin.gf
Normal file
24
book/examples/chapter2/FoodHin.gf
Normal file
@@ -0,0 +1,24 @@
|
||||
|
||||
concrete FoodHin of Food = {
|
||||
flags coding = utf8 ;
|
||||
lincat Comment, Item, Kind, Quality = Str ;
|
||||
lin
|
||||
Pred item quality = item ++ quality ++ "है" ;
|
||||
This kind = "यह" ++ kind ;
|
||||
That kind = "वह" ++ kind ;
|
||||
Mod quality kind = quality ++ kind ;
|
||||
Wine = "मदिरा" ;
|
||||
Cheese = "पनीर" ;
|
||||
Fish = "मछली" ;
|
||||
Very quality = "अति" ++ quality ;
|
||||
Fresh = "ताज़ा" ;
|
||||
Warm = "गरम" ;
|
||||
Italian = "इटली" ;
|
||||
Expensive = "बहुमूल्य" ;
|
||||
Delicious = "स्वादिष्ट" ;
|
||||
Boring = "अरुचिकर" ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
19
book/examples/chapter2/FoodIta.gf
Normal file
19
book/examples/chapter2/FoodIta.gf
Normal file
@@ -0,0 +1,19 @@
|
||||
concrete FoodIta of Food = {
|
||||
lincat
|
||||
Comment, Item, Kind, Quality = Str ;
|
||||
lin
|
||||
Pred item quality = item ++ "è" ++ quality ;
|
||||
This kind = "questo" ++ kind ;
|
||||
That kind = "quel" ++ kind ;
|
||||
Mod quality kind = kind ++ quality ;
|
||||
Wine = "vino" ;
|
||||
Cheese = "formaggio" ;
|
||||
Fish = "pesce" ;
|
||||
Very quality = "molto" ++ quality ;
|
||||
Fresh = "fresco" ;
|
||||
Warm = "caldo" ;
|
||||
Italian = "italiano" ;
|
||||
Expensive = "caro" ;
|
||||
Delicious = "delizioso" ;
|
||||
Boring = "noioso" ;
|
||||
}
|
||||
8
book/examples/chapter2/Letters.gf
Normal file
8
book/examples/chapter2/Letters.gf
Normal file
@@ -0,0 +1,8 @@
|
||||
abstract Letters = {
|
||||
|
||||
cat L ;
|
||||
fun
|
||||
a, b, c, d, e, f, g, h, i, j, k, l, m,
|
||||
n, o, p, q, r, s, t, u, v, w, x, y, z : L ;
|
||||
|
||||
}
|
||||
31
book/examples/chapter2/LettersCnc.gf
Normal file
31
book/examples/chapter2/LettersCnc.gf
Normal file
@@ -0,0 +1,31 @@
|
||||
concrete LettersCnc of Letters = {
|
||||
|
||||
lincat L = Str ;
|
||||
lin
|
||||
a = "a" ;
|
||||
b = "b" ;
|
||||
c = "c" ;
|
||||
d = "d" ;
|
||||
e = "e" ;
|
||||
f = "f" ;
|
||||
g = "g" ;
|
||||
h = "h" ;
|
||||
i = "i" ;
|
||||
j = "j" ;
|
||||
k = "k" ;
|
||||
l = "l" ;
|
||||
m = "m" ;
|
||||
n = "n" ;
|
||||
o = "o" ;
|
||||
p = "p" ;
|
||||
q = "q" ;
|
||||
r = "r" ;
|
||||
s = "s" ;
|
||||
t = "t" ;
|
||||
u = "u" ;
|
||||
v = "v" ;
|
||||
w = "w" ;
|
||||
x = "x" ;
|
||||
y = "y" ;
|
||||
z = "z" ;
|
||||
}
|
||||
7
book/examples/chapter2/Strings.gf
Normal file
7
book/examples/chapter2/Strings.gf
Normal file
@@ -0,0 +1,7 @@
|
||||
abstract Strings = Letters ** {
|
||||
|
||||
cat S ;
|
||||
fun
|
||||
E : S ;
|
||||
C : L -> S -> S ;
|
||||
}
|
||||
5
book/examples/chapter2/StringsBW.gf
Normal file
5
book/examples/chapter2/StringsBW.gf
Normal file
@@ -0,0 +1,5 @@
|
||||
concrete StringsBW of Strings = LettersCnc ** {
|
||||
lincat S = Str ;
|
||||
lin E = [] ;
|
||||
lin C head tail = tail ++ head ;
|
||||
}
|
||||
5
book/examples/chapter2/StringsFW.gf
Normal file
5
book/examples/chapter2/StringsFW.gf
Normal file
@@ -0,0 +1,5 @@
|
||||
concrete StringsFW of Strings = LettersCnc ** {
|
||||
lincat S = Str ;
|
||||
lin E = [] ;
|
||||
lin C head tail = head ++ tail ;
|
||||
}
|
||||
10
book/examples/chapter2/Ticket.gf
Normal file
10
book/examples/chapter2/Ticket.gf
Normal file
@@ -0,0 +1,10 @@
|
||||
abstract Ticket = {
|
||||
|
||||
flags startcat = Request ;
|
||||
cat
|
||||
Request ; Station ;
|
||||
fun
|
||||
Ticket : Station -> Station -> Request ;
|
||||
Hamburg, Paris : Station ;
|
||||
|
||||
}
|
||||
19
book/examples/chapter2/TicketEng.gf
Normal file
19
book/examples/chapter2/TicketEng.gf
Normal file
@@ -0,0 +1,19 @@
|
||||
concrete TicketEng of Ticket = {
|
||||
|
||||
lincat
|
||||
Request, Station = Str ;
|
||||
lin
|
||||
Ticket X Y =
|
||||
((("I" ++ ("would like" | "want") ++ "to get" |
|
||||
("may" | "can") ++ "I get" |
|
||||
"can you give me" |
|
||||
[]) ++
|
||||
"a ticket") |
|
||||
[]) ++
|
||||
"from" ++ X ++ "to" ++ Y ++
|
||||
("please" | []) ;
|
||||
|
||||
Hamburg = "Hamburg" ;
|
||||
Paris = "Paris" ;
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user