(ctx any, format string, args ...any)
| 306 | } |
| 307 | |
| 308 | func (p *prattParserWorker) reportError(ctx any, format string, args ...any) ast.Expr { |
| 309 | if p.isRecoveryLimitExceeded() { |
| 310 | return p.helper.newExpr(common.NoLocation) |
| 311 | } |
| 312 | p.errorCount++ |
| 313 | var location common.Location |
| 314 | err := p.helper.newExpr(ctx) |
| 315 | switch c := ctx.(type) { |
| 316 | case common.Location: |
| 317 | location = c |
| 318 | case token: |
| 319 | location = p.helper.getLocation(err.ID()) |
| 320 | default: |
| 321 | location = p.helper.getLocation(err.ID()) |
| 322 | } |
| 323 | if p.errorCount <= p.errorReportingLimit { |
| 324 | p.errors.reportErrorAtID(err.ID(), location, format, args...) |
| 325 | } |
| 326 | if p.isRecoveryLimitExceeded() { |
| 327 | p.peekTok = token{kind: tokEnd, start: p.length, end: p.length} |
| 328 | } |
| 329 | return err |
| 330 | } |
| 331 | |
| 332 | func (p *prattParserWorker) reportSyntaxError(ctx any, format string, args ...any) ast.Expr { |
| 333 | return p.reportError(ctx, "Syntax error: "+format, args...) |
no test coverage detected