From e2c26b8e6f814528fee144ef3a80e186b6eb7a70 Mon Sep 17 00:00:00 2001 From: Paul Hinze Date: Tue, 1 Dec 2015 10:22:31 -0600 Subject: [PATCH] support heredoc identifiers with numbers fixes https://github.com/hashicorp/terraform/issues/4079 --- hcl/scanner/scanner.go | 6 +++--- hcl/scanner/scanner_test.go | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/hcl/scanner/scanner.go b/hcl/scanner/scanner.go index 4bc21bd5..c9b40677 100644 --- a/hcl/scanner/scanner.go +++ b/hcl/scanner/scanner.go @@ -389,7 +389,7 @@ func (s *Scanner) scanHeredoc() { // Scan the identifier ch := s.next() - for isLetter(ch) { + for isLetter(ch) || isDigit(ch) { ch = s.next() } @@ -571,12 +571,12 @@ func isLetter(ch rune) bool { return 'a' <= ch && ch <= 'z' || 'A' <= ch && ch <= 'Z' || ch == '_' || ch >= 0x80 && unicode.IsLetter(ch) } -// isHexadecimal returns true if the given rune is a decimal digit +// isDigit returns true if the given rune is a decimal digit func isDigit(ch rune) bool { return '0' <= ch && ch <= '9' || ch >= 0x80 && unicode.IsDigit(ch) } -// isHexadecimal returns true if the given rune is a decimal number +// isDecimal returns true if the given rune is a decimal number func isDecimal(ch rune) bool { return '0' <= ch && ch <= '9' } diff --git a/hcl/scanner/scanner_test.go b/hcl/scanner/scanner_test.go index f5ef8c0a..7c4eb5b8 100644 --- a/hcl/scanner/scanner_test.go +++ b/hcl/scanner/scanner_test.go @@ -73,6 +73,7 @@ var tokenLists = map[string][]tokenPair{ }, "heredoc": []tokenPair{ {token.HEREDOC, "<