Don't allow two equals for the same key

This commit is contained in:
Thomas Pelletier
2013-12-10 17:28:16 +01:00
parent 5ffe2e5565
commit e8d5dbf787
2 changed files with 12 additions and 4 deletions
+4 -4
View File
@@ -192,6 +192,10 @@ func lexRvalue(l *lexer) stateFn {
for {
next := l.peek()
switch next {
case '.':
return l.errorf("cannot start float with a dot")
case '=':
return l.errorf("cannot have multiple equals for the same key")
case '[':
l.depth += 1
return lexLeftBracket
@@ -234,10 +238,6 @@ func lexRvalue(l *lexer) stateFn {
return lexNumber
}
if next == '.' {
return l.errorf("cannot start float with a dot")
}
if isSpace(next) {
l.ignore()
}
+8
View File
@@ -284,6 +284,14 @@ func TestFloatWithTwoDots(t *testing.T) {
})
}
func TestDoubleEqualKey(t *testing.T) {
testFlow(t, "foo= = 2", []token{
token{tokenKey, "foo"},
token{tokenEqual, "="},
token{tokenError, "cannot have multiple equals for the same key"},
})
}
func TestKeyEqualNumber(t *testing.T) {
testFlow(t, "foo = 42", []token{
token{tokenKey, "foo"},