add synchronize to rust
This commit is contained in:
parent
ae959f7768
commit
491f75f6e9
@ -191,6 +191,17 @@ impl Parser {
|
|||||||
Err(ParserError::ExpressionExpected(prev.line))
|
Err(ParserError::ExpressionExpected(prev.line))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn synchronize(&mut self) {
|
||||||
|
let _ = self.advance();
|
||||||
|
while !self.is_at_end()
|
||||||
|
&& self.previous().unwrap().token_type != Semicolon
|
||||||
|
&& !&[Class, Fun, Var, For, If, While, Print, Return]
|
||||||
|
.contains(&self.current_token.token_type)
|
||||||
|
{
|
||||||
|
let _ = self.advance();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Try to parse the provided tokens into an AST.
|
/// Try to parse the provided tokens into an AST.
|
||||||
|
Loading…
Reference in New Issue
Block a user