Merge pull request #185 from hashicorp/f-list-of-lists
hcl/parser: parse list of lists
This commit is contained in:
commit
88e9565e99
@ -207,6 +207,16 @@ func TestDecode_interface(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"list_of_lists.hcl",
|
||||||
|
false,
|
||||||
|
map[string]interface{}{
|
||||||
|
"foo": []interface{}{
|
||||||
|
[]interface{}{"foo"},
|
||||||
|
[]interface{}{"bar"},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"list_of_maps.hcl",
|
"list_of_maps.hcl",
|
||||||
false,
|
false,
|
||||||
|
@ -389,9 +389,15 @@ func (p *Parser) listType() (*ast.ListType, error) {
|
|||||||
l.Add(node)
|
l.Add(node)
|
||||||
needComma = true
|
needComma = true
|
||||||
case token.LBRACK:
|
case token.LBRACK:
|
||||||
// TODO(arslan) should we support nested lists? Even though it's
|
node, err := p.listType()
|
||||||
// written in README of HCL, it's not a part of the grammar
|
if err != nil {
|
||||||
// (not defined in parse.y)
|
return nil, &PosError{
|
||||||
|
Pos: tok.Pos,
|
||||||
|
Err: fmt.Errorf(
|
||||||
|
"error while trying to parse list within list: %s", err),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
l.Add(node)
|
||||||
case token.RBRACK:
|
case token.RBRACK:
|
||||||
// finished
|
// finished
|
||||||
l.Rbrack = p.tok.Pos
|
l.Rbrack = p.tok.Pos
|
||||||
|
2
test-fixtures/list_of_lists.hcl
Normal file
2
test-fixtures/list_of_lists.hcl
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
foo = [["foo"], ["bar"]]
|
||||||
|
|
Loading…
Reference in New Issue
Block a user