First pass at multi-user support

This commit is contained in:
Derek Collison
2016-05-13 12:27:57 -07:00
parent 01b635cc8f
commit 46a9e6f0bc
9 changed files with 160 additions and 11 deletions

View File

@@ -610,7 +610,7 @@ func lexString(lx *lexer) stateFn {
return lexStringEscape
// Termination of non-quoted strings
case isNL(r) || r == eof || r == optValTerm ||
r == arrayValTerm || r == arrayEnd ||
r == arrayValTerm || r == arrayEnd || r == mapEnd ||
isWhitespace(r):
lx.backup()

View File

@@ -698,3 +698,41 @@ func TestUnquotedIPAddr(t *testing.T) {
lx = lex("listen = [localhost:4222, localhost:4333]")
expect(t, lx, expectedItems)
}
var arrayOfMaps = `
authorization {
users = [
{user: alice, password: foo}
{user: bob, password: bar}
]
timeout: 0.5
}
`
func TestArrayOfMaps(t *testing.T) {
expectedItems := []item{
{itemKey, "authorization", 2},
{itemMapStart, "", 2},
{itemKey, "users", 3},
{itemArrayStart, "", 3},
{itemMapStart, "", 4},
{itemKey, "user", 4},
{itemString, "alice", 4},
{itemKey, "password", 4},
{itemString, "foo", 4},
{itemMapEnd, "", 4},
{itemMapStart, "", 5},
{itemKey, "user", 5},
{itemString, "bob", 5},
{itemKey, "password", 5},
{itemString, "bar", 5},
{itemMapEnd, "", 5},
{itemArrayEnd, "", 6},
{itemKey, "timeout", 7},
{itemFloat, "0.5", 7},
{itemMapEnd, "", 8},
{itemEOF, "", 9},
}
lx := lex(arrayOfMaps)
expect(t, lx, expectedItems)
}