vendor: Update to lastest hashicorp/hcl

Catches https://github.com/hashicorp/hcl/pull/137
Fixes #7142
This commit is contained in:
Paul Hinze 2016-07-11 12:59:31 -05:00
parent 29c1d36cf4
commit f48ddfb142
No known key found for this signature in database
GPG Key ID: B69DEDF2D55501C0
4 changed files with 81 additions and 35 deletions

View File

@ -81,9 +81,20 @@ FOO
* Boolean values: `true`, `false`
* Arrays can be made by wrapping it in `[]`. Example:
`["foo", "bar", 42]`. Arrays can contain primitives
and other arrays, but cannot contain objects. Objects must
use the block syntax shown below.
`["foo", "bar", 42]`. Arrays can contain primitives,
other arrays, and objects. As an alternative, lists
of objects can be created with repeated blocks, using
this structure:
```hcl
service {
key = "value"
}
service {
key = "value"
}
```
Objects and nested objects are created using the structure shown below:

View File

@ -79,6 +79,13 @@ func (p *Parser) objectList() (*ast.ObjectList, error) {
}
node.Add(n)
// object lists can be optionally comma-delimited e.g. when a list of maps
// is being expressed, so a comma is allowed here - it's simply consumed
tok := p.scan()
if tok.Type != token.COMMA {
p.unscan()
}
}
return node, nil
}
@ -311,15 +318,20 @@ func (p *Parser) listType() (*ast.ListType, error) {
needComma := false
for {
tok := p.scan()
switch tok.Type {
case token.NUMBER, token.FLOAT, token.STRING, token.HEREDOC:
if needComma {
if needComma {
switch tok.Type {
case token.COMMA, token.RBRACK:
default:
return nil, &PosError{
Pos: tok.Pos,
Err: fmt.Errorf("unexpected token: %s. Expecting %s", tok.Type, token.COMMA),
Err: fmt.Errorf(
"error parsing list, expected comma or list end, got: %s",
tok.Type),
}
}
}
switch tok.Type {
case token.NUMBER, token.FLOAT, token.STRING, token.HEREDOC:
node, err := p.literalType()
if err != nil {
return nil, err
@ -343,6 +355,18 @@ func (p *Parser) listType() (*ast.ListType, error) {
needComma = false
continue
case token.LBRACE:
// Looks like a nested object, so parse it out
node, err := p.objectType()
if err != nil {
return nil, &PosError{
Pos: tok.Pos,
Err: fmt.Errorf(
"error while trying to parse object within list: %s", err),
}
}
l.Add(node)
needComma = true
case token.BOOL:
// TODO(arslan) should we support? not supported by HCL yet
case token.LBRACK:

View File

@ -525,16 +525,27 @@ func (s *Scanner) scanEscape() rune {
// scanDigits scans a rune with the given base for n times. For example an
// octal notation \184 would yield in scanDigits(ch, 8, 3)
func (s *Scanner) scanDigits(ch rune, base, n int) rune {
start := n
for n > 0 && digitVal(ch) < base {
ch = s.next()
if ch == eof {
// If we see an EOF, we halt any more scanning of digits
// immediately.
break
}
n--
}
if n > 0 {
s.err("illegal char escape")
}
// we scanned all digits, put the last non digit char back
s.unread()
if n != start {
// we scanned all digits, put the last non digit char back,
// only if we read anything at all
s.unread()
}
return ch
}

50
vendor/vendor.json vendored
View File

@ -826,70 +826,70 @@
"revision": "7e3c02b30806fa5779d3bdfc152ce4c6f40e7b38"
},
{
"checksumSHA1": "SJIgBfV02h1fsqCAe5DHj/JbHoM=",
"checksumSHA1": "ydHBPi04mEh+Tir+2JkpSIMckcw=",
"path": "github.com/hashicorp/hcl",
"revision": "61f5143284c041681f76a5b63efcb232aaa94737",
"revisionTime": "2016-06-24T12:12:30Z"
"revision": "364df430845abef160a0bfb3a59979f746bf4956",
"revisionTime": "2016-07-08T14:13:38Z"
},
{
"checksumSHA1": "IxyvRpCFeoJBGl2obLKJV7RCGjg=",
"path": "github.com/hashicorp/hcl/hcl/ast",
"revision": "61f5143284c041681f76a5b63efcb232aaa94737",
"revisionTime": "2016-06-24T12:12:30Z"
"revision": "364df430845abef160a0bfb3a59979f746bf4956",
"revisionTime": "2016-07-08T14:13:38Z"
},
{
"checksumSHA1": "5HVecyfmcTm6OTffEi6LGayQf5M=",
"path": "github.com/hashicorp/hcl/hcl/fmtcmd",
"revision": "61f5143284c041681f76a5b63efcb232aaa94737",
"revisionTime": "2016-06-24T12:12:30Z"
"revision": "364df430845abef160a0bfb3a59979f746bf4956",
"revisionTime": "2016-07-08T14:13:38Z"
},
{
"checksumSHA1": "cO89nXP9rKQCcm0zKGbtBCWK2ok=",
"checksumSHA1": "l2oQxBsZRwn6eZjf+whXr8c9+8c=",
"path": "github.com/hashicorp/hcl/hcl/parser",
"revision": "61f5143284c041681f76a5b63efcb232aaa94737",
"revisionTime": "2016-06-24T12:12:30Z"
"revision": "364df430845abef160a0bfb3a59979f746bf4956",
"revisionTime": "2016-07-08T14:13:38Z"
},
{
"checksumSHA1": "CSmwxPOTz7GSpnWPF9aGkbVeR64=",
"path": "github.com/hashicorp/hcl/hcl/printer",
"revision": "61f5143284c041681f76a5b63efcb232aaa94737",
"revisionTime": "2016-06-24T12:12:30Z"
"revision": "364df430845abef160a0bfb3a59979f746bf4956",
"revisionTime": "2016-07-08T14:13:38Z"
},
{
"checksumSHA1": "WZM0q7Sya8PcGj607x1npgcEPa4=",
"checksumSHA1": "FHZ1IXjWHUyuMjy/wQChE4pSoPg=",
"path": "github.com/hashicorp/hcl/hcl/scanner",
"revision": "61f5143284c041681f76a5b63efcb232aaa94737",
"revisionTime": "2016-06-24T12:12:30Z"
"revision": "364df430845abef160a0bfb3a59979f746bf4956",
"revisionTime": "2016-07-08T14:13:38Z"
},
{
"checksumSHA1": "riN5acfVDm4j6LhWXauqiWH5n84=",
"path": "github.com/hashicorp/hcl/hcl/strconv",
"revision": "61f5143284c041681f76a5b63efcb232aaa94737",
"revisionTime": "2016-06-24T12:12:30Z"
"revision": "364df430845abef160a0bfb3a59979f746bf4956",
"revisionTime": "2016-07-08T14:13:38Z"
},
{
"checksumSHA1": "c6yprzj06ASwCo18TtbbNNBHljA=",
"path": "github.com/hashicorp/hcl/hcl/token",
"revision": "61f5143284c041681f76a5b63efcb232aaa94737",
"revisionTime": "2016-06-24T12:12:30Z"
"revision": "364df430845abef160a0bfb3a59979f746bf4956",
"revisionTime": "2016-07-08T14:13:38Z"
},
{
"checksumSHA1": "jQ45CCc1ed/nlV7bbSnx6z72q1M=",
"path": "github.com/hashicorp/hcl/json/parser",
"revision": "61f5143284c041681f76a5b63efcb232aaa94737",
"revisionTime": "2016-06-24T12:12:30Z"
"revision": "364df430845abef160a0bfb3a59979f746bf4956",
"revisionTime": "2016-07-08T14:13:38Z"
},
{
"checksumSHA1": "S1e0F9ZKSnqgOLfjDTYazRL28tA=",
"path": "github.com/hashicorp/hcl/json/scanner",
"revision": "61f5143284c041681f76a5b63efcb232aaa94737",
"revisionTime": "2016-06-24T12:12:30Z"
"revision": "364df430845abef160a0bfb3a59979f746bf4956",
"revisionTime": "2016-07-08T14:13:38Z"
},
{
"checksumSHA1": "fNlXQCQEnb+B3k5UDL/r15xtSJY=",
"path": "github.com/hashicorp/hcl/json/token",
"revision": "61f5143284c041681f76a5b63efcb232aaa94737",
"revisionTime": "2016-06-24T12:12:30Z"
"revision": "364df430845abef160a0bfb3a59979f746bf4956",
"revisionTime": "2016-07-08T14:13:38Z"
},
{
"checksumSHA1": "vWW3HXm7OTOMISuZPcCSJODRYkU=",