From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id 6417DBB81 for ; Fri, 18 Nov 2005 10:22:53 +0100 (CET) Received: from x86unx3.comp.nus.edu.sg (x86unx3.comp.nus.edu.sg [137.132.80.24]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id jAI9Movb016051 for ; Fri, 18 Nov 2005 10:22:52 +0100 Received: from e500d.comp.nus.edu.sg (e500d.comp.nus.edu.sg [137.132.90.69]) by x86unx3.comp.nus.edu.sg (8.9.1-20030924/8.9.1) with SMTP id RAA14257 for ; Fri, 18 Nov 2005 17:22:48 +0800 (GMT-8) Received: from sn40.comp.nus.edu.sg(137.132.80.15) by e500d.comp.nus.edu.sg via csmap id 399e706e_5815_11da_9bc6_0030482985c3_32084; Fri, 18 Nov 2005 17:25:14 +0800 (SGT) Received: from zhuping (soccf-pls-037.ddns.comp.nus.edu.sg [172.18.179.29]) (authenticated bits=0) by sn40.comp.nus.edu.sg (8.13.1/8.13.1) with ESMTP id jAI9MgOf011070 (version=TLSv1/SSLv3 cipher=RC4-MD5 bits=128 verify=NOT) for ; Fri, 18 Nov 2005 17:22:45 +0800 (SGT) Message-ID: <001d01c5ec21$a25b8570$1db312ac@comp.nus.edu.sg> From: "Zhu Ping" To: Subject: Using Frontc Date: Fri, 18 Nov 2005 17:22:37 +0800 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_0018_01C5EC64.AC194870" X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2900.2527 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2527 X-Miltered: at concorde with ID 437D9D6A.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; ocaml:01 cdk:01 libc:01 cdk:01 tar:01 ocaml:01 ocamlopt:01 usr:01 lib:01 lib:01 ocaml-:01 usr:01 ocaml-:01 pervasives:01 cmi:01 X-Attachments: cset="gb2312" cset="gb2312" X-Spam-Checker-Version: SpamAssassin 3.0.3 (2005-04-27) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=HTML_60_70,HTML_MESSAGE autolearn=disabled version=3.0.3 This is a multi-part message in MIME format. ------=_NextPart_000_0018_01C5EC64.AC194870 Content-Type: text/plain; charset="gb2312" Content-Transfer-Encoding: quoted-printable Dear OCaml users: I'm using Frontc, which is one of the libraries released in CDK, to = parse C source code. I downloded the complete binaries for Linux i386 libc6 from = http://pauillac.inria.fr/cdk/binaries/binaries-3.03/gz/cdk-3.03.tar.gz = and installed it on a Linux server by following the installation = instructions. The following code (mail.ml) is the main ocaml program that use Frontc = to parse a sample code written in C language. open Frontc (* -------------------------------------- Test case for sample1.c = --------------------------------------*) let parse_result =3D Frontc.parse_file "/home/sand/zhuping/sample1.c" = error_channel;=20 I compiled the maim.ml using this command: ocamlopt -I = /usr/local/lib/cdk-3.03/lib/ocaml-3.03/ main.ml =20 But some error returns: = /usr/local/lib/cdk-3.03/lib/ocaml-3.03/pervasives.cmi is not a compiled = interface All the Frontc codes located under the directory = /usr/local/lib/cdk-3.03/lib/ocaml-3.03/ are compiled codes:=20 frontc.a frontc.cma frontc.cmi frontc.cmx frontc.cmxa clexer.cmi clexer.cmx cparser.cmi cparser.cmx cabs.cmi cabs.cmx cprint.cmi cprint.cmx There are no source implementation/interface files with respect to the = corresponding files listed above. Can anybody help to to solve this problem? Thank you very much for = your help:) ------=_NextPart_000_0018_01C5EC64.AC194870 Content-Type: text/html; charset="gb2312" Content-Transfer-Encoding: quoted-printable
Dear OCaml users:
 
  I'm using Frontc, which = is one of the=20 libraries released in CDK, to parse C source code.
 
  I downloded the complete = binaries for Linux=20 i386 libc6 from http://pauillac.inria.fr/cdk/binaries/binaries-3.03/gz/cdk-3.03.ta= r.gz and=20 installed it on a Linux server by following the installation=20 instructions.
 
  The following code=20 (mail.ml) is the main ocaml program that use Frontc to = parse a=20 sample code written in C language.
 
 
  open Frontc
  (* = --------------------------------------=20 Test case for sample1.c = --------------------------------------*)
  let parse_result =3D = Frontc.parse_file=20 "/home/sand/zhuping/sample1.c" error_channel;
 

  I compiled the maim.ml using this command: =20 ocamlopt -I /usr/local/lib/cdk-3.03/lib/ocaml-3.03/=20 main.ml
 
  But some error returns:=20 /usr/local/lib/cdk-3.03/lib/ocaml-3.03/pervasives.cmi is not a compiled=20 interface
 
  All the Frontc codes = located=20 under the directory /usr/local/lib/cdk-3.03/lib/ocaml-3.03/ are = compiled=20 codes:
   =20 frontc.a
    frontc.cma
   =20 frontc.cmi
    frontc.cmx
   =20 frontc.cmxa
   =20 clexer.cmi
    clexer.cmx
   =20 cparser.cmi
    cparser.cmx
   =20 cabs.cmi
    cabs.cmx
   =20 cprint.cmi
    cprint.cmx

There are no source = implementation/interface files=20 with respect to the corresponding files listed above.
 
  Can anybody help to to solve = this problem?=20 Thank you very much for your=20 help:)
------=_NextPart_000_0018_01C5EC64.AC194870-- From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id 37583BB81 for ; Fri, 18 Nov 2005 10:52:19 +0100 (CET) Received: from fork.recoil.org (fork.recoil.org [194.70.3.132]) by concorde.inria.fr (8.13.0/8.13.0) with SMTP id jAI9qIFF019437 for ; Fri, 18 Nov 2005 10:52:19 +0100 Received: (qmail 18008 invoked by uid 10000); 18 Nov 2005 09:52:14 -0000 Date: Fri, 18 Nov 2005 09:52:14 +0000 From: Anil Madhavapeddy To: Zhu Ping Cc: caml-list@yquem.inria.fr Subject: Re: [Caml-list] Using Frontc Message-ID: <20051118095213.GA5394@fork.recoil.org> References: <001d01c5ec21$a25b8570$1db312ac@comp.nus.edu.sg> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <001d01c5ec21$a25b8570$1db312ac@comp.nus.edu.sg> User-Agent: Mutt/1.5.9i X-Miltered: at concorde with ID 437DA452.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; anil:01 anil:01 caml-list:01 cdk:01 parser:01 ocaml:01 wrote:01 snip:02 parse:02 berkeley:03 berkeley:03 zhu:04 cambridge:04 problem:05 fri:05 X-Spam-Checker-Version: SpamAssassin 3.0.3 (2005-04-27) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.0.3 On Fri, Nov 18, 2005 at 05:22:37PM +0800, Zhu Ping wrote: > > I'm using Frontc, which is one of the libraries released in > CDK, to parse C source code. (snip) > > There are no source implementation/interface files with respect to > the corresponding files listed above. > > Can anybody help to to solve this problem? Thank you very much for > your help:) You haven't said if you must get FrontC to work, or can use any C parser. If you dont mind using another package, CIL from Berkeley is written in OCaml and is actively developed (and very very good). You can find more details at http://manju.cs.berkeley.edu/cil/ -- Anil Madhavapeddy http://anil.recoil.org University of Cambridge http://www.cl.cam.ac.uk From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by yquem.inria.fr (Postfix) with ESMTP id 9470ABB9C for ; Sun, 20 Nov 2005 09:45:08 +0100 (CET) Received: from x86unx3.comp.nus.edu.sg (x86unx3.comp.nus.edu.sg [137.132.80.24]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id jAK8j5aW032220 for ; Sun, 20 Nov 2005 09:45:07 +0100 Received: from e500c.comp.nus.edu.sg (e500c.comp.nus.edu.sg [137.132.90.68]) by x86unx3.comp.nus.edu.sg (8.9.1-20030924/8.9.1) with SMTP id QAA01709; Sun, 20 Nov 2005 16:44:58 +0800 (GMT-8) Received: from sn40.comp.nus.edu.sg(137.132.80.15) by e500c.comp.nus.edu.sg via csmap id 0615cd3a_59a2_11da_9a5e_003048298555_4282; Sun, 20 Nov 2005 16:45:38 +0800 (SGT) Received: from zhuping (soccf-pls-037.ddns.comp.nus.edu.sg [172.18.179.29]) (authenticated bits=0) by sn40.comp.nus.edu.sg (8.13.1/8.13.1) with ESMTP id jAK8iuAP022316 (version=TLSv1/SSLv3 cipher=RC4-MD5 bits=128 verify=NOT); Sun, 20 Nov 2005 16:44:57 +0800 (SGT) Message-ID: <002c01c5edae$afd08d20$1db312ac@comp.nus.edu.sg> From: "Zhu Ping" To: "Anil Madhavapeddy" Cc: Subject: Re: [Caml-list] Using Frontc Date: Sun, 20 Nov 2005 16:44:51 +0800 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_0029_01C5EDF1.BA545F40" X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2900.2527 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2527 X-Miltered: at nez-perce with ID 43803791.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; caml-list:01 parsing:01 ocaml:01 ocamlc:01 ocamlc:01 cmo:01 cmo:01 utime:01 anil:01 anil:01 caml-list:01 cdk:01 parser:01 ocaml:01 parsing:01 X-Attachments: cset="gb2312" cset="gb2312" X-Spam-Checker-Version: SpamAssassin 3.0.3 (2005-04-27) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.1 required=5.0 tests=HTML_40_50,HTML_MESSAGE autolearn=disabled version=3.0.3 This is a multi-part message in MIME format. ------=_NextPart_000_0029_01C5EDF1.BA545F40 Content-Type: text/plain; charset="gb2312" Content-Transfer-Encoding: quoted-printable Dear Madhavapeddy: I used FrontC because I hope the parsing result w.r.t a C source code is = represented in OCaml code. I installed CIT and linked my main program with the library released in = CIL. My main program (main.ml) now is: open Frontc (* -------------------------------------- Test case for sample1.wh = --------------------------------------*) let parse_result =3D Frontc.parse "/home/sand/zhuping/sample1.c";=20 The main program is successfully compiled without linking by executing: = ocamlc -c -I /home/sand/cil/obj/x86_LINUX main.ml But an error occurs when I linked the related object codes together: =20 ocamlc -o main -I /home/sand/cil/obj/x86_LINUX/ pretty.cmo trace.cmo = errormsg.cmo cabs.cmo cabsvisit.cmo escape.cmo cprint.cmo patch.cmo = frontc.cmo main.cmo "Error while linking /home/sand/cil/obj/x86_LINUX/patch.cmo: Reference = to undefined global 'Unix' " I looked into the patch.ml code and found this piece of code where = 'Unix' is referenced: let gettime () : float =3D (Unix.times ()).Unix.tms_utime Can anybody help me to solve this problem?=20 Thank you very much for your help:) ----- Original Message -----=20 From: "Anil Madhavapeddy" To: "Zhu Ping" Cc: Sent: Friday, November 18, 2005 5:52 PM Subject: Re: [Caml-list] Using Frontc > On Fri, Nov 18, 2005 at 05:22:37PM +0800, Zhu Ping wrote: >>=20 >> I'm using Frontc, which is one of the libraries released in >> CDK, to parse C source code. > (snip) >>=20 >> There are no source implementation/interface files with respect to >> the corresponding files listed above. >>=20 >> Can anybody help to to solve this problem? Thank you very much for >> your help:) >=20 > You haven't said if you must get FrontC to work, or can use any C > parser. If you dont mind using another package, CIL from Berkeley > is written in OCaml and is actively developed (and very very good). >=20 > You can find more details at http://manju.cs.berkeley.edu/cil/ >=20 > --=20 > Anil Madhavapeddy = http://anil.recoil.org > University of Cambridge = http://www.cl.cam.ac.uk > ------=_NextPart_000_0029_01C5EDF1.BA545F40 Content-Type: text/html; charset="gb2312" Content-Transfer-Encoding: quoted-printable
Dear Madhavapeddy:
 
I used FrontC because I hope the parsing result w.r.t a C source = code is=20 represented in OCaml code.
 
I installed CIT and linked my main program with the library = released in=20 CIL.
 
My main program (main.ml) now is:
 
  open Frontc
  (* = -------------------------------------- Test=20 case for sample1.wh --------------------------------------*)
  = let=20 parse_result =3D Frontc.parse "/home/sand/zhuping/sample1.c";
 
The main program is successfully compiled without linking by = executing:=20 ocamlc -c -I /home/sand/cil/obj/x86_LINUX  main.ml
 
But an error occurs when I linked the related object codes = together: =20
 
ocamlc -o main -I /home/sand/cil/obj/x86_LINUX/ pretty.cmo = trace.cmo=20 errormsg.cmo cabs.cmo cabsvisit.cmo escape.cmo cprint.cmo patch.cmo = frontc.cmo=20 main.cmo
 
"Error while linking /home/sand/cil/obj/x86_LINUX/patch.cmo: = Reference to=20 undefined global 'Unix' "
 
I looked into the patch.ml code and found this piece of code where = 'Unix'=20 is referenced:
let gettime () : float =3D (Unix.times = ()).Unix.tms_utime
 
 
Can anybody help me to solve this problem?
 
Thank you very much for your help:)
 
 
----- Original Message -----=20
From: "Anil Madhavapeddy" <anil@recoil.org>
To: "Zhu Ping" <zhuping@comp.nus.edu.sg>
Cc: <caml-list@yquem.inria.fr>=
Sent: Friday, November 18, 2005 5:52 PM
Subject: Re: [Caml-list] Using Frontc

> On Fri, Nov 18, 2005 at 05:22:37PM +0800, Zhu Ping=20 wrote:
>>
>> I'm using Frontc, which is one of the = libraries=20 released in
>> CDK, to parse C source code.
> = (snip)
>>=20
>> There are no source implementation/interface files with = respect=20 to
>> the corresponding files listed above.
>> =
>>=20 Can anybody help to to solve this problem? Thank you very much = for
>>=20 your help:)
>
> You haven't said if you must get FrontC to = work, or=20 can use any C
> parser.  If you dont mind using another = package, CIL=20 from Berkeley
> is written in OCaml and is actively developed (and = very=20 very good).
>
> You can find more details at http://manju.cs.berkeley.edu/c= il/
>=20
> --
> Anil=20 Madhavapeddy          &= nbsp;           &n= bsp;         =20 http://anil.recoil.org
> = University=20 of=20 Cambridge          &nbs= p;            = ;  =20 http://www.cl.cam.ac.uk
> ------=_NextPart_000_0029_01C5EDF1.BA545F40-- From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id 15158BB9C for ; Sun, 20 Nov 2005 13:37:48 +0100 (CET) Received: from mx.laposte.net (mx.laposte.net [81.255.54.11]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id jAKCblU1024965 for ; Sun, 20 Nov 2005 13:37:47 +0100 Received: from [192.168.1.10] (80.125.71.169) by mx.laposte.net (7.2.060.1) (authenticated as matthieu.dubuget) id 42FA13AB05AA702B; Sun, 20 Nov 2005 13:36:48 +0100 Message-ID: <43806DF3.1000806@laposte.net> Date: Sun, 20 Nov 2005 13:37:07 +0100 From: Matthieu Dubuget Reply-To: matthieu.dubuget@laposte.net User-Agent: Debian Thunderbird 1.0.7 (X11/20051017) X-Accept-Language: fr-fr, fr, en-us MIME-Version: 1.0 To: Zhu Ping Cc: Anil Madhavapeddy , caml-list@yquem.inria.fr Subject: Re: [Caml-list] Using Frontc References: <002c01c5edae$afd08d20$1db312ac@comp.nus.edu.sg> In-Reply-To: <002c01c5edae$afd08d20$1db312ac@comp.nus.edu.sg> X-Enigmail-Version: 0.93.0.0 Content-Type: text/plain; charset=GB2312 Content-Transfer-Encoding: 7bit X-Miltered: at concorde with ID 43806E1B.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; matthieu:01 dubuget:01 matthieu:01 dubuget:01 caml-list:01 ocamlc:01 cmo:01 cmo:01 ocamlc:01 cabs:98 cabs:98 unix:01 undefined:01 cma:01 linking:02 X-Spam-Checker-Version: SpamAssassin 3.0.3 (2005-04-27) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.0.3 > ocamlc -o main -I /home/sand/cil/obj/x86_LINUX/ pretty.cmo trace.cmo > errormsg.cmo cabs.cmo cabsvisit.cmo escape.cmo cprint.cmo patch.cmo > frontc.cmo main.cmo > "Error while linking /home/sand/cil/obj/x86_LINUX/patch.cmo: Reference > to undefined global 'Unix' " Try this : ocamlc -o main -I /home/sand/cil/obj/x86_LINUX/ unix .cma pretty.cmo trace.cmo errormsg.cmo cabs.cmo cabsvisit.cmo escape.cmo cprint.cmo patch.cmo frontc.cmo main.cmo Salutations Matthieu From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id 8F092BB9C for ; Mon, 21 Nov 2005 09:42:18 +0100 (CET) Received: from x86unx3.comp.nus.edu.sg (x86unx3.comp.nus.edu.sg [137.132.80.24]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id jAL8gGjh023578 for ; Mon, 21 Nov 2005 09:42:17 +0100 Received: from e500c.comp.nus.edu.sg (e500c.comp.nus.edu.sg [137.132.90.68]) by x86unx3.comp.nus.edu.sg (8.9.1-20030924/8.9.1) with SMTP id QAA16256; Mon, 21 Nov 2005 16:42:04 +0800 (GMT-8) Received: from sn40.comp.nus.edu.sg(137.132.80.15) by e500c.comp.nus.edu.sg via csmap id cbd54280_5a6a_11da_8116_003048298555_4280; Mon, 21 Nov 2005 16:42:49 +0800 (SGT) Received: from zhuping (soccf-pls-037.ddns.comp.nus.edu.sg [172.18.179.29]) (authenticated bits=0) by sn40.comp.nus.edu.sg (8.13.1/8.13.1) with ESMTP id jAL8feag021238 (version=TLSv1/SSLv3 cipher=RC4-MD5 bits=128 verify=NOT); Mon, 21 Nov 2005 16:42:03 +0800 (SGT) Message-ID: <000e01c5ee77$724858b0$1db312ac@comp.nus.edu.sg> From: "Zhu Ping" To: Cc: "Anil Madhavapeddy" , References: <002c01c5edae$afd08d20$1db312ac@comp.nus.edu.sg> <43806DF3.1000806@laposte.net> Subject: Re: [Caml-list] Using Frontc Date: Mon, 21 Nov 2005 16:41:35 +0800 MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset="gb2312"; reply-type=original Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2900.2527 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2527 X-Miltered: at concorde with ID 43818868.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; caml-list:01 ocamlc:01 ocamlc:01 -custom:01 usr:01 lib:01 ocaml:01 usr:01 lib:01 ocaml:01 cmo:01 cmo:01 util:01 clist:01 toplevel:01 X-Spam-Checker-Version: SpamAssassin 3.0.3 (2005-04-27) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.0.3 I have successfully compiled my main program by executing the following two commands sequentially: $ ocamlc -c -I /home/sand/cil/obj/x86_LINUX main.ml $ ocamlc -o main -custom /home/sand/cil/obj/x86_LINUX/perfcount.o /usr/lib/ocaml/unix.cma /usr/lib/ocaml/str.cma -I /home/sand/cil/obj/x86_LINUX/ pretty.cmo trace.cmo errormsg.cmo cabs.cmo cabsvisit.cmo escape.cmo cprint.cmo patch.cmo stats.cmo lexerhack.cmo machdep.cmo clexer.cmo cparser.cmo inthash.cmo util.cmo clist.cmo cilversion.cmo alpha.cmo cil.cmo cilutil.cmo cabs2cil.cmo frontc.cmo main.cmo But you can't see anything by just typing "./main" To print the value of "parse_result" defined in my main.ml, I first build my toplevel interpretator by executing: $ ocamlmktop -o mytoplevel -custom /home/sand/cil/obj/x86_LINUX/perfcount.o /usr/lib/ocaml/unix.cma /usr/lib/ocaml/str.cma -I /home/sand/cil/obj/x86_LINUX/ pretty.cmo trace.cmo errormsg.cmo cabs.cmo cabsvisit.cmo escape.cmo cprint.cmo patch.cmo stats.cmo lexerhack.cmo machdep.cmo clexer.cmo cparser.cmo inthash.cmo util.cmo clist.cmo cilversion.cmo alpha.cmo cil.cmo cilutil.cmo cabs2cil.cmo frontc.cmo main.cmo Then in this new toplevel the value of "parse_result" is propoerly displayed You can refer to the book "Developing Applications With Objective Caml" (page 322) to know more details about building a new toplevel interpretator which can use an external C function in the toplevel interactive loop. The pity now is the CIL format seems too complicated for me. I like the data structure defined in an earlier version of FrontC (http://casse.hugues.free.fr/projects/frontc.html) better:). However I still have problems in compiling FrontC sources downloaded from the site http://casse.hugues.free.fr/projects/frontc.html. Did anyone successfully install FrontC in Linux/Unix? Anyway, thank you all for your help:) ----- Original Message ----- From: "Matthieu Dubuget" To: "Zhu Ping" Cc: "Anil Madhavapeddy" ; Sent: Sunday, November 20, 2005 8:37 PM Subject: Re: [Caml-list] Using Frontc > >> ocamlc -o main -I /home/sand/cil/obj/x86_LINUX/ pretty.cmo trace.cmo >> errormsg.cmo cabs.cmo cabsvisit.cmo escape.cmo cprint.cmo patch.cmo >> frontc.cmo main.cmo >> "Error while linking /home/sand/cil/obj/x86_LINUX/patch.cmo: Reference >> to undefined global 'Unix' " > > Try this : > ocamlc -o main -I /home/sand/cil/obj/x86_LINUX/ unix .cma pretty.cmo > trace.cmo errormsg.cmo cabs.cmo cabsvisit.cmo escape.cmo cprint.cmo > patch.cmo frontc.cmo main.cmo > > Salutations > > Matthieu > From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id 671A4BB9C for ; Mon, 21 Nov 2005 10:55:04 +0100 (CET) Received: from moutng.kundenserver.de (moutng.kundenserver.de [212.227.126.173]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id jAL9t4Jc001681 for ; Mon, 21 Nov 2005 10:55:04 +0100 Received: from [212.227.126.160] (helo=mrelayng.kundenserver.de) by moutng.kundenserver.de with esmtp (Exim 3.35 #1) id 1Ee8O0-00063j-00; Mon, 21 Nov 2005 10:54:56 +0100 Received: from [84.58.129.121] (helo=gate.lan.gerd-stolpmann.de) by mrelayng.kundenserver.de with asmtp (Exim 3.35 #1) id 1Ee8O0-0006dm-00; Mon, 21 Nov 2005 10:54:56 +0100 Received: from gps.dynxs.de (localhost [127.0.0.1]) by gate.lan.gerd-stolpmann.de (Postfix) with ESMTP id 0EBCEC097; Mon, 21 Nov 2005 10:54:56 +0100 (CET) Received: from 192.168.1.2 (proxying for 194.127.8.19) (SquirrelMail authenticated user gerd) by gps.dynxs.de with HTTP; Mon, 21 Nov 2005 10:54:56 +0100 (CET) Message-ID: <4373.192.168.1.2.1132566896.squirrel@gps.dynxs.de> In-Reply-To: <000e01c5ee77$724858b0$1db312ac@comp.nus.edu.sg> References: <002c01c5edae$afd08d20$1db312ac@comp.nus.edu.sg> <43806DF3.1000806@laposte.net> <000e01c5ee77$724858b0$1db312ac@comp.nus.edu.sg> Date: Mon, 21 Nov 2005 10:54:56 +0100 (CET) Subject: Re: [Caml-list] Using Frontc From: "Gerd Stolpmann" To: "Zhu Ping" Cc: matthieu.dubuget@laposte.net, caml-list@yquem.inria.fr, "Anil Madhavapeddy" User-Agent: SquirrelMail/1.4.4 MIME-Version: 1.0 Content-Type: text/plain;charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable X-Provags-ID: kundenserver.de abuse@kundenserver.de auth:a6865a839c0178d9aa0ce41878507ea2 X-Miltered: at concorde with ID 43819978.001 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; caml-list:01 gerd:01 stolpmann:01 findlib:01 ocamlfind:01 ocamlc:01 -package:01 gerd:01 matthieu:01 dubuget:01 matthieu:01 dubuget:01 anil:01 anil:01 caml-list:01 X-Spam-Checker-Version: SpamAssassin 3.0.3 (2005-04-27) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.0.3 > The pity now is the CIL format seems too complicated for me. I like the > data > structure defined in an earlier version of FrontC > (http://casse.hugues.free.fr/projects/frontc.html) better:). However I > still > have problems in compiling FrontC sources downloaded from the site > http://casse.hugues.free.fr/projects/frontc.html. Did anyone successful= ly > install FrontC in Linux/Unix? FrontC is available in GODI, http://godi.ocaml-programming.de. This is probably the simplest way to install it. Furthermore, this also simplifie= s using libraries, as GODI supports findlib for all libraries, i.e. you jus= t say ocamlfind ocamlc -package frontc -c your_module.ml and get rid of the .cma nightmare. Gerd > ----- Original Message ----- > From: "Matthieu Dubuget" > To: "Zhu Ping" > Cc: "Anil Madhavapeddy" ; > Sent: Sunday, November 20, 2005 8:37 PM > Subject: Re: [Caml-list] Using Frontc > > >> >>> ocamlc -o main -I /home/sand/cil/obj/x86_LINUX/ pretty.cmo trace.cmo >>> errormsg.cmo cabs.cmo cabsvisit.cmo escape.cmo cprint.cmo patch.cmo >>> frontc.cmo main.cmo >>> "Error while linking /home/sand/cil/obj/x86_LINUX/patch.cmo: Referenc= e >>> to undefined global 'Unix' " >> >> Try this : >> ocamlc -o main -I /home/sand/cil/obj/x86_LINUX/ unix .cma pretty.cmo >> trace.cmo errormsg.cmo cabs.cmo cabsvisit.cmo escape.cmo cprint.cmo >> patch.cmo frontc.cmo main.cmo >> >> Salutations >> >> Matthieu >> > > _______________________________________________ > Caml-list mailing list. Subscription management: > http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list > Archives: http://caml.inria.fr > Beginner's list: http://groups.yahoo.com/group/ocaml_beginners > Bug reports: http://caml.inria.fr/bin/caml-bugs > > ------------------------------------------------------------ Gerd Stolpmann * Viktoriastr. 45 * 64293 Darmstadt * Germany gerd@gerd-stolpmann.de http://www.gerd-stolpmann.de ------------------------------------------------------------ From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id 87828BB9C for ; Thu, 24 Nov 2005 07:13:32 +0100 (CET) Received: from x86unx3.comp.nus.edu.sg (x86unx3.comp.nus.edu.sg [137.132.80.24]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id jAO6DUiV019560 for ; Thu, 24 Nov 2005 07:13:31 +0100 Received: from e500d.comp.nus.edu.sg (e500d.comp.nus.edu.sg [137.132.90.69]) by x86unx3.comp.nus.edu.sg (8.9.1-20030924/8.9.1) with SMTP id OAA23266; Thu, 24 Nov 2005 14:13:16 +0800 (GMT-8) Received: from sn40.comp.nus.edu.sg(137.132.80.15) by e500d.comp.nus.edu.sg via csmap id ccd26066_5cb1_11da_8794_0030482985c3_6522; Thu, 24 Nov 2005 14:16:07 +0800 (SGT) Received: from zhuping ([172.18.178.75]) (authenticated bits=0) by sn40.comp.nus.edu.sg (8.13.1/8.13.1) with ESMTP id jAO6Cnv1025400 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT); Thu, 24 Nov 2005 14:12:50 +0800 (SGT) Message-ID: <438559DC.5020906@comp.nus.edu.sg> Date: Thu, 24 Nov 2005 14:12:44 +0800 From: Zhu Ping User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.8) Gecko/20050513 Fedora/1.7.8-2 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Gerd Stolpmann Cc: matthieu.dubuget@laposte.net, caml-list@yquem.inria.fr, Anil Madhavapeddy Subject: Re: [Caml-list] Using Frontc References: <002c01c5edae$afd08d20$1db312ac@comp.nus.edu.sg> <43806DF3.1000806@laposte.net> <000e01c5ee77$724858b0$1db312ac@comp.nus.edu.sg> <4373.192.168.1.2.1132566896.squirrel@gps.dynxs.de> In-Reply-To: <4373.192.168.1.2.1132566896.squirrel@gps.dynxs.de> Content-Type: text/plain; charset=GB2312 Content-Transfer-Encoding: 7bit X-Miltered: at concorde with ID 43855A0A.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; caml-list:01 gerd:01 stolpmann:01 stdout:01 accum:01 accum:01 compilation:01 ocamlc:01 lib:01 ocaml:01 ocamlc:01 lib:01 ocaml:01 cmo:01 parsing:01 X-Spam-Checker-Version: SpamAssassin 3.0.3 (2005-04-27) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.0.3 Dear Gerd Stolpmann Thank you very much for recommending GODI. I have successfully installed GODI, compiled and linked my code with the FrontC library. My main program *main.ml* is as following: open Frontc let parse_result = Frontc.parse_file "/home/dreamer/code/sample1.c" stdout;; The sample C code sample1.c is: int main(int base, int expon) { int accum = 1; while (expon > 0) { accum = base * accum; expon = expon - 1; } return(accum); } I performed the compilation and linking by executing the following two commands: ocamlc -c -I /opt/godi/lib/ocaml/pkg-lib/FrontC main.ml ocamlc -o main /opt/godi/lib/ocaml/std-lib/unix.cma -I /opt/godi/lib/ocaml/pkg-lib/FrontC frontc.cma main.cmo To display the parsing result explicitly I built my toplevel: ocamlmktop -o mytoplevel /opt/godi/lib/ocaml/std-lib/unix.cma -I /opt/godi/lib/ocaml/pkg-lib/FrontC frontc.cma ./mytoplevel #directory "/home/dreamer/code/";; #directory "/opt/godi/lib/ocaml/pkg-lib/FrontC/";; #use "main.ml";; The output is: /home/dreamer/code/sample1.c[1] Invalid symbol: int main(int base, int expon) /home/dreamer/code/sample1.c[2] Invalid symbol: { /home/dreamer/code/sample1.c[3] Invalid symbol: int accum = 1; /home/dreamer/code/sample1.c[4] Invalid symbol: while (expon > 0) { /home/dreamer/code/sample1.c[5] Invalid symbol: accum = base * accum; /home/dreamer/code/sample1.c[6] Invalid symbol: expon = expon - 1; /home/dreamer/code/sample1.c[7] Invalid symbol: } /home/dreamer/code/sample1.c[8] Invalid symbol: return(accum); /home/dreamer/code/sample1.c[9] Invalid symbol: } val parse_result : Frontc.parsing_result = PARSING_OK [Cabs.FUNDEF ((Cabs.INT (Cabs.NO_SIZE, Cabs.NO_SIGN), Cabs.NO_STORAGE, ("main", Cabs.PROTO (Cabs.INT (Cabs.NO_SIZE, Cabs.NO_SIGN), [(Cabs.INT (Cabs.NO_SIZE, Cabs.NO_SIGN), Cabs.NO_STORAGE, ("base", Cabs.INT (Cabs.NO_SIZE, Cabs.NO_SIGN), [], Cabs.NOTHING)); (Cabs.INT (Cabs.NO_SIZE, Cabs.NO_SIGN), Cabs.NO_STORAGE, ("expon", Cabs.INT (Cabs.NO_SIZE, Cabs.NO_SIGN), [], Cabs.NOTHING))], false), [], Cabs.NOTHING)), ([Cabs.DECDEF (Cabs.INT (Cabs.NO_SIZE, Cabs.NO_SIGN), Cabs.NO_STORAGE, [("accum", Cabs.INT (Cabs.NO_SIZE, Cabs.NO_SIGN), [], Cabs.CONSTANT (Cabs.CONST_INT "1"))])], Cabs.SEQUENCE (Cabs.WHILE (Cabs.BINARY (Cabs.GT, Cabs.VARIABLE "expon", Cabs.CONSTANT (Cabs.CONST_INT "0")), Cabs.BLOCK ([], Cabs.SEQUENCE (Cabs.COMPUTATION (Cabs.BINARY (Cabs.ASSIGN, Cabs.VARIABLE "accum", Cabs.BINARY (Cabs.MUL, Cabs.VARIABLE "base", Cabs.VARIABLE "accum"))), Cabs.COMPUTATION (Cabs.BINARY (Cabs.ASSIGN, Cabs.VARIABLE "expon", Cabs.BINARY (Cabs.SUB, Cabs.VARIABLE "expon", Cabs.CONSTANT (Cabs.CONST_INT "1"))))))), Cabs.RETURN (Cabs.VARIABLE "accum"))))] Why the parsing result is correct in the presence of lexing errors? Thank you very much for your help:) Gerd Stolpmann wrote: >>The pity now is the CIL format seems too complicated for me. I like the data structure defined in an earlier version of FrontC >>(http://casse.hugues.free.fr/projects/frontc.html) better:). However I still have problems in compiling FrontC sources downloaded from the site >>http://casse.hugues.free.fr/projects/frontc.html. Did anyone successfullyinstall FrontC in Linux/Unix? >> >> >FrontC is available in GODI, http://godi.ocaml-programming.de. This is probably the simplest way to install it. Furthermore, this also simplifies >using libraries, as GODI supports findlib for all libraries, i.e. you just say > >ocamlfind ocamlc -package frontc -c your_module.ml > >and get rid of the .cma nightmare. > >Gerd > From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by yquem.inria.fr (Postfix) with ESMTP id A9A24BB9C for ; Thu, 24 Nov 2005 11:26:24 +0100 (CET) Received: from ash25e.internode.on.net (ash25e.internode.on.net [203.16.214.182]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id jAOAQMUd018519 for ; Thu, 24 Nov 2005 11:26:23 +0100 Received: from rosella (ppp45-3.lns2.syd6.internode.on.net [59.167.45.3]) by ash25e.internode.on.net (8.12.9/8.12.6) with ESMTP id jAOAPLGO014829; Thu, 24 Nov 2005 20:55:22 +1030 (CST) (envelope-from skaller@users.sourceforge.net) Subject: Re: [Caml-list] Using Frontc From: skaller To: Zhu Ping Cc: Gerd Stolpmann , matthieu.dubuget@laposte.net, caml-list@yquem.inria.fr, Anil Madhavapeddy In-Reply-To: <438559DC.5020906@comp.nus.edu.sg> References: <002c01c5edae$afd08d20$1db312ac@comp.nus.edu.sg> <43806DF3.1000806@laposte.net> <000e01c5ee77$724858b0$1db312ac@comp.nus.edu.sg> <4373.192.168.1.2.1132566896.squirrel@gps.dynxs.de> <438559DC.5020906@comp.nus.edu.sg> Content-Type: text/plain Date: Thu, 24 Nov 2005 21:25:20 +1100 Message-Id: <1132827920.8955.9.camel@rosella> Mime-Version: 1.0 X-Mailer: Evolution 2.4.1 Content-Transfer-Encoding: 7bit X-Miltered: at nez-perce with ID 4385954E.001 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; caml-list:01 parser:01 lexing:01 lexeme:01 lexbuf:01 lexing:01 lexeme:01 lexbuf:01 emits:01 wrote:01 sourceforge:01 recursively:01 int:01 int:01 parse:02 X-Spam-Checker-Version: SpamAssassin 3.0.3 (2005-04-27) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.0.3 On Thu, 2005-11-24 at 14:12 +0800, Zhu Ping wrote: > > /home/dreamer/code/sample1.c[1] Invalid symbol: int main(int base, int > expon) > /home/dreamer/code/sample1.c[2] Invalid symbol: { Spurious CR by any chance? Only one error per line here. Weird though, it should handle it. Anyhow the reason it works is simple enough: the parser is called 'initial' and here is the rule in question: | _ {E.parse_error "Invalid symbol" (Lexing.lexeme_start lexbuf) (Lexing.lexeme_end lexbuf); initial lexbuf} so you can see it emits a diagnostic .. and then continues by recursively calling itself again .. ignoring the error. -- John Skaller Felix, successor to C++: http://felix.sf.net