(str: string)
| 137 | } |
| 138 | |
| 139 | function expect(str: string) { |
| 140 | if (kind === str) { |
| 141 | lex(); |
| 142 | return; |
| 143 | } |
| 144 | |
| 145 | let found; |
| 146 | if (kind === 'EOF') { |
| 147 | found = '[end of file]'; |
| 148 | } else if (end - start > 1) { |
| 149 | found = '`' + string.slice(start, end) + '`'; |
| 150 | } else { |
| 151 | const match = string.slice(start).match(/^.+?\b/); |
| 152 | found = '`' + (match ? match[0] : string[start]) + '`'; |
| 153 | } |
| 154 | |
| 155 | throw syntaxError(`Expected ${str} but found ${found}.`); |
| 156 | } |
| 157 | |
| 158 | type SyntaxErrorPosition = { start: number; end: number }; |
| 159 |
searching dependent graphs…