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)
| 53 | // |
| 54 | // The limit must be >= 1, and is recommended to be less than the default of 256. |
| 55 | func ErrorRecoveryLookaheadTokenLimit(limit int) Option { |
| 56 | return func(opts *options) error { |
| 57 | if limit < 1 { |
| 58 | return fmt.Errorf("error recovery lookahead token limit must be at least 1: %d", limit) |
| 59 | } |
| 60 | opts.errorRecoveryTokenLookaheadLimit = limit |
| 61 | return nil |
| 62 | } |
| 63 | } |
| 64 | |
| 65 | // ErrorRecoveryLimit limits the number of attempts the parser will perform to recover from an error. |
| 66 | func ErrorRecoveryLimit(limit int) Option { |
no outgoing calls