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 p49F6VAD000565 for ; Mon, 9 May 2011 17:06:31 +0200 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Ai8DAHECyE3RVdg2kGdsb2JhbACXYIZaAYc1BQgUAQEBAQkJDQcUBCGIcaFBjBmCMYRdNohfAQEDBoYGBIIpjTyIQIIxO4Mz X-IronPort-AV: E=Sophos;i="4.64,341,1301868000"; d="scan'208";a="94721706" Received: from mail-qw0-f54.google.com ([209.85.216.54]) by mail4-smtp-sop.national.inria.fr with ESMTP/TLS/RC4-SHA; 09 May 2011 17:05:51 +0200 Received: by qwc9 with SMTP id 9so5488877qwc.27 for ; Mon, 09 May 2011 08:05:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-type; bh=lzkCJYvCigx2bMhRUmuaItOXhz6gGz4ZXoe2dypMRbY=; b=k8PNVt+csRe+Jtg3O95GbjqbDVt04vrl/iM/bku2vC6iHoh9H4OPZ8WEumr4rBQjM6 WzQNJyTFPoBMPZHlChRzQr9PbkwmSEYcV9M0rEYgNGFjWmP2nljTVYno0SW2iaaMVA1m /IE15Mbr/c7jpSuigsIlZK0td5EVW0HPSPQRc= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; b=LDuXMStZ28zm6fSMmN8EqZ0JLGKRyZWB0XITukMR4cpBr5irtkXckrYDm0205uLRuR Eu6ja2UA+vMJP74C5rx5afArGAIDuKX3spL/PH6l2Z+7LNadYOeQNDkCi/bAopkT6DE0 Svin6Bux47kcY/fbsAipq06QGAsbMq21KTLUk= Received: by 10.52.174.176 with SMTP id bt16mr947737vdc.282.1304953550113; Mon, 09 May 2011 08:05:50 -0700 (PDT) MIME-Version: 1.0 Received: by 10.52.114.5 with HTTP; Mon, 9 May 2011 08:05:30 -0700 (PDT) In-Reply-To: <4DC7F736.6050807@gmail.com> References: <4DC7F736.6050807@gmail.com> From: Gabriel Scherer Date: Mon, 9 May 2011 17:05:30 +0200 Message-ID: To: bob zhang Cc: caml-list@inria.fr Content-Type: multipart/alternative; boundary=bcaec51ba1f5cd8d6704a2d92c03 Subject: Re: [Caml-list] two bugs in camlp4? Help!! --bcaec51ba1f5cd8d6704a2d92c03 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable > > when I type > value x ~num(num=3D3) y =3D num > 0 ; > --> value x: ~?num:int -> bool > > However, the signature can not be parsed by Camlp4 however, I tried parse_sig "value x : ?num:int -> bool ;", it's ok, > This seems to be a bug in the printer. (By the way, it is not useful to declare an optional argument as last parameter of a function, because it cannot be erased. You will have to pass it explicitely (otherwise caml couldn't make the difference between writing the function and writing the function application, writing (x ~num:None) to get the default value). module X : sig type a =3D int; and b =3D (int * int); end > you can see the semi is redudant, it is an error? > Again, this looks like a printer issue. The correct syntax has no semicolon before "and": (type .. and .. and ...) is a single phrase. For a relatively comprehensive documentation of the revised syntax=B9, see http://caml.inria.fr/pub/docs/tutorial-camlp4/tutorial005.html (This is the revised syntax as of camlp4 < 3.10, and possibly Camlp5; in current versions of Camlp4 I think the rules have been slightly relaxed, but that it is backward-compatible.) 2011/5/9 bob zhang > Hi, all, > I am not sure that I made a mistake or two minor bugs in camlp4 revised > syntax? > > Both cases are in toploop, after I type > > #camlp4r;; > #load "camlp4rf.cma"; > Register.loaded_modules; > - : ref (list string) =3D > {Pervasives.contents=3D > ["Camlp4ListComprenhsion"; "Camlp4MacroParser"; "Camlp4MacroParser"; > "Camlp4GrammarParser"; "Camlp4OCamlRevisedParserParser"; > "Camlp4QuotationExpander"; "Camlp4OCamlRevisedParser"]} > > > case1: > for the signature parsing, > > when I type > value x ~num(num=3D3) y =3D num > 0 ; > --> value x: ~?num:int -> bool > > However, the signature can not be parsed by Camlp4 > value parse_sig =3D Camlp4.PreCast.Syntax.(Gram.parse_string sig_item > Loc.ghost); > > parse_sig "value x : ~?num:int -> bool;" will raie an exception > however, I tried parse_sig "value x : ?num:int -> bool ;", it's ok, > > - : Camlp4.PreCast.Syntax.Ast.sig_item =3D > Camlp4.PreCast.Syntax.Ast.SgVal "x" > (Camlp4.PreCast.Syntax.Ast.TyArr > (Camlp4.PreCast.Syntax.Ast.TyOlb "num" > (Camlp4.PreCast.Syntax.Ast.TyId > (Camlp4.PreCast.Syntax.Ast.IdLid "int"))) > (Camlp4.PreCast.Syntax.Ast.TyId > (Camlp4.PreCast.Syntax.Ast.IdLid "bool"))) > case 2: > when I type > module X =3D struct type a =3D int and b =3D (int * int); end; > in the toploop > module X : sig type a =3D int; and b =3D (int * int); end > you can see the semi is redudant, it is an error? > > I thought Camlp4 was heavily used in bootstrapping itself, did I make > some stupid assumptions?? > > Thanks > > > > > -- > Caml-list mailing list. Subscription management and archives: > https://sympa-roc.inria.fr/wws/info/caml-list > Beginner's list: http://groups.yahoo.com/group/ocaml_beginners > Bug reports: http://caml.inria.fr/bin/caml-bugs > > --bcaec51ba1f5cd8d6704a2d92c03 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
when I type
value x ~num(num=3D3) y =3D num > 0 ;
--> value x: ~?num:int -> bo= ol

However, the signature can not be parsed by Camlp4=A0
however, I tried parse_sig= "value x : ?num:int -> bool ;", it's ok,

This seems to be a bug in the printer.
(By the wa= y, it is not useful to declare an optional argument as last parameter of a = function, because it cannot be erased. You will have to pass it explicitely= (otherwise caml couldn't make the difference between writing the funct= ion and writing the function application, writing (x ~num:None) to get the = default value).

= =A0module X : sig type a =3D int; and b =3D (int * int); end
you can see the semi is redudant, it is an error?

= Again, this looks like a printer issue. The correct syntax has no semicolon= before "and":=A0 (type .. and .. and ...) is a single phrase.

For a relatively comprehensive documentation of the revised syntax=B9, = see
=A0 http://caml.inria.fr/pub/docs/tutorial-camlp4/tutorial005.html
(This is the revised syntax as of camlp4 < 3.10, and possibly Camlp5; in= current versions of Camlp4 I think the rules have been slightly relaxed, b= ut that it is backward-compatible.)

2011/5/9 bob zhang <<= a href=3D"mailto:bobzhang1988@gmail.com">bobzhang1988@gmail.com>
Hi, all,
I am not sure that I made a mistake or two minor bugs in camlp4 revised
syntax?

Both cases are in toploop, after I type

#camlp4r;;
#load "camlp4rf.cma";
Register.loaded_modules;
- : ref (list string) =3D
{Pervasives.contents=3D
["Camlp4ListComprenhsion"; "Camlp4MacroParser"; "C= amlp4MacroParser";
"Camlp4GrammarParser"; "Camlp4OCamlRevisedParserParser"= ;
"Camlp4QuotationExpander"; "Camlp4OCamlRevisedParser"]}=


case1:
for the signature parsing,

when I type
value x ~num(num=3D3) y =3D num > 0 ;
--> value x: ~?num:int -> bool

However, the signature can not be parsed by Camlp4
value parse_sig =3D Camlp4.PreCast.Syntax.(Gram.parse_string sig_item
Loc.ghost);

parse_sig "value x : ~?num:int -> bool;" will raie an exceptio= n
however, I tried parse_sig "value x : ?num:int -> bool ;", it&= #39;s ok,

- : Camlp4.PreCast.Syntax.Ast.sig_item =3D
Camlp4.PreCast.Syntax.Ast.SgVal <abstr> "x"
(Camlp4.PreCast.Syntax.Ast.TyArr <abstr>
(Camlp4.PreCast.Syntax.Ast.TyOlb <abstr> "num"
(Camlp4.PreCast.Syntax.Ast.TyId <abstr>
(Camlp4.PreCast.Syntax.Ast.IdLid <abstr> "int")))
(Camlp4.PreCast.Syntax.Ast.TyId <abstr>
(Camlp4.PreCast.Syntax.Ast.IdLid <abstr> "bool")))
case 2:
when I type
module X =3D struct type a =3D int and b =3D (int * int); end;
in the toploop
module X : sig type a =3D int; and b =3D (int * int); end
you can see the semi is redudant, it is an error?

I thought Camlp4 was heavily used in bootstrapping itself, did I make
some stupid assumptions??

Thanks




--
Caml-list mailing list. =A0Subscription management and archives:
https://sympa-roc.inria.fr/wws/info/caml-list
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs


--bcaec51ba1f5cd8d6704a2d92c03--