All pastes #951606 Raw Edit

Something

public text v1 · immutable
·published 2008-03-21 15:00 UTC
rendered paste body
module Id = struct
  let name = "pr_gettext" 
  let version = "$Id$" 
end 

module Make (Syntax : Camlp4.Sig.Syntax)
  : Camlp4.Sig.Printer(Syntax.Ast).S =
struct
  module Loc = Syntax.Loc
  module Ast = Syntax.Ast

  class visitor = object
    inherit Ast.fold as super

    val t = []
    method t = t

    method expr = function
    | <:expr@loc< f $str:singular$ >> ->
      let t = str :: t in
      {< t = t >}

    | e -> super#expr e
  end

  let print_interf ?input_file ?output_file _ = ()

  let print_implem ?input_file ?output_file ast =
    let visitor = (new visitor)#str_item in
    let t = (visitor ast)#t in
    List.iter prerr_endline t
end

(* Register the new printer. *)
module M = Camlp4.Register.Printer(Id)(Make)