func (p *parser) VectorSelector(name string) *VectorSelector {
	var matchers []*labels.Matcher
	// Parse label matching if any.
	if t := p.peek(); t.typ == ItemLeftBrace {
		matchers = p.labelMatchers(ItemEQL, ItemNEQ, ItemEQLRegex, ItemNEQRegex)
	}
	// Metric name must not be set in the label matchers and before at the same time.
	if name != "" {
		for _, m := range matchers {
			if m.Name == labels.MetricName {
				p.errorf("metric name must not be set twice: %q or %q", name, m.Value)
			}
		}
		// Set name label matching.
		m, err := labels.NewMatcher(labels.MatchEqual, labels.MetricName, name)
		if err != nil {
			panic(err) // Must not happen with metric.Equal.
		}
		matchers = append(matchers, m)
	}

	if len(matchers) == 0 {
		p.errorf("vector selector must contain label matchers or metric name")
	}
	// A Vector selector must contain at least one non-empty matcher to prevent
	// implicit selection of all metrics (e.g. by a typo).
	notEmpty := false
	for _, lm := range matchers {
		if !lm.Matches("") {
			notEmpty = true
			break
		}
	}
	if !notEmpty {
		p.errorf("vector selector must contain at least one non-empty matcher")
	}

	return &VectorSelector{
		Name:          name,
		LabelMatchers: matchers,
	}
}
func (p *parser) VectorSelector(name string) *VectorSelector {
	var matchers []*labels.Matcher
	
	if t := p.peek(); t.typ == ItemLeftBrace {
		matchers = p.labelMatchers(ItemEQL, ItemNEQ, ItemEQLRegex, ItemNEQRegex)
	}
	
	if name != "" {
		for _, m := range matchers {
			if m.Name == labels.MetricName {
				p.errorf("metric name must not be set twice: %q or %q", name, m.Value)
			}
		}
		
		m, err := labels.NewMatcher(labels.MatchEqual, labels.MetricName, name)
		if err != nil {
			panic(err) 
		}
		matchers = append(matchers, m)
	}

	if len(matchers) == 0 {
		p.errorf("vector selector must contain label matchers or metric name")
	}
	
	
	notEmpty := false
	for _, lm := range matchers {
		if !lm.Matches("") {
			notEmpty = true
			break
		}
	}
	if !notEmpty {
		p.errorf("vector selector must contain at least one non-empty matcher")
	}

	return &VectorSelector{
		Name:          name,
		LabelMatchers: matchers,
	}
}
func ( p * parser ) VectorSelector ( name string ) * VectorSelector { var matchers [ ] * labels . Matcher // Parse label matching if any. if t := p . peek ( ) ; t . typ == ItemLeftBrace { matchers = p . labelMatchers ( ItemEQL , ItemNEQ , ItemEQLRegex , ItemNEQRegex ) } // Metric name must not be set in the label matchers and before at the same time. if name != " " { for _ , m := range matchers { if m . Name == labels . MetricName { p . errorf ( " " , name , m . Value ) } } // Set name label matching. m , err := labels . NewMatcher ( labels . MatchEqual , labels . MetricName , name ) if err != nil { panic ( err ) // Must not happen with metric.Equal. } matchers = append ( matchers , m ) } if len ( matchers ) == 0 { p . errorf ( " " ) } // A Vector selector must contain at least one non-empty matcher to prevent // implicit selection of all metrics (e.g. by a typo). notEmpty := false for _ , lm := range matchers { if ! lm . Matches ( " " ) { notEmpty = true break } } if ! notEmpty { p . errorf ( " " ) } return & VectorSelector { Name : name , LabelMatchers : matchers , } }
// VectorSelector parses a new (instant) vector selector.
//
//		<metric_identifier> [<label_matchers>]
//		[<metric_identifier>] <label_matchers>
//
VectorSelector parses a new ( instant ) vector selector . <metric_identifier > [ <label_matchers > ] [ <metric_identifier > ] <label_matchers >