pub fn synchronize(tokens: ParserIter) {
	while let Some(token) = tokens.peek() {
		match token.token_type {
			TokenType::Class
			| TokenType::Fun
			| TokenType::Let
			| TokenType::Const
			| TokenType::For
			| TokenType::If
			| TokenType::Print
			| TokenType::Return => {
				break;
			}

			_ => {
				if TokenType::Semicolon == tokens.next().unwrap().token_type {
					break;
				}
			}
		}
	}
}
// call only if the token that the parser choked on is not ';'
// TODO: add sync context (like parsing methods or global sync etc.)
call only if the token that the parser choked on is not ';'
TODO: add sync context (like parsing methods or global sync etc.)
call only if the token that the parser choked on is not ' ; ' TODO : add sync context ( like parsing methods or global sync etc . )
pub fn synchronize(tokens: ParserIter) {
	while let Some(token) = tokens.peek() {
		match token.token_type {
			TokenType::Class
			| TokenType::Fun
			| TokenType::Let
			| TokenType::Const
			| TokenType::For
			| TokenType::If
			| TokenType::Print
			| TokenType::Return => {
				break;
			}
			_ => {
				if TokenType::Semicolon == tokens.next().unwrap().token_type {
					break;
				}
			}
		}
	}
}
pub fn synchronize ( tokens : ParserIter ) { while let Some ( token ) = tokens . peek ( ) { match token . token_type { TokenType :: Class | TokenType :: Fun | TokenType :: Let | TokenType :: Const | TokenType :: For | TokenType :: If | TokenType :: Print | TokenType :: Return => { break ; } _ => { if TokenType :: Semicolon == tokens . next ( ) . unwrap ( ) . token_type { break ; } } } } }
call only if the token that the parser choked on is not ';'
TODO: add sync context (like parsing methods or global sync etc.)
call only if the token that the parser choked on is not ' ; ' TODO : add sync context ( like parsing methods or global sync etc . )
tokens
ParserIter
tokens
ParserIter