hare

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

commit 3fd05e229b728a739001d0b3faadfcc99eee11b7
parent 27bc1805b31bb31f4552137425b6b6f02517a070
Author: Alexey Yerin <yyp@disroot.org>
Date:   Sun, 18 Apr 2021 22:12:56 +0300

hare/parse: enclose expected tokens in ''

Especially helpful when the wanted token is a comma, compare this:
    file.ha:5,2: Syntax error: Unexpected }, was expecting ,, )

To this:
    file.ha:5,2: Syntax error: Unexpected '}', was expecting ',', ')'

Diffstat:
Mhare/parse/parse.ha | 4++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/hare/parse/parse.ha b/hare/parse/parse.ha @@ -41,12 +41,12 @@ fn want(lexer: *lex::lexer, want: lex::ltok...) (lex::token | error) = { let buf = strio::dynamic(); defer io::close(buf); for (let i = 0z; i < len(want); i += 1) { - fmt::fprintf(buf, "{}", lex::tokstr((want[i], void, mkloc(lexer)))); + fmt::fprintf(buf, "'{}'", lex::tokstr((want[i], void, mkloc(lexer)))); if (i + 1 < len(want)) { fmt::fprint(buf, ", "); }; }; - return syntaxerr(mkloc(lexer), "Unexpected {}, was expecting {}", + return syntaxerr(mkloc(lexer), "Unexpected '{}', was expecting {}", lex::tokstr(tok), strio::string(buf)); };