New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ocamlbuild does not warn for bad input #5212
Comments
Comment author: @ygrek
This error is reported by your shell, not ocamlbuild, see |
Comment author: @ygrek
One can see the list of available tags with 'ocamlbuild -documentation', but warning about not-used tags makes sense indeed.
With the attached patch (one for 3.11 and another for 3.12 branch) it becomes : File "_tags", line 1, column 0: |
Comment author: thelema 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. |
Comment author: @ygrek The patch to show lexing error position in _tags looks rather simple, maybe suitable for 4.00? Attached version for the current trunk. |
Comment author: meyer Looks good, applied, thank you. |
Comment author: @gasche Let me (try to) summarize the state of this bug report: (1) is a ambitious demand that tags that were detected to be "useless"
(3) is a bash error that cannot be solved The error message for (2) should probably mention the problem with (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 |
Comment author: @damiendoligez ocamlbuild is now a separate project that lives on GitHub. |
Original bug ID: 5212
Reporter: william
Status: resolved (set by @damiendoligez on 2017-03-03T15:17:37Z)
Resolution: suspended
Priority: normal
Severity: feature
Version: 3.12.0
Category: -for ocamlbuild use https://github.com/ocaml/ocamlbuild/issues
Tags: patch
Related to: #6087
Monitored by: @bobzhang @ygrek thelema @hcarty
Bug description
I 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 information
file 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)
File attachments
The text was updated successfully, but these errors were encountered: