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.
- Host: GitHub
- URL: https://github.com/purefunctor/ocaml-jsoo-parse
- Owner: purefunctor
- License: bsd-3-clause
- Created: 2021-12-06T13:45:55.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2021-12-06T15:58:06.000Z (over 4 years ago)
- Last Synced: 2025-01-25T06:41:21.998Z (over 1 year ago)
- Language: OCaml
- Homepage:
- Size: 7.81 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.org
- License: LICENSE
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