Consumes the next unit.
(skipCharacter byte)
| 123 | |
| 124 | // Consumes the next unit. |
| 125 | func (l *intervalLexer) consumeUnit(skipCharacter byte) string { |
| 126 | if l.err != nil { |
| 127 | return "" |
| 128 | } |
| 129 | |
| 130 | offset := l.offset |
| 131 | for ; l.offset < len(l.str); l.offset++ { |
| 132 | if (l.str[l.offset] >= '0' && l.str[l.offset] <= '9') || |
| 133 | l.str[l.offset] == skipCharacter || |
| 134 | l.str[l.offset] == '-' { |
| 135 | break |
| 136 | } |
| 137 | } |
| 138 | |
| 139 | if offset == l.offset { |
| 140 | l.err = pgerror.Newf( |
| 141 | pgcode.InvalidDatetimeFormat, "interval: missing unit at position %d: %q", offset, l.str) |
| 142 | return "" |
| 143 | } |
| 144 | return l.str[offset:l.offset] |
| 145 | } |
| 146 | |
| 147 | // Consumes any number of spaces. |
| 148 | func (l *intervalLexer) consumeSpaces() { |
no test coverage detected