chore: Switch to this repository from predecessor
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Glen Whitney 2021-01-30 15:37:53 -08:00
parent 9ecfa63f58
commit 7b00b01856
23 changed files with 733 additions and 32 deletions

View file

@ -15,12 +15,12 @@ rules // Analysis
// single-file analysis
editor-analyze = stx-editor-analyze(pre-analyze, post-analyze|"statics", "programOk")
// see README.md for details on how to switch to multi-file analysis
// see docs/implementation.md for details on how to switch to multi-file analysis
// multi-file analysis
// editor-analyze = stx-editor-analyze(pre-analyze, post-analyze|"statics", "projectOk", "fileOk")
pre-analyze = origin-track-forced(explicate-injections-fostr-Start)
post-analyze = origin-track-forced(implicate-injections-fostr-Start)
pre-analyze = origin-track-forced(explicate-injections-fostr-Ex)
post-analyze = origin-track-forced(implicate-injections-fostr-Ex)
rules // Editor Services

View file

@ -6,6 +6,9 @@ imports
pp
outline
analysis
haskell
javascript
python
rules // Debugging

41
trans/haskell.str Normal file
View file

@ -0,0 +1,41 @@
module haskell
imports libstrategolib signatures/-
signature
constructors
TopLevel: Ex -> Ex
rules
hs: TopLevel(x) -> $[import System.IO
data IOStream = StdIO
stdio :: IO IOStream
stdio = return StdIO
receives :: Show b => IO a -> b -> IO a
receives s d = do
temp <- s
putStr(show d)
return temp
main = do
[<hs>x]]
hs: Stdio() -> $[stdio]
hs: Int(x) -> x
hs: Sum(x) -> $[sum [<hs>x]]
hs: Receives(x, y) -> $[[<hs>x] `receives` [<hs>y]]
hs: [] -> $<[]>
hs: [x | xs] -> $<[<<hs>x><<hstail>xs>]>
strategies
// wrap expression in a toplevel and then apply code generation
haskell = !TopLevel(<id>); hs
// translate each element of a list, prepending each with ',', and concatenate
hstail = foldr(!"", \ (x,y) -> $<, <<hs>x><y>> \)
// Interface haskell code generation with editor services and file system
to-haskell: (selected, _, _, path, project-path) -> (filename, result)
with filename := <guarantee-extension(|"hs")> path
; result := <haskell> selected

31
trans/javascript.str Normal file
View 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

34
trans/python.str Normal file
View file

@ -0,0 +1,34 @@
module python
imports libstrategolib signatures/-
signature
constructors
TopLevel: Ex -> Ex
rules
py: TopLevel(x) -> $[import sys
class StdioC:
def receives(self, v):
print(v, file=sys.stdout, end='')
return self
Stdio = StdioC()
[<py>x]]
py: Stdio() -> $[Stdio]
py: Int(x) -> x
py: Sum(x) -> $[sum([<py>x])]
py: Receives(x, y) -> $[[<py>x].receives([<py>y])]
py: [] -> $<[]>
py: [x | xs] -> $<[<<py>x><<pytail>xs>]>
strategies
// wrap expression in a toplevel and then apply code generation
python = !TopLevel(<id>); py
// translate each element of a list, prepending each with ',', and concatenate
pytail = foldr(!"", \ (x,y) -> $[, [<py>x][y]] \)
// Interface python code generation with editor services and file system
to-python: (selected, _, _, path, project-path) -> (filename, result)
with filename := <guarantee-extension(|"py")> path
; result := <python> selected

View file

@ -1,12 +1,15 @@
module statics
// see README.md for details on how to switch to multi-file analysis
imports signatures/fostr-sig
// see docs/implementation.md for details on how to switch to multi-file analysis
rules // single-file entry point
programOk : Start
programOk : Ex
programOk(Empty()).
programOk(Sum(_)).
programOk(Receives(_,_)).
rules // multi-file entry point
@ -14,11 +17,6 @@ rules // multi-file entry point
projectOk(s).
fileOk : scope * Start
fileOk : scope * Ex
fileOk(s, Empty()).
signature
sorts Start constructors
Empty : Start
fileOk(s, Receives(_,_)).