(kind tokenKind, msg string)
| 267 | } |
| 268 | |
| 269 | func (p *prattParserWorker) expect(kind tokenKind, msg string) bool { |
| 270 | if p.peekTok.kind == kind { |
| 271 | p.nextToken() |
| 272 | return true |
| 273 | } |
| 274 | if p.recursionLimitExceeded || p.isRecoveryLimitExceeded() { |
| 275 | return false |
| 276 | } |
| 277 | if p.peekTok.kind != tokError { |
| 278 | if msg == "" { |
| 279 | tokText := p.tokenText(p.peekTok) |
| 280 | formattedTok := fmt.Sprintf("'%s'", tokText) |
| 281 | if p.peekTok.kind == tokEnd { |
| 282 | formattedTok = "<EOF>" |
| 283 | } |
| 284 | msg = fmt.Sprintf("mismatched input %s expecting '%s'", formattedTok, kind.String()) |
| 285 | } |
| 286 | p.reportSyntaxError(p.peekTok, "%s", msg) |
| 287 | } |
| 288 | p.synchronizeOnDelimiter() |
| 289 | return false |
| 290 | } |
| 291 | |
| 292 | func (p *prattParserWorker) synchronizeOnDelimiter() { |
| 293 | if p.recursionLimitExceeded || p.isRecoveryLimitExceeded() { |
no test coverage detected