ErrorRecoveryLookaheadTokenLimit limits the number of lexer tokens that may be considered during error recovery. Error recovery often involves looking ahead in the input to determine if there's a point at which parsing may successfully resume. In some pathological cases, the parser can look through
(limit int)
| 52 | // |
| 53 | // The limit must be >= 1, and is recommended to be less than the default of 256. |
| 54 | func ErrorRecoveryLookaheadTokenLimit(limit int) Option { |
| 55 | return func(opts *options) error { |
| 56 | if limit < 1 { |
| 57 | return fmt.Errorf("error recovery lookahead token limit must be at least 1: %d", limit) |
| 58 | } |
| 59 | opts.errorRecoveryTokenLookaheadLimit = limit |
| 60 | return nil |
| 61 | } |
| 62 | } |
| 63 | |
| 64 | // ErrorRecoveryLimit limits the number of attempts the parser will perform to recover from an error. |
| 65 | func ErrorRecoveryLimit(limit int) Option { |
no outgoing calls