Search Options

Results per page
Sort
Preferred Languages
Advance

Results 21 - 29 of 29 for KeyValueExpr (0.25 sec)

  1. src/go/parser/resolver.go

    		r.openScope(n.Pos())
    		defer r.closeScope()
    		r.walkFuncType(n)
    
    	case *ast.CompositeLit:
    		if n.Type != nil {
    			ast.Walk(r, n.Type)
    		}
    		for _, e := range n.Elts {
    			if kv, _ := e.(*ast.KeyValueExpr); kv != nil {
    				// See go.dev/issue/45160: try to resolve composite lit keys, but don't
    				// collect them as unresolved if resolution failed. This replicates
    				// existing behavior when resolving during parsing.
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Thu Nov 02 12:56:53 UTC 2023
    - 15.8K bytes
    - Viewed (0)
  2. src/go/doc/example.go

    			// (For an expression like fmt.Println, only add "fmt" to the
    			// set of unresolved names, not "Println".)
    			ast.Inspect(e.X, inspectFunc)
    			return false
    		case *ast.KeyValueExpr:
    			// For key value expressions, only inspect the value
    			// as the key should be resolved by the type of the
    			// composite literal.
    			ast.Inspect(e.Value, inspectFunc)
    			return false
    		}
    		return true
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Thu May 23 01:00:11 UTC 2024
    - 21.4K bytes
    - Viewed (0)
  3. src/cmd/compile/internal/syntax/printer.go

    			p.print(n.X)
    		} else {
    			// binary expr
    			// TODO(gri) eventually take precedence into account
    			// to control possibly missing parentheses
    			p.print(n.X, blank, n.Op, blank, n.Y)
    		}
    
    	case *KeyValueExpr:
    		p.print(n.Key, _Colon, blank, n.Value)
    
    	case *ListExpr:
    		p.printExprList(n.ElemList)
    
    	case *ArrayType:
    		var len interface{} = _DotDotDot
    		if n.Len != nil {
    			len = n.Len
    		}
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Thu Aug 24 07:17:27 UTC 2023
    - 21.5K bytes
    - Viewed (0)
  4. src/go/parser/parser_test.go

    	{name: "maplit", format: "package main; var x = «map[int]any{1:«nil»}»", parseMultiplier: 2},    // Parser nodes: CompositeLit, KeyValueExpr
    	{name: "dot", format: "package main; var x = «x.»x"},
    	{name: "index", format: "package main; var x = x«[1]»"},
    	{name: "slice", format: "package main; var x = x«[1:2]»"},
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Wed Jan 31 20:26:14 UTC 2024
    - 24.6K bytes
    - Viewed (0)
  5. src/go/printer/nodes.go

    		// generated code - simply ignore the size in this case by setting
    		// it to 0).
    		prevSize := size
    		const infinity = 1e6 // larger than any source line
    		size = p.nodeSize(x, infinity)
    		pair, isPair := x.(*ast.KeyValueExpr)
    		if size <= infinity && prev.IsValid() && next.IsValid() {
    			// x fits on a single line
    			if isPair {
    				size = p.nodeSize(pair.Key, infinity) // size <= infinity
    			}
    		} else {
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Tue Oct 17 18:53:17 UTC 2023
    - 52.6K bytes
    - Viewed (0)
  6. src/go/printer/testdata/parser.go

    		return p.parseLiteralValue(nil)
    	}
    
    	x := p.parseExpr(keyOk) // don't resolve if map key
    	if keyOk {
    		if p.tok == token.COLON {
    			colon := p.pos
    			p.next()
    			return &ast.KeyValueExpr{x, colon, p.parseElement(false)}
    		}
    		p.resolve(x) // not a map key
    	}
    
    	return x
    }
    
    func (p *parser) parseElementList() (list []ast.Expr) {
    	if p.trace {
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Thu Jul 20 20:19:51 UTC 2023
    - 50.5K bytes
    - Viewed (0)
  7. src/cmd/compile/internal/syntax/parser.go

    	p.xnest++
    	p.want(_Lbrace)
    	x.Rbrace = p.list("composite literal", _Comma, _Rbrace, func() bool {
    		// value
    		e := p.bare_complitexpr()
    		if p.tok == _Colon {
    			// key ':' value
    			l := new(KeyValueExpr)
    			l.pos = p.pos()
    			p.next()
    			l.Key = e
    			l.Value = p.bare_complitexpr()
    			e = l
    			x.NKeys++
    		}
    		x.ElemList = append(x.ElemList, e)
    		return false
    	})
    	p.xnest--
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Thu May 30 19:19:55 UTC 2024
    - 62.9K bytes
    - Viewed (0)
  8. src/cmd/vendor/golang.org/x/tools/internal/stdlib/manifest.go

    		{"InterfaceType.Interface", Field, 0},
    		{"InterfaceType.Methods", Field, 0},
    		{"IsExported", Func, 0},
    		{"IsGenerated", Func, 21},
    		{"KeyValueExpr", Type, 0},
    		{"KeyValueExpr.Colon", Field, 0},
    		{"KeyValueExpr.Key", Field, 0},
    		{"KeyValueExpr.Value", Field, 0},
    		{"LabeledStmt", Type, 0},
    		{"LabeledStmt.Colon", Field, 0},
    		{"LabeledStmt.Label", Field, 0},
    		{"LabeledStmt.Stmt", Field, 0},
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Tue Apr 02 02:20:05 UTC 2024
    - 534.2K bytes
    - Viewed (0)
  9. src/go/parser/parser.go

    func (p *parser) parseElement() ast.Expr {
    	if p.trace {
    		defer un(trace(p, "Element"))
    	}
    
    	x := p.parseValue()
    	if p.tok == token.COLON {
    		colon := p.pos
    		p.next()
    		x = &ast.KeyValueExpr{Key: x, Colon: colon, Value: p.parseValue()}
    	}
    
    	return x
    }
    
    func (p *parser) parseElementList() (list []ast.Expr) {
    	if p.trace {
    		defer un(trace(p, "ElementList"))
    	}
    
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Fri Dec 08 20:07:50 UTC 2023
    - 72.2K bytes
    - Viewed (0)
Back to top