Skip to content
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

Closed
vicuna opened this issue Jan 25, 2011 · 7 comments
Closed

ocamlbuild does not warn for bad input #5212

vicuna opened this issue Jan 25, 2011 · 7 comments

Comments

@vicuna
Copy link

@vicuna vicuna commented Jan 25, 2011

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

@vicuna
Copy link
Author

@vicuna vicuna commented Jan 26, 2011

Comment author: @ygrek

  • "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

@vicuna
Copy link
Author

@vicuna vicuna commented Jan 27, 2011

Comment author: @ygrek

  • "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")

@vicuna
Copy link
Author

@vicuna vicuna commented Jan 11, 2012

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.

@vicuna
Copy link
Author

@vicuna vicuna commented Jul 9, 2012

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.

@vicuna
Copy link
Author

@vicuna vicuna commented Jan 1, 2013

Comment author: meyer

Looks good, applied, thank you.

@vicuna
Copy link
Author

@vicuna vicuna commented Jun 16, 2013

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"
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.

@vicuna
Copy link
Author

@vicuna vicuna commented Mar 3, 2017

Comment author: @damiendoligez

ocamlbuild is now a separate project that lives on GitHub.
PR transferred to ocaml/ocamlbuild#219

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant