6 "github.com/hashicorp/hil/ast"
7 "github.com/hashicorp/hil/scanner"
10 type ParseError struct {
15 func Errorf(pos ast.Pos, format string, args ...interface{}) error {
17 Message: fmt.Sprintf(format, args...),
22 // TokenErrorf is a convenient wrapper around Errorf that uses the
23 // position of the given token.
24 func TokenErrorf(token *scanner.Token, format string, args ...interface{}) error {
25 return Errorf(token.Pos, format, args...)
28 func ExpectationError(wanted string, got *scanner.Token) error {
29 return TokenErrorf(got, "expected %s but found %s", wanted, got)
32 func (e *ParseError) Error() string {
33 return fmt.Sprintf("parse error at %s: %s", e.Pos, e.Message)
36 func (e *ParseError) String() string {