| 27 | } |
| 28 | |
| 29 | func (p *Parser) Parse() (map[string]string, error) { |
| 30 | result := make(map[string]string) |
| 31 | lastProp := "" |
| 32 | for { |
| 33 | p.skipWhitespace() |
| 34 | if p.eof() { |
| 35 | break |
| 36 | } |
| 37 | propName, err := p.parseIdentifierColon(lastProp) |
| 38 | if err != nil { |
| 39 | return nil, err |
| 40 | } |
| 41 | lastProp = propName |
| 42 | p.skipWhitespace() |
| 43 | value, err := p.parseValue(propName) |
| 44 | if err != nil { |
| 45 | return nil, err |
| 46 | } |
| 47 | result[propName] = value |
| 48 | p.skipWhitespace() |
| 49 | if p.eof() { |
| 50 | break |
| 51 | } |
| 52 | if !p.expectChar(';') { |
| 53 | break |
| 54 | } |
| 55 | } |
| 56 | p.skipWhitespace() |
| 57 | if !p.eof() { |
| 58 | return nil, fmt.Errorf("bad style attribute, unexpected character %q at pos %d", string(p.Input[p.Pos]), p.Pos+1) |
| 59 | } |
| 60 | return result, nil |
| 61 | } |
| 62 | |
| 63 | func (p *Parser) parseIdentifierColon(lastProp string) (string, error) { |
| 64 | start := p.Pos |