Skip to content

harukamm/block_of_ocaml

Repository files navigation

block_of_ocaml

Print AST of OCaml code as XML

How to use

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>

Running tests

$ python test.py

Compiling to JavaScript

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>"

References

About

Print AST of OCaml code as XML

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published