summaryrefslogtreecommitdiff
path: root/book/examples/chapter2
diff options
context:
space:
mode:
authoraarne <aarne@chalmers.se>2010-11-22 12:55:37 +0000
committeraarne <aarne@chalmers.se>2010-11-22 12:55:37 +0000
commit76ba03b545600054176612201de78dca16eb65e1 (patch)
tree5615286b239bee637b32465e9cbf36807ab2c318 /book/examples/chapter2
parent0bf41793694e8b3101d09e34858eba8ab2c8c5b6 (diff)
started a subdir for the book
Diffstat (limited to 'book/examples/chapter2')
-rw-r--r--book/examples/chapter2/Copy.gf7
-rw-r--r--book/examples/chapter2/CopyAbs.gf6
-rw-r--r--book/examples/chapter2/Food.gf13
-rw-r--r--book/examples/chapter2/FoodEng.gf19
-rw-r--r--book/examples/chapter2/FoodHin.gf24
-rw-r--r--book/examples/chapter2/FoodIta.gf19
-rw-r--r--book/examples/chapter2/Letters.gf8
-rw-r--r--book/examples/chapter2/LettersCnc.gf31
-rw-r--r--book/examples/chapter2/Strings.gf7
-rw-r--r--book/examples/chapter2/StringsBW.gf5
-rw-r--r--book/examples/chapter2/StringsFW.gf5
-rw-r--r--book/examples/chapter2/Ticket.gf10
-rw-r--r--book/examples/chapter2/TicketEng.gf19
13 files changed, 173 insertions, 0 deletions
diff --git a/book/examples/chapter2/Copy.gf b/book/examples/chapter2/Copy.gf
new file mode 100644
index 000000000..58d74861c
--- /dev/null
+++ b/book/examples/chapter2/Copy.gf
@@ -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 ;
+}
diff --git a/book/examples/chapter2/CopyAbs.gf b/book/examples/chapter2/CopyAbs.gf
new file mode 100644
index 000000000..9a915568b
--- /dev/null
+++ b/book/examples/chapter2/CopyAbs.gf
@@ -0,0 +1,6 @@
+abstract CopyAbs = {
+ cat S ; AB ;
+ fun s : AB -> S ;
+ end : AB ;
+ a,b : AB -> AB ;
+}
diff --git a/book/examples/chapter2/Food.gf b/book/examples/chapter2/Food.gf
new file mode 100644
index 000000000..7cf779b4c
--- /dev/null
+++ b/book/examples/chapter2/Food.gf
@@ -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 ;
+}
diff --git a/book/examples/chapter2/FoodEng.gf b/book/examples/chapter2/FoodEng.gf
new file mode 100644
index 000000000..f2ed510fe
--- /dev/null
+++ b/book/examples/chapter2/FoodEng.gf
@@ -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" ;
+}
diff --git a/book/examples/chapter2/FoodHin.gf b/book/examples/chapter2/FoodHin.gf
new file mode 100644
index 000000000..0f6f25c5e
--- /dev/null
+++ b/book/examples/chapter2/FoodHin.gf
@@ -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 = "अरुचिकर" ;
+ }
+
+
+
+
diff --git a/book/examples/chapter2/FoodIta.gf b/book/examples/chapter2/FoodIta.gf
new file mode 100644
index 000000000..466104432
--- /dev/null
+++ b/book/examples/chapter2/FoodIta.gf
@@ -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" ;
+}
diff --git a/book/examples/chapter2/Letters.gf b/book/examples/chapter2/Letters.gf
new file mode 100644
index 000000000..2b5a62d2d
--- /dev/null
+++ b/book/examples/chapter2/Letters.gf
@@ -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 ;
+
+}
diff --git a/book/examples/chapter2/LettersCnc.gf b/book/examples/chapter2/LettersCnc.gf
new file mode 100644
index 000000000..3301f5465
--- /dev/null
+++ b/book/examples/chapter2/LettersCnc.gf
@@ -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" ;
+}
diff --git a/book/examples/chapter2/Strings.gf b/book/examples/chapter2/Strings.gf
new file mode 100644
index 000000000..411ceed53
--- /dev/null
+++ b/book/examples/chapter2/Strings.gf
@@ -0,0 +1,7 @@
+abstract Strings = Letters ** {
+
+cat S ;
+fun
+ E : S ;
+ C : L -> S -> S ;
+}
diff --git a/book/examples/chapter2/StringsBW.gf b/book/examples/chapter2/StringsBW.gf
new file mode 100644
index 000000000..8e558d953
--- /dev/null
+++ b/book/examples/chapter2/StringsBW.gf
@@ -0,0 +1,5 @@
+concrete StringsBW of Strings = LettersCnc ** {
+ lincat S = Str ;
+ lin E = [] ;
+ lin C head tail = tail ++ head ;
+}
diff --git a/book/examples/chapter2/StringsFW.gf b/book/examples/chapter2/StringsFW.gf
new file mode 100644
index 000000000..c0f80c313
--- /dev/null
+++ b/book/examples/chapter2/StringsFW.gf
@@ -0,0 +1,5 @@
+concrete StringsFW of Strings = LettersCnc ** {
+ lincat S = Str ;
+ lin E = [] ;
+ lin C head tail = head ++ tail ;
+}
diff --git a/book/examples/chapter2/Ticket.gf b/book/examples/chapter2/Ticket.gf
new file mode 100644
index 000000000..f3f2dd851
--- /dev/null
+++ b/book/examples/chapter2/Ticket.gf
@@ -0,0 +1,10 @@
+abstract Ticket = {
+
+flags startcat = Request ;
+cat
+ Request ; Station ;
+fun
+ Ticket : Station -> Station -> Request ;
+ Hamburg, Paris : Station ;
+
+}
diff --git a/book/examples/chapter2/TicketEng.gf b/book/examples/chapter2/TicketEng.gf
new file mode 100644
index 000000000..54e44741d
--- /dev/null
+++ b/book/examples/chapter2/TicketEng.gf
@@ -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" ;
+
+}