Handle non-alpha chars in keys
This commit is contained in:
@@ -68,7 +68,9 @@ func isAlphanumeric(r rune) bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func isKeyChar(r rune) bool {
|
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 {
|
func isDigit(r rune) bool {
|
||||||
|
|||||||
@@ -113,6 +113,15 @@ func TestBasicKeyAndEqual(t *testing.T) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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) {
|
func TestKeyEqualStringEscape(t *testing.T) {
|
||||||
testFlow(t, "foo = \"hello\\\"\"", []token{
|
testFlow(t, "foo = \"hello\\\"\"", []token{
|
||||||
token{tokenKey, "foo"},
|
token{tokenKey, "foo"},
|
||||||
|
|||||||
Reference in New Issue
Block a user