forked from glen/fostr
Glen Whitney
b9c8532899
Note that ultimately a terminated sequence may have a slightly different semantics (applying streams to `_|_`, most likely) but for now they don't.
30 lines
782 B
Plaintext
30 lines
782 B
Plaintext
module javascript
|
|
imports libstrategolib signatures/- util
|
|
|
|
rules
|
|
js: TopLevel(x) -> $[const Stdio = {
|
|
gets: v => { process.stdout.write(String(v)); return Stdio; },
|
|
}
|
|
function to(data, strm) {
|
|
strm.gets(data);
|
|
return data;
|
|
}
|
|
[x]]
|
|
|
|
js: Stream() -> $[Stdio]
|
|
js: Int(x) -> x
|
|
js: Sum(x,y) -> $[[x] + [y]]
|
|
js: Gets(x, y) -> $[[x].gets([y])]
|
|
js: To(x, y) -> $[to([x],[y])]
|
|
js: Terminate(x) -> x
|
|
js: Sequence(l) -> <join(|";\n")>l
|
|
|
|
strategies
|
|
|
|
javascript = bottomup(try(js))
|
|
|
|
// 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
|