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(data,strm): strm.receives(data) return data 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) -> $[forwards([x],[y])] 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