use ::Filter; use std::str::FromStr; grammar; pub Main: Filter = { => { let coefficients: Vec<_> = eq.1.iter().map(|decibel| 10f64.powf(decibel / 10f64).sqrt()).collect(); // TODO: add decibel_to_ratio conversion function let preamp = 10f64.powf(preamp / 10f64); Filter { preamp, frequencies: eq.0, coefficients } } } Preamp: f64 = { "Preamp:" } Eq: (Vec, Vec) = { "GraphicEQ:" ";")+> => { let mut values = values; values.push(end); values.into_iter().unzip() } } Decibel: f64 = { "dB" } Float: f64 = { , => <> as f64, => <> as f64, } RawFloat: f64 = r"-?[0-9]*\.[0-9]+" => f64::from_str(<>).unwrap(); SignedInteger: i32 = r"-[0-9]+" => i32::from_str(<>).unwrap(); Integer: u32 = r"[0-9]+"=> u32::from_str(<>).unwrap(); // vim: ft=rust