Code Monkey home page Code Monkey logo

block_of_ocaml's Introduction

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

block_of_ocaml's People

Contributors

harukamm avatar

Stargazers

 avatar  avatar  avatar

block_of_ocaml's Issues

Which is ocaml version for make this project?

  • OCaml is 4.06.1
➜  block_of_ocaml_2 git:(master) make
ocamlfind ocamldep my_parse.mli > ._bcdi/my_parse.di
ocamlfind ocamldep main.ml > ._d/main.d
ocamlfind ocamldep my_compile.ml > ._d/my_compile.d
ocamlfind ocamldep my_parse.ml > ._d/my_parse.d
ocamlfind ocamldep astToBlock.ml > ._d/astToBlock.d
ocamlfind ocamldep xml.ml > ._d/xml.d
ocamlfind ocamlc -package compiler-libs.common,compiler-libs.bytecomp -c xml.ml
findlib: [WARNING] Interface topdirs.cmi occurs in several directories: /Users/clojure/.opam/4.06.1/lib/ocaml, /Users/clojure/.opam/4.06.1/lib/ocaml/compiler-libs
ocamlfind ocamlc -package compiler-libs.common,compiler-libs.bytecomp -c astToBlock.ml
findlib: [WARNING] Interface topdirs.cmi occurs in several directories: /Users/clojure/.opam/4.06.1/lib/ocaml, /Users/clojure/.opam/4.06.1/lib/ocaml/compiler-libs
ocamlfind ocamlc -package compiler-libs.common,compiler-libs.bytecomp -c my_parse.mli
findlib: [WARNING] Interface topdirs.cmi occurs in several directories: /Users/clojure/.opam/4.06.1/lib/ocaml, /Users/clojure/.opam/4.06.1/lib/ocaml/compiler-libs
ocamlfind ocamlc -package compiler-libs.common,compiler-libs.bytecomp -c my_parse.ml
findlib: [WARNING] Interface topdirs.cmi occurs in several directories: /Users/clojure/.opam/4.06.1/lib/ocaml, /Users/clojure/.opam/4.06.1/lib/ocaml/compiler-libs
ocamlfind ocamlc -package compiler-libs.common,compiler-libs.bytecomp -c my_compile.ml
findlib: [WARNING] Interface topdirs.cmi occurs in several directories: /Users/clojure/.opam/4.06.1/lib/ocaml, /Users/clojure/.opam/4.06.1/lib/ocaml/compiler-libs
ocamlfind ocamlc -package compiler-libs.common,compiler-libs.bytecomp -c main.ml
findlib: [WARNING] Interface topdirs.cmi occurs in several directories: /Users/clojure/.opam/4.06.1/lib/ocaml, /Users/clojure/.opam/4.06.1/lib/ocaml/compiler-libs
File "main.ml", line 49, characters 8-29:
Error: Unbound value Clflags.print_timings
make[1]: *** [main.cmo] Error 2
make: *** [byte-code] Error 2
➜  block_of_ocaml_2 git:(master)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.