From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by walapai.inria.fr (8.13.6/8.13.6) with ESMTP id p49FKJQj001443 for ; Mon, 9 May 2011 17:20:19 +0200 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Ar0FAM8FyE1KfVO2kGdsb2JhbACEUpMOjhIFCBQBAQEBCQkNBxQEIapAi108gjGEZDaIXwEBAwaBJINggQIEhj6JJ4U5gweCMTuDPg X-IronPort-AV: E=Sophos;i="4.64,341,1301868000"; d="scan'208";a="107901333" Received: from mail-pv0-f182.google.com ([74.125.83.182]) by mail1-smtp-roc.national.inria.fr with ESMTP/TLS/RC4-SHA; 09 May 2011 17:20:12 +0200 Received: by pvg11 with SMTP id 11so3761258pvg.27 for ; Mon, 09 May 2011 08:19:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:message-id:date:from:user-agent:mime-version :newsgroups:to:cc:subject:references:in-reply-to:content-type :content-transfer-encoding; bh=z2Id+WaVgesFaHvxRzgoxkvqWhw+A2TNWM+DE2MP3BQ=; b=Fddn0iIOoKxowH6dJDgR9Prk8EVj3+6m4qYQg5GdkwHGKAm+bag4RzeDse3S4pexKe DEJYamoNt+d6M7lVu/lNp6Ex7zLEPNLPoh2WhA7UyD+SZBzpJpWhbBvFOnmNhlqBt/cW fTx1lyyLcPw7FPpPhk8fy0+faGglmfty+kTKk= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:newsgroups:to:cc :subject:references:in-reply-to:content-type :content-transfer-encoding; b=HNSBAKVjlpava0PkvEDMw9bimpZaUHviVn5isH9QnPhPLyu9sW5ombzugk+xUHZC6r oA9Vmmp+wv6SuLiQevHLQY9dnJQJ67JNsftBa6GuBJ2hZfCovNChHRTyCE3y6MQslve1 DHlnBw5wophrje7xcOiFm/OdcASEyBbZM/8Ug= Received: by 10.142.222.15 with SMTP id u15mr3623754wfg.183.1304954360853; Mon, 09 May 2011 08:19:20 -0700 (PDT) Received: from th206029.ip.tsinghua.edu.cn (th206029.ip.tsinghua.edu.cn [59.66.206.29]) by mx.google.com with ESMTPS id x11sm8232464wfd.13.2011.05.09.08.19.17 (version=SSLv3 cipher=OTHER); Mon, 09 May 2011 08:19:20 -0700 (PDT) Message-ID: <4DC805F2.3030905@gmail.com> Date: Mon, 09 May 2011 23:19:14 +0800 From: bobzhang User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; zh-CN; rv:1.9.2.17) Gecko/20110414 Thunderbird/3.1.10 MIME-Version: 1.0 Newsgroups: gmane.comp.lang.caml.inria To: Gabriel Scherer CC: caml-list@inria.fr References: <4DC7F736.6050807@gmail.com> In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Subject: [Caml-list] Re: two bugs in camlp4? Help!! Hi, thanks, the first bug is the parser, I mean Camlp4.PreCast.Syntax.Gram.sig_item The second is about printer, right? I used the two toy examples just to demonstrate my ideas. Thanks again. 于 11-5-9 下午11:05, Gabriel Scherer 写道: > when I type > value x ~num(num=3) y = 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 = int; and b = (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¹, 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) = > {Pervasives.contents= > ["Camlp4ListComprenhsion"; "Camlp4MacroParser"; "Camlp4MacroParser"; > "Camlp4GrammarParser"; "Camlp4OCamlRevisedParserParser"; > "Camlp4QuotationExpander"; "Camlp4OCamlRevisedParser"]} > > > case1: > for the signature parsing, > > when I type > value x ~num(num=3) y = num > 0 ; > --> value x: ~?num:int -> bool > > However, the signature can not be parsed by Camlp4 > value parse_sig = 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 = > 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 = struct type a = int and b = (int * int); end; > in the toploop > module X : sig type a = int; and b = (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 > >