Handle non-alpha chars in keys
diff --git a/lexer.go b/lexer.go index 91f93c9..5efbf6b 100644 --- a/lexer.go +++ b/lexer.go
@@ -68,7 +68,9 @@ } func isKeyChar(r rune) bool { - return isAlphanumeric(r) || r == '-' + // "Keys start with the first non-whitespace character and end with the last + // non-whitespace character before the equals sign." + return !(isSpace(r) || r == '\n' || r == eof || r == '=') } func isDigit(r rune) bool {
diff --git a/lexer_test.go b/lexer_test.go index 1d7e37b..6436378 100644 --- a/lexer_test.go +++ b/lexer_test.go
@@ -113,6 +113,15 @@ }) } +func TestKeyWithSharpAndEqual(t *testing.T) { + testFlow(t, "key#name = 5", []token{ + token{tokenKey, "key#name"}, + token{tokenEqual, "="}, + token{tokenInteger, "5"}, + token{tokenEOF, ""}, + }) +} + func TestKeyEqualStringEscape(t *testing.T) { testFlow(t, "foo = \"hello\\\"\"", []token{ token{tokenKey, "foo"},