From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by walapai.inria.fr (8.13.6/8.13.6) with ESMTP id oBT0MuVt006633 for ; Wed, 29 Dec 2010 01:22:56 +0100 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AsEAAKsOGk1KfVI0kGdsb2JhbACkKggVAQEBAQkJDAcRBCClHol3ghiEfC6IEwEBAwWFRQSLBIMdaQ X-IronPort-AV: E=Sophos;i="4.60,242,1291590000"; d="scan'208";a="83548093" Received: from mail-ww0-f52.google.com ([74.125.82.52]) by mail4-smtp-sop.national.inria.fr with ESMTP; 29 Dec 2010 01:22:49 +0100 Received: by wwd20 with SMTP id 20so9640246wwd.9 for ; Tue, 28 Dec 2010 16:22:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:from:content-type :content-transfer-encoding:subject:date:message-id:to:mime-version :x-mailer; bh=CUwRSPYzjg32a/ZlGcNztAij/hKWKX3kClfUnlvzIKY=; b=Ki+hr+rK/nPU+otNVYsKHw+m8VRulhU/n5X/IaNK1tcajSIZjbeW7Iqu069dk9b0j8 09+t0PvTGQvZbqO9jtrx9J2ZwKpbkoaZoynGgxlO2WPPhsc0plrdi1ooY7hOSOKE5SHz Bg8vOJSLM2yGA8aT8iFt+kC9GbXpJz79RQiJM= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:content-type:content-transfer-encoding:subject:date:message-id :to:mime-version:x-mailer; b=tggsDQmwdv8UydI86JkTV29VE0lWyvgOjzwO6cPOQoQZiK3zFa5xEqZfZUCMRYFK8P kVL44sLeobIU5KL9I6sr723J8bD7sL609auDhR3FWHwQ6x9NMw/SeXGbaysew+Lwz74z +bbustb/R37B7GPsV5sZYxDsAZYN2eWTkEhxs= Received: by 10.227.198.203 with SMTP id ep11mr8335876wbb.221.1293582167997; Tue, 28 Dec 2010 16:22:47 -0800 (PST) Received: from [192.168.0.196] ([95.60.213.7]) by mx.google.com with ESMTPS id p49sm5702950wes.18.2010.12.28.16.22.46 (version=TLSv1/SSLv3 cipher=RC4-MD5); Tue, 28 Dec 2010 16:22:47 -0800 (PST) From: Joel Reymont Content-Type: text/plain; charset=us-ascii Date: Wed, 29 Dec 2010 00:22:44 +0000 Message-Id: <7ABEB515-2F72-4CB7-BDE1-1695FA9970A4@gmail.com> To: caml-list@inria.fr Mime-Version: 1.0 (Apple Message framework v1082) X-Mailer: Apple Mail (2.1082) Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by walapai.inria.fr id oBT0MuVt006633 Subject: [Caml-list] fixing swig Here's what happens when building OCaml examples in the latest SWIG: --- ocamlc -I ` camlp4 -where` -pp "camlp4o pa_extend.cmo q_MLast.cmo" -c swigp4.ml File "swig.ml", line 159, characters 54-57: Warning 20: this argument will not be used by the function. File "swigp4.ml", line 26, characters 2-6: Parse error: Deprecated syntax, the grammar module is expected File "swigp4.ml", line 1, characters 0-1: Error: Preprocessor error make[1]: *** [ocaml_static_cpp] Error 2 --- The following code from swigp4.ml needs to be fixed but I don't know enough Camlp4 to do it :-(. If a kind soul can lend me a hand with this then I can try to incorporate the changes back into SWIG. Thanks in advance, Joel --- swigp4.ml --- open Pcaml ;; let lap x y = x :: y let c_ify e loc = match e with <:expr< $int:_$ >> -> <:expr< (C_int $e$) >> | <:expr< $str:_$ >> -> <:expr< (C_string $e$) >> | <:expr< $chr:_$ >> -> <:expr< (C_char $e$) >> | <:expr< $flo:_$ >> -> <:expr< (C_double $e$) >> | <:expr< True >> -> <:expr< (C_bool $e$) >> | <:expr< False >> -> <:expr< (C_bool $e$) >> | _ -> <:expr< $e$ >> let mk_list args loc f = let rec mk_list_inner args loc f = match args with [] -> <:expr< [] >> | x :: xs -> (let loc = MLast.loc_of_expr x in <:expr< [ ($f x loc$) ] @ ($mk_list_inner xs loc f$) >>) in match args with [] -> <:expr< (Obj.magic C_void) >> | [ a ] -> <:expr< (Obj.magic $f a loc$) >> | _ -> <:expr< (Obj.magic (C_list ($mk_list_inner args loc f$))) >> EXTEND expr: [ [ e1 = expr ; "'" ; "[" ; e2 = expr ; "]" -> <:expr< (invoke $e1$) "[]" (C_list [ $c_ify e2 loc$ ]) >> | e1 = expr ; "->" ; l = LIDENT ; "(" ; args = LIST0 (expr LEVEL "simple") SEP "," ; ")" -> <:expr< (invoke $e1$) $str:l$ ($mk_list args loc c_ify$) >> | e1 = expr ; "->" ; u = UIDENT ; "(" ; args = LIST0 (expr LEVEL "simple") SEP "," ; ")" -> <:expr< (invoke $e1$) $str:u$ ($mk_list args loc c_ify$) >> | e1 = expr ; "->" ; s = expr LEVEL "simple" ; "(" ; args = LIST0 (expr LEVEL "simple") SEP "," ; ")" -> <:expr< (invoke $e1$) $s$ ($mk_list args loc c_ify$) >> | e1 = expr ; "'" ; "." ; "(" ; args = LIST0 (expr LEVEL "simple") SEP "," ; ")" -> <:expr< (invoke $e1$) "()" ($mk_list args loc c_ify$) >> | e1 = expr ; "'" ; "->" ; l = LIDENT ; "(" ; args = LIST0 (expr LEVEL "simple") SEP "," ; ")" -> <:expr< (invoke ((invoke $e1$) "->" C_void)) $str:l$ ($mk_list args loc c_ify$) >> | e1 = expr ; "'" ; "->" ; u = UIDENT ; "(" ; args = LIST0 (expr LEVEL "simple") SEP "," ; ")" -> <:expr< (invoke ((invoke $e1$) "->" C_void)) $str:u$ ($mk_list args loc c_ify$) >> | e1 = expr ; "'" ; "->" ; s = expr LEVEL "simple" ; "(" ; args = LIST0 (expr LEVEL "simple") SEP "," ; ")" -> <:expr< (invoke ((invoke $e1$) "->" C_void)) $s$ ($mk_list args loc c_ify$) >> | e1 = expr ; "'" ; "++" -> <:expr< (invoke $e1$) "++" C_void >> | e1 = expr ; "'" ; "--" -> <:expr< (invoke $e1$) "--" C_void >> | e1 = expr ; "'" ; "-" ; e2 = expr -> <:expr< (invoke $e1$) "-" (C_list [ $c_ify e2 loc$ ]) >> | e1 = expr ; "'" ; "+" ; e2 = expr -> <:expr< (invoke $e1$) "+" (C_list [ $c_ify e2 loc$ ]) >> | e1 = expr ; "'" ; "*" ; e2 = expr -> <:expr< (invoke $e1$) "*" (C_list [ $c_ify e2 loc$ ]) >> | "'" ; "&" ; e1 = expr -> <:expr< (invoke $e1$) "&" C_void >> | "'" ; "!" ; e1 = expr -> <:expr< (invoke $e1$) "!" C_void >> | "'" ; "~" ; e1 = expr -> <:expr< (invoke $e1$) "~" C_void >> | e1 = expr ; "'" ; "/" ; e2 = expr -> <:expr< (invoke $e1$) "/" (C_list [ $c_ify e2 loc$ ]) >> | e1 = expr ; "'" ; "%" ; e2 = expr -> <:expr< (invoke $e1$) "%" (C_list [ $c_ify e2 loc$ ]) >> | e1 = expr ; "'" ; "lsl" ; e2 = expr -> <:expr< (invoke $e1$) ("<" ^ "<") (C_list [ $c_ify e2 loc$ ]) >> | e1 = expr ; "'" ; "lsr" ; e2 = expr -> <:expr< (invoke $e1$) (">" ^ ">") (C_list [ $c_ify e2 loc$ ]) >> | e1 = expr ; "'" ; "<" ; e2 = expr -> <:expr< (invoke $e1$) "<" (C_list [ $c_ify e2 loc$ ]) >> | e1 = expr ; "'" ; "<=" ; e2 = expr -> <:expr< (invoke $e1$) "<=" (C_list [ $c_ify e2 loc$ ]) >> | e1 = expr ; "'" ; ">" ; e2 = expr -> <:expr< (invoke $e1$) ">" (C_list [ $c_ify e2 loc$ ]) >> | e1 = expr ; "'" ; ">=" ; e2 = expr -> <:expr< (invoke $e1$) ">=" (C_list [ $c_ify e2 loc$ ]) >> | e1 = expr ; "'" ; "==" ; e2 = expr -> <:expr< (invoke $e1$) "==" (C_list [ $c_ify e2 loc$ ]) >> | e1 = expr ; "'" ; "!=" ; e2 = expr -> <:expr< (invoke $e1$) "!=" (C_list [ $c_ify e2 loc$ ]) >> | e1 = expr ; "'" ; "&" ; e2 = expr -> <:expr< (invoke $e1$) "&" (C_list [ $c_ify e2 loc$ ]) >> | e1 = expr ; "'" ; "^" ; e2 = expr -> <:expr< (invoke $e1$) "^" (C_list [ $c_ify e2 loc$ ]) >> | e1 = expr ; "'" ; "|" ; e2 = expr -> <:expr< (invoke $e1$) "|" (C_list [ $c_ify e2 loc$ ]) >> | e1 = expr ; "'" ; "&&" ; e2 = expr -> <:expr< (invoke $e1$) "&&" (C_list [ $c_ify e2 loc$ ]) >> | e1 = expr ; "'" ; "||" ; e2 = expr -> <:expr< (invoke $e1$) "||" (C_list [ $c_ify e2 loc$ ]) >> | e1 = expr ; "'" ; "=" ; e2 = expr -> <:expr< (invoke $e1$) "=" (C_list [ $c_ify e2 loc$ ]) >> | e1 = expr ; "'" ; "+=" ; e2 = expr -> <:expr< (invoke $e1$) "+=" (C_list [ $c_ify e2 loc$ ]) >> | e1 = expr ; "'" ; "-=" ; e2 = expr -> <:expr< (invoke $e1$) "-=" (C_list [ $c_ify e2 loc$ ]) >> | e1 = expr ; "'" ; "*=" ; e2 = expr -> <:expr< (invoke $e1$) "*=" (C_list [ $c_ify e2 loc$ ]) >> | e1 = expr ; "'" ; "/=" ; e2 = expr -> <:expr< (invoke $e1$) "/=" (C_list [ $c_ify e2 loc$ ]) >> | e1 = expr ; "'" ; "%=" ; e2 = expr -> <:expr< (invoke $e1$) "%=" (C_list [ $c_ify e2 loc$ ]) >> | e1 = expr ; "'" ; "lsl" ; "=" ; e2 = expr -> <:expr< (invoke $e1$) ("<" ^ "<=") (C_list [ $c_ify e2 loc$ ]) >> | e1 = expr ; "'" ; "lsr" ; "=" ; e2 = expr -> <:expr< (invoke $e1$) (">" ^ ">=") (C_list [ $c_ify e2 loc$ ]) >> | e1 = expr ; "'" ; "&=" ; e2 = expr -> <:expr< (invoke $e1$) "&=" (C_list [ $c_ify e2 loc$ ]) >> | e1 = expr ; "'" ; "^=" ; e2 = expr -> <:expr< (invoke $e1$) "^=" (C_list [ $c_ify e2 loc$ ]) >> | e1 = expr ; "'" ; "|=" ; e2 = expr -> <:expr< (invoke $e1$) "|=" (C_list [ $c_ify e2 loc$ ]) >> | "'" ; e = expr -> c_ify e loc | c = expr ; "as" ; id = LIDENT -> <:expr< $lid:"get_" ^ id$ $c$ >> | c = expr ; "to" ; id = LIDENT -> <:expr< $uid:"C_" ^ id$ $c$ >> | "`" ; "`" ; l = LIDENT -> <:expr< C_enum `$lid:l$ >> | "`" ; "`" ; u = UIDENT -> <:expr< C_enum `$uid:u$ >> | f = expr ; "'" ; "(" ; args = LIST0 (expr LEVEL "simple") SEP "," ; ")" -> <:expr< $f$ ($mk_list args loc c_ify$) >> ] ] ; END ;; --- http://wagerlabs.com | @wagerlabs | http://www.linkedin.com/in/joelreymont