Skip to content

Commit

Permalink
support heredoc identifiers with numbers
Browse files Browse the repository at this point in the history
  • Loading branch information
phinze committed Dec 1, 2015
1 parent 8a65681 commit e2c26b8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
6 changes: 3 additions & 3 deletions hcl/scanner/scanner.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}

Expand Down Expand Up @@ -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'
}
Expand Down
1 change: 1 addition & 0 deletions hcl/scanner/scanner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ var tokenLists = map[string][]tokenPair{
},
"heredoc": []tokenPair{
{token.HEREDOC, "<<EOF\nhello\nworld\nEOF"},
{token.HEREDOC, "<<EOF123\nhello\nworld\nEOF123"},
},
"string": []tokenPair{
{token.STRING, `" "`},
Expand Down

0 comments on commit e2c26b8

Please sign in to comment.