()
| 60 | } |
| 61 | |
| 62 | consumeParen(): CursorV2 { |
| 63 | if (this.read() !== "(") throw new Error("Expecting ("); |
| 64 | |
| 65 | const start = this.ptr + 1; |
| 66 | let counter = 1; |
| 67 | |
| 68 | // Find the matching closing paren |
| 69 | while (counter > 0) { |
| 70 | if (!this.next()) throw new Error("Expecting closing paren"); |
| 71 | if (this.read() === "(") counter++; |
| 72 | if (this.read() === ")") counter--; |
| 73 | } |
| 74 | |
| 75 | const newCursor = new CursorV2(this.tokens.slice(start, this.ptr)); |
| 76 | this.next(); |
| 77 | |
| 78 | return newCursor; |
| 79 | } |
| 80 | |
| 81 | consume() { |
| 82 | const value = this.read(); |
no test coverage detected