diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/image.rs | 84 | ||||
| -rw-r--r-- | src/main.rs | 2 |
2 files changed, 47 insertions, 39 deletions
diff --git a/src/image.rs b/src/image.rs index 9522364..09c23e1 100644 --- a/src/image.rs +++ b/src/image.rs @@ -346,44 +346,52 @@ impl FlowChart { } fn build(&mut self, ast: &[DepthExpr]) { - // for node in ast { - // match node { - // DepthExpr::Decision { - // cond, - // t, - // then_branch, - // else_branch, - // } => todo!(), - // DepthExpr::IO(_) => todo!(), - // DepthExpr::Process(_) => todo!(), - // } - // } - self.draw_process("abcdefghijklmnospa", VDirection::Up); - self.draw_direction(None, None); - self.draw_process("abc", VDirection::Up); - self.draw_direction(None, None); - self.draw_process("a", VDirection::Up); - let offset = self.offset; - self.draw_direction(None, None); - self.draw_process("a", VDirection::Up); - self.draw_direction(None, None); - let a = self.draw_process("a", VDirection::Up); - self.draw_direction( - Some(&NCOffset { - x: self - .offset - .center, - y: self - .offset - .y - - a.y, - }), - Some(&NCOffset { - x: offset.x + 100, - y: offset.y, - }), - ); - self.draw_process("a", VDirection::Down); + for node in ast { + let mut skip_dir = false; + match node { + // DepthExpr::Decision { + // cond, + // t, + // then_branch, + // else_branch, + // } => todo!(), + // DepthExpr::IO(_) => todo!(), + DepthExpr::Process(s) => { + println!("{}", s); + self.draw_process(s, VDirection::Up); + } + _ => skip_dir = true, + }; + if !skip_dir { + self.draw_direction(None, None); + } + } + // self.draw_process("abcdefghijklmnospa", VDirection::Up); + // self.draw_direction(None, None); + // self.draw_process("abc", VDirection::Up); + // self.draw_direction(None, None); + // self.draw_process("a", VDirection::Up); + // let offset = self.offset; + // self.draw_direction(None, None); + // self.draw_process("a", VDirection::Up); + // self.draw_direction(None, None); + // let a = self.draw_process("a", VDirection::Up); + // self.draw_direction( + // Some(&NCOffset { + // x: self + // .offset + // .center, + // y: self + // .offset + // .y + // - a.y, + // }), + // Some(&NCOffset { + // x: offset.x + 100, + // y: offset.y, + // }), + // ); + // self.draw_process("a", VDirection::Down); } } diff --git a/src/main.rs b/src/main.rs index f926b00..67c2e43 100644 --- a/src/main.rs +++ b/src/main.rs @@ -5,7 +5,7 @@ use java2flowchart::image::FlowChart; use java2flowchart::parser; fn main() { - let test = "if (first) {firstthen; if (firstthenif) {firstthenifthen} else {firstthenelse}} else {firstelse}println('a')"; + let test = "first; if (first) {firstthen; if (firstthenif) {firstthenifthen} else {firstthenelse}} else {firstelse}println('a'); second; thirdlongprocess"; let ast = parse(&parser::parse(test)); |
