From: Peter Zotov <whitequark@whitequark.org>
To: caml-list@inria.fr
Subject: Re: [Caml-list] Writing preprocessor using compiler-libs
Date: Wed, 30 Jul 2014 03:32:19 +0400 [thread overview]
Message-ID: <a0fde45c8ceb9b225b2f4b1d98674f3f@whitequark.org> (raw)
In-Reply-To: <20140729214735.GA24140@delli7.univ-savoie.fr>
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
prev parent reply other threads:[~2014-07-29 23:32 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-29 21:47 Christophe Raffalli
2014-07-29 23:32 ` Peter Zotov [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=a0fde45c8ceb9b225b2f4b1d98674f3f@whitequark.org \
--to=whitequark@whitequark.org \
--cc=caml-list@inria.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox