(any ast.Any, err error)
| 76 | } |
| 77 | |
| 78 | func (p *Parser) decorate(any ast.Any, err error) (ast.Value, error) { |
| 79 | if err != nil { |
| 80 | return nil, err |
| 81 | } |
| 82 | // See if there's a first decorator. |
| 83 | val, ok, err := p.matchDecorator(any, nil) |
| 84 | if err != nil { |
| 85 | return nil, err |
| 86 | } |
| 87 | if !ok { |
| 88 | // No decorator. Just return the input value. |
| 89 | return anyAsValue(any), nil |
| 90 | } |
| 91 | // Now see if there are additional decorators to apply as casts and |
| 92 | // return value chain, wrapped if at all, as an ast.Value. |
| 93 | for { |
| 94 | outer, ok, err := p.matchDecorator(nil, val) |
| 95 | if err != nil { |
| 96 | return nil, err |
| 97 | } |
| 98 | if !ok { |
| 99 | return val, nil |
| 100 | } |
| 101 | val = outer |
| 102 | } |
| 103 | } |
| 104 | |
| 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. |
no test coverage detected