git.delta.rocks / jrsonnet / refs/commits / 708403715eb7

difftreelog

Merge pull request #58 from CertainLach/fix/number-parsing

Yaroslav Bolyukin2021-08-14parents: #5e5ab6b #fc291eb.patch.diff
in: master
Fix number parsing

3 files changed

modifiedcmds/jrsonnet/src/main.rsdiffbeforeafterboth
131131
132fn 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)?;
136136
137 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();
modifiedcrates/jrsonnet-evaluator/src/error.rsdiffbeforeafterboth
189#[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}
195195
modifiedcrates/jrsonnet-parser/src/lib.rsdiffbeforeafterboth
44 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 digits
47 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 format
49 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>")
5050
51 /// Reserved word followed by any non-alphanumberic51 /// Reserved word followed by any non-alphanumberic
52 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()