Print AST of OCaml code as XML
To compile, just execute: make
$ ./block_of_ocaml "2 + 1"
<block type="int_arithmetic_typed"><field name="OP_INT">ADD_INT</field><value name="A"><block type="int_typed"><field name="INT">2</field></block></value><value name="B"><block type="int_typed"><field name="INT">1</field></block></value></block>
$ python test.py
You might need to run js_of_ocaml with options such as +weak.js, +toplevel.js, and +dynlink.js to provide missing primitives.
$ make bcl
$ make -C web
Function named blockOfOCaml
is exposed to JavaScript.
> blockOfOCaml("2 + 1")
"<block type="int_arithmetic_typed"><field name="OP_INT">ADD_INT</field><value name="A"><block type="int_typed"><field name="INT">2</field></block></value><value name="B"><block type="int_typed"><field name="INT">1</field></block></value></block>"