lexOptions lexes the options that precede a command specification.
(l *lexer)
| 444 | |
| 445 | // lexOptions lexes the options that precede a command specification. |
| 446 | func lexOptions(l *lexer) stateFn { |
| 447 | for { |
| 448 | n := l.next() |
| 449 | if any(n, spaces) { |
| 450 | l.acceptRun(spaces) |
| 451 | l.emit(itemSpace) |
| 452 | } else if n == ':' { |
| 453 | l.emit(itemColon) |
| 454 | return lexCommand |
| 455 | } else if n == '+' { |
| 456 | l.acceptWord() |
| 457 | l.emit(itemBareString) |
| 458 | } else { |
| 459 | l.errorf("invalid command option") |
| 460 | return nil |
| 461 | } |
| 462 | } |
| 463 | } |
| 464 | |
| 465 | // lexCommand lexes a single command. Commands can either be unquoted and on a |
| 466 | // single line, or quoted and span multiple lines. |