Merge pull request #70 from hashicorp/phinze/heredoc-ids-with-numbers

support heredoc identifiers with numbers
This commit is contained in:
James Nugent 2015-12-01 12:13:28 -05:00
commit cc4142e424
2 changed files with 4 additions and 3 deletions

View File

@ -389,7 +389,7 @@ func (s *Scanner) scanHeredoc() {
// Scan the identifier // Scan the identifier
ch := s.next() ch := s.next()
for isLetter(ch) { for isLetter(ch) || isDigit(ch) {
ch = s.next() 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) 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 { func isDigit(ch rune) bool {
return '0' <= ch && ch <= '9' || ch >= 0x80 && unicode.IsDigit(ch) 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 { func isDecimal(ch rune) bool {
return '0' <= ch && ch <= '9' return '0' <= ch && ch <= '9'
} }

View File

@ -73,6 +73,7 @@ var tokenLists = map[string][]tokenPair{
}, },
"heredoc": []tokenPair{ "heredoc": []tokenPair{
{token.HEREDOC, "<<EOF\nhello\nworld\nEOF"}, {token.HEREDOC, "<<EOF\nhello\nworld\nEOF"},
{token.HEREDOC, "<<EOF123\nhello\nworld\nEOF123"},
}, },
"string": []tokenPair{ "string": []tokenPair{
{token.STRING, `" "`}, {token.STRING, `" "`},