From 5aaa3e75b9cbb892d547f1b075e47dc00246bd5b Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Fri, 6 Nov 2015 23:42:45 -0800 Subject: [PATCH] hcl/parser: scan errors should come through as well --- hcl/parser/parser.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/hcl/parser/parser.go b/hcl/parser/parser.go index 24e878d..d09b608 100644 --- a/hcl/parser/parser.go +++ b/hcl/parser/parser.go @@ -44,8 +44,15 @@ var errEofToken = errors.New("EOF token found") // Parse returns the fully parsed source and returns the abstract syntax tree. func (p *Parser) Parse() (*ast.File, error) { f := &ast.File{} - var err error + var err, scerr error + p.sc.Error = func(pos token.Pos, msg string) { + scerr = fmt.Errorf("%s: %s", pos, msg) + } + f.Node, err = p.objectList() + if scerr != nil { + return nil, scerr + } if err != nil { return nil, err }