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

Method parseDecorator

sup/parser-values.go:124–160  ·  view source on GitHub ↗
(any ast.Any, val ast.Value)

Source from the content-addressed store, hash-verified

122}
123
124func (p *Parser) parseDecorator(any ast.Any, val ast.Value) (ast.Value, error) {
125 l := p.lexer
126 // We can have either:
127 // Case 1: =<name>
128 // Case 2: <type-component> (unions and typedefs with unions must have parens)
129 ok, err := l.match('=')
130 if err != nil {
131 return nil, err
132 }
133 if ok {
134 name, err := l.scanTypeName()
135 if name == "" || err != nil {
136 return nil, p.error("bad short-form type definition")
137 }
138 return &ast.DefValue{
139 Kind: "DefValue",
140 Of: any,
141 TypeName: name,
142 }, nil
143 }
144 typ, err := p.matchTypeComponent()
145 if err != nil {
146 return nil, err
147 }
148 if any != nil {
149 return &ast.CastValue{
150 Kind: "CastValue",
151 Of: anyAsValue(any),
152 Type: typ,
153 }, nil
154 }
155 return &ast.CastValue{
156 Kind: "CastValue",
157 Of: val,
158 Type: typ,
159 }, nil
160}
161
162func (p *Parser) matchPrimitive() (*ast.Primitive, error) {
163 if val, err := p.matchStringPrimitive(); val != nil || err != nil {

Callers 1

matchDecoratorMethod · 0.95

Calls 5

errorMethod · 0.95
matchTypeComponentMethod · 0.95
anyAsValueFunction · 0.85
scanTypeNameMethod · 0.80
matchMethod · 0.45

Tested by

no test coverage detected