From d10c170409219fdf6d2105ee4778944ae7db620d Mon Sep 17 00:00:00 2001 From: Derek Collison Date: Mon, 25 Mar 2013 19:05:13 -0700 Subject: [PATCH] Assure semi-colon chaining on same line works --- conf/lex.go | 7 ++----- conf/lex_test.go | 15 +++++++++++++++ 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/conf/lex.go b/conf/lex.go index 6290826f..2308ea22 100644 --- a/conf/lex.go +++ b/conf/lex.go @@ -236,12 +236,9 @@ func lexTopValueEnd(lx *lexer) stateFn { } lx.backup() fallthrough - case isWhitespace(r) || r == optValTerm: + case isWhitespace(r): return lexTopValueEnd - case isNL(r): - lx.ignore() - return lexTop - case r == eof: + case isNL(r) || r == eof || r == optValTerm: lx.ignore() return lexTop } diff --git a/conf/lex_test.go b/conf/lex_test.go index ad1b4701..2ae21bb0 100644 --- a/conf/lex_test.go +++ b/conf/lex_test.go @@ -332,6 +332,21 @@ func TestOptionalSemicolons(t *testing.T) { expect(t, lx, expectedItems) } +func TestSemicolonChaining(t *testing.T) { + expectedItems := []item{ + {itemKey, "foo", 1}, + {itemString, "1", 1}, + {itemKey, "bar", 1}, + {itemFloat, "2.2", 1}, + {itemKey, "baz", 1}, + {itemBool, "true", 1}, + {itemEOF, "", 1}, + } + + lx := lex("foo='1'; bar=2.2; baz=true;") + expect(t, lx, expectedItems) +} +