Skip to content

Commit

Permalink
Improve the flowchart translator and add history API. (#15)
Browse files Browse the repository at this point in the history
  • Loading branch information
ArthurSonzogni authored Mar 18, 2021
1 parent bbf3788 commit fe9fd23
Show file tree
Hide file tree
Showing 21 changed files with 257 additions and 109 deletions.
2 changes: 2 additions & 0 deletions src/input_output_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ int main(int, const char**) {
std::cout << output << std::endl;
std::cout << "---------------------" << std::endl;
result = EXIT_FAILURE;

//std::ofstream(test.path() / "output") << output_computed;
}
}
}
Expand Down
5 changes: 3 additions & 2 deletions test/Flowchart/doloop/output
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
while("arthur")
"chocolat"
┌─────────────┐
│Unimplemented│
└─────────────┘
38 changes: 36 additions & 2 deletions test/Flowchart/example/output
Original file line number Diff line number Diff line change
@@ -1,2 +1,36 @@
while("arthur")
"chocolat"
┌─────┐
│start│
└──┬──┘
__________▽__________
╱ ╲ ┌──────────────┐
╱ ╲________________________________________________________________________________________│Very expensive│
╲ Does it cost > 1000 ? ╱yes └──────────────┘
╲_____________________╱
│no
_________▽_________ ___________________
╱ ╲ ╱ ╲ ┌──────────────┐
╱ ╲__________________ ╱ ╲_______________________________│Very expensive│
╲ Does it cost > 100? ╱yes ╲ Does it cost > 0.5? ╱yes └──────────────┘
╲___________________╱ ╲___________________╱
│no │no
________▽_________ _________▽_________
╱ ╲ ┌───────┐ ╱ ╲ ┌─────────┐
╱ ╲_________│Correct│ ╱ ╲____________________│expensive│
╲ Does it cost > 10? ╱yes └───────┘ ╲ Does it cost > 0.1? ╱yes └─────────┘
╲__________________╱ ╲___________________╱
│no │no
________▽________ _________▽__________
╱ ╲ ┌─────┐ ╱ ╲ ┌───────┐
╱ ╲___│Cheap│ ╱ ╲__________│Correct│
╲ Does it cost > 1? ╱yes└─────┘ ╲ Does it cost > 0.01? ╱yes └───────┘
╲_________________╱ ╲____________________╱
│no │no
┌───▽──┐ __________▽__________
│coucou│ ╱ ╲ ┌─────┐
└──────┘ ╱ ╲___│Cheap│
╲ Does it cost > 0.001? ╱yes└─────┘
╲_____________________╱
│no
┌──────▽──────┐
│Take my money│
└─────────────┘
25 changes: 14 additions & 11 deletions test/Flowchart/if-returned-0/output
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
┌─┐ ┌─┐ ┌─┐
│a│─>│b│─>│c│
└┬┘ └┬┘ └┬┘
┌▽┐ ┌▽┐ │
│e│ │d│ │
└┬┘ └┬┘ │
│ └─┬──┘
└──┬───┘
┌▽┐
│f│
└─┘
___ ___
╱ ╲ ╱ ╲ ┌─┐
╱ ╲___╱ ╲___│c│
╲ a ╱yes╲ b ╱yes└┬┘
╲___╱ ╲___╱ │
│no │no │
┌▽┐ ┌▽┐ │
│e│ │d│ │
└┬┘ └┬┘ │
│ └───┬───┘
└──────┬──────┘
┌▽┐
│f│
└─┘
25 changes: 14 additions & 11 deletions test/Flowchart/if-returned-1/output
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
┌─┐ ┌─┐ ┌─┐
│a│─>│b│─>│c│
└┬┘ └┬┘ └─┘
┌▽┐ ┌▽┐
│e│ │d│
└┬┘ └┬┘
│ │
└─┬──┘
┌▽┐
│f│
└─┘
___ ___
╱ ╲ ╱ ╲ ┌─┐
╱ ╲___╱ ╲___│c│
╲ a ╱yes╲ b ╱yes└─┘
╲___╱ ╲___╱
│no │no
┌▽┐ ┌▽┐
│e│ │d│
└┬┘ └┬┘
│ │
└────┬────┘
┌▽┐
│f│
└─┘
25 changes: 14 additions & 11 deletions test/Flowchart/if-returned-2/output
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
┌─┐ ┌─┐ ┌─┐
│a│─>│b│─>│c│
└┬┘ └┬┘ └┬┘
┌▽┐ ┌▽┐ │
│e│ │d│ │
└┬┘ └─┘ │
│ │
└────┬────┘
┌▽┐
│f│
└─┘
___ ___
╱ ╲ ╱ ╲ ┌─┐
╱ ╲___╱ ╲___│c│
╲ a ╱yes╲ b ╱yes└┬┘
╲___╱ ╲___╱ │
│no │no │
┌▽┐ ┌▽┐ │
│e│ │d│ │
└┬┘ └─┘ │
│ │
└────────┬────────┘
┌▽┐
│f│
└─┘
25 changes: 14 additions & 11 deletions test/Flowchart/if-returned-3/output
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
┌─┐ ┌─┐ ┌─┐
│a│─>│b│─>│c│
└┬┘ └┬┘ └┬┘
┌▽┐ ┌▽┐ │
│e│ │d│ │
└─┘ └┬┘ │
└─┬──┘
┌▽┐
│f│
└─┘
___ ___
╱ ╲ ╱ ╲ ┌─┐
╱ ╲___╱ ╲___│c│
╲ a ╱yes╲ b ╱yes└┬┘
╲___╱ ╲___╱ │
│no │no │
┌▽┐ ┌▽┐ │
│e│ │d│ │
└─┘ └┬┘ │
└───┬───┘
┌▽┐
│f│
└─┘
25 changes: 14 additions & 11 deletions test/Flowchart/if-returned-4/output
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
┌─┐ ┌─┐ ┌─┐
│a│─>│b│─>│c│
└┬┘ └┬┘ └─┘
┌▽┐ ┌▽┐
│e│ │d│
└─┘ └┬┘
┌▽┐
│f│
└─┘
___ ___
╱ ╲ ╱ ╲ ┌─┐
╱ ╲___╱ ╲___│c│
╲ a ╱yes╲ b ╱yes└─┘
╲___╱ ╲___╱
│no │no
┌▽┐ ┌▽┐
│e│ │d│
└─┘ └┬┘
┌▽┐
│f│
└─┘
25 changes: 14 additions & 11 deletions test/Flowchart/if-returned-5/output
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
┌─┐ ┌─┐ ┌─┐
│a│─>│b│─>│c│
└┬┘ └┬┘ └┬┘
┌▽┐ ┌▽┐ │
│e│ │d│ │
└─┘ └─┘ │
┌▽┐
│f│
└─┘
___ ___
╱ ╲ ╱ ╲ ┌─┐
╱ ╲___╱ ╲___│c│
╲ a ╱yes╲ b ╱yes└┬┘
╲___╱ ╲___╱ │
│no │no │
┌▽┐ ┌▽┐ │
│e│ │d│ │
└─┘ └─┘ │
┌▽┐
│f│
└─┘
23 changes: 13 additions & 10 deletions test/Flowchart/if-returned-6/output
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
┌─┐ ┌─┐ ┌─┐
│a│─>│b│─>│c│
└┬┘ └┬┘ └─┘
┌▽┐ ┌▽┐
│e│ │d│
└┬┘ └─┘
┌▽┐
│f│
└─┘
___ ___
╱ ╲ ╱ ╲ ┌─┐
╱ ╲___╱ ╲___│c│
╲ a ╱yes╲ b ╱yes└─┘
╲___╱ ╲___╱
│no │no
┌▽┐ ┌▽┐
│e│ │d│
└┬┘ └─┘
┌▽┐
│f│
└─┘
21 changes: 12 additions & 9 deletions test/Flowchart/if-returned-7/output
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
┌─┐ ┌─┐ ┌─┐
│a│─>│b│─>│c│
└┬┘ └┬┘ └─┘
┌▽┐ ┌▽┐
│e│ │d│
└─┘ └─┘
┌─┐
│f│
└─┘
___ ___
╱ ╲ ╱ ╲ ┌─┐
╱ ╲___╱ ╲___│c│
╲ a ╱yes╲ b ╱yes└─┘
╲___╱ ╲___╱
│no │no
┌▽┐ ┌▽┐
│e│ │d│
└─┘ └─┘
┌─┐
│f│
└─┘
7 changes: 5 additions & 2 deletions test/Flowchart/if_1/output
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
┌┬┐
└┴┘
___
╱ ╲ ┌─┐
╱ ╲│b│
╲ a ╱└─┘
╲___╱
7 changes: 5 additions & 2 deletions test/Flowchart/if_1_brace/output
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
┌┬┐
└┴┘
___
╱ ╲ ┌─┐
╱ ╲│b│
╲ a ╱└─┘
╲___╱
9 changes: 7 additions & 2 deletions test/Flowchart/if_2/output
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
┌┬┐
└┴┘
___
╱ ╲ ┌─┐
╱ ╲│b│
╲ a ╱└┬┘
╲___╱ ┌▽┐
│c│
└─┘
11 changes: 9 additions & 2 deletions test/Flowchart/if_3/output
Original file line number Diff line number Diff line change
@@ -1,2 +1,9 @@
┌┬┐
└┴┘
___
╱ ╲ ┌─┐
╱ ╲│b│
╲ a ╱└┬┘
╲_│_╱ │
├────┘
┌▽┐
│c│
└─┘
7 changes: 5 additions & 2 deletions test/Flowchart/if_with_space_condition/output
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
┌┬┐
└┴┘
___
╱ ╲ ┌───┐
╱ ╲│c d│
╲ a b ╱└───┘
╲___╱
5 changes: 3 additions & 2 deletions test/Flowchart/whileloop/output
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
while("arthur")
"chocolat"
┌─────────────┐
│Unimplemented│
└─────────────┘
15 changes: 13 additions & 2 deletions test/Flowchart/xkcd-do-you-understand-flowchart-2/output
Original file line number Diff line number Diff line change
@@ -1,2 +1,13 @@
while("arthur")
"chocolat"
┌─────────────┐
│Unimplemented│
└──────┬──────┘
┌───────▽──────┐
│LET'S GO DRING│
└───────┬──────┘
┌────▽───┐
│6 DRINKS│
└────┬───┘
┌─────────▽─────────┐
│HEY, I SHOULD TRY │
│INSTALLING FREEBSD!│
└───────────────────┘
15 changes: 13 additions & 2 deletions test/Flowchart/xkcd-do-you-understand-flowchart-switch/output
Original file line number Diff line number Diff line change
@@ -1,2 +1,13 @@
while("arthur")
"chocolat"
┌─────────────┐
│Unimplemented│
└──────┬──────┘
┌───────▽──────┐
│LET'S GO DRING│
└───────┬──────┘
┌────▽───┐
│6 DRINKS│
└────┬───┘
┌─────────▽─────────┐
│HEY, I SHOULD TRY │
│INSTALLING FREEBSD!│
└───────────────────┘
39 changes: 37 additions & 2 deletions test/Flowchart/xkcd-do-you-understand-flowchart/output
Original file line number Diff line number Diff line change
@@ -1,2 +1,37 @@
while("arthur")
"chocolat"
_________________
╱ ╲ ┌─────┐
╱ DO YOU UNDERSTAND ╲____________________________________________________│GOOD!│
╲ FLOW CHARTS? ╱yes └──┬──┘
╲_________________╱ │
│no │
_________▽_________ ______________________ │
╱ ╲ ╱ ╲ ┌────┐ │
╱ OKAY, YOU SEE THE ╲________________╱ ... AND YOU CAN SEE ╲___│GOOD│ │
╲ LINE LABELED "YES"? ╱yes ╲ THE ONES LABELED "NO"? ╱yes└──┬─┘ │
╲___________________╱ ╲______________________╱ │ │
│no │no │ │
________▽_________ _________▽__________ │ │
╱ ╲ ┌───────────┐ ╱ ╲ │ │
╱ BUT YOU SEE THE ╲___│WAIT, WHAT?│ ╱ BUT YOU JUST ╲___ │ │
╲ ONES LABELED "NO"? ╱yes└───────────┘ ╲ FOLLOWED THEM TWICE? ╱yes│ │ │
╲__________________╱ ╲____________________╱ │ │ │
│no │no │ │ │
┌───▽───┐ │ │ │ │
│LISTEN.│ └───────┬───────┘ │ │
└───┬───┘ ┌──────▽─────┐ │ │
┌─────▽────┐ │(THAT WASN'T│ │ │
│I HATE YOU│ │A QUESTION) │ │ │
└──────────┘ └──────┬─────┘ │ │
┌────▽───┐ │ │
│SCREW IT│ │ │
└────┬───┘ │ │
└─────┬─────┘ │
│ │
└─────┬─────┘
┌───────▽──────┐
│LET'S GO DRING│
└───────┬──────┘
┌─────────▽─────────┐
│HEY, I SHOULD TRY │
│INSTALLING FREEBSD!│
└───────────────────┘
12 changes: 10 additions & 2 deletions test/Flowchart/xkcd-local-computer-expert/output
Original file line number Diff line number Diff line change
@@ -1,2 +1,10 @@
while("arthur")
"chocolat"
┌─────┐
│START│
└──┬──┘
┌──────▽──────┐
│Unimplemented│
└──────┬──────┘
┌────────▽───────┐
│ASK SOMEONE FOR │
│HELP OR GIVE UP.│
└────────────────┘

0 comments on commit fe9fd23

Please sign in to comment.