forked from GitHub/gf-core
multimodality exx
This commit is contained in:
8
grammars/prelude/HTML.gf
Normal file
8
grammars/prelude/HTML.gf
Normal file
@@ -0,0 +1,8 @@
|
||||
resource HTML = open Prelude in {
|
||||
oper
|
||||
tag : Str -> Str = \t -> "<" + t + ">" ;
|
||||
endtag : Str -> Str = \t -> tag ("/" + t) ;
|
||||
intag : Str -> Str -> Str = \t,s -> tag t ++ s ++ endtag t ;
|
||||
intagAttr : Str -> Str -> Str -> Str =
|
||||
\t,a,s -> ("<" + t) ++ (a + ">") ++ s ++ endtag t ;
|
||||
}
|
||||
12
grammars/prelude/Latex.gf
Normal file
12
grammars/prelude/Latex.gf
Normal file
@@ -0,0 +1,12 @@
|
||||
resource Latex = open Prelude in {
|
||||
oper
|
||||
command : Str -> Str = \c -> "\\" + c ;
|
||||
fun1 : Str -> Str -> Str = \f,x -> "\\" + f + "{" ++ x ++ "}" ;
|
||||
fun2 : Str -> Str -> Str -> Str =
|
||||
\f,x,y -> "\\" + f + "{" ++ x ++ "}{" ++ y ++ "}" ;
|
||||
begin : Str -> Str = \e -> "\\begin{" + e + "}" ;
|
||||
end : Str -> Str = \e -> "\\end{" + e + "}" ;
|
||||
inEnv : Str -> Str -> Str = \e,s -> begin e ++ s ++ end e ;
|
||||
}
|
||||
|
||||
|
||||
@@ -3,9 +3,10 @@
|
||||
concrete TimetableEng of Timetable = open Prelude in {
|
||||
|
||||
lin
|
||||
MkTable cs ts = ss (["trains on the line from"] ++ cs.s ++ ":" ++ ts.s) ;
|
||||
MkTable cs ts =
|
||||
ss (["The following trains run on the line from"] ++ cs.s ++ "." ++ ts.s) ;
|
||||
NilTrain _ = ss [] ;
|
||||
ConsTrain cs n t ts = ss (n.s ++ ":" ++ t.s ++ ";") ;
|
||||
ConsTrain cs n t ts = ss (n.s ++ ":" ++ t.s ++ "." ++ ts.s) ;
|
||||
OneCity c = c ;
|
||||
ConsCity c cs = ss (c.s ++ "to" ++ cs.s) ;
|
||||
|
||||
@@ -16,7 +17,7 @@ concrete TimetableEng of Timetable = open Prelude in {
|
||||
CityTrain c s cs t = ss (c.s ++ s.s ++ "," ++ t.s) ;
|
||||
|
||||
T i = prefixSS "at" i ;
|
||||
N n = prefixSS "train" n ;
|
||||
N n = prefixSS "Train" n ;
|
||||
C s = s ;
|
||||
|
||||
}
|
||||
|
||||
@@ -1,24 +1,24 @@
|
||||
--# -path=.:../prelude
|
||||
|
||||
concrete TimetableHTML of Timetable = open Prelude in {
|
||||
concrete TimetableHTML of Timetable = open Prelude, HTML in {
|
||||
|
||||
lin
|
||||
MkTable cs ts =
|
||||
ss ("<table>" ++ "<tr><td></td>"++ cs.s ++ </tr> ++ ts.s ++ "</table>") ;
|
||||
ss (intagAttr "table"
|
||||
"border=ON" (intag "tr" (intag "td" [] ++ cs.s) ++ ts.s)) ;
|
||||
NilTrain _ = ss [] ;
|
||||
ConsTrain cs n t ts =
|
||||
ss ("<tr>" ++ n.s ++ t.s ++ "</tr>") ;
|
||||
OneCity c = ss ("<td>" ++ c ++ "</td>") ;
|
||||
ConsCity c cs = ss (c.s ++ "to" ++ cs.s) ;
|
||||
ConsTrain cs n t ts = ss (intag "tr" (intag "td" n.s ++ t.s) ++ ts.s) ;
|
||||
OneCity c = ss (intag "td" c.s) ;
|
||||
ConsCity c cs = ss (intag "td" c.s ++ cs.s) ;
|
||||
|
||||
StopTime t = t ;
|
||||
NoStop = ss ["no stop"] ;
|
||||
StopTime t = ss (intag "td" t.s) ;
|
||||
NoStop = ss (intag "td" "-") ;
|
||||
|
||||
LocTrain c s = cc2 c s ;
|
||||
CityTrain c s cs t = ss (c.s ++ s.s ++ "," ++ t.s) ;
|
||||
LocTrain c s = s ;
|
||||
CityTrain c s cs t = ss (s.s ++ t.s) ;
|
||||
|
||||
T i = prefixSS "at" i ;
|
||||
N n = prefixSS "train" n ;
|
||||
C s = s ;
|
||||
T i = i ;
|
||||
N n = ss (intag "b" n.s) ;
|
||||
C s = ss (intag "b" s.s) ;
|
||||
|
||||
}
|
||||
|
||||
28
grammars/timetable/TimetableLatex.gf
Normal file
28
grammars/timetable/TimetableLatex.gf
Normal file
@@ -0,0 +1,28 @@
|
||||
--# -path=.:../prelude
|
||||
|
||||
concrete TimetableLatex of Timetable = open Prelude, Latex in {
|
||||
|
||||
lincat
|
||||
CityList = {s,s2 : Str} ; -- s2 encodes table width
|
||||
|
||||
lin
|
||||
MkTable cs ts =
|
||||
ss ("\\documentstyle{article}" ++ inEnv "document" (
|
||||
(inEnv "tabular" ("{" ++ cs.s2 ++ "}" ++ "&" ++ cs.s ++
|
||||
command "hline" ++ ts.s)))) ;
|
||||
NilTrain _ = ss [] ;
|
||||
ConsTrain cs n t ts = ss (n.s ++ "&" ++ t.s ++ "\\\\" ++ ts.s) ;
|
||||
OneCity c = {s = c.s ++ "\\\\" ; s2 = "l|l"} ;
|
||||
ConsCity c cs = {s = c.s ++ "&" ++ cs.s ; s2 = "l|" ++ cs.s2} ;
|
||||
|
||||
StopTime t = t ;
|
||||
NoStop = ss "---" ;
|
||||
|
||||
LocTrain c s = s ;
|
||||
CityTrain c s cs t = ss (s.s ++ "&" ++ t.s) ;
|
||||
|
||||
T i = i ;
|
||||
N n = n ; --- ss (fun1 "textbf" n.s) ;
|
||||
C s = s ; --- ss (fun1 "textbf" s.s) ;
|
||||
|
||||
}
|
||||
36
grammars/timetable/click.gf
Normal file
36
grammars/timetable/click.gf
Normal file
@@ -0,0 +1,36 @@
|
||||
cat
|
||||
Request ;
|
||||
Place ;
|
||||
Position ;
|
||||
|
||||
fun
|
||||
GoTo : Place -> Request ;
|
||||
GoFromTo : Place -> Place -> Request ;
|
||||
|
||||
Named : String -> Place ;
|
||||
Pointed : Position -> Place ;
|
||||
|
||||
Pos : Int -> Int -> Position ;
|
||||
|
||||
lincat
|
||||
Request, Place = {s,s2 : Str} ;
|
||||
|
||||
lin
|
||||
GoTo x = {
|
||||
s = ["I want to go to"] ++ x.s ;
|
||||
s2 = x.s2
|
||||
} ;
|
||||
GoFromTo x y = {
|
||||
s = ["I want to go from"] ++ x.s ++ "to" ++ y.s ;
|
||||
s2 = x.s2 ++ "," ++ y.s2
|
||||
} ;
|
||||
|
||||
Named c = {
|
||||
s = c.s ;
|
||||
s2 = []
|
||||
} ;
|
||||
Pointed p = {
|
||||
s = "here" ;
|
||||
s2 = p.s
|
||||
} ;
|
||||
Pos x y = {s = "(" ++ x.s ++ "," ++ y.s ++ ")"} ;
|
||||
Reference in New Issue
Block a user