From ca96c7fd5c43b99873a67eb239176bd7a9e762f0 Mon Sep 17 00:00:00 2001 From: Silvan Jegen Date: Wed, 28 Dec 2016 20:07:57 +0100 Subject: Finish parsing of keyvalues --- conf/parser.go | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'conf') diff --git a/conf/parser.go b/conf/parser.go index 26784f4..cc85054 100644 --- a/conf/parser.go +++ b/conf/parser.go @@ -127,9 +127,21 @@ func (p *parser) keyvalue() bool { } p.advanceOneToken("keyvalue") - if p.cur.Type != Literal || p.cur.Type != Literal { + if p.cur.Type != Literal && p.cur.Type != Name { fmt.Fprintf(os.Stderr, "error when parsing keyvalue. Was expecting a literal or a name but got %q at line %d offset %d.\n", p.cur.Lit, p.cur.LineNr, p.cur.Offset) } - return false + tok, err := p.s.Peek() + if err != nil { + fmt.Fprintf(os.Stderr, "error when parsing keyvalue. Got an error when checking if there are more keyvalues: %v.\n", err) + return false + } + + fmt.Fprintf(os.Stderr, "peeked %q (type %d) at line %d offset %d.\n", tok.Lit, tok.Type, tok.LineNr, tok.Offset) + if tok.Type == ObjectDelimiter { + p.advanceOneToken("keyvaluelast") + return false + } + + return true } -- cgit v1.2.3