1
0
forked from GitHub/gf-core

completed book examples

This commit is contained in:
aarne
2010-11-22 15:48:52 +00:00
parent 46137ab6a6
commit b8f81b1a20
11 changed files with 110 additions and 9 deletions

View File

@@ -0,0 +1,4 @@
This 0.8
Mod 0.2
Wine 0.0
Fresh 0.4

View File

@@ -1,4 +1,4 @@
resource Exx = {
resource DefArtGer = {
param DetForm = DSg Gender Case | DPl Case ;
param Gender = Masc | Fem | Neutr ;

View File

@@ -1,18 +1,19 @@
--# -path=.:../foods:minimal:present
--# -path=.:present
concrete FoodsEng of Foods = open SyntaxEng,ParadigmsEng in {
concrete FoodsEng of Foods =
open SyntaxEng,ParadigmsEng in {
lincat
Phrase = Cl ;
Comment = Utt ;
Item = NP ;
Kind = CN ;
Quality = AP ;
lin
Is item quality = mkCl item quality ;
Pred item quality = mkUtt (mkCl item quality) ;
This kind = mkNP this_Quant kind ;
That kind = mkNP that_Quant kind ;
These kind = mkNP this_Quant plNum kind ;
Those kind = mkNP that_Quant plNum kind ;
QKind quality kind = mkCN quality kind ;
Mod quality kind = mkCN quality kind ;
Wine = mkCN (mkN "wine") ;
Pizza = mkCN (mkN "pizza") ;
Cheese = mkCN (mkN "cheese") ;

View File

@@ -0,0 +1,30 @@
abstract Arithm = {
cat
Prop ; -- proposition
Nat ; -- natural number
data
Zero : Nat ; -- 0
Succ : Nat -> Nat ; -- the successor of x
fun
Even : Nat -> Prop ; -- x is even
And : Prop -> Prop -> Prop ; -- A and B
cat Less Nat Nat ;
data LessZ : (y : Nat) -> Less Zero (Succ y) ;
data LessS : (x,y : Nat) -> Less x y -> Less (Succ x) (Succ y) ;
cat Span ;
data FromTo : (m,n : Nat) -> Less m n -> Span ;
fun one : Nat ;
def one = Succ Zero ;
fun twice : Nat -> Nat ;
def twice x = plus x x ;
fun plus : Nat -> Nat -> Nat ;
def
plus x Zero = x ;
plus x (Succ y) = Succ (plus x y) ;
}

View File

@@ -18,8 +18,8 @@ lin
Fan = mkCN (mkN "fan") ;
Switchable, Dimmable = <> ;
SwitchOn = mkV2 (mkV "on" (mkV "switch")) ;
SwitchOff = mkV2 (mkV "off" (mkV "switch")) ;
SwitchOn = mkV2 (partV (mkV "switch") "on") ;
SwitchOff = mkV2 (partV (mkV "switch") "off") ;
Dim = mkV2 (mkV "dim") ;
switchable_Light = <> ;

View File

@@ -0,0 +1,16 @@
abstract Smart = {
cat
Command ;
Kind ;
Device Kind ;
Action Kind ;
fun
Act : (k : Kind) -> Action k -> Device k -> Command ;
The : (k : Kind) -> Device k ; -- the light
Light, Fan : Kind ;
Dim : Action Light ;
SwitchOn, SwitchOff : (k : Kind) -> Action k ;
}

View File

@@ -0,0 +1,10 @@
abstract Map = {
flags startcat = Query ;
cat
Query ; Input ; Place ; Click ;
fun
GoFromTo : Place -> Place -> Input ;
ThisPlace : Click -> Place ;
QueryInput : Input -> Query ;
ClickCoord : Int -> Int -> Click ;
}

View File

@@ -0,0 +1,17 @@
concrete MapEng of Map = {
lincat
Query = {s : Str} ;
Input, Place = {s : Str ; p : Str} ;
Click = {p : Str} ;
lin
GoFromTo x y = {
s = "I want to go from" ++ x.s ++ "to" ++ y.s ;
p = x.p ++ y.p
} ;
ThisPlace c = {
s = "this place" ;
p = c.p
} ;
QueryInput i = {s = i.s ++ ";" ++ i.p} ;
ClickCoord x y = {p = "(" ++ x.s ++ "," ++ y.s ++ ")"} ;
}

View File

@@ -1,4 +1,4 @@
--# -path=alltenses
--# -path=.:present
concrete GeometryEng of Geometry = LogicEng **
open SyntaxEng, ParadigmsEng in {

View File

@@ -0,0 +1,7 @@
-- (c) Krasimir Angelov 2009
abstract Graftal = {
cat N; S;
fun z : N ;
s : N -> N ;
c : N -> S ;
}

View File

@@ -0,0 +1,16 @@
concrete Sierpinski of Graftal = {
lincat N = {a : Str; b : Str} ;
lincat S = {s : Str} ;
lin z = {a = A; b = B} ;
lin s x = {
a = x.b ++ R ++ x.a ++ R ++ x.b ;
b = x.a ++ L ++ x.b ++ L ++ x.a
} ;
lin c x = {s = "newpath 300 550 moveto" ++ x.a ++ "stroke showpage"} ;
oper A : Str = "0 2 rlineto" ;
oper B : Str = "0 2 rlineto" ;
oper L : Str = "+60 rotate" ;
oper R : Str = "-60 rotate" ;
}