hcl/scanner: allow hyphens in idents

This commit is contained in:
Mitchell Hashimoto 2015-11-06 17:56:57 -08:00
parent 22bdcc2db1
commit 798e1c6c05
2 changed files with 2 additions and 1 deletions

View File

@ -454,7 +454,7 @@ func (s *Scanner) scanDigits(ch rune, base, n int) rune {
func (s *Scanner) scanIdentifier() string {
offs := s.srcPos.Offset - s.lastCharLen
ch := s.next()
for isLetter(ch) || isDigit(ch) {
for isLetter(ch) || isDigit(ch) || ch == '-' {
ch = s.next()
}

View File

@ -56,6 +56,7 @@ var tokenLists = map[string][]tokenPair{
{token.IDENT, "a"},
{token.IDENT, "a0"},
{token.IDENT, "foobar"},
{token.IDENT, "foo-bar"},
{token.IDENT, "abc123"},
{token.IDENT, "LGTM"},
{token.IDENT, "_"},