lexVariables reads a block of variable declarations.
(l *lexer)
| 365 | |
| 366 | // lexVariables reads a block of variable declarations. |
| 367 | func lexVariables(l *lexer) stateFn { |
| 368 | for { |
| 369 | n := l.eatSpaceAndComments() |
| 370 | if n == '@' { |
| 371 | l.acceptWord() |
| 372 | l.emit(itemVarName) |
| 373 | n = l.maybeSpace() |
| 374 | if n == '=' { |
| 375 | l.emit(itemEquals) |
| 376 | } |
| 377 | n = l.maybeSpace() |
| 378 | if n == eof { |
| 379 | l.errorf("unterminated variable assignment") |
| 380 | return nil |
| 381 | } else if any(n, quotes) { |
| 382 | err := l.acceptQuotedString(n) |
| 383 | if err != nil { |
| 384 | l.errorf("%s", err) |
| 385 | return nil |
| 386 | } |
| 387 | l.emit(itemQuotedString) |
| 388 | } else if !any(n, bareStringDisallowed) { |
| 389 | l.acceptLine(true) |
| 390 | l.emit(itemBareString) |
| 391 | } else { |
| 392 | l.errorf("= must be followed by a string") |
| 393 | return nil |
| 394 | } |
| 395 | } else { |
| 396 | l.backup() |
| 397 | return lexPatterns |
| 398 | } |
| 399 | } |
| 400 | } |
| 401 | |
| 402 | func lexTop(l *lexer) stateFn { |
| 403 | return lexVariables |
nothing calls this directly
no test coverage detected