Don't allow two equals for the same key
This commit is contained in:
@@ -192,6 +192,10 @@ func lexRvalue(l *lexer) stateFn {
|
|||||||
for {
|
for {
|
||||||
next := l.peek()
|
next := l.peek()
|
||||||
switch next {
|
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 '[':
|
case '[':
|
||||||
l.depth += 1
|
l.depth += 1
|
||||||
return lexLeftBracket
|
return lexLeftBracket
|
||||||
@@ -234,10 +238,6 @@ func lexRvalue(l *lexer) stateFn {
|
|||||||
return lexNumber
|
return lexNumber
|
||||||
}
|
}
|
||||||
|
|
||||||
if next == '.' {
|
|
||||||
return l.errorf("cannot start float with a dot")
|
|
||||||
}
|
|
||||||
|
|
||||||
if isSpace(next) {
|
if isSpace(next) {
|
||||||
l.ignore()
|
l.ignore()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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) {
|
func TestKeyEqualNumber(t *testing.T) {
|
||||||
testFlow(t, "foo = 42", []token{
|
testFlow(t, "foo = 42", []token{
|
||||||
token{tokenKey, "foo"},
|
token{tokenKey, "foo"},
|
||||||
|
|||||||
Reference in New Issue
Block a user