Skip to content

Commit

Permalink
feat(parser): make parser return flowurl
Browse files Browse the repository at this point in the history
  • Loading branch information
phodal committed Dec 17, 2021
1 parent a969c98 commit faab019
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions quake_core/src/parser/dsl_parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,8 @@ fn midway(decl: Pair<Rule>) -> Midway {
}
Rule::from | Rule::to | Rule::l_bracket | Rule::r_bracket => {}
Rule::rest_request => {
println!("{}", pair);
let url = rest_request(pair);
midway.from = TransflowSource::RestUrl(url);
}
Rule::filter_expr => {
for inner in pair.into_inner() {
Expand Down Expand Up @@ -229,7 +230,7 @@ fn endway(decl: Pair<Rule>) -> Endway {
Rule::from | Rule::to | Rule::l_bracket | Rule::r_bracket => {}
Rule::rest_request => {
let url = rest_request(pair);
println!("{:?}", url);
endway.from = TransflowSource::RestUrl(url);
}
Rule::filter_expr => {
for inner in pair.into_inner() {
Expand Down Expand Up @@ -414,7 +415,6 @@ mod tests {
.unwrap();

assert_eq!(1, unit.0.len());
println!("{:?}", unit);
if let SourceUnitPart::SimpleLayout(layout) = &unit.0[0] {
assert_eq!(layout.name, "Dashboard");
assert_eq!(3, layout.rows.len());
Expand All @@ -438,5 +438,19 @@ mod tests {
let unit = parse(define).unwrap();

println!("{:?}", unit);

if let SourceUnitPart::Transflow(decl) = &unit.0[0] {
match &decl.flows[0] {
TransflowEnum::Midway(_) => panic!(),
TransflowEnum::Endway(end) => match &end.from {
TransflowSource::RestUrl(url) => {
assert_eq!("https://quake.inherd.org", url.url);
}
_ => panic!(),
},
}
} else {
panic!();
}
}
}

0 comments on commit faab019

Please sign in to comment.