summaryrefslogtreecommitdiffstats
path: root/src/parsing/equalizer_apo.lalrpop
blob: 8003be7256886037bd28523b9002a799be98fc34 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
use crate::Filter;

use std::str::FromStr;

grammar;

pub Main: Filter = {
    <preamp: Preamp> <eq: Eq> => Filter { preamp, frequencies: eq.0, coefficients: eq.1 }

}

Preamp: f64 = {
    "Preamp:" <Decibel>
}

Eq: (Vec<u32>, Vec<f64>) = {
    "GraphicEQ:" <values:(<(Integer Float)> ";")+> <end:(Integer Float)> => {
        let mut values = values;
        values.push(end);
        values.into_iter().unzip()
    }
}

Decibel: f64 = {
    <Float> "dB"
}

Float: f64 = {
    <RawFloat>,
    <SignedInteger> => <> as f64,
    <Integer> => <> 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