Don't allow two equals for the same key
diff --git a/lexer.go b/lexer.go index 0ad27a2..679bb4d 100644 --- a/lexer.go +++ b/lexer.go
@@ -192,6 +192,10 @@ 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 @@ return lexNumber } - if next == '.' { - return l.errorf("cannot start float with a dot") - } - if isSpace(next) { l.ignore() }
diff --git a/lexer_test.go b/lexer_test.go index c2bb2f2..e3b5daf 100644 --- a/lexer_test.go +++ b/lexer_test.go
@@ -284,6 +284,14 @@ }) } +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"},