difftreelog
Merge pull request #58 from CertainLach/fix/number-parsing
in: master
Fix number parsing
3 files changed
cmds/jrsonnet/src/main.rsdiffbeforeafterboth131131132fn main_real(state: &EvaluationState, opts: Opts) -> Result<(), Error> {132fn main_real(state: &EvaluationState, opts: Opts) -> Result<(), Error> {133 opts.gc.configure_global();133 opts.gc.configure_global();134 opts.general.configure(&state)?;134 opts.general.configure(state)?;135 opts.manifest.configure(&state)?;135 opts.manifest.configure(state)?;136136137 let val = if opts.input.exec {137 let val = if opts.input.exec {138 state.evaluate_snippet_raw(138 state.evaluate_snippet_raw(158 }158 }159 for (file, data) in state.manifest_multi(val)?.iter() {159 for (file, data) in state.manifest_multi(val)?.iter() {160 let mut path = multi.clone();160 let mut path = multi.clone();161 path.push(&file as &str);161 path.push(file as &str);162 if opts.output.create_output_dirs {162 if opts.output.create_output_dirs {163 let mut dir = path.clone();163 let mut dir = path.clone();164 dir.pop();164 dir.pop();crates/jrsonnet-evaluator/src/error.rsdiffbeforeafterboth189#[macro_export]189#[macro_export]190macro_rules! throw {190macro_rules! throw {191 ($e: expr) => {191 ($e: expr) => {192 return Err($e.into());192 return Err($e.into())193 };193 };194}194}195195crates/jrsonnet-parser/src/lib.rsdiffbeforeafterboth44 rule digit() -> char = d:$(['0'..='9']) {d.chars().next().unwrap()}44 rule digit() -> char = d:$(['0'..='9']) {d.chars().next().unwrap()}45 rule end_of_ident() = !['0'..='9' | '_' | 'a'..='z' | 'A'..='Z']45 rule end_of_ident() = !['0'..='9' | '_' | 'a'..='z' | 'A'..='Z']46 /// Sequence of digits46 /// Sequence of digits47 rule uint() -> u64 = a:$(digit()+) { a.parse().unwrap() }47 rule uint_str() -> &'input str = a:$(digit()+) { a }48 /// Number in scientific notation format48 /// Number in scientific notation format49 rule number() -> f64 = quiet!{a:$(uint() ("." uint())? (['e'|'E'] (s:['+'|'-'])? uint())?) { a.parse().unwrap() }} / expected!("<number>")49 rule number() -> f64 = quiet!{a:$(uint_str() ("." uint_str())? (['e'|'E'] (s:['+'|'-'])? uint_str())?) {? a.parse().map_err(|_| "<number>") }} / expected!("<number>")505051 /// Reserved word followed by any non-alphanumberic51 /// Reserved word followed by any non-alphanumberic52 rule reserved() = ("assert" / "else" / "error" / "false" / "for" / "function" / "if" / "import" / "importstr" / "in" / "local" / "null" / "tailstrict" / "then" / "self" / "super" / "true") end_of_ident()52 rule reserved() = ("assert" / "else" / "error" / "false" / "for" / "function" / "if" / "import" / "importstr" / "in" / "local" / "null" / "tailstrict" / "then" / "self" / "super" / "true") end_of_ident()