Use *lexer.describe in parse error message

Make error messages for tokens like EOF, Ident, Int or Float easier to
understand.
This commit is contained in:
Eduardo Lopez
2020-03-21 17:23:56 -07:00
parent 1e9cbf3a0a
commit 0a23d453a0

View File

@@ -130,7 +130,7 @@ func parsePrimary(lex *lexer) Expr {
lex.next() // consume ','
}
if lex.token != ')' {
msg := fmt.Sprintf("got %q, want ')'", lex.token)
msg := fmt.Sprintf("got %s, want ')'", lex.describe())
panic(lexPanic(msg))
}
}