An error is returned when the number fails to parse.
@@ -150,7 +150,11 @@ fn parse_number(pair: Pair<Rule>, pc: &mut PositionCalculator) -> Result<Positio
debug_assert_eq!(pair.as_rule(), Rule::number);
let pos = pc.step(&pair);
Ok(Positioned::new(
- pair.as_str().parse().expect("failed to parse number"),
+ pair.as_str().parse().map_err(|err| Error::Syntax {
+ message: format!("invalid number: {}", err),
+ start: pos,
+ end: None,
+ })?,
pos,
))
}
