hcl/token: add Value for IDENT

This commit is contained in:
Mitchell Hashimoto 2015-11-06 18:29:48 -08:00
parent 798e1c6c05
commit 16ce140272
2 changed files with 3 additions and 0 deletions

View File

@ -133,6 +133,8 @@ func (t Token) Value() interface{} {
}
return int64(v)
case IDENT:
return t.Text
case STRING:
// It is wrapped in quotes always
return t.Text[1 : len(t.Text)-1]

View File

@ -47,6 +47,7 @@ func TestTokenValue(t *testing.T) {
{Token{Type: BOOL, Text: `false`}, false},
{Token{Type: FLOAT, Text: `3.14`}, float64(3.14)},
{Token{Type: NUMBER, Text: `42`}, int64(42)},
{Token{Type: IDENT, Text: `foo`}, "foo"},
{Token{Type: STRING, Text: `"foo"`}, "foo"},
}