forked from asklyphe-public/asklyphe
WIP ui
This commit is contained in:
parent
b7b466b774
commit
4f6063bf72
2 changed files with 13 additions and 5 deletions
|
@ -10,12 +10,13 @@ pub struct Calculation {
|
|||
pub fn calculate(query: &str) -> Option<Calculation> {
|
||||
debug!("Got query {}", query);
|
||||
let mut parser = Parser::new(Lexer::new(query));
|
||||
let res = parser.parse()?;
|
||||
let tree = parser.parse()?;
|
||||
let res = tree.eval();
|
||||
|
||||
debug!("Calculation: {}", query);
|
||||
debug!("Tree: {:?}", res);
|
||||
debug!("Result: {}", res.eval());
|
||||
None
|
||||
debug!("Tree: {:?}", tree);
|
||||
debug!("Result: {}", res);
|
||||
Some(Calculation {equation: query.to_string(), result: res.to_string()})
|
||||
}
|
||||
|
||||
// TODO: put into own crate with dependency astro-float = "0.9.2" so I can use more than f64
|
||||
|
@ -45,7 +46,7 @@ impl Op {
|
|||
BinOp::Divide => 2.0,
|
||||
BinOp::Exponent => 3.0,
|
||||
},
|
||||
Op::Func(_) => 0.9, // TODO: decide if this is a good LBP
|
||||
Op::Func(_) => 0.0, // TODO: decide if this is a good LBP
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -67,6 +67,13 @@
|
|||
</div>
|
||||
{% when None %}
|
||||
{% endmatch %}
|
||||
{% match complications.math %}
|
||||
{% when Some with (math) %}
|
||||
<div class="calculator-complication">
|
||||
<h1>{{ math.equation }} = {{ math.result }}</h1>
|
||||
</div>
|
||||
{% when None %}
|
||||
{% endmatch %}
|
||||
</div>
|
||||
</div>
|
||||
{% endmatch %}
|
||||
|
|
Loading…
Add table
Reference in a new issue