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!
ppx is the main syntax extension format supported by OCaml. It allows for many features that aren't included in the core language to be added on, particularly ones that involve reducing boilerplate code. For example, there's usually no need to write code manually for the serialization or comparison of types.
What is a PPX? PPX rewriters or PPX-es are preprocessors that are applied to your code before passing it on to the compiler. They don't operate on your code directly but on the Abstract Syntax Tree or AST resulting from its parsing.
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
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With