Skip to content
This repository has been archived by the owner on Jan 5, 2019. It is now read-only.

Commit

Permalink
fix issue 50
Browse files Browse the repository at this point in the history
  • Loading branch information
Ernest Micklei committed Mar 3, 2018
1 parent efd3625 commit 6eb67ab
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions option.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,8 @@ func (l *Literal) parse(p *Parser) error {
type NamedLiteral struct {
*Literal
Name string
// PrintsColon is true when the Name must be printed with a colon suffix
PrintsColon bool
}

// parseAggregate reads options written using aggregate syntax.
Expand Down Expand Up @@ -190,7 +192,15 @@ func parseAggregateConstants(p *Parser, container interface{}) (list []*NamedLit
return
}
key := lit
printsColon := false
// expect colon, aggregate or plain literal
pos, tok, lit = p.next()
if tCOLON == tok {
// consume it
printsColon = true
pos, tok, lit = p.next()
}
// see if nested aggregate is started
if tLEFTCURLY == tok {
nested, fault := parseAggregateConstants(p, container)
if fault != nil {
Expand All @@ -206,15 +216,14 @@ func parseAggregateConstants(p *Parser, container interface{}) (list []*NamedLit
}
continue
}
if tCOLON != tok {
err = p.unexpected(lit, "option aggregate key colon :", container)
return
}
// no aggregate, put back token
p.nextPut(pos, tok, lit)
// now we see plain literal
l := new(Literal)
l.Position = pos
if err = l.parse(p); err != nil {
return
}
list = append(list, &NamedLiteral{Name: key, Literal: l})
list = append(list, &NamedLiteral{Name: key, Literal: l, PrintsColon: printsColon})
}
}

0 comments on commit 6eb67ab

Please sign in to comment.