forked from GitHub/gf-core
Improving unicode menus, e.g. in Letter.
This commit is contained in:
287
examples/letter/Letter.gfcm
Normal file
287
examples/letter/Letter.gfcm
Normal file
File diff suppressed because one or more lines are too long
80
examples/letter/letter.Abs.gf
Normal file
80
examples/letter/letter.Abs.gf
Normal file
@@ -0,0 +1,80 @@
|
||||
--1 An Abstract Syntax for Business and Love Letters
|
||||
--
|
||||
-- This file defines the abstract syntax of a grammar set whose concrete syntax
|
||||
-- has so far been written to five languages: English, Finnish, French, Russian,
|
||||
-- and Swedish.
|
||||
--
|
||||
-- The main category of the grammar is $Letter$. The other categories are
|
||||
-- parts of the letter.
|
||||
|
||||
flags startcat=Letter ;
|
||||
|
||||
cat
|
||||
Letter ;
|
||||
Recipient ; Author ;
|
||||
Message ;
|
||||
Heading ; Ending ;
|
||||
Mode ; Sentence ; NounPhrase ; Position ;
|
||||
|
||||
-- There is just one top-level letter structure.
|
||||
|
||||
fun
|
||||
MkLetter : Heading -> Message -> Ending -> Letter ;
|
||||
|
||||
-- The heading consists of a greeting of the recipient. The $JustHello$
|
||||
-- function will actually suppress the name (and title) of the recipient,
|
||||
-- but the $Recipient$ argument keeps track of the gender and number.
|
||||
|
||||
DearRec : Recipient -> Heading ;
|
||||
PlainRec : Recipient -> Heading ;
|
||||
HelloRec : Recipient -> Heading ;
|
||||
JustHello : Recipient -> Heading ;
|
||||
|
||||
-- A message is a sentence with of without a *mode*, which is either
|
||||
-- regret or honour.
|
||||
|
||||
ModeSent : Mode -> Sentence -> Message ;
|
||||
PlainSent : Sentence -> Message ;
|
||||
|
||||
Honour, Regret : Mode ;
|
||||
|
||||
-- The ending is either formal or informal. It does not currently depend on
|
||||
-- the heading: making it so would eliminate formality mismatches between
|
||||
-- the heading and the ending.
|
||||
|
||||
FormalEnding : Author -> Ending ;
|
||||
InformalEnding : Author -> Ending ;
|
||||
|
||||
-- The recipient is either a colleague, colleagues, or darling.
|
||||
-- It can also be a named person. The gender distinction is made
|
||||
-- because there are things in the body of the letter that depend on it.
|
||||
|
||||
ColleagueHe, ColleagueShe : Recipient ;
|
||||
ColleaguesHe, ColleaguesShe : Recipient ;
|
||||
DarlingHe, DarlingShe : Recipient ;
|
||||
|
||||
NameHe, NameShe : String -> Recipient ;
|
||||
|
||||
-- For the author, there is likewise a fixed set of titles, plus the named author.
|
||||
-- Gender distinctions could be useful even here, for the same reason as with
|
||||
-- $Recipient$. Notice that the rendering of $Spouse$ will depend on the
|
||||
-- gender of the recipient.
|
||||
|
||||
President, Mother, Spouse, Dean : Author ;
|
||||
Name : String -> Author ;
|
||||
|
||||
-- As for the message body, no much choice is yet available: one can say that
|
||||
-- the recipient is promoted to some position, that someone has gone bankrupt,
|
||||
-- or that the author loves the recipient.
|
||||
|
||||
BePromoted : Position -> Sentence ;
|
||||
GoBankrupt : NounPhrase -> Sentence ;
|
||||
ILoveYou : Sentence ;
|
||||
|
||||
Competitor : NounPhrase ;
|
||||
Company : NounPhrase ;
|
||||
OurCustomers : NounPhrase ;
|
||||
|
||||
Senior : Position ;
|
||||
ProjectManager : Position ;
|
||||
|
||||
151
examples/letter/letter.Eng.gf
Normal file
151
examples/letter/letter.Eng.gf
Normal file
@@ -0,0 +1,151 @@
|
||||
--1 An English Concrete Syntax for Business and Love Letters
|
||||
--
|
||||
-- This file defines the English syntax of the grammar set
|
||||
-- whose abstract syntax is $letter.Abs.gf$.
|
||||
|
||||
include letter.Abs.gf ;
|
||||
|
||||
flags lexer=textlit ; unlexer=textlit ;
|
||||
|
||||
param Sex = masc | fem ;
|
||||
param Num = sg | pl ;
|
||||
param Kas = nom | acc ;
|
||||
param DepNum = depnum | cnum Num ;
|
||||
|
||||
lintype SS = {s : Str} ;
|
||||
lintype SSDep = {s : Num => Sex => Str} ; -- needs Num and Sex
|
||||
lintype SSSrc = {s : Str ; n : Num ; x : Sex} ; -- gives Num and Sex
|
||||
lintype SSSrc2 = {s : Num => Sex => Str ; n : DepNum ; x : Sex} ; -- gives and needs
|
||||
lintype SSDep2 = {s : DepNum => Sex => Num => Sex => Str} ; -- needs Auth's & Recp's
|
||||
lintype SSSrcNum = {s : Str ; n : Num} ; -- gives Num only
|
||||
|
||||
|
||||
oper
|
||||
ss : Str -> SS = \s -> {s = s} ;
|
||||
constNX : Str -> Num -> Sex -> SSSrc2 = \str,num,sex ->
|
||||
{s = table {_ => table {_ => str}} ; n = cnum num ; x = sex} ;
|
||||
|
||||
dep2num : DepNum -> Num -> Num = \dn,n -> case dn of {
|
||||
depnum => n ;
|
||||
cnum cn => cn
|
||||
} ;
|
||||
|
||||
lincat
|
||||
Letter = SS ;
|
||||
Recipient = SSSrc ;
|
||||
Author = SSSrc2 ;
|
||||
Message = SSDep2 ;
|
||||
Heading = SSSrc ;
|
||||
Ending = SSSrc2 ;
|
||||
Mode = SSDep2 ;
|
||||
Sentence = SSDep2 ;
|
||||
NounPhrase = SSSrcNum ;
|
||||
Position = SSDep ;
|
||||
|
||||
lin
|
||||
MkLetter head mess end =
|
||||
ss (head.s ++ "," ++ "<p>" ++
|
||||
mess.s ! end.n ! end.x ! head.n ! head.x ++ "." ++ "<p>" ++
|
||||
end.s ! head.n ! head.x) ;
|
||||
|
||||
DearRec rec = {s = "Dear" ++ rec.s ; n = rec.n ; x = rec.x} ;
|
||||
PlainRec rec = rec ;
|
||||
HelloRec rec = {s = "Hello" ++ rec.s ; n = rec.n ; x = rec.x} ;
|
||||
JustHello rec = {s = "Hello" ; n = rec.n ; x = rec.x} ;
|
||||
|
||||
ModeSent mode sent =
|
||||
{s =
|
||||
table {dna => table {xa => table {nr => table {xr =>
|
||||
mode.s ! dna ! xa ! nr ! xr ++ sent.s ! dna ! xa ! nr ! xr}}}}
|
||||
} ;
|
||||
PlainSent sent = sent ;
|
||||
|
||||
FormalEnding auth =
|
||||
{s = table {n => table {x =>
|
||||
["Sincerely yours <p>"] ++ auth.s ! n ! x}} ; n = auth.n ; x = auth.x} ;
|
||||
InformalEnding auth =
|
||||
{s = table {n => table {x =>
|
||||
["With best regards <p>"] ++ auth.s ! n ! x}} ; n = auth.n ; x = auth.x} ;
|
||||
|
||||
ColleaguesHe = {s = kollega ! pl ; n = pl ; x = masc} ;
|
||||
ColleaguesShe = {s = kollega ! pl ; n = pl ; x = fem} ;
|
||||
ColleagueHe = {s = kollega ! sg ; n = sg ; x = masc} ;
|
||||
ColleagueShe = {s = kollega ! sg ; n = sg ; x = fem} ;
|
||||
DarlingHe = {s = "darling" ; n = sg ; x = masc} ;
|
||||
DarlingShe = {s = "darling" ; n = sg ; x = fem} ;
|
||||
NameHe s = {s = s.s ; n = sg ; x = masc} ;
|
||||
NameShe s = {s = s.s ; n = sg ; x = fem} ;
|
||||
|
||||
|
||||
Honour = {s =
|
||||
table {dna => table {xa => table {nr => table {xr =>
|
||||
let {na = dep2num dna nr} in
|
||||
ego ! na ! nom ++ ["have the honour to inform you that"]}}}}
|
||||
} ;
|
||||
|
||||
Regret = {s =
|
||||
table {dna => table {xa => table {nr => table {xr =>
|
||||
let {na = dep2num dna nr} in
|
||||
ego ! na ! nom ++ am ! na ++ ["sorry to inform you that"]}}}}
|
||||
} ;
|
||||
|
||||
|
||||
President = constNX ["the President"] sg masc ;
|
||||
Mother = constNX "Mom" sg fem ;
|
||||
Spouse = {s = table {
|
||||
sg => table {fem => ["your husband"] ; masc => ["your wife"]} ;
|
||||
pl => table {fem => ["your husbands"] ; masc => ["your wives"]}
|
||||
} ; n = depnum ; x = masc} ; -- sex does not matter here
|
||||
Dean = constNX ["the Dean"] sg masc ;
|
||||
Name s = constNX s.s sg masc ; ---
|
||||
|
||||
BePromoted pos = {s =
|
||||
table {na => table {xa => table {nr => table {xr =>
|
||||
["you have been promoted to"] ++
|
||||
pos.s ! nr ! xr}}}}
|
||||
} ;
|
||||
GoBankrupt np = {s =
|
||||
table {na => table {xa => table {nr => table {xr =>
|
||||
np.s ++ have ! np.n ++ ["gone bankrupt"]}}}}
|
||||
} ;
|
||||
ILoveYou = {s =
|
||||
table {na => table {xa => table {nr => table {xr =>
|
||||
ego ! dep2num na nr ! nom ++ ["love you"]}}}}
|
||||
} ;
|
||||
|
||||
Company = {s = ["our company"] ; n = sg} ;
|
||||
Competitor = {s = ["our worst competitor"] ; n = sg} ;
|
||||
OurCustomers = {s = ["our customers"] ; n = pl} ;
|
||||
|
||||
Senior = {s =
|
||||
table {
|
||||
sg => table {x => ["a senior fellow"]} ;
|
||||
pl => table {x => ["senior fellows"]}
|
||||
}} ;
|
||||
ProjectManager = {s =
|
||||
table {
|
||||
sg => table {_ => ["a project manager"]} ;
|
||||
pl => table {_ => ["project managers"]}
|
||||
}} ;
|
||||
|
||||
oper
|
||||
|
||||
kollega :
|
||||
Num => Str =
|
||||
table {sg => "colleague" ; pl => "colleagues"} ;
|
||||
|
||||
am :
|
||||
Num => Str =
|
||||
table {sg => "am" ; pl => "are"} ;
|
||||
|
||||
have :
|
||||
Num => Str =
|
||||
table {sg => "has" ; pl => "have"} ;
|
||||
|
||||
ego :
|
||||
Num => Kas => Str =
|
||||
table {
|
||||
sg => table {nom => "I" ; acc => "me"} ;
|
||||
pl => table {nom => "we" ; acc => "us"}
|
||||
} ;
|
||||
|
||||
179
examples/letter/letter.Fin.gf
Normal file
179
examples/letter/letter.Fin.gf
Normal file
@@ -0,0 +1,179 @@
|
||||
--1 A Finnish Concrete Syntax for Business and Love Letters
|
||||
--
|
||||
-- This file defines the Finnish syntax of the grammar set
|
||||
-- whose abstract syntax is $letter.Abs.gf$.
|
||||
|
||||
include letter.Abs.gf ;
|
||||
|
||||
flags lexer=textlit ; unlexer=textlit ;
|
||||
|
||||
-- modified from French in 20 min, 15/6/2002
|
||||
|
||||
param Gen = masc | fem ;
|
||||
param Num = sg | pl ;
|
||||
param Kas = nom | acc ;
|
||||
param DepNum = depnum | cnum Num ;
|
||||
param DepGen = depgen | cgen Gen ;
|
||||
|
||||
lintype SS = {s : Str} ;
|
||||
lintype SSDep = {s : Num => Gen => Str} ; -- needs Num and Gen
|
||||
lintype SSSrc = {s : Str ; n : Num ; g : Gen} ; -- gives Num and Gen
|
||||
lintype SSSrc2 = {s : Num => Gen => Str ; n : DepNum ; g : DepGen} ; -- gives&needs
|
||||
lintype SSDep2 = {s : DepNum => DepGen => Num => Gen => Str} ; -- needs Auth's&Rec's
|
||||
lintype SSSrcGen = {s : Str ; n : Num ; g : Gen} ; -- gives Num and Gen
|
||||
|
||||
oper
|
||||
ss : Str -> SS = \s -> {s = s} ;
|
||||
|
||||
noDep : (P : Type) -> Str -> P => Str = \_,s -> table {_ => s} ;
|
||||
|
||||
cher : Num => Gen => Tok =
|
||||
table {sg => noDep Gen "rakas" ; pl => noDep Gen "rakkaat"} ;
|
||||
|
||||
egosum : Num => Str =
|
||||
table {sg => "olen" ; pl => "olemme"} ;
|
||||
egohabeo : Num => Str =
|
||||
table {sg => "minulla" ++ "on" ; pl => "meillä" ++ "on"} ;
|
||||
fuisti : Num => Str =
|
||||
table {sg => "sinut" ++ "on"; pl => "teidät" ++ "on"} ;
|
||||
quePrep = "että" ; ----
|
||||
tuinformare : Num => Str =
|
||||
table {sg => "ilmoittaa" ++ "sinulle" ; pl => "ilmoittaa" ++ "teille"} ;
|
||||
|
||||
regNom : Str -> Num => Str = \pora -> table {sg => pora ; pl => pora + "t"} ;
|
||||
|
||||
avoir : Num => Str =
|
||||
table {sg => "on"; pl => "ovat"} ;
|
||||
|
||||
mes : Num => Str = table {sg => "minun" ; pl => "meidän"} ;
|
||||
|
||||
teamo : Num => Num => Str = table {
|
||||
sg => table {sg => "rakastan" ++ "sinua" ;
|
||||
pl => "rakastan" ++ "teitä"} ;
|
||||
pl => table {sg => "rakastamme" ++ "sinua" ;
|
||||
pl => "rakastamme" ++ "teitä"}
|
||||
} ;
|
||||
|
||||
constNG : Str -> Num -> Gen -> SSSrc2 = \str,num,gen ->
|
||||
{s = table {_ => table {_ => str}} ; n = cnum num ; g = cgen gen} ;
|
||||
|
||||
dep2num : DepNum -> Num -> Num = \dn,n -> case dn of {
|
||||
depnum => n ;
|
||||
cnum cn => cn
|
||||
} ;
|
||||
dep2gen : DepGen -> Gen -> Gen = \dg,g -> case dg of {
|
||||
depgen => case g of {
|
||||
masc => fem ;
|
||||
fem => masc
|
||||
}; -- negative dependence: the author is of opposite sex
|
||||
cgen cg => cg
|
||||
} ;
|
||||
|
||||
|
||||
lincat
|
||||
Letter = SS ;
|
||||
Recipient = SSSrc ;
|
||||
Author = SSSrc2 ;
|
||||
Message = SSDep2 ;
|
||||
Heading = SSSrc ;
|
||||
Ending = SSSrc2 ;
|
||||
Mode = SSDep2 ;
|
||||
Sentence = SSDep2 ;
|
||||
NounPhrase = SSSrcGen ;
|
||||
Position = SSDep ;
|
||||
|
||||
lin
|
||||
MkLetter head mess end =
|
||||
ss (head.s ++ "," ++ "<p>" ++
|
||||
mess.s ! end.n ! end.g ! head.n ! head.g ++ "." ++ "<p>" ++
|
||||
end.s ! head.n ! head.g) ;
|
||||
|
||||
DearRec rec = {s = cher ! rec.n ! rec.g ++ rec.s ; n = rec.n ; g = rec.g} ;
|
||||
PlainRec rec = rec ;
|
||||
HelloRec rec = {s = "Terve" ++ rec.s ; n = rec.n ; g = rec.g} ;
|
||||
JustHello rec = {s = "Terve" ; n = rec.n ; g = rec.g} ;
|
||||
|
||||
ModeSent mode sent =
|
||||
{s =
|
||||
table {na => table {xa => table {nr => table {xr =>
|
||||
mode.s ! na ! xa ! nr ! xr ++ sent.s ! na ! xa ! nr ! xr}}}}
|
||||
} ;
|
||||
PlainSent sent = sent ;
|
||||
|
||||
FormalEnding auth =
|
||||
{s = table {n => table {g => ["parhain terveisin <p>"] ++ auth.s ! n ! g}} ;
|
||||
n = auth.n ; g = auth.g} ;
|
||||
InformalEnding auth =
|
||||
{s = table {n => table {g => ["terveisin <p>"] ++ auth.s ! n ! g}} ;
|
||||
n = auth.n ; g = auth.g} ;
|
||||
|
||||
ColleaguesHe = {s = regNom "kollega" ! pl ; n = pl ; g = masc} ;
|
||||
ColleaguesShe = {s = regNom "kollega" ! pl ; n = pl ; g = fem} ;
|
||||
ColleagueHe = {s = regNom "kollega" ! sg ; n = sg ; g = masc} ;
|
||||
ColleagueShe = {s = regNom "kollega" ! sg ; n = sg ; g = fem} ;
|
||||
DarlingHe = {s = "kulta" ; n = sg ; g = masc} ;
|
||||
DarlingShe = {s = "kulta" ; n = sg ; g = fem} ;
|
||||
NameHe s = {s = s.s ; n = sg ; g = masc} ;
|
||||
NameShe s = {s = s.s ; n = sg ; g = fem} ;
|
||||
|
||||
|
||||
Honour = {s =
|
||||
table {na => table {xa => table {nr => table {xr =>
|
||||
egohabeo ! dep2num na nr ++
|
||||
["kunnia"] ++ tuinformare ! nr ++ quePrep}}}}
|
||||
} ;
|
||||
|
||||
Regret = {s =
|
||||
table {na => table {ga => table {nr => table {gr =>
|
||||
mes ! dep2num na nr ++
|
||||
["on valitettavasti ilmoitettava"] ++ quePrep}}}}
|
||||
} ;
|
||||
|
||||
|
||||
President = constNG ["presidentti"] sg masc ;
|
||||
Mother = constNG ["äiti"] sg fem ;
|
||||
Spouse = {s = table {
|
||||
sg => table {fem => ["miehesi"] ; masc => ["vaimosi"]} ;
|
||||
pl => table {fem => ["miehenne"] ; masc => ["vaimonne"]}
|
||||
} ; n = depnum ; g = depgen} ;
|
||||
Dean = constNG ["dekaani"] sg masc ;
|
||||
Name s = constNG s.s sg masc ; ---
|
||||
|
||||
BePromoted pos = {s =
|
||||
table {na => table {xa => table {nr => table {xr =>
|
||||
fuisti ! nr ++ "ylennetty" ++
|
||||
pos.s ! nr ! xr}}}}
|
||||
} ;
|
||||
GoBankrupt np = {s =
|
||||
table {na =>
|
||||
table {xa =>
|
||||
table {nr =>
|
||||
table {xr =>
|
||||
np.s ++ avoir ! np.n ++
|
||||
(case np.n of {sg => "mennyt" ; pl => "menneet"}) ++
|
||||
"konkurssiin"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} ;
|
||||
|
||||
ILoveYou = {s =
|
||||
table {na => table {xa => table {nr => table {xr =>
|
||||
teamo ! dep2num na nr ! nr}}}}} ;
|
||||
|
||||
Company = {s = ["yrityksemme"] ; n = sg ; g = fem} ;
|
||||
Competitor = {s = ["pahin kilpailijamme"] ; n = sg ; g = masc} ;
|
||||
OurCustomers = {s = ["asiakkaamme"] ; n = pl ; g = masc} ;
|
||||
|
||||
Senior = {s = table {sg => table {g => ["vanhemmaksi tutkijaksi"]} ;
|
||||
pl => table {g => ["vanhemmiksi tutkijoiksi"]}
|
||||
}
|
||||
} ;
|
||||
|
||||
ProjectManager = {s =
|
||||
table {
|
||||
sg => table {_ => ["projektipäälliköksi"]} ;
|
||||
pl => table {_ => ["projektipäälliköiksi"]}
|
||||
}} ;
|
||||
|
||||
168
examples/letter/letter.Fra.gf
Normal file
168
examples/letter/letter.Fra.gf
Normal file
@@ -0,0 +1,168 @@
|
||||
--1 An French Concrete Syntax for Business and Love Letters
|
||||
--
|
||||
-- This file defines the French syntax of the grammar set
|
||||
-- whose abstract syntax is $letter.Abs.gf$.
|
||||
|
||||
include letter.Abs.gf ;
|
||||
|
||||
flags lexer=textlit ; unlexer=textlit ;
|
||||
|
||||
param Gen = masc | fem ;
|
||||
param Num = sg | pl ;
|
||||
param Kas = nom | acc ;
|
||||
param DepNum = depnum | cnum Num ;
|
||||
param DepGen = depgen | cgen Gen ;
|
||||
|
||||
lintype SS = {s : Str} ;
|
||||
lintype SSDep = {s : Num => Gen => Str} ; -- needs Num and Gen
|
||||
lintype SSSrc = {s : Str ; n : Num ; g : Gen} ; -- gives Num and Gen
|
||||
lintype SSSrc2 = {s : Num => Gen => Str ; n : DepNum ; g : DepGen} ; -- gives&needs
|
||||
lintype SSDep2 = {s : DepNum => DepGen => Num => Gen => Str} ; -- needs Auth's&Rec's
|
||||
lintype SSSrcGen = {s : Str ; n : Num ; g : Gen} ; -- gives Num and Gen
|
||||
|
||||
oper
|
||||
ss : Str -> SS = \s -> {s = s} ;
|
||||
cher : Num => Gen => Tok =
|
||||
table {n => table {masc => regNom "cher" ! n ; fem => regNom "chère" ! n}};
|
||||
regAdj : Str -> Gen => Num => Str = \s ->
|
||||
table {masc => regNom s ; fem => regNom (s + "e")} ;
|
||||
regNom : Str -> Num => Str = \s -> table {sg => s ; pl => s + "s"} ;
|
||||
egosum : Num => Str =
|
||||
table {sg => "je" ++ "suis" ; pl => "nous" ++ "sommes"} ;
|
||||
egohabeo : Num => Str =
|
||||
table {sg => "j'ai" ; pl => "nous" ++ "avons"} ;
|
||||
fuisti : Num => Str =
|
||||
table {sg => "tu" ++ "as" ++ "été"; pl => "vous" ++ "avez" ++ "été"} ;
|
||||
quePrep = "que" ; ----
|
||||
tuinformare : Num => Str =
|
||||
table {sg => "t'informer"; pl => "vous" ++ "informer"} ;
|
||||
|
||||
avoir : Num => Str =
|
||||
table {sg => "a"; pl => "ont"} ;
|
||||
|
||||
mes : Num => Str = table {sg => "mes" ; pl => "nos"} ;
|
||||
|
||||
teamo : Num => Num => Str = table {
|
||||
sg => table {sg => "je" ++ "t'aime" ;
|
||||
pl => "je" ++ "vous" ++ "aime"} ;
|
||||
pl => table {sg => "nous" ++ "t'aimons" ;
|
||||
pl => "nous" ++ "vous" ++ "aimons"}
|
||||
} ;
|
||||
|
||||
constNG : Str -> Num -> Gen -> SSSrc2 = \str,num,gen ->
|
||||
{s = table {_ => table {_ => str}} ; n = cnum num ; g = cgen gen} ;
|
||||
|
||||
dep2num : DepNum -> Num -> Num = \dn,n -> case dn of {
|
||||
depnum => n ;
|
||||
cnum sg => sg ;
|
||||
cnum pl => pl
|
||||
} ;
|
||||
dep2gen : DepGen -> Gen -> Gen = \dg,g -> case dg of {
|
||||
depgen => case g of {
|
||||
masc => fem ;
|
||||
fem => masc
|
||||
}; -- negative dependence: the author is of opposite sex
|
||||
cgen cg => cg
|
||||
} ;
|
||||
|
||||
|
||||
lincat
|
||||
Letter = SS ;
|
||||
Recipient = SSSrc ;
|
||||
Author = SSSrc2 ;
|
||||
Message = SSDep2 ;
|
||||
Heading = SSSrc ;
|
||||
Ending = SSSrc2 ;
|
||||
Mode = SSDep2 ;
|
||||
Sentence = SSDep2 ;
|
||||
NounPhrase = SSSrcGen ;
|
||||
Position = SSDep ;
|
||||
|
||||
lin
|
||||
MkLetter head mess end =
|
||||
ss (head.s ++ "," ++ "<p>" ++
|
||||
mess.s ! end.n ! end.g ! head.n ! head.g ++ "." ++ "<p>" ++
|
||||
end.s ! head.n ! head.g) ;
|
||||
|
||||
DearRec rec = {s = cher ! rec.n ! rec.g ++ rec.s ; n = rec.n ; g = rec.g} ;
|
||||
PlainRec rec = rec ;
|
||||
HelloRec rec = {s = "Bonjour" ++ rec.s ; n = rec.n ; g = rec.g} ;
|
||||
JustHello rec = {s = "Bonjour" ; n = rec.n ; g = rec.g} ;
|
||||
|
||||
ModeSent mode sent =
|
||||
{s =
|
||||
table {na => table {xa => table {nr => table {xr =>
|
||||
mode.s ! na ! xa ! nr ! xr ++ sent.s ! na ! xa ! nr ! xr}}}}
|
||||
} ;
|
||||
PlainSent sent = sent ;
|
||||
|
||||
FormalEnding auth =
|
||||
{s =
|
||||
table {n => table {g =>
|
||||
"avec" ++ mes ! dep2num auth.n n ++
|
||||
["salutations distinguées <p>"] ++ auth.s ! n ! g}} ;
|
||||
n = auth.n ; g = auth.g} ;
|
||||
InformalEnding auth =
|
||||
{s = table {n => table {g => ["Amicalement <p>"] ++ auth.s ! n ! g}} ;
|
||||
n = auth.n ; g = auth.g} ;
|
||||
|
||||
ColleaguesHe = {s = regNom "collègue" ! pl ; n = pl ; g = masc} ;
|
||||
ColleaguesShe = {s = regNom "collègue" ! pl ; n = pl ; g = fem} ;
|
||||
ColleagueHe = {s = regNom "collègue" ! sg ; n = sg ; g = masc} ;
|
||||
ColleagueShe = {s = regNom "collègue" ! sg ; n = sg ; g = fem} ;
|
||||
DarlingHe = {s = "chéri" ; n = sg ; g = masc} ;
|
||||
DarlingShe = {s = "chérie" ; n = sg ; g = fem} ;
|
||||
NameHe s = {s = s.s ; n = sg ; g = masc} ;
|
||||
NameShe s = {s = s.s ; n = sg ; g = fem} ;
|
||||
|
||||
Honour = {s =
|
||||
table {na => table {xa => table {nr => table {xr =>
|
||||
egohabeo ! dep2num na nr ++
|
||||
["l'honneur de"] ++ tuinformare ! nr ++ quePrep}}}}
|
||||
} ;
|
||||
|
||||
Regret = {s =
|
||||
table {na => table {ga => table {nr => table {gr =>
|
||||
let {dga = dep2gen ga gr ; dna = dep2num na nr} in
|
||||
egosum ! dna ++ regAdj "désolé" ! dga ! dna ++
|
||||
["d'informer"] ++ quePrep}}}}
|
||||
} ;
|
||||
|
||||
|
||||
President = constNG ["le président"] sg masc ;
|
||||
Mother = constNG ["maman"] sg fem ;
|
||||
Spouse = {s = table {
|
||||
sg => table {fem => ["ton mari"] ; masc => ["ta femme"]} ;
|
||||
pl => table {fem => ["vos maris"] ; masc => ["vos femmes"]}
|
||||
} ; n = depnum ; g = depgen} ;
|
||||
Dean = constNG ["le doyen"] sg masc ;
|
||||
Name s = constNG s.s sg masc ; ---
|
||||
|
||||
BePromoted pos = {s =
|
||||
table {na => table {xa => table {nr => table {xr =>
|
||||
fuisti ! nr ++ regAdj "promu" ! xr ! nr ++
|
||||
pos.s ! nr ! xr}}}}
|
||||
} ;
|
||||
GoBankrupt np = {s =
|
||||
table {na => table {xa => table {nr => table {xr =>
|
||||
np.s ++ avoir ! np.n ++ ["fait banqueroute"]}}}}
|
||||
} ;
|
||||
ILoveYou = {s =
|
||||
table {na => table {xa => table {nr => table {xr =>
|
||||
teamo ! dep2num na nr ! nr}}}}
|
||||
} ;
|
||||
|
||||
Company = {s = ["notre entreprise"] ; n = sg ; g = fem} ;
|
||||
Competitor = {s = ["notre pire compétiteur"] ; n = sg ; g = masc} ;
|
||||
OurCustomers = {s = ["nos clients"] ; n = pl ; g = masc} ;
|
||||
|
||||
Senior = {s = table {sg => table {g => ["responsable scientifique"]} ;
|
||||
pl => table {g => ["responsables scientifiques"]}
|
||||
}
|
||||
} ;
|
||||
|
||||
ProjectManager = {s =
|
||||
table {
|
||||
sg => table {_ => ["chef de projet"]} ;
|
||||
pl => table {_ => ["chefs de projets"]}
|
||||
}} ;
|
||||
178
examples/letter/letter.RusU.gf
Normal file
178
examples/letter/letter.RusU.gf
Normal file
@@ -0,0 +1,178 @@
|
||||
include letter.Abs.gf ;
|
||||
|
||||
flags lexer=textlit ; unlexer=textlit ; coding=utf8 ;
|
||||
|
||||
param Gen = masc | fem ;
|
||||
param Num = sg | pl ;
|
||||
param Kas = nom | acc ;
|
||||
param DepNum = depnum | cnum Num ;
|
||||
param DepGen = depgen | cgen Gen ;
|
||||
|
||||
lintype SS = {s : Str} ;
|
||||
lintype SSDep = {s : Num => Gen => Str} ; -- needs Num and Gen
|
||||
lintype SSSrc = {s : Str ; n : Num ; g : Gen} ; -- gives Num and Gen
|
||||
lintype SSSrc2 = {s : Num => Gen => Str ; n : DepNum ; g : DepGen} ; -- gives&needs
|
||||
lintype SSDep2 = {s : DepNum => DepGen => Num => Gen => Str} ; -- needs Auth's&Rec's
|
||||
lintype SSSrcGen = {s : Str ; n : Num ; g : Gen} ; -- gives Num and Gen
|
||||
|
||||
oper
|
||||
ss : Str -> SS = \s -> {s = s} ;
|
||||
regAdj : Str -> Num => Gen => Tok =\s -> table {
|
||||
sg => table {masc => s+"ой"; fem => s+"ая"};
|
||||
pl => table {masc => s+"ие"; fem => s+"ие"}
|
||||
};
|
||||
regVer : Str -> Num => Gen => Str = \s -> table {
|
||||
sg => table {masc => s; fem => s+"а"};
|
||||
pl => table {masc => s+"ы"; fem => s+"ы"}
|
||||
};
|
||||
|
||||
hello : Str -> Num => Str = \s ->
|
||||
table {sg => s ; pl => s+"те" } ;
|
||||
|
||||
regVerPerf : Str -> Num => Gen => Str = \s -> table {
|
||||
sg => table {masc => s+"ся"; fem => s+"ось"};
|
||||
pl => table {masc => s+"ись"; fem => s+"ись"}
|
||||
};
|
||||
|
||||
ego : Num => Str =
|
||||
table {sg => "я" ; pl => "вы" } ;
|
||||
egoHave : Num => Str =
|
||||
table {sg => ["я имею"] ; pl => ["мы имеем"]} ;
|
||||
|
||||
haveBeen : Num => Gen => Str = table {
|
||||
sg => table {masc => ["ты был"] ; fem => ["ты была"] };
|
||||
pl => table {masc => ["вы были"]; fem => ["вы были"]}
|
||||
};
|
||||
|
||||
thatPrep = [", что"] ;
|
||||
informYou : Num => Str =
|
||||
table {sg => ["сообщить тебе"]; pl => ["сообщить вам"]} ;
|
||||
|
||||
loveYou : Num => Num => Str = table {
|
||||
sg => table {sg => ["я тебя люблю"] ;
|
||||
pl => ["я вас люблю"]} ;
|
||||
pl => table {sg => ["мы тебя любим"] ;
|
||||
pl => ["мы вас любим"]}
|
||||
} ;
|
||||
|
||||
constNG : Str -> Num -> Gen -> SSSrc2 = \str,num,gen ->
|
||||
{s = table {_ => table {_ => str}} ; n = cnum num ; g = cgen gen} ;
|
||||
|
||||
dep2num : DepNum -> Num -> Num = \dn,n -> case dn of {
|
||||
depnum => n ;
|
||||
cnum cn => cn
|
||||
} ;
|
||||
dep2gen : DepGen -> Gen -> Gen = \dg,g -> case dg of {
|
||||
depgen => case g of {
|
||||
masc => fem ;
|
||||
fem => masc
|
||||
}; -- negative dependence: the author is of opposite sex
|
||||
cgen cg => cg
|
||||
} ;
|
||||
|
||||
|
||||
lincat
|
||||
Letter = SS ;
|
||||
Recipient = SSSrc ;
|
||||
Author = SSSrc2 ;
|
||||
Message = SSDep2 ;
|
||||
Heading = SSSrc ;
|
||||
Ending = SSSrc2 ;
|
||||
Mode = SSDep2 ;
|
||||
Sentence = SSDep2 ;
|
||||
NounPhrase = SSSrcGen ;
|
||||
Position = SSDep ;
|
||||
|
||||
lin
|
||||
MkLetter head mess end =
|
||||
ss (head.s ++ "," ++ "<p>" ++
|
||||
mess.s ! end.n ! end.g ! head.n ! head.g ++ "." ++ "<p>" ++
|
||||
end.s ! head.n ! head.g) ;
|
||||
|
||||
DearRec rec = {s = regAdj "Дорог"
|
||||
! rec.n ! rec.g ++ rec.s ; n = rec.n ; g = rec.g} ;
|
||||
PlainRec rec = rec ;
|
||||
HelloRec rec = {s = hello "Здравствуй" ! rec.n ++ rec.s ; n = rec.n ; g = rec.g} ;
|
||||
JustHello rec = {s = hello "Здравствуй" ! rec.n ; n = rec.n ; g = rec.g} ;
|
||||
|
||||
ModeSent mode sent =
|
||||
{s =
|
||||
table {na => table {xa => table {nr => table {xr =>
|
||||
mode.s ! na ! xa ! nr ! xr ++ sent.s ! na ! xa ! nr ! xr}}}}
|
||||
} ;
|
||||
PlainSent sent = sent ;
|
||||
|
||||
FormalEnding auth =
|
||||
{s =
|
||||
table {n => table {g =>
|
||||
"С" ++
|
||||
["наилучшими пожеланиями, <p>"] ++ auth.s ! n ! g}} ;
|
||||
n = auth.n ; g = auth.g} ;
|
||||
InformalEnding auth =
|
||||
{s = table {n => table {g => ["С дружеским приветом, <p>"] ++ auth.s ! n ! g}} ;
|
||||
n = auth.n ; g = auth.g} ;
|
||||
|
||||
ColleaguesHe = {s = "коллеги" ; n = pl ; g = masc} ;
|
||||
ColleaguesShe = {s = "коллеги" ; n = pl ; g = fem} ;
|
||||
ColleagueHe = {s = "коллега" ; n = sg ; g = masc} ;
|
||||
ColleagueShe = {s = "коллега" ; n = sg ; g = fem} ;
|
||||
DarlingHe = {s = "любимый" ; n = sg ; g = masc} ;
|
||||
DarlingShe = {s = "любимая" ; n = sg ; g = fem} ;
|
||||
NameHe s = {s = s.s ; n = sg ; g = masc} ;
|
||||
NameShe s = {s = s.s ; n = sg ; g = fem} ;
|
||||
|
||||
|
||||
Honour = {s =
|
||||
table {na => table {xa => table {nr => table {xr =>
|
||||
egoHave ! dep2num na nr ++
|
||||
["честь"] ++ informYou ! nr ++ thatPrep}}}}
|
||||
} ;
|
||||
|
||||
Regret = {s =
|
||||
table {na => table {ga => table {nr => table {gr =>
|
||||
let {dga = dep2gen ga gr ; dna = dep2num na nr} in
|
||||
ego ! dna ++ regVer "вынужден" ! dna ! dga ++
|
||||
["сообщить"] ++ thatPrep}}}}
|
||||
} ;
|
||||
|
||||
|
||||
President = constNG ["президент"] sg masc ;
|
||||
Mother = constNG ["мама"] sg fem ;
|
||||
Spouse = {s = table {
|
||||
sg => table {fem => ["твой муж"] ; masc => ["твоя жена"]} ;
|
||||
pl => table {fem => ["ваши мужья"] ; masc => ["ваши жены"]}
|
||||
} ; n = depnum ; g = depgen} ;
|
||||
Dean = constNG ["декан"] sg masc ;
|
||||
Name s = constNG s.s sg masc ; ---
|
||||
|
||||
BePromoted pos = {s =
|
||||
table {na => table {xa => table {nr => table {xr =>
|
||||
haveBeen ! nr ! xr ++ regVer "назначен" ! nr ! xr ++
|
||||
pos.s ! nr ! xr}}}}
|
||||
} ;
|
||||
GoBankrupt np = {s =
|
||||
table {na => table {xa => table {nr => table {xr =>
|
||||
np.s ++ regVerPerf "обанкротил" ! np.n ! np.g }}}}
|
||||
} ;
|
||||
ILoveYou = {s =
|
||||
table {na => table {xa => table {nr => table {xr =>
|
||||
loveYou ! dep2num na nr ! nr}}}}
|
||||
} ;
|
||||
|
||||
Company = {s = ["наше предприятие"] ; n = sg ; g = fem} ;
|
||||
Competitor = {s = ["наш конкурент"] ; n = sg ; g = masc} ;
|
||||
OurCustomers = {s = ["наши клиенты"] ; n = pl ; g = masc} ;
|
||||
|
||||
Senior = {s = table {sg => table {g => ["старшим научным сотрудником"]} ;
|
||||
pl => table {g =>[ "старшими научными сотрудниками"]}
|
||||
}
|
||||
} ;
|
||||
|
||||
ProjectManager = {s =
|
||||
table {
|
||||
sg => table {_ => ["менеджером проекта"]} ;
|
||||
pl => table {_ => ["менеджерами проектов"]}
|
||||
}} ;
|
||||
|
||||
|
||||
|
||||
161
examples/letter/letter.Sve.gf
Normal file
161
examples/letter/letter.Sve.gf
Normal file
@@ -0,0 +1,161 @@
|
||||
--1 An Swedish Concrete Syntax for Business and Love Letters
|
||||
--
|
||||
-- This file defines the Swedish syntax of the grammar set
|
||||
-- whose abstract syntax is $letter.Abs.gf$.
|
||||
|
||||
|
||||
include letter.Abs.gf ;
|
||||
|
||||
flags lexer=textlit ; unlexer=textlit ;
|
||||
|
||||
printname Letter = "Brev" ;
|
||||
printname MkLetter = "brevmall" ;
|
||||
|
||||
param Sex = masc | fem ;
|
||||
param Gen = en | ett ;
|
||||
param Num = sg | pl ;
|
||||
param Kas = nom | acc ;
|
||||
param DepNum = depnum | cnum Num ;
|
||||
|
||||
lintype SS = {s : Str} ;
|
||||
lintype SSDep = {s : Num => Sex => Str} ; -- needs Num and Sex
|
||||
lintype SSSrc = {s : Str ; n : Num ; x : Sex} ; -- gives Num and Sex
|
||||
lintype SSSrc2 = {s : Num => Sex => Str ; n : DepNum ; x : Sex} ; -- gives and needs
|
||||
lintype SSDep2 = {s : DepNum => Sex => Num => Sex => Str} ; -- needs Auth's & Recp's
|
||||
lintype SSSrcGen = {s : Str ; n : Num ; g : Gen} ; -- gives Num and Gen
|
||||
|
||||
|
||||
oper
|
||||
ss : Str -> SS = \s -> {s = s} ;
|
||||
|
||||
constNX : Str -> Num -> Sex -> SSSrc2 = \str,num,sex ->
|
||||
{s = table {_ => table {_ => str}} ; n = cnum num ; x = sex} ;
|
||||
|
||||
dep2num : DepNum -> Num -> Num = \dn,n -> case dn of {
|
||||
depnum => n ;
|
||||
cnum cn => cn
|
||||
} ;
|
||||
|
||||
lincat
|
||||
Letter = SS ;
|
||||
Recipient = SSSrc ;
|
||||
Author = SSSrc2 ;
|
||||
Message = SSDep2 ;
|
||||
Heading = SSSrc ;
|
||||
Ending = SSSrc2 ;
|
||||
Mode = SSDep2 ;
|
||||
Sentence = SSDep2 ;
|
||||
NounPhrase = SSSrcGen ;
|
||||
Position = SSDep ;
|
||||
|
||||
lin
|
||||
MkLetter head mess end =
|
||||
ss (head.s ++ "," ++ "<p>" ++
|
||||
mess.s ! end.n ! end.x ! head.n ! head.x ++ "." ++ "<p>" ++
|
||||
end.s ! head.n ! head.x) ;
|
||||
|
||||
DearRec rec = {s = kaer ! rec.n ! rec.x ++ rec.s ; n = rec.n ; x = rec.x} ;
|
||||
PlainRec rec = rec ;
|
||||
HelloRec rec = {s = "Hej" ++ rec.s ; n = rec.n ; x = rec.x} ;
|
||||
JustHello rec = {s = "Hej" ; n = rec.n ; x = rec.x} ;
|
||||
|
||||
ModeSent mode sent =
|
||||
{s =
|
||||
table {na => table {xa => table {nr => table {xr =>
|
||||
mode.s ! na ! xa ! nr ! xr ++ sent.s ! na ! xa ! nr ! xr}}}}
|
||||
} ;
|
||||
PlainSent sent = sent ;
|
||||
|
||||
FormalEnding auth =
|
||||
{s = table {n => table {x =>
|
||||
["Med vänlig hälsning <p>"] ++ auth.s ! n ! x}} ; n = auth.n ; x = auth.x} ;
|
||||
|
||||
InformalEnding auth =
|
||||
{s = table {n => table {x =>
|
||||
["Med hälsningar <p>"] ++ auth.s ! n ! x}} ; n = auth.n ; x = auth.x} ;
|
||||
|
||||
ColleaguesHe = {s = kollega ! pl ; n = pl ; x = masc} ;
|
||||
ColleaguesShe = {s = kollega ! pl ; n = pl ; x = fem} ;
|
||||
ColleagueHe = {s = kollega ! sg ; n = sg ; x = masc} ;
|
||||
ColleagueShe = {s = kollega ! sg ; n = sg ; x = fem} ;
|
||||
DarlingHe = {s = "älskling" ; n = sg ; x = masc} ;
|
||||
DarlingShe = {s = "älskling" ; n = sg ; x = fem} ;
|
||||
NameHe s = {s = s.s ; n = sg ; x = masc} ;
|
||||
NameShe s = {s = s.s ; n = sg ; x = fem} ;
|
||||
|
||||
Honour = {s =
|
||||
table {na => table {xa => table {nr => table {xr =>
|
||||
jag ! dep2num na nr ! nom ++ ["har äran att meddela"] ++
|
||||
du ! nr ! acc ++ "att"}}}}
|
||||
} ;
|
||||
|
||||
Regret = {s =
|
||||
table {na => table {xa => table {nr => table {xr =>
|
||||
jag ! dep2num na nr ! nom ++ ["måste tyvärr meddela"] ++
|
||||
du ! nr ! acc ++ "att"}}}}
|
||||
} ;
|
||||
|
||||
|
||||
President = constNX ["Presidenten"] sg masc ;
|
||||
Mother = constNX ["Mamma"] sg fem ;
|
||||
Spouse = {s = table {
|
||||
sg => table {fem => ["din man"] ; masc => ["din hustru"]} ;
|
||||
pl => table {fem => ["era män"] ; masc => ["era hustrur"]}
|
||||
} ; n = depnum ; x = masc} ; -- sex does not matter here
|
||||
Dean = constNX ["Dekanus"] sg masc ;
|
||||
Name s = constNX s.s sg masc ; ---
|
||||
|
||||
BePromoted pos = {s =
|
||||
table {na => table {xa => table {nr => table {xr =>
|
||||
du ! nr ! nom ++ ["har blivit"] ++ befordrad ! nr ++
|
||||
"till" ++ pos.s ! nr ! xr}}}}
|
||||
} ;
|
||||
GoBankrupt np = {s =
|
||||
table {na => table {xa => table {nr => table {xr =>
|
||||
np.s ++ ["har gått i konkurs"]}}}}
|
||||
} ;
|
||||
ILoveYou = {s =
|
||||
table {na => table {xa => table {nr => table {xr =>
|
||||
jag ! dep2num na nr ! nom ++ ["älskar"] ++ du ! nr ! acc}}}}
|
||||
} ;
|
||||
|
||||
Company = {s = ["vårt företag"] ; n = sg ; g = ett} ;
|
||||
Competitor = {s = ["vår värsta konkurrent"] ; n = sg ; g = en} ;
|
||||
OurCustomers = {s = ["våra kunder"] ; n = pl ; g = en} ;
|
||||
|
||||
Senior = {s = table {n => table {x => ["äldre forskare"]}}} ;
|
||||
ProjectManager = {s =
|
||||
table {
|
||||
sg => table {_ => "projektchef"} ;
|
||||
pl => table {_ => "projektchefer"}
|
||||
}} ;
|
||||
|
||||
oper
|
||||
|
||||
kaer :
|
||||
Num => Sex => Str =
|
||||
table {
|
||||
sg => table {masc => "Käre" ; fem => "Kära"} ;
|
||||
pl => table {_ => "Kära"}
|
||||
} ;
|
||||
|
||||
kollega :
|
||||
Num => Str =
|
||||
table {sg => "kollega" ; pl => "kollegor"} ;
|
||||
|
||||
befordrad :
|
||||
Num => Str =
|
||||
table {sg => "befordrad" ; pl => "befordrade"} ;
|
||||
|
||||
jag :
|
||||
Num => Kas => Str =
|
||||
table {
|
||||
sg => table {nom => "jag" ; acc => "mig"} ;
|
||||
pl => table {nom => "vi" ; acc => "oss"}
|
||||
} ;
|
||||
du :
|
||||
Num => Kas => Str =
|
||||
table {
|
||||
sg => table {nom => "du" ; acc => "dig"} ;
|
||||
pl => table {nom => "ni" ; acc => "er"}
|
||||
} ;
|
||||
13
examples/letter/mkLetter.gfs
Normal file
13
examples/letter/mkLetter.gfs
Normal file
@@ -0,0 +1,13 @@
|
||||
-- to make a multilingual gfcm grammar for rapid loading. AR 29/1/2004
|
||||
-- to run: gf2+ <mkLetter.gfs
|
||||
|
||||
i -old -abs=Letter -cnc=English letter.Eng.gf
|
||||
i -old -abs=Letter -cnc=French letter.Fra.gf
|
||||
i -old -abs=Letter -cnc=Swedish letter.Sve.gf
|
||||
i -old -abs=Letter -cnc=Finnish letter.Fin.gf
|
||||
i -old -abs=Letter -cnc=Russian letter.RusU.gf
|
||||
s
|
||||
pm | wf Letter.gfcm
|
||||
|
||||
|
||||
|
||||
@@ -409,7 +409,7 @@ displaySStateJavaX isNew env state = encodeUTF8 $ mkUnicode $
|
||||
]
|
||||
where
|
||||
(tree,msg,menu) = displaySState env state
|
||||
menu' = [tagXML "show" [s] ++ tagXML "send" [c] | (s,c) <- menu]
|
||||
menu' = [tagXML "show" [unicode s] ++ tagXML "send" [c] | (s,c) <- menu]
|
||||
(ls,grs) = unzip $ lgrs
|
||||
lgrs = allActiveStateGrammarsWithNames env
|
||||
lins = (langAbstract, exp) : linAll
|
||||
@@ -423,6 +423,11 @@ displaySStateJavaX isNew env state = encodeUTF8 $ mkUnicode $
|
||||
gr = firstStateGrammar env
|
||||
mark = markOptXML -- markOptJava
|
||||
|
||||
unicode = case getOptVal opts menuDisplay of
|
||||
Just lang -> optDecodeUTF8 (stateGrammarOfLang env (language lang))
|
||||
_ -> id
|
||||
|
||||
|
||||
langAbstract = language "Abstract"
|
||||
langXML = language "XML"
|
||||
|
||||
|
||||
@@ -1 +1 @@
|
||||
module Today where today = "Wed Jan 28 14:24:20 CET 2004"
|
||||
module Today where today = "Thu Jan 29 13:42:01 CET 2004"
|
||||
|
||||
Reference in New Issue
Block a user