continue statements now working
This commit is contained in:
@@ -235,6 +235,16 @@ impl Parser {
|
||||
Expression::Break
|
||||
}
|
||||
|
||||
// match continue statements
|
||||
TokenType::Keyword(Keyword::Continue) => {
|
||||
// make sure the next token is a semi-colon
|
||||
let next = token_from_option!(self.get_next()?);
|
||||
if !token_matches!(next, TokenType::Symbol(Symbol::Semicolon)) {
|
||||
return Err(Error::UnexpectedToken(next.clone()));
|
||||
}
|
||||
Expression::Continue
|
||||
}
|
||||
|
||||
// match syscalls with a `syscall` keyword
|
||||
TokenType::Identifier(ref id) if SysCall::is_syscall(id) => {
|
||||
Expression::Syscall(self.syscall()?)
|
||||
@@ -1192,3 +1202,4 @@ impl Parser {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -214,6 +214,7 @@ pub enum Expression {
|
||||
Binary(BinaryExpression),
|
||||
Block(BlockExpression),
|
||||
Break,
|
||||
Continue,
|
||||
Declaration(String, Box<Expression>),
|
||||
DeviceDeclaration(DeviceDeclarationExpression),
|
||||
Function(FunctionExpression),
|
||||
@@ -237,6 +238,7 @@ impl std::fmt::Display for Expression {
|
||||
Expression::Binary(e) => write!(f, "{}", e),
|
||||
Expression::Block(e) => write!(f, "{}", e),
|
||||
Expression::Break => write!(f, "break"),
|
||||
Expression::Continue => write!(f, "continue"),
|
||||
Expression::Declaration(id, e) => write!(f, "(let {} = {})", id, e),
|
||||
Expression::DeviceDeclaration(e) => write!(f, "{}", e),
|
||||
Expression::Function(e) => write!(f, "{}", e),
|
||||
@@ -254,4 +256,3 @@ impl std::fmt::Display for Expression {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user