[Grace-core] Minigrace in the browser

Michael Homer mwh at ecs.vuw.ac.nz
Thu Jun 30 19:46:09 PDT 2011


Hi,
The last few days I've implemented a JavaScript backend for my
compiler alongside the LLVM one and gotten it up to scratch. Since the
compiler is self-hosting that also means that I have a compiler that
runs entirely in-browser: <http://ecs.vuw.ac.nz/~mwh/minigrace/js/>
(note: 33k lines of JavaScript, may be slow in older browsers, but
runs fine where I've tested).

To use it, Grace code goes into the top(-left) textarea and the result
of the compilation appears in the top-right/second. The bottom-left is
standard output (and input) and the bottom-right standard error. At
the bottom are the obvious options for compiling and running code, and
three alternative outputs: list of tokens, parse tree, and LLVM
bitcode. You can also load up most of my test cases (the ones that
don't depend on a Unicode character database or control characters)
for examples of what the compiler supports at the moment - those are
loaded synchronously over the network, so there will be a delay.

Everything runs entirely on the client side. The compiler is capable
of building itself in the browser, but the code that's running is
generated by the native compiler's --target js option. The vast
majority of the code is generated, but there is a small amount (~1.5%)
of hand-written JavaScript for the built-in types and necessary
standard library, and interfacing with the checkboxes on the page. It
supports essentially all of the functionality of the native compiler
other than filesystem access and Unicode properties.

Have at it! That version is from my live working tree, so it may be
temporarily broken occasionally, but if there's a persistent error I'm
interested to hear about it.
-Michael


More information about the Grace-core mailing list