forked from glen/fostr
Glen Whitney
991976d3a8
feat: sequencing of expressions with newline to same indent Also revised README to reflect greater emphasis on streams. Haskell code generation unsurprisingly required a fairly significant rework. Resolves #3. Co-authored-by: Glen Whitney <glen@studioinfinity.org> Reviewed-on: glen/fostr#11 Co-Authored-By: Glen Whitney <glen@nobody@nowhere.net> Co-Committed-By: Glen Whitney <glen@nobody@nowhere.net>
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
|