token.go: added a few error functions
This commit is contained in:
parent
5da5a61a42
commit
b185f1df3a
6
token.go
6
token.go
@ -104,6 +104,10 @@ func (tk *Token) ErrorExpectedGot(symbol string) (err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (tk *Token) ErrorExpectedGotString(symbol, got string) (err error) {
|
func (tk *Token) ErrorExpectedGotString(symbol, got string) (err error) {
|
||||||
err = fmt.Errorf("[%d:%d] expected `%s`, got `%s`", tk.row, tk.col, symbol, got)
|
return tk.ErrorExpectedGotStringWithPrefix("expected", symbol, got)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (tk *Token) ErrorExpectedGotStringWithPrefix(prefix, symbol, got string) (err error) {
|
||||||
|
err = fmt.Errorf("[%d:%d] %s `%s`, got `%s`", tk.row, tk.col, prefix, symbol, got)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user