stateFns lexPatterns reads and emits consecutive file patterns. Strings can be interspersed with comments.
(l *lexer)
| 325 | // lexPatterns reads and emits consecutive file patterns. Strings can be |
| 326 | // interspersed with comments. |
| 327 | func lexPatterns(l *lexer) stateFn { |
| 328 | for { |
| 329 | n := l.eatSpaceAndComments() |
| 330 | if n == eof { |
| 331 | l.emit(itemEOF) |
| 332 | return nil |
| 333 | } else if n == '!' { |
| 334 | pk := l.next() |
| 335 | if any(pk, quotes) { |
| 336 | err := l.acceptQuotedString(pk) |
| 337 | if err != nil { |
| 338 | l.errorf("%s", err) |
| 339 | return nil |
| 340 | } |
| 341 | l.emit(itemQuotedString) |
| 342 | } else if !any(pk, bareStringDisallowed) { |
| 343 | l.acceptBareString() |
| 344 | l.emit(itemBareString) |
| 345 | } else { |
| 346 | l.errorf("! must be followed by a string") |
| 347 | return nil |
| 348 | } |
| 349 | } else if any(n, quotes) { |
| 350 | err := l.acceptQuotedString(n) |
| 351 | if err != nil { |
| 352 | l.errorf("%s", err) |
| 353 | return nil |
| 354 | } |
| 355 | l.emit(itemQuotedString) |
| 356 | } else if !any(n, bareStringDisallowed) { |
| 357 | l.acceptBareString() |
| 358 | l.emit(itemBareString) |
| 359 | } else { |
| 360 | l.backup() |
| 361 | return lexBlockStart |
| 362 | } |
| 363 | } |
| 364 | } |
| 365 | |
| 366 | // lexVariables reads a block of variable declarations. |
| 367 | func lexVariables(l *lexer) stateFn { |
nothing calls this directly
no test coverage detected