You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
31 lines
685 B
Go
31 lines
685 B
Go
package errors
|
|
|
|
import "golox/token"
|
|
|
|
type Logger interface {
|
|
Error(line int, message string)
|
|
ErrorAtToken(t token.Token, message string)
|
|
RuntimeError(message string)
|
|
}
|
|
|
|
type mockErrorLogger struct {
|
|
Errors []string
|
|
RuntimeErrors []string
|
|
}
|
|
|
|
func (el *mockErrorLogger) Error(line int, message string) {
|
|
el.Errors = append(el.Errors, message)
|
|
}
|
|
|
|
func (el *mockErrorLogger) ErrorAtToken(t token.Token, message string) {
|
|
el.Errors = append(el.Errors, message)
|
|
}
|
|
|
|
func (el *mockErrorLogger) RuntimeError(message string) {
|
|
el.RuntimeErrors = append(el.RuntimeErrors, message)
|
|
}
|
|
|
|
func NewMockErrorLogger() *mockErrorLogger {
|
|
return &mockErrorLogger{[]string{}, []string{}}
|
|
}
|