ParseWithRecovery parses a token stream, recovering from errors to collect multiple errors and return a partial AST with successfully parsed statements. WARNING: This method mutates the parser's internal state (tokens, currentPos) and is NOT safe for concurrent use on the same Parser instance. For
(tokens []token.Token)
| 161 | // defer parser.PutParser(p) |
| 162 | // stmts, errs := p.ParseWithRecovery(tokens) |
| 163 | func (p *Parser) ParseWithRecovery(tokens []token.Token) ([]ast.Statement, []error) { |
| 164 | // Wrap legacy token.Token into models.TokenWithSpan for the unified path. |
| 165 | wrapped := make([]models.TokenWithSpan, len(tokens)) |
| 166 | for i, t := range tokens { |
| 167 | wrapped[i] = models.WrapToken(models.Token{Type: t.Type, Value: t.Literal}) |
| 168 | } |
| 169 | return p.parseWithRecovery(preprocessTokens(wrapped)) |
| 170 | } |
| 171 | |
| 172 | // ParseWithRecoveryFromModelTokens parses tokenizer output with error recovery. |
| 173 | func (p *Parser) ParseWithRecoveryFromModelTokens(tokens []models.TokenWithSpan) ([]ast.Statement, []error) { |