promql/parse.go
func (p *parser) primaryExpr() Expr {
	switch t := p.next(); {
	case t.typ == ItemNumber:
		f := p.number(t.val)
		return &NumberLiteral{f}

	case t.typ == ItemString:
		return &StringLiteral{p.unquoteString(t.val)}

	case t.typ == ItemLeftBrace:
		// Metric selector without metric name.
		p.backup()
		return p.VectorSelector("")

	case t.typ == ItemIdentifier:
		// Check for function call.
		if p.peek().typ == ItemLeftParen {
			return p.call(t.val)
		}
		fallthrough // Else metric selector.

	case t.typ == ItemMetricIdentifier:
		return p.VectorSelector(t.val)

	case t.typ.isAggregator():
		p.backup()
		return p.aggrExpr()

	default:
		p.errorf("no valid expression found")
	}
	return nil
}
func (p *parser) primaryExpr() Expr {
	switch t := p.next(); {
	case t.typ == ItemNumber:
		f := p.number(t.val)
		return &NumberLiteral{f}

	case t.typ == ItemString:
		return &StringLiteral{p.unquoteString(t.val)}

	case t.typ == ItemLeftBrace:
		// Metric selector without metric name.
		p.backup()
		return p.VectorSelector("")

	case t.typ == ItemIdentifier:
		// Check for function call.
		if p.peek().typ == ItemLeftParen {
			return p.call(t.val)
		}
		fallthrough // Else metric selector.

	case t.typ == ItemMetricIdentifier:
		return p.VectorSelector(t.val)

	case t.typ.isAggregator():
		p.backup()
		return p.aggrExpr()

	default:
		p.errorf("no valid expression found")
	}
	return nil
}
// primaryExpr parses a primary expression.
//
//		<metric_name> | <function_call> | <Vector_aggregation> | <literal>
//