MCPcopy Create free account
hub / github.com/brimdata/super / matchDecorator

Method matchDecorator

sup/parser-values.go:107–122  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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.
107func (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
124func (p *Parser) parseDecorator(any ast.Any, val ast.Value) (ast.Value, error) {
125 l := p.lexer

Callers 1

decorateMethod · 0.95

Calls 4

parseDecoratorMethod · 0.95
peek3Method · 0.80
noEOFFunction · 0.70
skipMethod · 0.45

Tested by

no test coverage detected