MCPcopy Create free account
hub / github.com/nsf/gocode / parse_parameter

Method parse_parameter

package_text.go:224–247  ·  view source on GitHub ↗

Parameter = ( identifier | "?" ) [ "..." ] Type [ string_lit ] .

()

Source from the content-addressed store, hash-verified

222
223// Parameter = ( identifier | "?" ) [ "..." ] Type [ string_lit ] .
224func (p *gc_parser) parse_parameter() *ast.Field {
225 // name
226 name, _ := p.parse_name()
227
228 // type
229 var typ ast.Expr
230 if p.tok == '.' {
231 p.expect_special("...")
232 typ = &ast.Ellipsis{Elt: p.parse_type()}
233 } else {
234 typ = p.parse_type()
235 }
236
237 var tag string
238 if p.tok == scanner.String {
239 tag = p.expect(scanner.String)
240 }
241
242 return &ast.Field{
243 Names: []*ast.Ident{ast.NewIdent(name)},
244 Type: typ,
245 Tag: &ast.BasicLit{Kind: token.STRING, Value: tag},
246 }
247}
248
249// Parameters = "(" [ ParameterList ] ")" .
250// ParameterList = { Parameter "," } Parameter .

Callers 1

parse_parametersMethod · 0.95

Calls 4

parse_nameMethod · 0.95
expect_specialMethod · 0.95
parse_typeMethod · 0.95
expectMethod · 0.95

Tested by

no test coverage detected