-
Notifications
You must be signed in to change notification settings - Fork 1.2k
ocamlbuild does not warn for bad input #5212
Description
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)