forked from glen/fostr
34 lines
841 B
Plaintext
34 lines
841 B
Plaintext
module javascript
|
|
imports libstrategolib signatures/- util
|
|
|
|
signature
|
|
constructors
|
|
TopLevel: Ex -> Ex
|
|
|
|
rules
|
|
js: TopLevel(x) -> $[const Stdio = {
|
|
receives: v => { process.stdout.write(String(v)); return Stdio; },
|
|
}
|
|
function forwards(data, strm) {
|
|
strm.receives(data);
|
|
return data;
|
|
}
|
|
[x]]
|
|
|
|
js: Stdio() -> $[Stdio]
|
|
js: Int(x) -> x
|
|
js: Sum(x) -> $[[x].reduce((v,w) => v+w)]
|
|
js: Receives(x, y) -> $[[x].receives([y])]
|
|
js: Enters(x, y) -> $[forwards([x],[y])]
|
|
|
|
jslist: x -> $<[<<join(|", ")>x>]>
|
|
|
|
strategies
|
|
|
|
javascript = bottomup(try(js <+ jslist))
|
|
|
|
// Interface javascript code generation with editor services and file system
|
|
to-javascript: (selected, _, _, path, project-path) -> (filename, result)
|
|
with filename := <guarantee-extension(|"js")> path
|
|
; result := <javascript> selected
|