mirror of
https://github.com/rm-dr/daisy
synced 2025-02-21 22:49:24 -08:00
Fixed decimal parsing
This commit is contained in:
parent
88078fea5a
commit
9b099bb408
@ -72,7 +72,14 @@ impl PreToken {
|
||||
#[inline(always)]
|
||||
pub fn to_token(self) -> Result<Token, (LineLocation, ParserError)>{
|
||||
match self {
|
||||
PreToken::PreNumber(l, s) => {
|
||||
PreToken::PreNumber(l, mut s) => {
|
||||
|
||||
// The length check here ensures that
|
||||
// `.` is not parsed as `0.`
|
||||
// That should be a syntax error.
|
||||
if s.len() != 1 && &s[0..1] == "." {
|
||||
s.insert(0, '0');
|
||||
}
|
||||
|
||||
let r = Quantity::new_rational_from_float_string(&s);
|
||||
if r.is_none() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user