synchronize advances the parser past the current error to a synchronization point: either past a semicolon or to a statement-starting keyword.
()
| 99 | // synchronize advances the parser past the current error to a synchronization point: |
| 100 | // either past a semicolon or to a statement-starting keyword. |
| 101 | func (p *Parser) synchronize() { |
| 102 | for p.currentPos < len(p.tokens) && !p.isType(models.TokenTypeEOF) { |
| 103 | // If we hit a semicolon, consume it and stop |
| 104 | if p.isType(models.TokenTypeSemicolon) { |
| 105 | p.advance() |
| 106 | return |
| 107 | } |
| 108 | // If we hit a statement-starting keyword, stop (don't consume it) |
| 109 | if p.isStatementStartingKeyword() { |
| 110 | return |
| 111 | } |
| 112 | p.advance() |
| 113 | } |
| 114 | } |
| 115 | |
| 116 | // ParseMultiWithRecovery obtains a parser from the pool and parses a token stream, |
| 117 | // recovering from errors to collect multiple errors and return a partial AST. |
no test coverage detected