diff options
| author | aarne <unknown> | 2004-09-15 14:36:27 +0000 |
|---|---|---|
| committer | aarne <unknown> | 2004-09-15 14:36:27 +0000 |
| commit | a25ee154e760a424ef4aef46a6e3d6fdf1079cf1 (patch) | |
| tree | 50315c6fe03325fca09e1a922172de111faa7639 /grammars/multiple | |
| parent | 7697b222d0b7053e4b955a6ab9ba2ad0d6c9c512 (diff) | |
introducing multiple inheritance
Diffstat (limited to 'grammars/multiple')
| -rw-r--r-- | grammars/multiple/City.gf | 7 | ||||
| -rw-r--r-- | grammars/multiple/CityEng.gf | 5 | ||||
| -rw-r--r-- | grammars/multiple/Math.gf | 7 | ||||
| -rw-r--r-- | grammars/multiple/MathEng.gf | 5 | ||||
| -rw-r--r-- | grammars/multiple/System.gf | 4 | ||||
| -rw-r--r-- | grammars/multiple/SystemCity.gf | 4 | ||||
| -rw-r--r-- | grammars/multiple/SystemCityEng.gf | 6 | ||||
| -rw-r--r-- | grammars/multiple/SystemEng.gf | 3 | ||||
| -rw-r--r-- | grammars/multiple/SystemMath.gf | 4 | ||||
| -rw-r--r-- | grammars/multiple/SystemMathEng.gf | 6 | ||||
| -rw-r--r-- | grammars/multiple/Top.gf | 7 | ||||
| -rw-r--r-- | grammars/multiple/TopCity.gf | 1 | ||||
| -rw-r--r-- | grammars/multiple/TopCityEng.gf | 3 | ||||
| -rw-r--r-- | grammars/multiple/TopEng.gf | 6 | ||||
| -rw-r--r-- | grammars/multiple/TopMath.gf | 1 | ||||
| -rw-r--r-- | grammars/multiple/TopMathEng.gf | 3 | ||||
| -rw-r--r-- | grammars/multiple/User.gf | 7 | ||||
| -rw-r--r-- | grammars/multiple/UserCity.gf | 5 | ||||
| -rw-r--r-- | grammars/multiple/UserCityEng.gf | 6 | ||||
| -rw-r--r-- | grammars/multiple/UserEng.gf | 5 | ||||
| -rw-r--r-- | grammars/multiple/UserMath.gf | 5 | ||||
| -rw-r--r-- | grammars/multiple/UserMathEng.gf | 6 | ||||
| -rw-r--r-- | grammars/multiple/UserUnionCity.gf | 1 | ||||
| -rw-r--r-- | grammars/multiple/map.txt | 32 |
24 files changed, 139 insertions, 0 deletions
diff --git a/grammars/multiple/City.gf b/grammars/multiple/City.gf new file mode 100644 index 000000000..b8023ac84 --- /dev/null +++ b/grammars/multiple/City.gf @@ -0,0 +1,7 @@ +abstract City = { + cat + City ; + fun + MkCity : String -> City ; +} ; + diff --git a/grammars/multiple/CityEng.gf b/grammars/multiple/CityEng.gf new file mode 100644 index 000000000..8c67ab675 --- /dev/null +++ b/grammars/multiple/CityEng.gf @@ -0,0 +1,5 @@ +concrete CityEng of City = open Prelude in { + lin + MkCity s = s ; +} ; + diff --git a/grammars/multiple/Math.gf b/grammars/multiple/Math.gf new file mode 100644 index 000000000..6e6a48db6 --- /dev/null +++ b/grammars/multiple/Math.gf @@ -0,0 +1,7 @@ +abstract Math = { + cat + Number ; + fun + MkNumber : Int -> Number ; +} ; + diff --git a/grammars/multiple/MathEng.gf b/grammars/multiple/MathEng.gf new file mode 100644 index 000000000..9d9bf3414 --- /dev/null +++ b/grammars/multiple/MathEng.gf @@ -0,0 +1,5 @@ +concrete MathEng of Math = open Prelude in { + lin + MkNumber i = i ; +} ; + diff --git a/grammars/multiple/System.gf b/grammars/multiple/System.gf new file mode 100644 index 000000000..b3587c106 --- /dev/null +++ b/grammars/multiple/System.gf @@ -0,0 +1,4 @@ +abstract System = { + cat Reply ; + fun Bye : Reply ; +} diff --git a/grammars/multiple/SystemCity.gf b/grammars/multiple/SystemCity.gf new file mode 100644 index 000000000..08196f73d --- /dev/null +++ b/grammars/multiple/SystemCity.gf @@ -0,0 +1,4 @@ +abstract SystemCity = System, City ** { + fun + RDistance : City -> City -> Int -> Reply ; +} ;
\ No newline at end of file diff --git a/grammars/multiple/SystemCityEng.gf b/grammars/multiple/SystemCityEng.gf new file mode 100644 index 000000000..ddf15248a --- /dev/null +++ b/grammars/multiple/SystemCityEng.gf @@ -0,0 +1,6 @@ +concrete SystemCityEng of SystemCity = SystemEng, CityEng ** open + Prelude in { + lin + RDistance x y d = + ss (["the distance from"] ++ x.s ++ "to" ++ y.s ++ "is" ++ d.s) ; +} ; diff --git a/grammars/multiple/SystemEng.gf b/grammars/multiple/SystemEng.gf new file mode 100644 index 000000000..96f6d80c7 --- /dev/null +++ b/grammars/multiple/SystemEng.gf @@ -0,0 +1,3 @@ +concrete SystemEng of System = open Prelude in { + lin Bye = ss "bye" ; +} diff --git a/grammars/multiple/SystemMath.gf b/grammars/multiple/SystemMath.gf new file mode 100644 index 000000000..7e2173111 --- /dev/null +++ b/grammars/multiple/SystemMath.gf @@ -0,0 +1,4 @@ +abstract SystemMath = System, Math ** { + fun + RSum : Number -> Number -> Int -> Reply ; +} ; diff --git a/grammars/multiple/SystemMathEng.gf b/grammars/multiple/SystemMathEng.gf new file mode 100644 index 000000000..11aca7952 --- /dev/null +++ b/grammars/multiple/SystemMathEng.gf @@ -0,0 +1,6 @@ +concrete SystemMathEng of SystemMath = SystemEng, MathEng ** open + Prelude in { + lin + RSum x y d = + ss (["the sum of"] ++ x.s ++ "and" ++ y.s ++ "is" ++ d.s) ; +} ; diff --git a/grammars/multiple/Top.gf b/grammars/multiple/Top.gf new file mode 100644 index 000000000..67170f30a --- /dev/null +++ b/grammars/multiple/Top.gf @@ -0,0 +1,7 @@ +abstract Top = User, System ** { + cat + Move ; + fun + MUser : Query -> Move ; + MSystem : Reply -> Move ; +} diff --git a/grammars/multiple/TopCity.gf b/grammars/multiple/TopCity.gf new file mode 100644 index 000000000..894142b18 --- /dev/null +++ b/grammars/multiple/TopCity.gf @@ -0,0 +1 @@ +abstract TopCity = Top, UserCity, SystemCity ** {} ; diff --git a/grammars/multiple/TopCityEng.gf b/grammars/multiple/TopCityEng.gf new file mode 100644 index 000000000..ef1f01ade --- /dev/null +++ b/grammars/multiple/TopCityEng.gf @@ -0,0 +1,3 @@ +--# -path=.:../prelude + +concrete TopCityEng of TopCity = TopEng, UserCityEng, SystemCityEng ** {} ; diff --git a/grammars/multiple/TopEng.gf b/grammars/multiple/TopEng.gf new file mode 100644 index 000000000..6265ed2c3 --- /dev/null +++ b/grammars/multiple/TopEng.gf @@ -0,0 +1,6 @@ + +concrete TopEng of Top = UserEng, SystemEng ** open Prelude in { + lin + MUser q = q ; + MSystem r = r ; +} diff --git a/grammars/multiple/TopMath.gf b/grammars/multiple/TopMath.gf new file mode 100644 index 000000000..997e7299d --- /dev/null +++ b/grammars/multiple/TopMath.gf @@ -0,0 +1 @@ +abstract TopMath = Top, UserMath, SystemMath ** {} ; diff --git a/grammars/multiple/TopMathEng.gf b/grammars/multiple/TopMathEng.gf new file mode 100644 index 000000000..5f803b33a --- /dev/null +++ b/grammars/multiple/TopMathEng.gf @@ -0,0 +1,3 @@ +--# -path=.:../prelude + +concrete TopMathEng of TopMath = TopEng, UserMathEng, SystemMathEng ** {} ; diff --git a/grammars/multiple/User.gf b/grammars/multiple/User.gf new file mode 100644 index 000000000..6822d2e75 --- /dev/null +++ b/grammars/multiple/User.gf @@ -0,0 +1,7 @@ +abstract User = { + cat + Query ; + fun + QQuit : Query ; +} ; + diff --git a/grammars/multiple/UserCity.gf b/grammars/multiple/UserCity.gf new file mode 100644 index 000000000..ee650421d --- /dev/null +++ b/grammars/multiple/UserCity.gf @@ -0,0 +1,5 @@ +abstract UserCity = User, City ** { + fun + QDistance : City -> City -> Query ; +} ; + diff --git a/grammars/multiple/UserCityEng.gf b/grammars/multiple/UserCityEng.gf new file mode 100644 index 000000000..a30b81510 --- /dev/null +++ b/grammars/multiple/UserCityEng.gf @@ -0,0 +1,6 @@ +concrete UserCityEng of UserCity = UserEng, CityEng ** open Prelude in + { + lin + QDistance x y = ss (["what is the distance from"] ++ x.s ++ "to" ++ y.s) ; + } + diff --git a/grammars/multiple/UserEng.gf b/grammars/multiple/UserEng.gf new file mode 100644 index 000000000..fcc233ddd --- /dev/null +++ b/grammars/multiple/UserEng.gf @@ -0,0 +1,5 @@ +concrete UserEng of User = open Prelude in { + lin + QQuit = ss ["that's enough"] ; +} ; + diff --git a/grammars/multiple/UserMath.gf b/grammars/multiple/UserMath.gf new file mode 100644 index 000000000..0bb6ebf80 --- /dev/null +++ b/grammars/multiple/UserMath.gf @@ -0,0 +1,5 @@ +abstract UserMath = User, Math ** { + fun + QSum : Number -> Number -> Query ; +} ; + diff --git a/grammars/multiple/UserMathEng.gf b/grammars/multiple/UserMathEng.gf new file mode 100644 index 000000000..c1a190b47 --- /dev/null +++ b/grammars/multiple/UserMathEng.gf @@ -0,0 +1,6 @@ +concrete UserMathEng of UserMath = UserEng, MathEng ** open Prelude in + { + lin + QSum x y = ss (["what is the sum of"] ++ x.s ++ "and" ++ y.s) ; + } + diff --git a/grammars/multiple/UserUnionCity.gf b/grammars/multiple/UserUnionCity.gf new file mode 100644 index 000000000..68115c626 --- /dev/null +++ b/grammars/multiple/UserUnionCity.gf @@ -0,0 +1 @@ +abstract UserUnionCity = union User, City ; diff --git a/grammars/multiple/map.txt b/grammars/multiple/map.txt new file mode 100644 index 000000000..1700f967c --- /dev/null +++ b/grammars/multiple/map.txt @@ -0,0 +1,32 @@ +Using multiple inheritance in GF. AR 15/9/2004. + +The following diagrams show inheritance between abstract syntaxes in two simple systems. + + TopCity + / | \ + / | \ + SystemCity UserCity Top + / \ / \ + System City User + + + TopMath + / | \ + / | \ + SystemMath UserMath Top + / \ / \ + System Math User + + +Idea of each module: + + User -- User's moves on any domain + System -- System's moves on any domain + Top -- grammar covering both kinds of moves + X = Math, City -- possible domains + UserX -- User's domain specific moves + SystemX -- System's domain specific moves + TopX -- all moves on the domain X + +In parallel to the abstract syntax hierarchies, we have of course +hierarchies of concrete syntaxes for any language; this directory contains Eng. |
