chore: Switch to this repository from predecessor
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
9ecfa63f58
commit
7b00b01856
23 changed files with 733 additions and 32 deletions
31
trans/javascript.str
Normal file
31
trans/javascript.str
Normal file
|
@ -0,0 +1,31 @@
|
|||
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; }
|
||||
}
|
||||
[<js>x]]
|
||||
|
||||
js: Stdio() -> $[Stdio]
|
||||
js: Int(x) -> x
|
||||
js: Sum(x) -> $[[<js>x].reduce((v,w) => v+w)]
|
||||
js: Receives(x, y) -> $[[<js>x].receives([<js>y])]
|
||||
js: [] -> $<[]>
|
||||
js: [x | xs] -> $<[<<js>x><<jstail>xs>]>
|
||||
|
||||
strategies
|
||||
// wrap expression in a toplevel and then apply code generation
|
||||
javascript = !TopLevel(<id>); js
|
||||
|
||||
// translate each element of a list, prepending each with ',', and concatenate
|
||||
jstail = foldr(!"", \ (x,y) -> $<, <<js>x><y>> \)
|
||||
|
||||
// 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
|
Loading…
Add table
Add a link
Reference in a new issue