* [Caml-list] two bugs in camlp4? Help!! @ 2011-05-09 14:16 bob zhang 2011-05-09 15:05 ` Gabriel Scherer 2011-05-10 11:20 ` [Caml-list] " xclerc 0 siblings, 2 replies; 4+ messages in thread From: bob zhang @ 2011-05-09 14:16 UTC (permalink / raw) To: caml-list, bobzhang1988 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 <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 = 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 ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Caml-list] two bugs in camlp4? Help!! 2011-05-09 14:16 [Caml-list] two bugs in camlp4? Help!! bob zhang @ 2011-05-09 15:05 ` Gabriel Scherer 2011-05-09 15:19 ` [Caml-list] " bobzhang 2011-05-10 11:20 ` [Caml-list] " xclerc 1 sibling, 1 reply; 4+ messages in thread From: Gabriel Scherer @ 2011-05-09 15:05 UTC (permalink / raw) To: bob zhang; +Cc: caml-list [-- Attachment #1: Type: text/plain, Size: 3066 bytes --] > > 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 <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) = > {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 <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 = 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 > > [-- Attachment #2: Type: text/html, Size: 4647 bytes --] ^ permalink raw reply [flat|nested] 4+ messages in thread
* [Caml-list] Re: two bugs in camlp4? Help!! 2011-05-09 15:05 ` Gabriel Scherer @ 2011-05-09 15:19 ` bobzhang 0 siblings, 0 replies; 4+ messages in thread From: bobzhang @ 2011-05-09 15:19 UTC (permalink / raw) To: Gabriel Scherer; +Cc: caml-list 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 <bobzhang1988@gmail.com <mailto: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) = > {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 <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 = 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 > > ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Caml-list] two bugs in camlp4? Help!! 2011-05-09 14:16 [Caml-list] two bugs in camlp4? Help!! bob zhang 2011-05-09 15:05 ` Gabriel Scherer @ 2011-05-10 11:20 ` xclerc 1 sibling, 0 replies; 4+ messages in thread From: xclerc @ 2011-05-10 11:20 UTC (permalink / raw) To: Caml List, bobzhang1988; +Cc: xclerc Clerc Le 9 mai 2011 à 16:16, bob zhang a écrit : > 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 Under 3.12.x, "value x ~num(num=3) y = num > 0 ;" cannot be parsed. It is likely that what you want to write is "value x ?(num = 3) y = num > 0;". The printed signature is then "value x : ~?num:int -> 'a -> bool" which is bogus. It should be "value x : ?num:int -> 'a -> bool"; a fix has just been committed for inclusion in the upcoming 3.12.1. > 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? This is another bug in the toplevel printer for the revised grammar. Another fix has been committed. Thanks for reporting, Xavier Clerc ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2011-05-10 11:20 UTC | newest] Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2011-05-09 14:16 [Caml-list] two bugs in camlp4? Help!! bob zhang 2011-05-09 15:05 ` Gabriel Scherer 2011-05-09 15:19 ` [Caml-list] " bobzhang 2011-05-10 11:20 ` [Caml-list] " xclerc
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox