Deprecated: Parse is provided for backward compatibility only. Use ParseFromModelTokens with a []models.TokenWithSpan slice from the tokenizer instead. This shim wraps each token.Token into a zero-span models.TokenWithSpan and has no position information. Parse parses a slice of token.Token into an
(tokens []token.Token)
| 251 | // |
| 252 | // Thread Safety: NOT thread-safe - use separate parser instances per goroutine. |
| 253 | func (p *Parser) Parse(tokens []token.Token) (*ast.AST, error) { |
| 254 | // Wrap legacy token.Token into models.TokenWithSpan (spans are zero). |
| 255 | wrapped := make([]models.TokenWithSpan, len(tokens)) |
| 256 | for i, t := range tokens { |
| 257 | wrapped[i] = models.WrapToken(models.Token{Type: t.Type, Value: t.Literal}) |
| 258 | } |
| 259 | // Preprocessing still normalises compound tokens and keyword types. |
| 260 | preprocessed := preprocessTokens(wrapped) |
| 261 | return p.parseTokens(preprocessed) |
| 262 | } |
| 263 | |
| 264 | // parseTokens is the core parsing routine. It takes a preprocessed |
| 265 | // []models.TokenWithSpan (already normalised by preprocessTokens) and returns |