@@ -139,7 +139,7 @@ func (p *Parser) parse() (labels.Matchers, error) {
139
139
type parseFn func (l * Lexer ) (parseFn , error )
140
140
141
141
func (p * Parser ) parseOpenParen (l * Lexer ) (parseFn , error ) {
142
- // Can start with an optional open brace
142
+ // Can start with an optional open brace.
143
143
hasOpenParen , err := p .accept (l .Peek , TokenOpenBrace )
144
144
if err != nil {
145
145
if errors .Is (err , ErrEOF ) {
@@ -149,14 +149,14 @@ func (p *Parser) parseOpenParen(l *Lexer) (parseFn, error) {
149
149
}
150
150
if hasOpenParen {
151
151
// If the token was an open brace it must be scanned so the token
152
- // following it can be peeked
152
+ // following it can be peeked.
153
153
if _ , err = l .Scan (); err != nil {
154
154
panic ("Unexpected error scanning open brace" )
155
155
}
156
156
}
157
157
p .hasOpenParen = hasOpenParen
158
158
// If the next token is a close brace there are no matchers in the input
159
- // and we can just parse the close brace
159
+ // and we can just parse the close brace.
160
160
if hasCloseParen , err := p .accept (l .Peek , TokenCloseBrace ); err != nil {
161
161
return nil , fmt .Errorf ("%s: %w" , err , ErrNoCloseBrace )
162
162
} else if hasCloseParen {
@@ -167,12 +167,12 @@ func (p *Parser) parseOpenParen(l *Lexer) (parseFn, error) {
167
167
168
168
func (p * Parser ) parseCloseParen (l * Lexer ) (parseFn , error ) {
169
169
if p .hasOpenParen {
170
- // If there was an open brace there must be a matching close brace
170
+ // If there was an open brace there must be a matching close brace.
171
171
if _ , err := p .expect (l .Scan , TokenCloseBrace ); err != nil {
172
172
return nil , fmt .Errorf ("%s: %w" , err , ErrNoCloseBrace )
173
173
}
174
174
} else {
175
- // If there was no open brace there must not be a close brace either
175
+ // If there was no open brace there must not be a close brace either.
176
176
if _ , err := p .expect (l .Peek , TokenCloseBrace ); err == nil {
177
177
return nil , fmt .Errorf ("0:%d: }: %w" , len (p .input ), ErrNoOpenBrace )
178
178
}
@@ -185,7 +185,7 @@ func (p *Parser) parseComma(l *Lexer) (parseFn, error) {
185
185
return nil , fmt .Errorf ("%s: %s" , err , "expected a comma" )
186
186
}
187
187
// The token after the comma can be another matcher, a close brace or the
188
- // end of input
188
+ // end of input.
189
189
tok , err := p .expect (l .Peek , TokenCloseBrace , TokenIdent , TokenQuoted )
190
190
if err != nil {
191
191
if errors .Is (err , ErrEOF ) {
@@ -219,13 +219,13 @@ func (p *Parser) parseLabelMatcher(l *Lexer) (parseFn, error) {
219
219
220
220
// The next token is the label name. This can either be an ident which
221
221
// accepts just [a-zA-Z_] or a quoted which accepts all UTF-8 characters
222
- // in double quotes
222
+ // in double quotes.
223
223
if tok , err = p .expect (l .Scan , TokenIdent , TokenQuoted ); err != nil {
224
224
return nil , fmt .Errorf ("%s: %w" , err , ErrNoLabelName )
225
225
}
226
226
labelName = tok .Value
227
227
228
- // The next token is the operator such as '=', '!=', '=~' and '!~'
228
+ // The next token is the operator such as '=', '!=', '=~' and '!~'.
229
229
if tok , err = p .expect (l .Scan , TokenOperator ); err != nil {
230
230
return nil , fmt .Errorf ("%s: %s" , err , ErrNoOperator )
231
231
}
@@ -235,7 +235,7 @@ func (p *Parser) parseLabelMatcher(l *Lexer) (parseFn, error) {
235
235
236
236
// The next token is the label value. This too can either be an ident
237
237
// which accepts just [a-zA-Z_] or a quoted which accepts all UTF-8
238
- // characters in double quotes
238
+ // characters in double quotes.
239
239
if tok , err = p .expect (l .Scan , TokenIdent , TokenQuoted ); err != nil {
240
240
return nil , fmt .Errorf ("%s: %s" , err , ErrNoLabelValue )
241
241
}
@@ -261,7 +261,7 @@ func (p *Parser) parseLabelMatcherEnd(l *Lexer) (parseFn, error) {
261
261
tok , err := p .expect (l .Peek , TokenComma , TokenCloseBrace )
262
262
if err != nil {
263
263
// If this is the end of input we still need to check if the optional
264
- // open brace has a matching close brace
264
+ // open brace has a matching close brace.
265
265
if errors .Is (err , ErrEOF ) {
266
266
return p .parseCloseParen , nil
267
267
}
0 commit comments