hare

[hare] The Hare programming language
git clone https://git.torresjrjr.com/hare.git
Log | Files | Refs | README | LICENSE

commit 5fde468d3c041437ef017e083890e5695b3d0ac0
parent 7609148ab49a74c15b6618780ccfad8b6f13e8b2
Author: Dridi Boukelmoune <dridi.boukelmoune@gmail.com>
Date:   Fri, 12 May 2023 19:50:01 +0200

error: Align located messages with other toolchains

The make(1) integration in Vim can identify error messages with a
location and build a list of them that can then be navigated. When
make(1) is executed directly from vim, for example with `:make` or
`:make check` such error messages will be registered and the editor
will switch the current buffer to the first error location.

This integration requires error messages to be in the form of:

    file:line:column: description

Vim switches to the `file` file and moves the cursors to line `line`
and column `column`, showing `description` in its status bar, which
is very convenient.

The test case was updated for consistency, to represent the source
code position in the same file:line:column form. Test failures for
the lexer don't result in a "located" error message anyway.

Signed-off-by: Dridi Boukelmoune <dridi.boukelmoune@gmail.com>

Diffstat:
Mcmd/harec/errors.ha | 2+-
Mhare/lex/+test.ha | 2+-
Mhare/lex/lex.ha | 2+-
3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/cmd/harec/errors.ha b/cmd/harec/errors.ha @@ -35,7 +35,7 @@ fn printerr_syntax(err: lex::syntax) void = { let line = bufio::scanline(file) as []u8; defer free(line); let line = strings::fromutf8_unsafe(line); - fmt::errorfln("{}:{},{}: Syntax error: {}", + fmt::errorfln("{}:{}:{}: syntax error: {}", location.path, location.line, location.col, details)!; fmt::errorln(line)!; for (let i = 0u; i < location.col - 2; i += 1) { diff --git a/hare/lex/+test.ha b/hare/lex/+test.ha @@ -79,7 +79,7 @@ fn lextest(in: str, expected: []token) void = { vassert(tl.1, etok.1); if (tl.2.line != etok.2.line || tl.2.col != etok.2.col || tl.2.path != etok.2.path) { - fmt::errorfln("{}:{},{} != {}:{},{}", + fmt::errorfln("{}:{}:{} != {}:{}:{}", tl.2.path, tl.2.line, tl.2.col, etok.2.path, etok.2.line, etok.2.col)!; abort(); diff --git a/hare/lex/lex.ha b/hare/lex/lex.ha @@ -52,7 +52,7 @@ export fn strerror(err: error) const str = { case let err: io::error => return io::strerror(err); case let s: syntax => - return fmt::bsprintf(buf, "{}:{},{}: Syntax error: {}", + return fmt::bsprintf(buf, "{}:{}:{}: syntax error: {}", s.0.path, s.0.line, s.0.col, s.1); }; };