* Parses a regex-delimited group: the largest sequence of tokens * whose concatenated strings match `regex`. Returns the string * formed by the tokens plus some position information.
(regex, modeName)
| 15481 | |
| 15482 | |
| 15483 | parseRegexGroup(regex, modeName) { |
| 15484 | const outerMode = this.mode; |
| 15485 | this.mode = "text"; |
| 15486 | const firstToken = this.nextToken; |
| 15487 | let lastToken = firstToken; |
| 15488 | let str = ""; |
| 15489 | |
| 15490 | while (this.nextToken.text !== "EOF" && regex.test(str + this.nextToken.text)) { |
| 15491 | lastToken = this.nextToken; |
| 15492 | str += lastToken.text; |
| 15493 | this.consume(); |
| 15494 | } |
| 15495 | |
| 15496 | if (str === "") { |
| 15497 | throw new ParseError("Invalid " + modeName + ": '" + firstToken.text + "'", firstToken); |
| 15498 | } |
| 15499 | |
| 15500 | this.mode = outerMode; |
| 15501 | return firstToken.range(lastToken, str); |
| 15502 | } |
| 15503 | /** |
| 15504 | * Parses a color description. |
| 15505 | */ |
no test coverage detected