Switch indentation to tabs
This commit is contained in:
parent
1bb3819350
commit
4ac7e74c6b
@ -1 +1 @@
|
||||
tab_spaces=2
|
||||
hard_tabs=true
|
||||
|
||||
@ -221,7 +221,9 @@ fn evaluate_node(ast_node: &AstNode) -> Result<Number, String> {
|
||||
Factorial => {
|
||||
let result = factorial(child_answer.value);
|
||||
if result.is_nan() {
|
||||
return Err("Can only perform factorial on integers from 0 to 1000".to_string());
|
||||
return Err(
|
||||
"Can only perform factorial on integers from 0 to 1000".to_string()
|
||||
);
|
||||
}
|
||||
Ok(Number::new(result, child_answer.unit))
|
||||
}
|
||||
|
||||
@ -262,13 +262,17 @@ pub fn eval(
|
||||
let eval_start = Instant::now();
|
||||
match evaluator::evaluate(&ast) {
|
||||
Ok(answer) => {
|
||||
let eval_time = Instant::now().duration_since(eval_start).as_nanos() as f32;
|
||||
let eval_time =
|
||||
Instant::now().duration_since(eval_start).as_nanos() as f32;
|
||||
|
||||
if verbose {
|
||||
println!("Evaluated value: {} {:?}", answer.value, answer.unit);
|
||||
println!("\u{23f1} {:.3}ms lexing", lex_time / 1000.0 / 1000.0);
|
||||
println!("\u{23f1} {:.3}ms parsing", parse_time / 1000.0 / 1000.0);
|
||||
println!("\u{23f1} {:.3}ms evaluation", eval_time / 1000.0 / 1000.0);
|
||||
println!(
|
||||
"\u{23f1} {:.3}ms evaluation",
|
||||
eval_time / 1000.0 / 1000.0
|
||||
);
|
||||
}
|
||||
|
||||
Ok(answer)
|
||||
|
||||
@ -349,7 +349,8 @@ pub fn parse_level_7(tokens: &[Token], pos: usize) -> Result<(AstNode, usize), S
|
||||
)),
|
||||
}
|
||||
}
|
||||
Token::Operator(LeftParen) => parse_level_1(tokens, pos + 1).and_then(|(node, next_pos)| {
|
||||
Token::Operator(LeftParen) => {
|
||||
parse_level_1(tokens, pos + 1).and_then(|(node, next_pos)| {
|
||||
if let Some(&Token::Operator(RightParen)) = tokens.get(next_pos) {
|
||||
let mut paren_node = AstNode::new(Token::Paren);
|
||||
paren_node.children.push(node);
|
||||
@ -361,7 +362,8 @@ pub fn parse_level_7(tokens: &[Token], pos: usize) -> Result<(AstNode, usize), S
|
||||
tokens.get(next_pos)
|
||||
))
|
||||
}
|
||||
}),
|
||||
})
|
||||
}
|
||||
_ => Err(format!(
|
||||
"Unexpected token {:?}, expected paren or number",
|
||||
token
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user