An open API service indexing awesome lists of open source software.

https://github.com/purefunctor/ocaml-jsoo-parse

An example of a menhir/ocamllex-based parser compiled to JavaScript using js_of_ocaml.
https://github.com/purefunctor/ocaml-jsoo-parse

Last synced: 3 months ago
JSON representation

An example of a menhir/ocamllex-based parser compiled to JavaScript using js_of_ocaml.

Awesome Lists containing this project

README

          

* ocaml-jsoo-parse
An example of a =menhir= / =ocamllex= -based parser compiled to JavaScript using
=js_of_ocaml=. Exposes a =parse= function that outputs the JSON representation of the AST type
defined in OCaml code. This makes it possible to deserialize the value into another representation,
such as an equivalent data type in PureScript.

** Usage
Ensure that you have an OCaml and Node.js installation.
#+begin_src sh
$ dune build
...

$ node
Welcome to Node.js v16.13.0.
Type ".help" for more information.
> const { parse } = require("./_build/default/bin/main.bc.js")
undefined
> parse("0 - 0 + 1 + 1 * (10 / 10 - 10)")
'[1,0,[1,0,[1,1,[0,0],[0,0]],[0,1]],[1,2,[0,1],[1,1,[1,3,[0,10],[0,10]],[0,10]]]]'
>
#+end_src