Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0005212OCamlOCamlbuild (the tool)public2011-01-26 00:072013-01-01 05:45
Reporterwilliam 
Assigned Tomeyer 
PrioritynormalSeveritymajorReproducibilityalways
StatusassignedResolutionopen 
PlatformOSOS Version
Product Version3.12.0 
Target Version4.00.2+devFixed in Version 
Summary0005212: ocamlbuild does not warn for bad input
DescriptionI saw a parser example in the Genlex module. It took me HOURS to compile a similar example in ocamlbuild! This tool is fantastic for meany reasons, but is a bit weak for useability. Hopefully that can be improved, with better messaging :

- "ocamlbuild -tags camlp4 example.byte" does not work, but it does not tell that the camlp4 tag is not recognised or not usefull

- "ocamlbuild -tags pp example.byte" explains that pp waits for an argument, which is good, but :

- "ocamlbuild -tags pp(camlp4o) example.byte" gives the error "bash: syntax error near unexpected token `('" which is not clear that it comes from ocamlbuild. a line such as "ocamlbuild tag : bash : syntax error near unexpected token '('" would be better

- "echo "example.ml:pp(camlp4o)" > _tags ; ocamlbuild example.byte" gives the error "Failure: lexing: empty token." where it is not clear that it comes from the _tags file, ant that it is due to ocamlbuild. One could think it comes from camlp4. A better localisation of the error would be appreciated. Example : "File _tags, line 1, character 0-10 : bad syntax"

- "echo "<example.ml>:pp(camlp4o)" > _tags ; ocamlbuild example.byte" enventually works. But why the "-tags pp(camlp4o)" option refuses it? It is not clear at all what to put on the tags option and what to put in the _tags file. At least, every line such as "true : pp(camlp4o)" should be equivalent to "-tags pp(camlp4o)" ?

Thanks,
William
Additional Informationfile example.ml :

open Genlex
let _ =
  let str = Stream.of_string "2 * (1 + 2)" in
  let lexer = Genlex.make_lexer [] in
  let rec parse_expr = parser
      [< 'Int n >] -> n
    | [< 'Kwd "("; n = parse_expr; 'Kwd ")" >] -> n
    | [< n1 = parse_expr; n2 = parse_remainder n1 >] -> n2
  and parse_remainder n1 = parser
      [< 'Kwd "+"; n2 = parse_expr >] -> n1+n2
  in
  Printf.printf "hello\n%!";
  parse_expr (lexer str)
TagsNo tags attached.
Attached Filesdiff file icon lexing_error_pos_3.11.diff [^] (10,018 bytes) 2011-01-27 16:24 [Show Content]
diff file icon lexing_error_pos_3.12.diff [^] (11,326 bytes) 2011-01-27 16:25 [Show Content]
diff file icon lexing_error_pos_4.00_svn.diff [^] (11,812 bytes) 2012-07-09 11:39 [Show Content]

- Relationships

-  Notes
(0005791)
ygrek (reporter)
2011-01-26 09:45

> - "ocamlbuild -tags pp(camlp4o) example.byte" gives the error "bash: syntax error near unexpected token `('" which is not clear that it comes from ocamlbuild

This error is reported by your shell, not ocamlbuild, see `man bash` for bash syntax rules. Correct way to execute this command in bash is :
ocamlbuild -tags 'pp(camlp4o)' example.byte
(0005792)
ygrek (reporter)
2011-01-27 16:24

> - "ocamlbuild -tags camlp4 example.byte" does not work, but it does not tell that the camlp4 tag is not recognised or not usefull

One can see the list of available tags with 'ocamlbuild -documentation', but warning about not-used tags makes sense indeed.

> gives the error "Failure: lexing: empty token."
Yes, this confused me too.

With the attached patch (one for 3.11 and another for 3.12 branch) it becomes :

File "_tags", line 1, column 0:
Lexing error: Bad key "example.ml" : Failure("lexing: empty token")
(0006643)
thelema (reporter)
2012-01-11 17:58

This is definitely a very sore spot for those unwary users that stumble onto it and get a true error message that does nothing to point to the actual cause of the problem.
(0007664)
ygrek (reporter)
2012-07-09 11:39

The patch to show lexing error position in _tags looks rather simple, maybe suitable for 4.00? Attached version for the current trunk.
(0008674)
meyer (developer)
2013-01-01 05:45

Looks good, applied, thank you.

- Issue History
Date Modified Username Field Change
2011-01-26 00:07 william New Issue
2011-01-26 09:45 ygrek Note Added: 0005791
2011-01-27 16:24 ygrek Note Added: 0005792
2011-01-27 16:24 ygrek File Added: lexing_error_pos_3.11.diff
2011-01-27 16:25 ygrek File Added: lexing_error_pos_3.12.diff
2011-05-17 16:43 doligez Status new => acknowledged
2011-06-06 13:02 xclerc Status acknowledged => assigned
2011-06-06 13:02 xclerc Assigned To => xclerc
2012-01-11 17:58 thelema Note Added: 0006643
2012-02-02 15:17 protz Category OCamlbuild => OCamlbuild (the tool)
2012-07-06 16:24 doligez Target Version => 4.01.0+dev
2012-07-09 11:39 ygrek File Added: lexing_error_pos_4.00_svn.diff
2012-07-09 11:39 ygrek Note Added: 0007664
2012-07-31 13:36 doligez Target Version 4.01.0+dev => 4.00.1+dev
2012-09-06 19:22 frisch Target Version 4.00.1+dev => 4.00.2+dev
2013-01-01 05:45 meyer Note Added: 0008674
2013-01-01 05:45 meyer Assigned To xclerc => meyer


Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker