* [Caml-list] Writing preprocessor using compiler-libs
@ 2014-07-29 21:47 Christophe Raffalli
2014-07-29 23:32 ` Peter Zotov
0 siblings, 1 reply; 2+ messages in thread
From: Christophe Raffalli @ 2014-07-29 21:47 UTC (permalink / raw)
To: Caml list
[-- Attachment #1: Type: text/plain, Size: 366 bytes --]
Hello,
There are a few examples and documentation on how to write syntax extensions without camlp4 using -ppx compiler flags.
However, I could not find an example of writing a preprocessor compatible with -pp only using compiler-libs and without camlp4 ?
Anyone with an example, even very simple like a calculator ;-) Or some guide lines ...
Cheers,
Christophe
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [Caml-list] Writing preprocessor using compiler-libs
2014-07-29 21:47 [Caml-list] Writing preprocessor using compiler-libs Christophe Raffalli
@ 2014-07-29 23:32 ` Peter Zotov
0 siblings, 0 replies; 2+ messages in thread
From: Peter Zotov @ 2014-07-29 23:32 UTC (permalink / raw)
To: caml-list
On 2014-07-30 01:47, Christophe Raffalli wrote:
> Hello,
>
> There are a few examples and documentation on how to write syntax
> extensions without camlp4 using -ppx compiler flags.
>
> However, I could not find an example of writing a preprocessor
> compatible with -pp only using compiler-libs and without camlp4 ?
The input format for -pp is plaintext; you can trivially use Lexer
and Parser from compiler-libs to get an OCaml AST.
The output format for -pp is either plaintext ('-pp cat' works), in
which case you can use Printast or Pprintast; or the same as for -ppx,
distinguished by the magic number, in which case you may use the
code from Ast_mapper[1] as an example.
[1]:
https://github.com/ocaml/ocaml/blob/68fe1ebd5a33636afd075419fa0362741f33f878/parsing/ast_mapper.ml#L652-L656
--
Peter Zotov
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-07-29 23:32 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-07-29 21:47 [Caml-list] Writing preprocessor using compiler-libs Christophe Raffalli
2014-07-29 23:32 ` Peter Zotov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox