module python imports libstrategolib signatures/- util 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 def forwards(self, v): self.receives(v) return v Stdio = StdioC() [x]] py: Stdio() -> $[Stdio] py: Int(x) -> x py: Sum(x) -> $[sum([x])] py: Receives(x, y) -> $[[x].receives([y])] py: Enters(x, y) -> $[[y].forwards([x])] pylist: x -> $<[<x>]> strategies // wrap with a toplevel, then generate code from the bottom up python = !TopLevel(); bottomup(try(py <+ pylist)) // Interface python code generation with editor services and file system to-python: (selected, _, _, path, project-path) -> (filename, result) with filename := path ; result := selected