Writing a parser for a DSL in OCaml using ppx and extension point
Asked Answered
S

1

9

Recently, it was announced in OCaml official github that Camlp4 is replaced by ppx rewriters and extension points (https://github.com/ocaml/camlp4):

Camlp4 was part of the official OCaml distribution until its version 4.01.0. Since then it has been replaced by a simpler system which is easier to maintain and to learn: ppx rewriters and extension points.

I have been using Camlp4 to write parsers for DSL (separated syntax from OCaml).

So, I would like to ask if the ppx rewriters tool can do the same thing?

Thank you for taking time to read my question!

Sinatra answered 14/6, 2016 at 11:19 Comment(0)
I
7

No. PPX is specialized to extend OCaml language functionality keeping its syntax, possibly using attributes and extension points. It does not provide a parser generator like CamlP4. If you are building a syntax completely different from OCaml, just stick to P4. PPX does not help you.

CamlP4 is not discontinued. It became an independent tool of OCaml compiler: https://github.com/ocaml/camlp4 You should also be able to install it using opam install camlp4.

Impost answered 14/6, 2016 at 13:24 Comment(1)
Thanks for your detail answer! It clears out my doubt about Camlp4 and PPX!Sinatra

© 2022 - 2024 — McMap. All rights reserved.