xgo/compiler/parser/error.go

22 lines
359 B
Go
Raw Normal View History

2019-01-09 10:17:42 +03:00
package parser
import (
"fmt"
"github.com/d5/tengo/compiler/source"
)
2019-01-09 10:17:42 +03:00
// Error represents a parser error.
2019-01-09 10:17:42 +03:00
type Error struct {
Pos source.FilePos
2019-01-09 10:17:42 +03:00
Msg string
}
func (e Error) Error() string {
if e.Pos.Filename != "" || e.Pos.IsValid() {
return fmt.Sprintf("Parse Error: %s\n\tat %s", e.Msg, e.Pos)
2019-01-09 10:17:42 +03:00
}
return fmt.Sprintf("Parse Error: %s", e.Msg)
2019-01-09 10:17:42 +03:00
}