From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@sympa.inria.fr Delivered-To: caml-list@sympa.inria.fr Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by sympa.inria.fr (Postfix) with ESMTPS id 3846B7FA4D for ; Wed, 30 Jul 2014 01:32:22 +0200 (CEST) Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of whitequark@whitequark.org) identity=pra; client-ip=176.58.103.125; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="whitequark@whitequark.org"; x-sender="whitequark@whitequark.org"; x-conformance=sidf_compatible Received-SPF: Pass (mail2-smtp-roc.national.inria.fr: domain of whitequark@whitequark.org designates 176.58.103.125 as permitted sender) identity=mailfrom; client-ip=176.58.103.125; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="whitequark@whitequark.org"; x-sender="whitequark@whitequark.org"; x-conformance=sidf_compatible; x-record-type="v=spf1" Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of postmaster@mail.whitequark.org) identity=helo; client-ip=176.58.103.125; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="whitequark@whitequark.org"; x-sender="postmaster@mail.whitequark.org"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ArkFAEgu2FOwOmd9/2dsb2JhbABag2BXgieuAAEBAQEBAQaBOpoXhwk+AYEqd4QEAQU4Ak8EBxgdESwrIYg+Cb9QEwSFfINlhF2BFRaENAWKbKUxg044LwU X-IPAS-Result: ArkFAEgu2FOwOmd9/2dsb2JhbABag2BXgieuAAEBAQEBAQaBOpoXhwk+AYEqd4QEAQU4Ak8EBxgdESwrIYg+Cb9QEwSFfINlhF2BFRaENAWKbKUxg044LwU X-IronPort-AV: E=Sophos;i="5.01,760,1400018400"; d="scan'208";a="87525945" Received: from fehu.whitequark.org (HELO mail.whitequark.org) ([176.58.103.125]) by mail2-smtp-roc.national.inria.fr with ESMTP; 30 Jul 2014 01:32:21 +0200 Received: by mail.whitequark.org (Postfix, from userid 33) id CF0C24D72B; Tue, 29 Jul 2014 23:32:19 +0000 (UTC) To: caml-list@inria.fr X-PHP-Originating-Script: 1000:rcube.php MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Wed, 30 Jul 2014 03:32:19 +0400 From: Peter Zotov In-Reply-To: <20140729214735.GA24140@delli7.univ-savoie.fr> References: <20140729214735.GA24140@delli7.univ-savoie.fr> Message-ID: X-Sender: whitequark@whitequark.org User-Agent: Roundcube Webmail/1.0.1 Subject: Re: [Caml-list] Writing preprocessor using compiler-libs 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