--- a/crates/jrsonnet-parser/src/lib.rs +++ b/crates/jrsonnet-parser/src/lib.rs @@ -44,9 +44,9 @@ rule digit() -> char = d:$(['0'..='9']) {d.chars().next().unwrap()} rule end_of_ident() = !['0'..='9' | '_' | 'a'..='z' | 'A'..='Z'] /// Sequence of digits - rule uint() -> u64 = a:$(digit()+) { a.parse().unwrap() } + rule uint_str() -> &'input str = a:$(digit()+) { a } /// Number in scientific notation format - rule number() -> f64 = quiet!{a:$(uint() ("." uint())? (['e'|'E'] (s:['+'|'-'])? uint())?) { a.parse().unwrap() }} / expected!("") + rule number() -> f64 = quiet!{a:$(uint_str() ("." uint_str())? (['e'|'E'] (s:['+'|'-'])? uint_str())?) {? a.parse().map_err(|_| "") }} / expected!("") /// Reserved word followed by any non-alphanumberic rule reserved() = ("assert" / "else" / "error" / "false" / "for" / "function" / "if" / "import" / "importstr" / "in" / "local" / "null" / "tailstrict" / "then" / "self" / "super" / "true") end_of_ident()