Ocaml's own compiler libraries provide cool ways to highlight source code and display syntax errors, through Location.print_report.
I managed to use it to display Menhir's messages with the location:
File "test_input", line 5, characters 9-10:
Error: Headers must not have trailing markers
But if I want it to have source highlighting like so:
File "inkc/lib/lexer.ml", line 13, characters 33-38:
13 | let any_blank = [%sedlex.regexp? blank | newline]
^^^^^
Error: Sedlex: unbound regexp blank
then I have to give it a Lexing.lexbuf instance with Location.input_buf := ...
It'd be nice if Sedlex had buffer conversion out of the box to support this.
As it is now, I can't even create a Lexing.lexbuf myself out of a Sedlexing.lexbuf because I don't have access to the buffer's actual contents. All I can get are locations. And small bits of the contents through the lexeme functions
Ocaml's own compiler libraries provide cool ways to highlight source code and display syntax errors, through
Location.print_report.I managed to use it to display Menhir's messages with the location:
But if I want it to have source highlighting like so:
then I have to give it a
Lexing.lexbufinstance withLocation.input_buf := ...It'd be nice if Sedlex had buffer conversion out of the box to support this.
As it is now, I can't even create a
Lexing.lexbufmyself out of aSedlexing.lexbufbecause I don't have access to the buffer's actual contents. All I can get are locations. And small bits of the contents through thelexemefunctions