2019-01-09 10:17:42 +03:00
|
|
|
package parser
|
|
|
|
|
2019-02-23 00:39:07 +03:00
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
|
|
|
|
"github.com/d5/tengo/compiler/source"
|
|
|
|
)
|
2019-01-09 10:17:42 +03:00
|
|
|
|
2019-01-15 09:24:33 +03:00
|
|
|
// Error represents a parser error.
|
2019-01-09 10:17:42 +03:00
|
|
|
type Error struct {
|
2019-01-11 12:16:34 +03:00
|
|
|
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() {
|
2019-02-23 00:39:07 +03:00
|
|
|
return fmt.Sprintf("Parse Error: %s\n\tat %s", e.Msg, e.Pos)
|
2019-01-09 10:17:42 +03:00
|
|
|
}
|
|
|
|
|
2019-02-23 00:39:07 +03:00
|
|
|
return fmt.Sprintf("Parse Error: %s", e.Msg)
|
2019-01-09 10:17:42 +03:00
|
|
|
}
|