Currently, the compiler service outputs unoptimized JavaScript. Send a POST request of a JSON object to our service and you'll get the synthesized layout engine:
var src = "interface I {} class C : I { children {} attributes { var x : int; } actions { x := 1; }}"; var myRequest = new Request({ url: 'http://ec2-54-218-69-113.us-west-2.compute.amazonaws.com/compile/', method: 'POST', data: JSON.stringify({ 'ftl': src, 'target': 'js' }), onSuccess: function(text, xml) { console.log("received from server: " + text.length + " characters"); if (text.substring(0,6) == "error:") console.error("Synthesis error: " + text.substring(6)); else console.log('result', JSON.parse(text)); } }).send();Switching to this compiler service model is exciting in a few ways, but the first two important ones will be:
- Legacy: as the FTL language upgrades, we'll just keep legacy compilers running. You won't need to see the bitrot for running legacy files. Once the API and site mature, we'll lock it in.
- Multiple backends: as hinted by the 'target' field, we're going to start exposing our multiple backends. Right now the naive JavaScript one is up, and next on bat is WebCL.
To play around, I posted an interactive fiddle.
No comments:
Post a Comment