@@ 30,10 30,7 @@ macro_rules! unexpected_token {
($self:expr, $message:expr, $token:expr) => {
$crate::error::KabelError::new(
$crate::error::ErrorKind::UnexpectedToken,
- format!(
- $message,
- $self.text[$token.start..$token.end].to_string()
- ),
+ format!($message, $self.text[$token.start..$token.end].to_string()),
$token.line,
$token.column,
$self.text[$token.line_start..$token.end].to_string(),
@@ 75,7 75,11 @@ impl Parser {
if let TokenType::RightParen = right_paren.token_type {
let block = self.block()?;
return Ok(AST {
- ast_type: ASTType::Function(Box::new(lit!(Ident, name, ident)), expressions, Box::new(block.clone())),
+ ast_type: ASTType::Function(
+ Box::new(lit!(Ident, name, ident)),
+ expressions,
+ Box::new(block.clone()),
+ ),
start: function_ident.start,
end: block.end,
line: function_ident.line,
@@ 88,7 92,11 @@ impl Parser {
return Err(unexpected_token!(self, "Expected ( found {}", left_paren));
}
} else {
- return Err(unexpected_token!(self, "Expected identifier found {}", ident));
+ return Err(unexpected_token!(
+ self,
+ "Expected identifier found {}",
+ ident
+ ));
}
}
@@ 169,7 177,11 @@ impl Parser {
column: if_ident.column,
});
} else {
- return Err(unexpected_token!(self, "Expected if found {}", else_if_ident));
+ return Err(unexpected_token!(
+ self,
+ "Expected if found {}",
+ else_if_ident
+ ));
}
}
return Err(unexpected_token!(self, "Unexpected token {}", else_ident));
@@ 265,7 277,11 @@ impl Parser {
return Err(unexpected_token!(self, "Expected = found {}", equal));
}
} else {
- return Err(unexpected_token!(self, "Expected identifier found {}", ident));
+ return Err(unexpected_token!(
+ self,
+ "Expected identifier found {}",
+ ident
+ ));
}
}
@@ 741,10 757,10 @@ pub enum ASTType {
Program(Vec<AST>),
Function(Box<AST>, Vec<AST>, Box<AST>), // name, args, block
- Loop(Box<AST>), // block
- While(Box<AST>, Box<AST>), // condition, block
+ Loop(Box<AST>), // block
+ While(Box<AST>, Box<AST>), // condition, block
If(Box<AST>, Box<AST>, Option<Box<AST>>), // condition, block, else/else if
- Block(Vec<AST>), // statements
+ Block(Vec<AST>), // statements
Decl(Box<AST>, Box<AST>), // identifier, expression
Binary(Box<AST>, BinOp, Box<AST>),