Merge pull request #9701 from hashicorp/update-hcl

vendor: update HCL
This commit is contained in:
Mitchell Hashimoto 2016-10-28 19:44:55 -04:00 committed by GitHub
commit 52e4b4563b
4 changed files with 49 additions and 30 deletions

View File

@ -50,7 +50,7 @@ func (p *Parser) Parse() (*ast.File, error) {
scerr = &PosError{Pos: pos, Err: errors.New(msg)} scerr = &PosError{Pos: pos, Err: errors.New(msg)}
} }
f.Node, err = p.objectList() f.Node, err = p.objectList(false)
if scerr != nil { if scerr != nil {
return nil, scerr return nil, scerr
} }
@ -62,11 +62,23 @@ func (p *Parser) Parse() (*ast.File, error) {
return f, nil return f, nil
} }
func (p *Parser) objectList() (*ast.ObjectList, error) { // objectList parses a list of items within an object (generally k/v pairs).
// The parameter" obj" tells this whether to we are within an object (braces:
// '{', '}') or just at the top level. If we're within an object, we end
// at an RBRACE.
func (p *Parser) objectList(obj bool) (*ast.ObjectList, error) {
defer un(trace(p, "ParseObjectList")) defer un(trace(p, "ParseObjectList"))
node := &ast.ObjectList{} node := &ast.ObjectList{}
for { for {
if obj {
tok := p.scan()
p.unscan()
if tok.Type == token.RBRACE {
break
}
}
n, err := p.objectItem() n, err := p.objectItem()
if err == errEofToken { if err == errEofToken {
break // we are finished break // we are finished
@ -288,7 +300,7 @@ func (p *Parser) objectType() (*ast.ObjectType, error) {
Lbrace: p.tok.Pos, Lbrace: p.tok.Pos,
} }
l, err := p.objectList() l, err := p.objectList(true)
// if we hit RBRACE, we are good to go (means we parsed all Items), if it's // if we hit RBRACE, we are good to go (means we parsed all Items), if it's
// not a RBRACE, it's an syntax error and we just return it. // not a RBRACE, it's an syntax error and we just return it.
@ -296,9 +308,9 @@ func (p *Parser) objectType() (*ast.ObjectType, error) {
return nil, err return nil, err
} }
// If there is no error, we should be at a RBRACE to end the object // No error, scan and expect the ending to be a brace
if p.tok.Type != token.RBRACE { if tok := p.scan(); tok.Type != token.RBRACE {
return nil, fmt.Errorf("object expected closing RBRACE got: %s", p.tok.Type) return nil, fmt.Errorf("object expected closing RBRACE got: %s", tok.Type)
} }
o.List = l o.List = l

View File

@ -48,6 +48,12 @@ func flattenListType(
item *ast.ObjectItem, item *ast.ObjectItem,
items []*ast.ObjectItem, items []*ast.ObjectItem,
frontier []*ast.ObjectItem) ([]*ast.ObjectItem, []*ast.ObjectItem) { frontier []*ast.ObjectItem) ([]*ast.ObjectItem, []*ast.ObjectItem) {
// If the list is empty, keep the original list
if len(ot.List) == 0 {
items = append(items, item)
return items, frontier
}
// All the elements of this object must also be objects! // All the elements of this object must also be objects!
for _, subitem := range ot.List { for _, subitem := range ot.List {
if _, ok := subitem.(*ast.ObjectType); !ok { if _, ok := subitem.(*ast.ObjectType); !ok {

View File

@ -86,6 +86,7 @@ func (p *Parser) objectList() (*ast.ObjectList, error) {
break break
} }
} }
return node, nil return node, nil
} }

48
vendor/vendor.json vendored
View File

@ -1302,68 +1302,68 @@
{ {
"checksumSHA1": "8OPDk+bKyRGJoKcS4QNw9F7dpE8=", "checksumSHA1": "8OPDk+bKyRGJoKcS4QNw9F7dpE8=",
"path": "github.com/hashicorp/hcl", "path": "github.com/hashicorp/hcl",
"revision": "6f5bfed9a0a22222fbe4e731ae3481730ba41e93", "revision": "8fa153c5b4e9d1ccecda7075821ffc7c1f6d912b",
"revisionTime": "2016-10-08T07:35:57Z" "revisionTime": "2016-10-28T23:32:40Z"
}, },
{ {
"checksumSHA1": "XQmjDva9JCGGkIecOgwtBEMCJhU=", "checksumSHA1": "XQmjDva9JCGGkIecOgwtBEMCJhU=",
"path": "github.com/hashicorp/hcl/hcl/ast", "path": "github.com/hashicorp/hcl/hcl/ast",
"revision": "6f5bfed9a0a22222fbe4e731ae3481730ba41e93", "revision": "8fa153c5b4e9d1ccecda7075821ffc7c1f6d912b",
"revisionTime": "2016-10-08T07:35:57Z" "revisionTime": "2016-10-28T23:32:40Z"
}, },
{ {
"checksumSHA1": "5HVecyfmcTm6OTffEi6LGayQf5M=", "checksumSHA1": "5HVecyfmcTm6OTffEi6LGayQf5M=",
"path": "github.com/hashicorp/hcl/hcl/fmtcmd", "path": "github.com/hashicorp/hcl/hcl/fmtcmd",
"revision": "6f5bfed9a0a22222fbe4e731ae3481730ba41e93", "revision": "8fa153c5b4e9d1ccecda7075821ffc7c1f6d912b",
"revisionTime": "2016-10-08T07:35:57Z" "revisionTime": "2016-10-28T23:32:40Z"
}, },
{ {
"checksumSHA1": "un4pN4yL5bl6LL3CgWacFbIeHVg=", "checksumSHA1": "croNloscHsjX87X+4/cKOURf1EY=",
"path": "github.com/hashicorp/hcl/hcl/parser", "path": "github.com/hashicorp/hcl/hcl/parser",
"revision": "6f5bfed9a0a22222fbe4e731ae3481730ba41e93", "revision": "8fa153c5b4e9d1ccecda7075821ffc7c1f6d912b",
"revisionTime": "2016-10-08T07:35:57Z" "revisionTime": "2016-10-28T23:32:40Z"
}, },
{ {
"checksumSHA1": "QjoxNbg+jBmtewexLaBZ8EJEl24=", "checksumSHA1": "QjoxNbg+jBmtewexLaBZ8EJEl24=",
"path": "github.com/hashicorp/hcl/hcl/printer", "path": "github.com/hashicorp/hcl/hcl/printer",
"revision": "6f5bfed9a0a22222fbe4e731ae3481730ba41e93", "revision": "8fa153c5b4e9d1ccecda7075821ffc7c1f6d912b",
"revisionTime": "2016-10-08T07:35:57Z" "revisionTime": "2016-10-28T23:32:40Z"
}, },
{ {
"checksumSHA1": "lgR7PSAZ0RtvAc9OCtCnNsF/x8g=", "checksumSHA1": "lgR7PSAZ0RtvAc9OCtCnNsF/x8g=",
"path": "github.com/hashicorp/hcl/hcl/scanner", "path": "github.com/hashicorp/hcl/hcl/scanner",
"revision": "6f5bfed9a0a22222fbe4e731ae3481730ba41e93", "revision": "8fa153c5b4e9d1ccecda7075821ffc7c1f6d912b",
"revisionTime": "2016-10-08T07:35:57Z" "revisionTime": "2016-10-28T23:32:40Z"
}, },
{ {
"checksumSHA1": "JlZmnzqdmFFyb1+2afLyR3BOE/8=", "checksumSHA1": "JlZmnzqdmFFyb1+2afLyR3BOE/8=",
"path": "github.com/hashicorp/hcl/hcl/strconv", "path": "github.com/hashicorp/hcl/hcl/strconv",
"revision": "6f5bfed9a0a22222fbe4e731ae3481730ba41e93", "revision": "8fa153c5b4e9d1ccecda7075821ffc7c1f6d912b",
"revisionTime": "2016-10-08T07:35:57Z" "revisionTime": "2016-10-28T23:32:40Z"
}, },
{ {
"checksumSHA1": "c6yprzj06ASwCo18TtbbNNBHljA=", "checksumSHA1": "c6yprzj06ASwCo18TtbbNNBHljA=",
"path": "github.com/hashicorp/hcl/hcl/token", "path": "github.com/hashicorp/hcl/hcl/token",
"revision": "6f5bfed9a0a22222fbe4e731ae3481730ba41e93", "revision": "8fa153c5b4e9d1ccecda7075821ffc7c1f6d912b",
"revisionTime": "2016-10-08T07:35:57Z" "revisionTime": "2016-10-28T23:32:40Z"
}, },
{ {
"checksumSHA1": "fpQQdjFUZOoslYuFNKZMSO0N0ik=", "checksumSHA1": "138aCV5n8n7tkGYMsMVQQnnLq+0=",
"path": "github.com/hashicorp/hcl/json/parser", "path": "github.com/hashicorp/hcl/json/parser",
"revision": "6f5bfed9a0a22222fbe4e731ae3481730ba41e93", "revision": "8fa153c5b4e9d1ccecda7075821ffc7c1f6d912b",
"revisionTime": "2016-10-08T07:35:57Z" "revisionTime": "2016-10-28T23:32:40Z"
}, },
{ {
"checksumSHA1": "YdvFsNOMSWMLnY6fcliWQa0O5Fw=", "checksumSHA1": "YdvFsNOMSWMLnY6fcliWQa0O5Fw=",
"path": "github.com/hashicorp/hcl/json/scanner", "path": "github.com/hashicorp/hcl/json/scanner",
"revision": "6f5bfed9a0a22222fbe4e731ae3481730ba41e93", "revision": "8fa153c5b4e9d1ccecda7075821ffc7c1f6d912b",
"revisionTime": "2016-10-08T07:35:57Z" "revisionTime": "2016-10-28T23:32:40Z"
}, },
{ {
"checksumSHA1": "fNlXQCQEnb+B3k5UDL/r15xtSJY=", "checksumSHA1": "fNlXQCQEnb+B3k5UDL/r15xtSJY=",
"path": "github.com/hashicorp/hcl/json/token", "path": "github.com/hashicorp/hcl/json/token",
"revision": "6f5bfed9a0a22222fbe4e731ae3481730ba41e93", "revision": "8fa153c5b4e9d1ccecda7075821ffc7c1f6d912b",
"revisionTime": "2016-10-08T07:35:57Z" "revisionTime": "2016-10-28T23:32:40Z"
}, },
{ {
"checksumSHA1": "RYz/9y1RMZfg+oMgEyJIWiSl1dU=", "checksumSHA1": "RYz/9y1RMZfg+oMgEyJIWiSl1dU=",