Glen Whitney
5d81316ce2
Some checks failed
continuous-integration/drone/push Build is failing
Also revised README to reflect greater emphasis on streams. Resolves #3.
33 lines
786 B
Plaintext
33 lines
786 B
Plaintext
module javascript
|
|
imports libstrategolib signatures/- util
|
|
|
|
signature
|
|
constructors
|
|
TopLevel: Ex -> Ex
|
|
|
|
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: 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
|