From f48ddfb1424e5de029416977d0bd0201d1704e4a Mon Sep 17 00:00:00 2001 From: Paul Hinze Date: Mon, 11 Jul 2016 12:59:31 -0500 Subject: [PATCH] vendor: Update to lastest hashicorp/hcl Catches https://github.com/hashicorp/hcl/pull/137 Fixes #7142 --- vendor/github.com/hashicorp/hcl/README.md | 17 +++++-- .../hashicorp/hcl/hcl/parser/parser.go | 34 +++++++++++-- .../hashicorp/hcl/hcl/scanner/scanner.go | 15 +++++- vendor/vendor.json | 50 +++++++++---------- 4 files changed, 81 insertions(+), 35 deletions(-) diff --git a/vendor/github.com/hashicorp/hcl/README.md b/vendor/github.com/hashicorp/hcl/README.md index 3d5b8bd92..e292d5999 100644 --- a/vendor/github.com/hashicorp/hcl/README.md +++ b/vendor/github.com/hashicorp/hcl/README.md @@ -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: diff --git a/vendor/github.com/hashicorp/hcl/hcl/parser/parser.go b/vendor/github.com/hashicorp/hcl/hcl/parser/parser.go index 37a72acbc..f46ed4cc0 100644 --- a/vendor/github.com/hashicorp/hcl/hcl/parser/parser.go +++ b/vendor/github.com/hashicorp/hcl/hcl/parser/parser.go @@ -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: diff --git a/vendor/github.com/hashicorp/hcl/hcl/scanner/scanner.go b/vendor/github.com/hashicorp/hcl/hcl/scanner/scanner.go index a3f34a7b5..174119a8d 100644 --- a/vendor/github.com/hashicorp/hcl/hcl/scanner/scanner.go +++ b/vendor/github.com/hashicorp/hcl/hcl/scanner/scanner.go @@ -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 } diff --git a/vendor/vendor.json b/vendor/vendor.json index 205d5b5a1..25225b8be 100644 --- a/vendor/vendor.json +++ b/vendor/vendor.json @@ -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=",