Commit 7ac2a20e authored by Pierre Donat-Bouillud's avatar Pierre Donat-Bouillud
Browse files

Fix parsing with several edges on same statement.

parent 3d1ef832
Pipeline #737 passed with stage
in 2 minutes and 49 seconds
n1 =
{
kind : "source",
in: 0,
out : 1,
text : "salut",
wcet : 20.0,
};
n2 = { kind : "plop", in : 1, out:1, wcet : 21.0,};
n3 = {kind : "plop", in: 1, out:1, wcet :20.0,};
n4 = {kind : "sink", in:1, wcet :5.0,};
n1.1 -> n2.1 -> n3.1 -> n4.1;
deadline = 50.0;
......@@ -15,9 +15,9 @@ WHITESPACE = _{ " " | "\t" | NEWLINE }
port_ident = ${ident ~ "." ~ port}
edges = {port_ident ~ "->" ~ (edges | port_ident)}
edge = {"->" ~ port_ident}
edges = {port_ident ~ edge+}
deadline = { "deadline" ~ "=" ~ fnumber}
......
......@@ -89,9 +89,10 @@ pub fn parse_audiograph(audiograph : &str, buffer_size: usize, nb_channels: usiz
let mut edges = Vec::new();
for inner_rule in inner_rules {
port_ident = inner_rule.into_inner();
port_ident = inner_rule.into_inner().next().unwrap().into_inner();
let dst_id = port_ident.next().unwrap().as_str().to_string();
let dst_port = port_ident.next().unwrap().as_str().parse().unwrap();
println!("dst_id = {}; dst_port = {}", dst_id, dst_port);
edges.push(Edge {src_id, src_port, dst_id : dst_id.clone(), dst_port});
src_id = dst_id;
src_port = dst_port;
......@@ -158,6 +159,14 @@ mod tests {
assert!(audiograph.nb_edges() == 6);
}
#[test]
fn build_audiograph_down_test() {
let audiograph = parse_audiograph_from_file("downsampling_test.ag", 64, 2, 44_100).expect("Impossible to open file.");
println!("Nodes={} and edges={}", audiograph.nb_nodes(), audiograph.nb_edges() );
assert!(audiograph.nb_nodes() == 6);
assert!(audiograph.nb_edges() == 7);
}
#[test]
fn audiograph_ident() {
assert!(AudiographParser::parse(Rule::ident, "rte45").is_ok());
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment