Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0005212OCamlOCamlbuild (the tool)public2011-01-26 00:072014-01-21 13:59
Reporterwilliam 
Assigned To 
PrioritynormalSeverityfeatureReproducibilityalways
StatusassignedResolutionopen 
PlatformOSOS Version
Product Version3.12.0 
Target Version4.01.1+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 :

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

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

(3) "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

(4) "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"

(5) "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)
Tagspatch
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
related to 0006087assignedgasche ocamlbuild, improve _tags parsing and error report 

-  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.
(0009520)
gasche (developer)
2013-06-16 21:21

Let me (try to) summarize the state of this bug report:

(1) is a ambitious demand that tags that were detected to be "useless"
    result in a warning. It would deserve it's own feature request.

    (Intuitively I can think of two distinct notions of uselessness:
     - the compilation would have happened in just the same way without the tag
     - no rule (including those that were not activated) tested that tag)

(3) is a bash error that cannot be solved

The error message for (2) should probably mention the problem with
(3), by explicitly mentioning that quoting may be necessary.

(4) was solved by ygrek

(5) is equivalent to (3): one should use -tags "pp(camlp4o)", with quotes



(1) is definitely delayed to 4.02+dev. If there is a volunteer to
propose a patch for (2) (explicitly mentioning the quoting issue), or
if I get really bored some morning, this may be applied earlier.

- 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
2013-06-16 19:13 gasche Description Updated View Revisions
2013-06-16 21:21 gasche Note Added: 0009520
2013-06-16 21:22 gasche Target Version 4.00.2+dev => 4.02.0+dev
2013-06-16 21:25 gasche Severity major => minor
2013-06-16 21:26 gasche Severity minor => feature
2013-07-12 18:15 doligez Target Version 4.02.0+dev => 4.01.1+dev
2013-07-26 18:35 gasche Relationship added related to 0006087
2013-10-08 15:22 doligez Tag Attached: patch
2014-01-21 13:59 doligez Assigned To meyer =>


Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker