Make all the lexer tests pass again
Try to make exact numbers if possible...
This commit is contained in:
parent
4d7d709b2f
commit
50baf2c118
1 changed files with 5 additions and 4 deletions
|
@ -15,7 +15,7 @@ pub enum Exactness { Exact, Inexact }
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct NumberBuilder {
|
pub struct NumberBuilder {
|
||||||
exact: Exactness,
|
exact: Option<Exactness>,
|
||||||
radix: Radix,
|
radix: Radix,
|
||||||
sign: Sign,
|
sign: Sign,
|
||||||
value: f64,
|
value: f64,
|
||||||
|
@ -25,7 +25,7 @@ pub struct NumberBuilder {
|
||||||
impl NumberBuilder {
|
impl NumberBuilder {
|
||||||
pub fn new() -> NumberBuilder {
|
pub fn new() -> NumberBuilder {
|
||||||
NumberBuilder {
|
NumberBuilder {
|
||||||
exact: Exactness::Inexact,
|
exact: None,
|
||||||
radix: Radix::Dec,
|
radix: Radix::Dec,
|
||||||
sign: Sign::Pos,
|
sign: Sign::Pos,
|
||||||
value: 0.0,
|
value: 0.0,
|
||||||
|
@ -34,7 +34,7 @@ impl NumberBuilder {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn exact<'a>(&'a mut self, ex: Exactness) -> &'a mut NumberBuilder {
|
pub fn exact<'a>(&'a mut self, ex: Exactness) -> &'a mut NumberBuilder {
|
||||||
self.exact = ex;
|
self.exact = Some(ex);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -80,7 +80,8 @@ impl NumberBuilder {
|
||||||
value
|
value
|
||||||
};
|
};
|
||||||
// TODO: Use an integer if we can.
|
// TODO: Use an integer if we can.
|
||||||
Number::from_float(value, self.exact == Exactness::Exact)
|
let exact = self.point == 0 || self.exact == Some(Exactness::Exact);
|
||||||
|
Number::from_float(value, exact)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn radix_value(&self) -> u32 {
|
pub fn radix_value(&self) -> u32 {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue