Avoid duplicate effort when parsing floats in the EDN parser.
This commit is contained in:
parent
c117f1e958
commit
2d7df69507
1 changed files with 1 additions and 7 deletions
|
@ -120,14 +120,8 @@ pub integer -> ValueAndSpan =
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
frac = sign? digit+ "." digit+
|
|
||||||
exp = sign? digit+ ("e" / "E") sign? digit+
|
|
||||||
frac_exp = sign? digit+ "." digit+ ("e" / "E") sign? digit+
|
|
||||||
|
|
||||||
// The order here is important - frac_exp must come before (exp / frac) or the
|
|
||||||
// parser assumes exp or frac when the float is really a frac_exp and fails
|
|
||||||
pub float -> ValueAndSpan =
|
pub float -> ValueAndSpan =
|
||||||
start:#position f:$( frac_exp / exp / frac ) end:#position {
|
start:#position f:$(sign? digit+ ("." digit+)? (("e" / "E") sign? digit+)?) end:#position {
|
||||||
ValueAndSpan {
|
ValueAndSpan {
|
||||||
inner: SpannedValue::Float(OrderedFloat(f.parse::<f64>().unwrap())),
|
inner: SpannedValue::Float(OrderedFloat(f.parse::<f64>().unwrap())),
|
||||||
span: Span::new(start, end)
|
span: Span::new(start, end)
|
||||||
|
|
Loading…
Reference in a new issue