caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] modified error messages for ocamlc
@ 2013-04-18 16:40 William Smith
  2013-04-21  7:37 ` Gabriel Scherer
  0 siblings, 1 reply; 12+ messages in thread
From: William Smith @ 2013-04-18 16:40 UTC (permalink / raw)
  To: Caml-list

[-- Attachment #1: Type: text/plain, Size: 1047 bytes --]

> > File "multilineError.ml", line 2, character 0-line 4, character 1:

> This added info is great, but if you change the format, then please take
> advantage of this opportunity to make use a more standard format so that
> other tools can recognize those messages without extra work.

> E.g:

> multilineError.ml:2.0-4.1: Warning 8: this pattern-matching is not exhaustive.


>        Stefan

This is harder than it looks because there are about a dozen places in the code where OCaml creates error messages.  They're spread out amongst all of the tools.

I believe I found them all, but each one requires careful work to avoid breaking things.   So far, I've only changed the one in ocamlc.  After finding them, I'll also need to learn how to trigger each of them to even test the change.

That's why I don't want to do it unless it's really useful to people.

I don't use emacs right now so I don't know how to test that part of the system.  Will using the standard Gnu error format be ok with what Daniel Bünzli was concerned about?

Bill
  


[-- Attachment #2: Type: text/html, Size: 1520 bytes --]

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [Caml-list] modified error messages for ocamlc
  2013-04-18 16:40 [Caml-list] modified error messages for ocamlc William Smith
@ 2013-04-21  7:37 ` Gabriel Scherer
  2013-04-21 10:53   ` Daniel Bünzli
  0 siblings, 1 reply; 12+ messages in thread
From: Gabriel Scherer @ 2013-04-21  7:37 UTC (permalink / raw)
  To: William Smith; +Cc: Caml-list

One use case would be supporting other editors in an easier way. I
just tried OCaml with Geany, and apparently the people that wrote
Geany's OCaml mode didn't bother with a custom error regexp parser. If
we had a command-line option to the compiler to produce gnu-standard
error messages, that would be a non-issue.

I think a patch affecting the error and warning-printing functions of
the Location module (parsing/location.ml) should be a very satisfying
first step (what kind of errors are you thinking about that aren't
handled by these functions?). I'm considering writing such a patch.

On Thu, Apr 18, 2013 at 6:40 PM, William Smith <bills@emu-bark.com> wrote:
>> File "multilineError.ml", line 2, character 0-line 4, character 1:
>
>> This added info is great, but if you change the format, then please take
>> advantage of this opportunity to make use a more standard format so that
>> other tools can recognize those messages without extra work.
>
>> E.g:
>
>> multilineError.ml:2.0-4.1: Warning 8: this pattern-matching is not
>> exhaustive.
>
>
>>        Stefan
>
> This is harder than it looks because there are about a dozen places in the
> code where OCaml creates error messages.  They're spread out amongst all of
> the tools.
>
> I believe I found them all, but each one requires careful work to avoid
> breaking things.   So far, I've only changed the one in ocamlc.  After
> finding them, I'll also need to learn how to trigger each of them to even
> test the change.
>
> That's why I don't want to do it unless it's really useful to people.
>
> I don't use emacs right now so I don't know how to test that part of the
> system.  Will using the standard Gnu error format be ok with what Daniel
> Bünzli was concerned about?
>
> Bill
>

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [Caml-list] modified error messages for ocamlc
  2013-04-21  7:37 ` Gabriel Scherer
@ 2013-04-21 10:53   ` Daniel Bünzli
  2013-04-21 11:28     ` Gabriel Scherer
  0 siblings, 1 reply; 12+ messages in thread
From: Daniel Bünzli @ 2013-04-21 10:53 UTC (permalink / raw)
  To: Gabriel Scherer; +Cc: William Smith, Caml-list



Le dimanche, 21 avril 2013 à 08:37, Gabriel Scherer a écrit :

> I think a patch affecting the error and warning-printing functions of
> the Location module (parsing/location.ml) should be a very satisfying
> first step (what kind of errors are you thinking about that aren't
> handled by these functions?). I'm considering writing such a patch.

Stacktraces in printexc.ml are an example (OT but if you are changing things in printexc could maybe grant the whish of that comment [1]...). There are quite a few places, see the end of this email for an over approximation of the places to change.

Also please make sure to update caml.el so that it works. Should be mainly about the caml-error-regexp, caml-error-chars-regexp constants. Maybe, because of the standardization it's actually just a matter of removing the addition made to compilation-error-regexp-alist.  

Best,

Daniel

[1] http://caml.inria.fr/mantis/view.php?id=5899#c8779


> git grep "\"File"
asmcomp/asmpackager.ml: fprintf ppf "File %a@ was not compiled with the `-for-pack %s' option"
asmcomp/asmpackager.ml: fprintf ppf "File %s not found" file
bytecomp/bytepackager.ml: fprintf ppf "File %a redefines %s"
bytecomp/bytepackager.ml: fprintf ppf "File %s not found" file
camlp4/Camlp4/Struct/Loc.ml: let res = sprintf "File \"%s\", line %d, characters %d-%d"
camlp4/boot/Camlp4.ml: sprintf "File \"%s\", line %d, characters %d-%d" x.file_name
debugger/loadprinter.ml: fprintf ppf "File %s loaded@." filename;
experimental/doligez/checkheaders: printf ("File \"%s\", line %d:\n", FILENAME, FNR);
lex/main.ml: "File \"%s\", line %d, character %d: character set expected.\n"
lex/main.ml: "File \"%s\", line %d, character %d: syntax error.\n"
lex/main.ml: "File \"%s\", line %d, character %d: %s.\n"
lex/main.ml: "File \"%s\":\n Position memory overflow, too many bindings\n"
lex/main.ml: "File \"%s\":\ntransition table overflow, automaton is too big\n"
lex/parser.mly: Printf.eprintf "File \"%s\", line %d, character %d:\n\
ocamlbuild/configuration.ml: parse_lexbuf ?dir (Printf.sprintf "File %S" file) (Lexing.from_channel ic)
ocamlbuild/hygiene.ml: Some(sf "File %s in %s has suffix %s" name path suffix)
ocamlbuild/hygiene.ml: Some(sf "Files %s and %s should not be together in %s" name name' path)
ocamlbuild/testsuite/level0.ml: ["*:a", "File \"_tags\", line 1, column 0: Lexing error: Invalid globbing pattern \"*\".";
ocamlbuild/testsuite/level0.ml: "\n<*{>:a", "File \"_tags\", line 2, column 0: Lexing error: Invalid globbing pattern \"<*{>\".";
ocamlbuild/testsuite/level0.ml: "<*>: ~@a,# ~a", "File \"_tags\", line 1, column 10: Lexing error: Only ',' separated tags are alllowed."];;
ocamldoc/odoc_messages.ml:let file_generated f = "File "^f^" generated."
ocamldoc/odoc_messages.ml: "File "^f^" exists, we don't generate it."
otherlibs/dynlink/dynlink.ml: Printf.sprintf "File_not_found %S" s
otherlibs/labltk/browser/editor.ml: val file_menu = new Jg_menu.c "File" ~parent:menus
otherlibs/labltk/browser/editor.ml: ("File `" ^ name ^ "' exists. Overwrite it?")
otherlibs/labltk/browser/fileselect.ml: let dfrl = Label.create dfr ~text:"Files" in
otherlibs/labltk/browser/shell.ml: let file_menu = new Jg_menu.c "File" ~parent:menus
otherlibs/labltk/browser/viewer.ml: let filemenu = new Jg_menu.c "File" ~parent:menus
otherlibs/labltk/browser/viewer.ml: let filemenu = new Jg_menu.c "File" ~parent:menus
otherlibs/labltk/compiler/maincompile.ml: prerr_string "File \""; prerr_string !input_name;
otherlibs/labltk/examples_camltk/fileopen.ml:let t = Label.create cvs [Text "File name"];;
otherlibs/labltk/examples_camltk/winskel.ml: let file = Menubutton.create mbar [Text "File"; UnderlinedChar 0]
otherlibs/labltk/jpf/fileselect.ml: let dfrl = Label.create dfr ~text: "Files" in
parsing/location.ml: ("File \"", "\", line ", ", characters ", "-", ":")
stdlib/filename.ml: if n < 0 then invalid_arg "Filename.chop_suffix" else String.sub name 0 n
stdlib/filename.ml: if i < 0 || is_dir_sep name i then invalid_arg "Filename.chop_extension"
stdlib/printexc.ml:let locfmt = format_of_string "File \"%s\", line %d, characters %d-%d: %s";;
testsuite/Makefile: @if [ ! -f $(FILE) ]; then echo "File '$(FILE)' does not exist."; exit 1; fi
tools/cmt2annot.ml: Printf.fprintf stderr "File was generated with an error\n%!";
tools/cmt2annot.ml: Printf.fprintf stderr "File was generated with an error\n%!";
tools/dumpobj.ml: printf "File \"%s\", line %d, characters %d-%d:\n" ls.Lexing.pos_fname
tools/objinfo.ml: printf "File %s\n" filename;
tools/scrapelabels.ml: "Event"; "Filename"; "Format"; "Gc"; "Genlex"; "Graphics";
toplevel/opttopdirs.ml: | None -> fprintf ppf "File not found: %s@." name0; false
toplevel/topdirs.ml: fprintf ppf "File %s is not a bytecode object file.@." name;
yacc/error.c: fprintf(stderr, "File \"%s\", line %d: unexpected end-of-file\n",
yacc/error.c: fprintf(stderr, "File \"%s\", line %d: syntax error\n",
yacc/error.c: fprintf(stderr, "File \"%s\", line %d: unmatched /*\n",
yacc/error.c: fprintf(stderr, "File \"%s\", line %d: unterminated string\n",
yacc/error.c: fprintf(stderr, "File \"%s\", line %d: unmatched %%{\n",
yacc/error.c: fprintf(stderr, "File \"%s\", line %d: unterminated %%union declaration\n",
yacc/error.c: fprintf(stderr, "File \"%s\", line %d: too many %%union declarations\n",
yacc/error.c: fprintf(stderr, "File \"%s\", line %d: illegal tag\n",
yacc/error.c: fprintf(stderr, "File \"%s\", line %d: illegal character\n",
yacc/error.c: fprintf(stderr, "File \"%s\", line %d: illegal use of reserved symbol \
yacc/error.c: fprintf(stderr, "File \"%s\", line %d: the start symbol `%s' cannot \
yacc/error.c: fprintf(stderr, "File \"%s\", line %d: warning: the type of `%s' has been \
yacc/error.c: fprintf(stderr, "File \"%s\", line %d: warning: the precedence of `%s' has \
yacc/error.c: fprintf(stderr, "File \"%s\", line %d: warning: the value of `%s' has been \
yacc/error.c: fprintf(stderr, "File \"%s\", line %d: the entry point `%s' is a \
yacc/error.c: fprintf(stderr, "File \"%s\", line %d: more than 256 entry points\n",
yacc/error.c: fprintf(stderr, "File \"%s\", line %d: no grammar has been specified\n",
yacc/error.c: fprintf(stderr, "File \"%s\", line %d: a token appears on the lhs \
yacc/error.c: fprintf(stderr, "File \"%s\", line %d: warning: conflicting %%prec \
yacc/error.c: fprintf(stderr, "File \"%s\", line %d: unterminated action\n",
yacc/error.c: fprintf(stderr, "File \"%s\", line %d: warning: $%d references beyond the \
yacc/error.c: fprintf(stderr, "File \"%s\", line %d: illegal $-name\n",
yacc/error.c: fprintf(stderr, "File \"%s\", line %d: $$ is untyped\n",
yacc/error.c: fprintf(stderr, "File \"%s\", line %d: $%d (%s) is untyped\n",
yacc/error.c: fprintf(stderr, "File \"%s\", line %d: $%d is unbound\n",
yacc/error.c: fprintf(stderr, "File \"%s\", line %d: $%d refers to terminal `%s', \
yacc/error.c: fprintf(stderr, "File \"%s\", line %d: no action specified for this \




^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [Caml-list] modified error messages for ocamlc
  2013-04-21 10:53   ` Daniel Bünzli
@ 2013-04-21 11:28     ` Gabriel Scherer
  0 siblings, 0 replies; 12+ messages in thread
From: Gabriel Scherer @ 2013-04-21 11:28 UTC (permalink / raw)
  To: Daniel Bünzli; +Cc: William Smith, Caml-list

In any case, I was thinking of an optional flag to use gnu-style error
messages. I'm not sure they're actually better in the general case
(Modulo the question of the end position, I personally prefer the
current format for human readability), and there are surely
error-message-parsing scripts around that I don't want to break --
people tend to get feral about their editor configuration.

On Sun, Apr 21, 2013 at 12:53 PM, Daniel Bünzli
<daniel.buenzli@erratique.ch> wrote:
>
>
> Le dimanche, 21 avril 2013 à 08:37, Gabriel Scherer a écrit :
>
>> I think a patch affecting the error and warning-printing functions of
>> the Location module (parsing/location.ml) should be a very satisfying
>> first step (what kind of errors are you thinking about that aren't
>> handled by these functions?). I'm considering writing such a patch.
>
> Stacktraces in printexc.ml are an example (OT but if you are changing things in printexc could maybe grant the whish of that comment [1]...). There are quite a few places, see the end of this email for an over approximation of the places to change.
>
> Also please make sure to update caml.el so that it works. Should be mainly about the caml-error-regexp, caml-error-chars-regexp constants. Maybe, because of the standardization it's actually just a matter of removing the addition made to compilation-error-regexp-alist.
>
> Best,
>
> Daniel
>
> [1] http://caml.inria.fr/mantis/view.php?id=5899#c8779
>
>
>> git grep "\"File"
> asmcomp/asmpackager.ml: fprintf ppf "File %a@ was not compiled with the `-for-pack %s' option"
> asmcomp/asmpackager.ml: fprintf ppf "File %s not found" file
> bytecomp/bytepackager.ml: fprintf ppf "File %a redefines %s"
> bytecomp/bytepackager.ml: fprintf ppf "File %s not found" file
> camlp4/Camlp4/Struct/Loc.ml: let res = sprintf "File \"%s\", line %d, characters %d-%d"
> camlp4/boot/Camlp4.ml: sprintf "File \"%s\", line %d, characters %d-%d" x.file_name
> debugger/loadprinter.ml: fprintf ppf "File %s loaded@." filename;
> experimental/doligez/checkheaders: printf ("File \"%s\", line %d:\n", FILENAME, FNR);
> lex/main.ml: "File \"%s\", line %d, character %d: character set expected.\n"
> lex/main.ml: "File \"%s\", line %d, character %d: syntax error.\n"
> lex/main.ml: "File \"%s\", line %d, character %d: %s.\n"
> lex/main.ml: "File \"%s\":\n Position memory overflow, too many bindings\n"
> lex/main.ml: "File \"%s\":\ntransition table overflow, automaton is too big\n"
> lex/parser.mly: Printf.eprintf "File \"%s\", line %d, character %d:\n\
> ocamlbuild/configuration.ml: parse_lexbuf ?dir (Printf.sprintf "File %S" file) (Lexing.from_channel ic)
> ocamlbuild/hygiene.ml: Some(sf "File %s in %s has suffix %s" name path suffix)
> ocamlbuild/hygiene.ml: Some(sf "Files %s and %s should not be together in %s" name name' path)
> ocamlbuild/testsuite/level0.ml: ["*:a", "File \"_tags\", line 1, column 0: Lexing error: Invalid globbing pattern \"*\".";
> ocamlbuild/testsuite/level0.ml: "\n<*{>:a", "File \"_tags\", line 2, column 0: Lexing error: Invalid globbing pattern \"<*{>\".";
> ocamlbuild/testsuite/level0.ml: "<*>: ~@a,# ~a", "File \"_tags\", line 1, column 10: Lexing error: Only ',' separated tags are alllowed."];;
> ocamldoc/odoc_messages.ml:let file_generated f = "File "^f^" generated."
> ocamldoc/odoc_messages.ml: "File "^f^" exists, we don't generate it."
> otherlibs/dynlink/dynlink.ml: Printf.sprintf "File_not_found %S" s
> otherlibs/labltk/browser/editor.ml: val file_menu = new Jg_menu.c "File" ~parent:menus
> otherlibs/labltk/browser/editor.ml: ("File `" ^ name ^ "' exists. Overwrite it?")
> otherlibs/labltk/browser/fileselect.ml: let dfrl = Label.create dfr ~text:"Files" in
> otherlibs/labltk/browser/shell.ml: let file_menu = new Jg_menu.c "File" ~parent:menus
> otherlibs/labltk/browser/viewer.ml: let filemenu = new Jg_menu.c "File" ~parent:menus
> otherlibs/labltk/browser/viewer.ml: let filemenu = new Jg_menu.c "File" ~parent:menus
> otherlibs/labltk/compiler/maincompile.ml: prerr_string "File \""; prerr_string !input_name;
> otherlibs/labltk/examples_camltk/fileopen.ml:let t = Label.create cvs [Text "File name"];;
> otherlibs/labltk/examples_camltk/winskel.ml: let file = Menubutton.create mbar [Text "File"; UnderlinedChar 0]
> otherlibs/labltk/jpf/fileselect.ml: let dfrl = Label.create dfr ~text: "Files" in
> parsing/location.ml: ("File \"", "\", line ", ", characters ", "-", ":")
> stdlib/filename.ml: if n < 0 then invalid_arg "Filename.chop_suffix" else String.sub name 0 n
> stdlib/filename.ml: if i < 0 || is_dir_sep name i then invalid_arg "Filename.chop_extension"
> stdlib/printexc.ml:let locfmt = format_of_string "File \"%s\", line %d, characters %d-%d: %s";;
> testsuite/Makefile: @if [ ! -f $(FILE) ]; then echo "File '$(FILE)' does not exist."; exit 1; fi
> tools/cmt2annot.ml: Printf.fprintf stderr "File was generated with an error\n%!";
> tools/cmt2annot.ml: Printf.fprintf stderr "File was generated with an error\n%!";
> tools/dumpobj.ml: printf "File \"%s\", line %d, characters %d-%d:\n" ls.Lexing.pos_fname
> tools/objinfo.ml: printf "File %s\n" filename;
> tools/scrapelabels.ml: "Event"; "Filename"; "Format"; "Gc"; "Genlex"; "Graphics";
> toplevel/opttopdirs.ml: | None -> fprintf ppf "File not found: %s@." name0; false
> toplevel/topdirs.ml: fprintf ppf "File %s is not a bytecode object file.@." name;
> yacc/error.c: fprintf(stderr, "File \"%s\", line %d: unexpected end-of-file\n",
> yacc/error.c: fprintf(stderr, "File \"%s\", line %d: syntax error\n",
> yacc/error.c: fprintf(stderr, "File \"%s\", line %d: unmatched /*\n",
> yacc/error.c: fprintf(stderr, "File \"%s\", line %d: unterminated string\n",
> yacc/error.c: fprintf(stderr, "File \"%s\", line %d: unmatched %%{\n",
> yacc/error.c: fprintf(stderr, "File \"%s\", line %d: unterminated %%union declaration\n",
> yacc/error.c: fprintf(stderr, "File \"%s\", line %d: too many %%union declarations\n",
> yacc/error.c: fprintf(stderr, "File \"%s\", line %d: illegal tag\n",
> yacc/error.c: fprintf(stderr, "File \"%s\", line %d: illegal character\n",
> yacc/error.c: fprintf(stderr, "File \"%s\", line %d: illegal use of reserved symbol \
> yacc/error.c: fprintf(stderr, "File \"%s\", line %d: the start symbol `%s' cannot \
> yacc/error.c: fprintf(stderr, "File \"%s\", line %d: warning: the type of `%s' has been \
> yacc/error.c: fprintf(stderr, "File \"%s\", line %d: warning: the precedence of `%s' has \
> yacc/error.c: fprintf(stderr, "File \"%s\", line %d: warning: the value of `%s' has been \
> yacc/error.c: fprintf(stderr, "File \"%s\", line %d: the entry point `%s' is a \
> yacc/error.c: fprintf(stderr, "File \"%s\", line %d: more than 256 entry points\n",
> yacc/error.c: fprintf(stderr, "File \"%s\", line %d: no grammar has been specified\n",
> yacc/error.c: fprintf(stderr, "File \"%s\", line %d: a token appears on the lhs \
> yacc/error.c: fprintf(stderr, "File \"%s\", line %d: warning: conflicting %%prec \
> yacc/error.c: fprintf(stderr, "File \"%s\", line %d: unterminated action\n",
> yacc/error.c: fprintf(stderr, "File \"%s\", line %d: warning: $%d references beyond the \
> yacc/error.c: fprintf(stderr, "File \"%s\", line %d: illegal $-name\n",
> yacc/error.c: fprintf(stderr, "File \"%s\", line %d: $$ is untyped\n",
> yacc/error.c: fprintf(stderr, "File \"%s\", line %d: $%d (%s) is untyped\n",
> yacc/error.c: fprintf(stderr, "File \"%s\", line %d: $%d is unbound\n",
> yacc/error.c: fprintf(stderr, "File \"%s\", line %d: $%d refers to terminal `%s', \
> yacc/error.c: fprintf(stderr, "File \"%s\", line %d: no action specified for this \
>
>
>

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [Caml-list] modified error messages for ocamlc
  2013-04-14 16:25 ` Daniel Bünzli
  2013-04-14 17:06   ` Gabriel Scherer
@ 2013-04-15 15:37   ` Jacques Le Normand
  1 sibling, 0 replies; 12+ messages in thread
From: Jacques Le Normand @ 2013-04-15 15:37 UTC (permalink / raw)
  To: Daniel Bünzli; +Cc: William Smith, caml

[-- Attachment #1: Type: text/plain, Size: 1274 bytes --]

I'd also like to see the standard gnu way.
On Apr 14, 2013 9:26 AM, "Daniel Bünzli" <daniel.buenzli@erratique.ch>
wrote:

> Le dimanche, 14 avril 2013 à 16:20, William Smith a écrit :
> > Would there be any interest in me making the change everywhere and
> submitting it as a patch?
>
> Not at all...
>
> > One concern I have is that it might break automated test scripts.
>
> That may be the case but more importantly your fancy way of reporting
> error messages is not recognized by emacs' compilation-mode. ocaml's
> current way of reporting allows compilation-mode to perfectly hilight the
> span of the error in your source *without* having to tweak the
> `compilation-error-regexp-alist` variable. That's not the case of your
> format.
>
> If something has to be changed I'd rather have the gnu standard way of
> reporting errors for ranges [1] which is both more compact and recognized
> by emacs' compilation-mode.
>
> Best,
>
> Daniel
>
> [1] http://www.gnu.org/prep/standards/standards.html#Errors
>
> --
> Caml-list mailing list.  Subscription management and archives:
> https://sympa.inria.fr/sympa/arc/caml-list
> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
> Bug reports: http://caml.inria.fr/bin/caml-bugs

[-- Attachment #2: Type: text/html, Size: 1882 bytes --]

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [Caml-list] modified error messages for ocamlc
  2013-04-14 15:20 William Smith
  2013-04-14 16:25 ` Daniel Bünzli
@ 2013-04-15  6:26 ` Raphaël Proust
  1 sibling, 0 replies; 12+ messages in thread
From: Raphaël Proust @ 2013-04-15  6:26 UTC (permalink / raw)
  To: William Smith; +Cc: Caml-list

On Sun, Apr 14, 2013 at 5:20 PM, William Smith <bills@emu-bark.com> wrote:
> Hi,
>
> I've made a change to my copy of ocamlc to modify error messages when they
> cover multiple lines.

I have a similar fork of the OCaml compiler with shorter/more
standard/easier to regexp/simpler to parse/*plan9's acme friendly*
(the last point was the most important for me):
https://github.com/raphael-proust/ocaml/commit/a5cb1414b590d3e0f49c2ee87bcb90459e34fcde

The way I distribute it (to myself, i.e. to my different machines) is via opam:
https://github.com/raphael-proust/opam-repo


It's an easy way to make it available not only to oneself, but to
anyone (with an opam installation) interested. (Any acme users out
there?) And it doesn't need to be patched in the main repository.

</my 9 cents>

Cheers,
-- 
______________
Raphaël Proust

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [Caml-list] modified error messages for ocamlc
  2013-04-14 18:19       ` Jonathan Protzenko
@ 2013-04-14 19:18         ` Daniel Bünzli
  0 siblings, 0 replies; 12+ messages in thread
From: Daniel Bünzli @ 2013-04-14 19:18 UTC (permalink / raw)
  To: Jonathan Protzenko; +Cc: William Smith, Caml-list, Gabriel Scherer

Le dimanche, 14 avril 2013 à 19:19, Jonathan Protzenko a écrit :
> The OCaml mode for emacs that's distributed along with the OCaml  
> sources contains (caml.el) :
>  
> 796 ;; Newer emacs versions support line/char ranges
> 797 ;; We will adapt OCaml to output error messages in a compatible  
> format.
> 798 ;; In the meantime we add the new format here in addition to the  
> old one.
> 799 (defconst caml-error-regexp-newstyle
> 800 "^[ A-\377]+ \"\\([^\"\n]+\\)\", line \\([0-9]+\\), char  
> \\([0-9]+\\) to line \\([0-9]+\\), char \\([0-9]+\\):"
> 801 "Regular expression matching the error messages produced by  
> ocamlc/ocamlopt.")
>  
> So there are provisions already in the Emacs mode for parsing  
> multi-line error formats. What refrains us from switching directly to  
> the format that's recognized by the already-distributed Caml mode ?


This discussion is very confusing. There's nothing special to be done here, it already works… The "old" version of the original message does exactly what it needs to do to highlight multiline errors.  

Daniel



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [Caml-list] modified error messages for ocamlc
  2013-04-14 17:57     ` Daniel Bünzli
@ 2013-04-14 18:19       ` Jonathan Protzenko
  2013-04-14 19:18         ` Daniel Bünzli
  0 siblings, 1 reply; 12+ messages in thread
From: Jonathan Protzenko @ 2013-04-14 18:19 UTC (permalink / raw)
  To: Daniel Bünzli; +Cc: William Smith, Caml-list, Gabriel Scherer

The OCaml mode for emacs that's distributed along with the OCaml 
sources contains (caml.el) :

 796 ;; Newer emacs versions support line/char ranges
 797 ;; We will adapt OCaml to output error messages in a compatible 
format.
 798 ;; In the meantime we add the new format here in addition to the 
old one.
 799 (defconst caml-error-regexp-newstyle
 800   "^[ A-\377]+ \"\\([^\"\n]+\\)\", line \\([0-9]+\\), char 
\\([0-9]+\\) to line \\([0-9]+\\), char \\([0-9]+\\):"
 801   "Regular expression matching the error messages produced by 
ocamlc/ocamlopt.")

So there are provisions already in the Emacs mode for parsing 
multi-line error formats. What refrains us from  switching directly to 
the format that's recognized by the already-distributed Caml mode ?

Cheers,

jonathan

On Sun 14 Apr 2013 07:57:36 PM CEST, Daniel Bünzli wrote:
> Le dimanche, 14 avril 2013 à 18:06, Gabriel Scherer a écrit :
>>>> Would there be any interest in me making the change everywhere and submitting it as a patch?
>>>
>>> Not at all...
>> I'm not sure if this is a language barrier thing, or sarcasm/irony
>> that got lost on the wire,
>
> No, it was a true answer, I'm not interesting in having changes introduced in ocaml that break features that are useful to me *every* day. Namely the ability of compilation-mode to precisely hilight the span of an error in my source, without having to tweak my .emacs. (That's said I'd have nothing against an implementation of gnu's standard).
>
>
>> On a related note, I have put in
>> http://caml.inria.fr/mantis/view.php?id=5044 some hooks for Emacs
>> compile-mode to parse additional error messages that are not supported
>> by default, namely the backtrace format and the location printed in
>> the 'assert false' error message.
>
> I still don't understand your issue here. For me everything works pefectly out of the box, character ranges included (or maybe I never fell on a specific case ?).
>
>> This is so convenient that I often
>> feed "ocamlbuild test.byte && ./test.byte" as my compilation command
>> in my edit-compile-test cycles.
>
> Yes, that's also what I do.
>
> Best,
>
> Daniel
>
>
>

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [Caml-list] modified error messages for ocamlc
  2013-04-14 17:06   ` Gabriel Scherer
@ 2013-04-14 17:57     ` Daniel Bünzli
  2013-04-14 18:19       ` Jonathan Protzenko
  0 siblings, 1 reply; 12+ messages in thread
From: Daniel Bünzli @ 2013-04-14 17:57 UTC (permalink / raw)
  To: Gabriel Scherer; +Cc: William Smith, Caml-list

Le dimanche, 14 avril 2013 à 18:06, Gabriel Scherer a écrit :
> > > Would there be any interest in me making the change everywhere and submitting it as a patch?
> >  
> > Not at all...
> I'm not sure if this is a language barrier thing, or sarcasm/irony
> that got lost on the wire,

No, it was a true answer, I'm not interesting in having changes introduced in ocaml that break features that are useful to me *every* day. Namely the ability of compilation-mode to precisely hilight the span of an error in my source, without having to tweak my .emacs. (That's said I'd have nothing against an implementation of gnu's standard).  
  

> On a related note, I have put in
> http://caml.inria.fr/mantis/view.php?id=5044 some hooks for Emacs
> compile-mode to parse additional error messages that are not supported
> by default, namely the backtrace format and the location printed in
> the 'assert false' error message.  

I still don't understand your issue here. For me everything works pefectly out of the box, character ranges included (or maybe I never fell on a specific case ?).  

> This is so convenient that I often
> feed "ocamlbuild test.byte && ./test.byte" as my compilation command
> in my edit-compile-test cycles.

Yes, that's also what I do.

Best,

Daniel



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [Caml-list] modified error messages for ocamlc
  2013-04-14 16:25 ` Daniel Bünzli
@ 2013-04-14 17:06   ` Gabriel Scherer
  2013-04-14 17:57     ` Daniel Bünzli
  2013-04-15 15:37   ` Jacques Le Normand
  1 sibling, 1 reply; 12+ messages in thread
From: Gabriel Scherer @ 2013-04-14 17:06 UTC (permalink / raw)
  To: Daniel Bünzli; +Cc: William Smith, Caml-list

>> Would there be any interest in me making the change everywhere and submitting it as a patch?
>
> Not at all...

I'm not sure if this is a language barrier thing, or sarcasm/irony
that got lost on the wire, but my personal reaction would rather be
that there indeed is some interest, especially if you follow Daniel's
excellent suggestion to respect the standard GNU format for that.

On a related note, I have put in
http://caml.inria.fr/mantis/view.php?id=5044 some hooks for Emacs
compile-mode to parse additional error messages that are not supported
by default, namely the backtrace format and the location printed in
the 'assert false' error message. This is so convenient that I often
feed "ocamlbuild test.byte && ./test.byte" as my compilation command
in my edit-compile-test cycles.


On Sun, Apr 14, 2013 at 6:25 PM, Daniel Bünzli
<daniel.buenzli@erratique.ch> wrote:
> Le dimanche, 14 avril 2013 à 16:20, William Smith a écrit :
>> Would there be any interest in me making the change everywhere and submitting it as a patch?
>
> Not at all...
>
>> One concern I have is that it might break automated test scripts.
>
> That may be the case but more importantly your fancy way of reporting error messages is not recognized by emacs' compilation-mode. ocaml's current way of reporting allows compilation-mode to perfectly hilight the span of the error in your source *without* having to tweak the `compilation-error-regexp-alist` variable. That's not the case of your format.
>
> If something has to be changed I'd rather have the gnu standard way of reporting errors for ranges [1] which is both more compact and recognized by emacs' compilation-mode.
>
> Best,
>
> Daniel
>
> [1] http://www.gnu.org/prep/standards/standards.html#Errors
>
> --
> Caml-list mailing list.  Subscription management and archives:
> https://sympa.inria.fr/sympa/arc/caml-list
> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
> Bug reports: http://caml.inria.fr/bin/caml-bugs

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [Caml-list] modified error messages for ocamlc
  2013-04-14 15:20 William Smith
@ 2013-04-14 16:25 ` Daniel Bünzli
  2013-04-14 17:06   ` Gabriel Scherer
  2013-04-15 15:37   ` Jacques Le Normand
  2013-04-15  6:26 ` Raphaël Proust
  1 sibling, 2 replies; 12+ messages in thread
From: Daniel Bünzli @ 2013-04-14 16:25 UTC (permalink / raw)
  To: William Smith; +Cc: Caml-list

Le dimanche, 14 avril 2013 à 16:20, William Smith a écrit :
> Would there be any interest in me making the change everywhere and submitting it as a patch?

Not at all...
  
> One concern I have is that it might break automated test scripts.

That may be the case but more importantly your fancy way of reporting error messages is not recognized by emacs' compilation-mode. ocaml's current way of reporting allows compilation-mode to perfectly hilight the span of the error in your source *without* having to tweak the `compilation-error-regexp-alist` variable. That's not the case of your format.

If something has to be changed I'd rather have the gnu standard way of reporting errors for ranges [1] which is both more compact and recognized by emacs' compilation-mode.

Best,

Daniel

[1] http://www.gnu.org/prep/standards/standards.html#Errors

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Caml-list] modified error messages for ocamlc
@ 2013-04-14 15:20 William Smith
  2013-04-14 16:25 ` Daniel Bünzli
  2013-04-15  6:26 ` Raphaël Proust
  0 siblings, 2 replies; 12+ messages in thread
From: William Smith @ 2013-04-14 15:20 UTC (permalink / raw)
  To: Caml-list

[-- Attachment #1: Type: text/plain, Size: 961 bytes --]

Hi,

I've made a change to my copy of ocamlc to modify error messages when 
they cover multiple lines.

For example, for the following code, the modified error message includes 
the line number and character offset of then end of the message instead 
of just the length of the message.

Would there be any interest in me making the change everywhere and 
submitting it as a patch?  I see about a dozen places in the source of 
the various tools where the change would be possible.   One concern I 
have is that it might break automated test scripts.

Bill Smith

let x = 1 in
(match x with
1 -> true
);;
--------
New:
File "multilineError.ml", line 2, character 0-line 4, character 1:
Warning 8: this pattern-matching is not exhaustive.
Here is an example of a value that is not matched:
0
--------
Old:
File "multilineError.ml", line 2, characters 0-28:
Warning 8: this pattern-matching is not exhaustive.
Here is an example of a value that is not matched:
0


[-- Attachment #2: Type: text/html, Size: 1707 bytes --]

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2013-04-21 11:28 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-04-18 16:40 [Caml-list] modified error messages for ocamlc William Smith
2013-04-21  7:37 ` Gabriel Scherer
2013-04-21 10:53   ` Daniel Bünzli
2013-04-21 11:28     ` Gabriel Scherer
  -- strict thread matches above, loose matches on Subject: below --
2013-04-14 15:20 William Smith
2013-04-14 16:25 ` Daniel Bünzli
2013-04-14 17:06   ` Gabriel Scherer
2013-04-14 17:57     ` Daniel Bünzli
2013-04-14 18:19       ` Jonathan Protzenko
2013-04-14 19:18         ` Daniel Bünzli
2013-04-15 15:37   ` Jacques Le Normand
2013-04-15  6:26 ` Raphaël Proust

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).