We pass both any and val in here to avoid having to backtrack. If we had proper backtracking, this would look a little more sensible.
(any ast.Any, val ast.Value)
| 105 | // We pass both any and val in here to avoid having to backtrack. |
| 106 | // If we had proper backtracking, this would look a little more sensible. |
| 107 | func (p *Parser) matchDecorator(any ast.Any, val ast.Value) (ast.Value, bool, error) { |
| 108 | l := p.lexer |
| 109 | // If there isn't a decorator, just return. A decorator cannot start |
| 110 | // with ":::" so we check this condition which arises when an IP6 address or net |
| 111 | // with a "::" prefix follows a map key (and so we are checking for a decorator |
| 112 | // here after the key value but before the key colon). |
| 113 | if lookahead, err := l.peek3(); err != nil || lookahead == "" || lookahead[:2] != "::" || lookahead == ":::" { |
| 114 | return nil, false, err |
| 115 | } |
| 116 | l.skip(2) |
| 117 | val, err := p.parseDecorator(any, val) |
| 118 | if noEOF(err) != nil { |
| 119 | return nil, false, err |
| 120 | } |
| 121 | return val, true, nil |
| 122 | } |
| 123 | |
| 124 | func (p *Parser) parseDecorator(any ast.Any, val ast.Value) (ast.Value, error) { |
| 125 | l := p.lexer |
no test coverage detected