Merge pull request #66 from hashicorp/b-heredoc-lists

Support HEREDOCs in lists
This commit is contained in:
James Nugent 2015-11-29 11:28:44 +00:00
commit 8a65681ce2
2 changed files with 10 additions and 1 deletions

View File

@ -264,7 +264,7 @@ func (p *Parser) listType() (*ast.ListType, error) {
for { for {
tok := p.scan() tok := p.scan()
switch tok.Type { switch tok.Type {
case token.NUMBER, token.FLOAT, token.STRING: case token.NUMBER, token.FLOAT, token.STRING, token.HEREDOC:
if needComma { if needComma {
return nil, &PosError{ return nil, &PosError{
Pos: tok.Pos, Pos: tok.Pos,

View File

@ -64,6 +64,15 @@ func TestListType(t *testing.T) {
`foo = ["123", 123]`, `foo = ["123", 123]`,
[]token.Type{token.STRING, token.NUMBER}, []token.Type{token.STRING, token.NUMBER},
}, },
{
`foo = [1,
"string",
<<EOF
heredoc contents
EOF
]`,
[]token.Type{token.NUMBER, token.STRING, token.HEREDOC},
},
} }
for _, l := range literals { for _, l := range literals {