module javascript imports libstrategolib signatures/- signature constructors TopLevel: Ex -> Ex rules js: TopLevel(x) -> $[const Stdio = { receives: v => { process.stdout.write(String(v)); return Stdio; } } [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: [] -> $<[]> js: [x | xs] -> $<[<x><xs>]> strategies // wrap expression in a toplevel and then apply code generation javascript = !TopLevel(); js // translate each element of a list, prepending each with ',', and concatenate jstail = foldr(!"", \ (x,y) -> $<, <x>> \) // Interface javascript code generation with editor services and file system to-javascript: (selected, _, _, path, project-path) -> (filename, result) with filename := path ; result := selected