readCommand reads to the next control character to find a command in the string. Command regexes constrain matches to the beginning of the string, and all commands consume an entire line.
(r []rune, i, end int)
| 20 | // to the beginning of the string, and all commands consume |
| 21 | // an entire line. |
| 22 | func readCommand(r []rune, i, end int) (Command, int) { |
| 23 | for ; i < end; i++ { |
| 24 | next := grab(r, i, end) |
| 25 | if next == 0 || (unicode.IsControl(next) && next != '\t') { |
| 26 | break |
| 27 | } |
| 28 | } |
| 29 | |
| 30 | for _, builder := range commandBuilders { |
| 31 | cmd := builder(string(r[:i])) |
| 32 | if cmd != nil { |
| 33 | return cmd, i |
| 34 | } |
| 35 | } |
| 36 | return nil, i |
| 37 | } |
| 38 | |
| 39 | // readMultilineComment finds the end of a multiline comment (ie, '*/'). |
| 40 | func readMultilineComment(r []rune, i, end int) (int, bool) { |