caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] Ast_iterator example?
@ 2019-07-12 13:25 Richard W.M. Jones
  2019-07-12 13:40 ` Nicolás Ojeda Bär
  0 siblings, 1 reply; 2+ messages in thread
From: Richard W.M. Jones @ 2019-07-12 13:25 UTC (permalink / raw)
  To: caml-list

[-- Attachment #1: Type: text/plain, Size: 283 bytes --]


As previously discussed:
https://sympa.inria.fr/sympa/arc/caml-list/2019-06/msg00050.html

I'm now trying to port ocaml-gettext to use ppx.  However I can't get
even a trivial Ast_iterator example to compile.  Does anyone have a
simple compilable example using Ast_iterator?

Rich.

[-- Attachment #2: gettext_plugin.ml --]
[-- Type: text/plain, Size: 3174 bytes --]

(**************************************************************************)
(*  ocaml-gettext: a library to translate messages                        *)
(*                                                                        *)
(*  Copyright (C) 2003-2008 Sylvain Le Gall <sylvain@le-gall.net>         *)
(*                                                                        *)
(*  This library is free software; you can redistribute it and/or         *)
(*  modify it under the terms of the GNU Lesser General Public            *)
(*  License as published by the Free Software Foundation; either          *)
(*  version 2.1 of the License, or (at your option) any later version;    *)
(*  with the OCaml static compilation exception.                          *)
(*                                                                        *)
(*  This library is distributed in the hope that it will be useful,       *)
(*  but WITHOUT ANY WARRANTY; without even the implied warranty of        *)
(*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU     *)
(*  Lesser General Public License for more details.                       *)
(*                                                                        *)
(*  You should have received a copy of the GNU Lesser General Public      *)
(*  License along with this library; if not, write to the Free Software   *)
(*  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307   *)
(*  USA                                                                   *)
(**************************************************************************)

(** PPX dumper to extract strings.
    @author Richard W.M. Jones
    @author Sylvain Le Gall
  *)

(* Extract the string which should be used for a gettext translation. Output a
   po_content list through the function Marshal.to_channel
   Functions that are looked for :
Functions     Arg 1      Arg 2      Arg 3      Arg 4      Arg 5      Arg 6   ...
s_            singular
f_            singular
sn_           singular   plural     _
fn_           singular   plural     _
gettext       _          singular
fgettext      _          singular
dgettext      _          domain     singular
fdgettext     _          domain     singular
dcgettext     _          domain     singular   _
fdcgettext    _          domain     singular   _
ngettext      _          singular   plural     _        
fngettext     _          singular   plural     _          
dngettext     _          domain     singular   plural     _
fdngettext    _          domain     singular   plural     _
dcngettext    _          domain     singular   plural     _          _   
fdcngettext   _          domain     singular   plural     _          _


All this function name should also be matched when they are called using a
module.
                                      
*)

let visit_expr (iterator : Ast_iterator.iterator) expr =
  ()

let ast_iterator () =
  { Ast_iterator.default_iterator with expr = visit_expr }
let transform hook_info structure =
  let astm = ast_iterator () in
  astm.structure astm structure
let () = Pparse.ImplementationHooks.add_hook "ocaml-gettext" transform

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-07-12 13:40 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-12 13:25 [Caml-list] Ast_iterator example? Richard W.M. Jones
2019-07-12 13:40 ` Nicolás Ojeda Bär

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).