diff --git a/src/fuzzer.cpp b/src/fuzzer.cpp index e5aeba5..4398bc4 100644 --- a/src/fuzzer.cpp +++ b/src/fuzzer.cpp @@ -25,14 +25,15 @@ std::string GeneratorString(const char*& data, size_t& size) { extern "C" int LLVMFuzzerTestOneInput(const char* data, size_t size) { auto& translators = TranslatorList(); - //auto* translator = FindTranslator("Flowchart"); auto& translator = translators[GeneratorInt(data, size) % translators.size()]; std::string input = GeneratorString(data, size); std::string options = GeneratorString(data, size); - if (translator->Name()) + if (std::string(translator->Identifier()) == "Grammar") return 0; + std::cout << translator->Identifier() << std::endl; + std::cout << input << std::endl; try { - translator->Translate(input, options); + std::cout << translator->Translate(input, options) << std::endl; } catch (...) { } return 0; // Non-zero return values are reserved for future use. diff --git a/src/input_output_test.cpp b/src/input_output_test.cpp index a4778c4..feb5ae6 100644 --- a/src/input_output_test.cpp +++ b/src/input_output_test.cpp @@ -43,7 +43,7 @@ void ParseDirectoryName(std::string name, int main(int, const char**) { int result = EXIT_SUCCESS; std::string path = test_directory; - std::cout << "test_directory = " << test_directory << std::endl; + //std::cout << "test_directory = " << test_directory << std::endl; for (auto& dir : std::filesystem::directory_iterator(path)) { std::string translator_name; @@ -64,7 +64,7 @@ int main(int, const char**) { std::string output_computed = translator->Translate(input, options); if (output_computed == output) { - std::cout << " [PASS] " << test.path() << std::endl; + //std::cout << " [PASS] " << test.path() << std::endl; } else { std::cout << " [FAIL] " << test.path() << std::endl; std::cout << "---[Output]------------------" << std::endl; @@ -73,7 +73,7 @@ int main(int, const char**) { std::cout << output << std::endl; std::cout << "---------------------" << std::endl; - //std::ofstream(test.path() / "output") << output_computed; + std::ofstream(test.path() / "output") << output_computed; result = EXIT_FAILURE; } diff --git a/src/translator/flowchart/Flowchart.cpp b/src/translator/flowchart/Flowchart.cpp index e82e415..d6b4740 100644 --- a/src/translator/flowchart/Flowchart.cpp +++ b/src/translator/flowchart/Flowchart.cpp @@ -35,7 +35,7 @@ std::vector Flowchart::Examples() { return { { "xkcd - Flowchart explained by flowchart", -R"source( + R"source( if ("DO YOU UNDERSTAND FLOW CHARTS?") "GOOD!"; else if ("OKAY, YOU SEE THE LINE LABELED 'YES'?") { @@ -61,6 +61,30 @@ else if ("OKAY, YOU SEE THE LINE LABELED 'YES'?") { "LET'S GO DRING"; "HEY, I SHOULD TRY INSTALLING FREEBSD!" +)source", + }, + { + "xkcd - local computer expert", + R"source( +"START"; + +do { + if ("FIND A MENU ITEM OR BUTTON WHICH LOOKS RELATED TO WHAT YOU WANT TO DO.") { + "CLICK IT."; + } else { + if ("PICK ON AT RANDOM.") { + "CLICK IT."; + } else { + "GOOGLE THE NAME OF THE PROGRAM PLUS A FEW WORDS RELATED TO WHAT YOU WANT TO DO. FOLLOW ANY INSTRUCTIONS."; + } + } + + if ("DID IT WORK?") + return "YOU'RE DONE!" + +} while("HAVE YOU BEEN TRYING THIS FOR LESS THAN AN HOUR?") + +"ASK SOMEONE FOR HELP OR GIVE UP." )source", }, }; @@ -115,8 +139,6 @@ void Shift(Draw& out, Point shift) { Shift(out.right, shift); } - -Point static_point; Point static_point_1; Point static_point_2; @@ -141,7 +163,7 @@ Draw ConnectVertically(Draw a, out.top = a.top; out.bottom = b.bottom; out.returned = b.returned; - + return out; } @@ -177,6 +199,8 @@ Draw ConnectVertically(Draw a, bottom = L'▽'; if (bottom == L'-') bottom = L'▽'; + if (bottom == L'_') + bottom = L'▽'; if (bottom == L' ') bottom = L'│'; @@ -235,7 +259,7 @@ Draw MergeBottoms(Draw draw) { int right = draw.bottom.back().x; draw.screen.DrawHorizontalLine(left, right, draw.screen.height() - 1, L'─'); - for(auto& it : draw.bottom) { + for (auto& it : draw.bottom) { draw.screen.DrawVerticalLine(it.y + 1, draw.screen.height() - 2, it.x, L'│'); auto& top = draw.screen.Pixel(it.x, it.y); @@ -263,7 +287,7 @@ Draw Parse(FlowchartParser::InstructionContext* instruction, bool is_final); Draw Parse(FlowchartParser::ProgramContext* program, bool is_final); Draw Parse(FlowchartParser::NoopContext* instruction, bool is_final); Draw Parse(FlowchartParser::WhileloopContext* whileloop, bool is_final); -// std::string Parse(FlowchartParser::DoloopContext* doloop); +Draw Parse(FlowchartParser::DoloopContext* doloop, bool is_final); Draw ParseUnmerged(FlowchartParser::ConditionContext* condition, bool is_final); @@ -357,7 +381,7 @@ std::vector Broke(std::wstring_view content) { do { right--; - } while (Broke(content, right).size() == lines_number); + } while (Broke(content, right).size() == lines_number && right >= 0); right++; return Broke(content, right); @@ -395,7 +419,7 @@ Draw Diamond(std::string content, bool is_final) { std::vector lines = Broke(content_ws); if (lines.size() % 2) { lines.push_back(L""); - std::rotate(lines.rbegin(), lines.rbegin() + 1, lines.rend()); + // std::rotate(lines.rbegin(), lines.rbegin() + 1, lines.rend()); } int width = 0; @@ -407,29 +431,29 @@ Draw Diamond(std::string content, bool is_final) { width = width + height + 2; Draw out; - out.screen.Resize(width, height+3); + out.screen.Resize(width, height + 3); - for (int x = height / 2+1; x < width - height / 2-1; ++x) { + for (int x = height / 2 + 1; x < width - height / 2 - 1; ++x) { out.screen.Pixel(x, 0) = L'_'; - out.screen.Pixel(x, height+2) = L'_'; + out.screen.Pixel(x, height + 2) = L'_'; } - for (int i = 0; i < height/2+1; ++i) { - int I = width-i-1; - out.screen.Pixel(i,1+height/2-i+0) = L'╱'; - out.screen.Pixel(i,1+height/2+i+1) = L'╲'; - out.screen.Pixel(I,1+height/2-i+0) = L'╲'; - out.screen.Pixel(I,1+height/2+i+1) = L'╱'; + for (int i = 0; i < height / 2 + 1; ++i) { + int I = width - i - 1; + out.screen.Pixel(i, 1 + height / 2 - i + 0) = L'╱'; + out.screen.Pixel(i, 1 + height / 2 + i + 1) = L'╲'; + out.screen.Pixel(I, 1 + height / 2 - i + 0) = L'╲'; + out.screen.Pixel(I, 1 + height / 2 + i + 1) = L'╱'; } - for(int i = 0; istring()), /*is_final=*/false); AddLabel(if_.screen, if_.bottom[0], L"no"); AddLabel(if_.screen, if_.right[0], L"yes"); @@ -565,8 +589,8 @@ Draw Parse(FlowchartParser::InstructionContext* instruction, bool is_final) { if (instruction->whileloop()) return Parse(instruction->whileloop(), is_final); - // if (instruction->doloop()) - // return Parse(instruction->doloop()); + if (instruction->doloop()) + return Parse(instruction->doloop(), is_final); if (instruction->group()) return Parse(instruction->group(), is_final); @@ -648,8 +672,7 @@ Draw Parse(FlowchartParser::WhileloopContext* whileloop, bool is_final) { Draw out; out.screen.Append(merged.screen, 1, 0); - out.screen.Resize(out.screen.width()+2, out.screen.height() + 1); - + out.screen.Resize(out.screen.width() + 2, out.screen.height() + 1); // --- if_left if_right ---- // | @@ -658,20 +681,21 @@ Draw Parse(FlowchartParser::WhileloopContext* whileloop, bool is_final) { // | | // ----------------------- - out.screen.DrawHorizontalLine(1, if_left.x, if_left.y, '_'); if (merged.bottom.size()) { out.screen.DrawHorizontalLine(if_right.x + 2, out.screen.width() - 2, if_right.y, '_'); - out.screen.DrawHorizontalLine(merged.bottom[0].x + 2, out.screen.width() - 1, + out.screen.DrawHorizontalLine(merged.bottom[0].x + 2, + out.screen.width() - 1, out.screen.height() - 1, L'─'); - out.screen.DrawVerticalLineComplete( - merged.bottom[0].y + 1, out.screen.height() - 2, merged.bottom[0].x + 1); - out.screen.DrawVerticalLineComplete(if_right.y+1, out.screen.height() - 1, + out.screen.DrawVerticalLineComplete(merged.bottom[0].y + 1, + out.screen.height() - 2, + merged.bottom[0].x + 1); + out.screen.DrawVerticalLineComplete(if_right.y + 1, out.screen.height() - 1, out.screen.width() - 1); out.screen.Pixel(merged.bottom[0].x + 1, out.screen.height() - 1) = L'└'; - out.screen.Pixel(out.screen.width()-1, out.screen.height() - 1) = L'┘'; + out.screen.Pixel(out.screen.width() - 1, out.screen.height() - 1) = L'┘'; auto& connector = out.screen.Pixel(merged.bottom[0].x + 1, merged.bottom[0].y); if (connector == L'─') @@ -688,6 +712,53 @@ Draw Parse(FlowchartParser::WhileloopContext* whileloop, bool is_final) { return out; } +Draw Parse(FlowchartParser::DoloopContext* doloop, bool is_final) { + Draw instruction = MergeBottoms(Parse(doloop->instruction(), is_final)); + instruction.left = {}; + instruction.right = {}; + Draw if_ = Diamond(Parse(doloop->string()), /*is_final=*/false); + Point instruction_position; + Point if_position; + Draw merged = ConnectVertically(std::move(instruction), std::move(if_), + instruction_position, if_position); + // |_______________ + // | | + //   [ ] | + // | | + // / \ if_right -- + // \ / + // | + // | + merged.left = {}; + merged.right = {}; + + AddLabel(merged.screen, merged.bottom[0], L"no"); + AddLabel(merged.screen, merged.right[0], L"yes"); + + // |___ + // | + // Add 2 empty line above + Screen merged_screen; + std::swap(merged.screen, merged_screen); + merged.screen.Resize(merged_screen.width() + 1, merged_screen.height() + 2); + merged.screen.Append(std::move(merged_screen), 0, 2); + Shift(merged, Point{0, 2}); + + merged.screen.DrawHorizontalLine(merged.right[0].x + 1, + merged.screen.width() - 1, + merged.right[0].y + 2, L'_'); + merged.screen.DrawHorizontalLine(merged.top[0].x + 1, + merged.screen.width() - 1, 1, L'─'); + merged.screen.DrawVerticalLineComplete(1, merged.right[0].y + 2, + merged.screen.width() - 1); + + merged.screen.DrawVerticalLineComplete(0, 2, merged.top[0].x); + + merged.screen.Pixel(merged.screen.width() - 1, 1) = L'╮'; + merged.screen.Pixel(merged.top[0].x + 1, 1) = L'◁'; + return merged; +} + } // namespace std::unique_ptr FlowchartTranslator() { diff --git a/test/Flowchart/doloop/output b/test/Flowchart/doloop/output index dbeb46e..d2e7446 100644 --- a/test/Flowchart/doloop/output +++ b/test/Flowchart/doloop/output @@ -1,3 +1,14 @@ -┌─────────────┐ -│Unimplemented│ -└─────────────┘ + │ + │◁────────╮ + ┌───┴──┐ │ + │arthur│ │ + └───┬──┘ │ + ┌───▽──┐ │ + │andrea│ │ + └───┬──┘ │ + ___▽____ │ + ╱ ╲ │ +╱ chocolat ╲___│ +╲ ╱yes + ╲________╱ + no diff --git a/test/Flowchart/example/output b/test/Flowchart/example/output index 5838b26..d954200 100644 --- a/test/Flowchart/example/output +++ b/test/Flowchart/example/output @@ -1,34 +1,34 @@ ┌─────┐ │start│ └──┬──┘ - _____________________ + __________▽__________ ╱ ╲ ┌──────────────┐ -╱ ╲________________________________________________________________________________________│Very expensive│ -╲ Does it cost > 1000 ? ╱yes └──────────────┘ +╱ Does it cost > 1000 ? ╲________________________________________________________________________________________│Very expensive│ +╲ ╱yes └──────────────┘ ╲_____________________╱ │no - ___________________ ___________________ + _________▽_________ ___________________ ╱ ╲ ╱ ╲ ┌──────────────┐ - ╱ ╲___________________╱ ╲_______________________________│Very expensive│ - ╲ Does it cost > 100? ╱yes ╲ Does it cost > 0.5? ╱yes └──────────────┘ + ╱ Does it cost > 100? ╲___________________╱ Does it cost > 0.5? ╲_______________________________│Very expensive│ + ╲ ╱yes ╲ ╱yes └──────────────┘ ╲___________________╱ ╲___________________╱ │no │no - __________________ ___________________ + ________▽_________ _________▽_________ ╱ ╲ ┌───────┐ ╱ ╲ ┌─────────┐ - ╱ ╲_________│Correct│ ╱ ╲____________________│expensive│ - ╲ Does it cost > 10? ╱yes └───────┘ ╲ Does it cost > 0.1? ╱yes └─────────┘ + ╱ Does it cost > 10? ╲_________│Correct│ ╱ Does it cost > 0.1? ╲____________________│expensive│ + ╲ ╱yes └───────┘ ╲ ╱yes └─────────┘ ╲__________________╱ ╲___________________╱ │no │no - _________________ ____________________ + ________▽________ _________▽__________ ╱ ╲ ┌─────┐ ╱ ╲ ┌───────┐ - ╱ ╲___│Cheap│ ╱ ╲__________│Correct│ - ╲ Does it cost > 1? ╱yes└─────┘ ╲ Does it cost > 0.01? ╱yes └───────┘ + ╱ Does it cost > 1? ╲___│Cheap│ ╱ Does it cost > 0.01? ╲__________│Correct│ + ╲ ╱yes└─────┘ ╲ ╱yes └───────┘ ╲_________________╱ ╲____________________╱ │no │no - ┌───▽──┐ _____________________ + ┌───▽──┐ __________▽__________ │coucou│ ╱ ╲ ┌─────┐ - └──────┘ ╱ ╲___│Cheap│ - ╲ Does it cost > 0.001? ╱yes└─────┘ + └──────┘ ╱ Does it cost > 0.001? ╲___│Cheap│ + ╲ ╱yes└─────┘ ╲_____________________╱ │no ┌──────▽──────┐ diff --git a/test/Flowchart/if-returned-0/output b/test/Flowchart/if-returned-0/output index a8212c8..d1f78f0 100644 --- a/test/Flowchart/if-returned-0/output +++ b/test/Flowchart/if-returned-0/output @@ -1,7 +1,7 @@ ___ ___ ╱ ╲ ╱ ╲ ┌─┐ -╱ ╲___╱ ╲___│c│ -╲ a ╱yes╲ b ╱yes└┬┘ +╱ a ╲___╱ b ╲___│c│ +╲ ╱yes╲ ╱yes└┬┘ ╲___╱ ╲___╱ │ │no │no │ ┌▽┐ ┌▽┐ │ diff --git a/test/Flowchart/if-returned-1/output b/test/Flowchart/if-returned-1/output index 62820ef..2467551 100644 --- a/test/Flowchart/if-returned-1/output +++ b/test/Flowchart/if-returned-1/output @@ -1,7 +1,7 @@ ___ ___ ╱ ╲ ╱ ╲ ┌─┐ -╱ ╲___╱ ╲___│c│ -╲ a ╱yes╲ b ╱yes└─┘ +╱ a ╲___╱ b ╲___│c│ +╲ ╱yes╲ ╱yes└─┘ ╲___╱ ╲___╱ │no │no ┌▽┐ ┌▽┐ diff --git a/test/Flowchart/if-returned-2/output b/test/Flowchart/if-returned-2/output index a58f7fa..d68a9d2 100644 --- a/test/Flowchart/if-returned-2/output +++ b/test/Flowchart/if-returned-2/output @@ -1,7 +1,7 @@ ___ ___ ╱ ╲ ╱ ╲ ┌─┐ -╱ ╲___╱ ╲___│c│ -╲ a ╱yes╲ b ╱yes└┬┘ +╱ a ╲___╱ b ╲___│c│ +╲ ╱yes╲ ╱yes└┬┘ ╲___╱ ╲___╱ │ │no │no │ ┌▽┐ ┌▽┐ │ diff --git a/test/Flowchart/if-returned-3/output b/test/Flowchart/if-returned-3/output index dfb365c..bd23732 100644 --- a/test/Flowchart/if-returned-3/output +++ b/test/Flowchart/if-returned-3/output @@ -1,7 +1,7 @@ ___ ___ ╱ ╲ ╱ ╲ ┌─┐ -╱ ╲___╱ ╲___│c│ -╲ a ╱yes╲ b ╱yes└┬┘ +╱ a ╲___╱ b ╲___│c│ +╲ ╱yes╲ ╱yes└┬┘ ╲___╱ ╲___╱ │ │no │no │ ┌▽┐ ┌▽┐ │ diff --git a/test/Flowchart/if-returned-4/output b/test/Flowchart/if-returned-4/output index 14d14f8..5b7759e 100644 --- a/test/Flowchart/if-returned-4/output +++ b/test/Flowchart/if-returned-4/output @@ -1,7 +1,7 @@ ___ ___ ╱ ╲ ╱ ╲ ┌─┐ -╱ ╲___╱ ╲___│c│ -╲ a ╱yes╲ b ╱yes└─┘ +╱ a ╲___╱ b ╲___│c│ +╲ ╱yes╲ ╱yes└─┘ ╲___╱ ╲___╱ │no │no ┌▽┐ ┌▽┐ diff --git a/test/Flowchart/if-returned-5/output b/test/Flowchart/if-returned-5/output index 0ded722..32dc4b8 100644 --- a/test/Flowchart/if-returned-5/output +++ b/test/Flowchart/if-returned-5/output @@ -1,7 +1,7 @@ ___ ___ ╱ ╲ ╱ ╲ ┌─┐ -╱ ╲___╱ ╲___│c│ -╲ a ╱yes╲ b ╱yes└┬┘ +╱ a ╲___╱ b ╲___│c│ +╲ ╱yes╲ ╱yes└┬┘ ╲___╱ ╲___╱ │ │no │no │ ┌▽┐ ┌▽┐ │ diff --git a/test/Flowchart/if-returned-6/output b/test/Flowchart/if-returned-6/output index c0c62ca..ad27643 100644 --- a/test/Flowchart/if-returned-6/output +++ b/test/Flowchart/if-returned-6/output @@ -1,7 +1,7 @@ ___ ___ ╱ ╲ ╱ ╲ ┌─┐ -╱ ╲___╱ ╲___│c│ -╲ a ╱yes╲ b ╱yes└─┘ +╱ a ╲___╱ b ╲___│c│ +╲ ╱yes╲ ╱yes└─┘ ╲___╱ ╲___╱ │no │no ┌▽┐ ┌▽┐ diff --git a/test/Flowchart/if-returned-7/output b/test/Flowchart/if-returned-7/output index 32d2259..a0dc7d7 100644 --- a/test/Flowchart/if-returned-7/output +++ b/test/Flowchart/if-returned-7/output @@ -1,7 +1,7 @@ ___ ___ ╱ ╲ ╱ ╲ ┌─┐ -╱ ╲___╱ ╲___│c│ -╲ a ╱yes╲ b ╱yes└─┘ +╱ a ╲___╱ b ╲___│c│ +╲ ╱yes╲ ╱yes└─┘ ╲___╱ ╲___╱ │no │no ┌▽┐ ┌▽┐ diff --git a/test/Flowchart/if_1/output b/test/Flowchart/if_1/output index 430c492..d2d176c 100644 --- a/test/Flowchart/if_1/output +++ b/test/Flowchart/if_1/output @@ -1,6 +1,6 @@ ___ ╱ ╲ ┌─┐ -╱ ╲___│b│ -╲ a ╱yes└─┘ +╱ a ╲___│b│ +╲ ╱yes└─┘ ╲___╱ no diff --git a/test/Flowchart/if_1_brace/output b/test/Flowchart/if_1_brace/output index 430c492..d2d176c 100644 --- a/test/Flowchart/if_1_brace/output +++ b/test/Flowchart/if_1_brace/output @@ -1,6 +1,6 @@ ___ ╱ ╲ ┌─┐ -╱ ╲___│b│ -╲ a ╱yes└─┘ +╱ a ╲___│b│ +╲ ╱yes└─┘ ╲___╱ no diff --git a/test/Flowchart/if_2/output b/test/Flowchart/if_2/output index 140328d..b6d9c60 100644 --- a/test/Flowchart/if_2/output +++ b/test/Flowchart/if_2/output @@ -1,7 +1,7 @@ ___ ╱ ╲ ┌─┐ -╱ ╲___│b│ -╲ a ╱yes└┬┘ +╱ a ╲___│b│ +╲ ╱yes└┬┘ ╲___╱ ┌▽┐ no │c│ └─┘ diff --git a/test/Flowchart/if_3/output b/test/Flowchart/if_3/output index 6bf78a6..7e0fd3a 100644 --- a/test/Flowchart/if_3/output +++ b/test/Flowchart/if_3/output @@ -1,7 +1,7 @@ ___ ╱ ╲ ┌─┐ -╱ ╲___│b│ -╲ a ╱yes└┬┘ +╱ a ╲___│b│ +╲ ╱yes└┬┘ ╲___╱ │ │no │ └─┬─────┘ diff --git a/test/Flowchart/if_with_space_condition/output b/test/Flowchart/if_with_space_condition/output index d1cdcdb..bd68ea5 100644 --- a/test/Flowchart/if_with_space_condition/output +++ b/test/Flowchart/if_with_space_condition/output @@ -1,6 +1,6 @@ ___ ╱ ╲ ┌───┐ -╱ ╲___│c d│ -╲ a b ╱yes└───┘ +╱ a b ╲___│c d│ +╲ ╱yes└───┘ ╲___╱ no diff --git a/test/Flowchart/whileloop-1/input b/test/Flowchart/whileloop-1/input new file mode 100644 index 0000000..bc63a2a --- /dev/null +++ b/test/Flowchart/whileloop-1/input @@ -0,0 +1,4 @@ +while("arthur") { + "chocolat 1" + "chocolat 2" +} diff --git a/test/Flowchart/whileloop-1/output b/test/Flowchart/whileloop-1/output new file mode 100644 index 0000000..7870d31 --- /dev/null +++ b/test/Flowchart/whileloop-1/output @@ -0,0 +1,13 @@ + ______ + ╱ ╲ + ____╱ arthur ╲_ + no ╲ ╱ │ + ╲______╱ │ + │yes │ + ┌─────▽────┐ │ + │chocolat 1│ │ + └─────┬────┘ │ + ┌─────▽────┐ │ + │chocolat 2│ │ + └─────┬────┘ │ + └──────┘ diff --git a/test/Flowchart/whileloop-2/input b/test/Flowchart/whileloop-2/input new file mode 100644 index 0000000..81020bf --- /dev/null +++ b/test/Flowchart/whileloop-2/input @@ -0,0 +1,8 @@ +while("Hungry") { + "eat"; + while("Thursty") { + "drink" + } +} + +"Sleep" diff --git a/test/Flowchart/whileloop-2/output b/test/Flowchart/whileloop-2/output new file mode 100644 index 0000000..1836ef2 --- /dev/null +++ b/test/Flowchart/whileloop-2/output @@ -0,0 +1,23 @@ + ______ + ╱ ╲ + _____╱ Hungry ╲____ + │ no ╲ ╱ │ + │ ╲______╱ │ + │ │yes │ + │ ┌─▽─┐ │ + │ │eat│ │ + │ └─┬─┘ │ + │ __▽____ │ + │ ╱ ╲ │ + │ ____╱ Thursty ╲_ │ + ││ no ╲ ╱ │ │ + ││ ╲_______╱ │ │ + ││ │yes │ │ + ││ ┌──▽──┐ │ │ + ││ │drink│ │ │ + ││ └──┬──┘ │ │ + ││ └──────┘ │ + │└──────────────────┘ +┌──▽──┐ +│Sleep│ +└─────┘ diff --git a/test/Flowchart/whileloop-return/input b/test/Flowchart/whileloop-return/input new file mode 100644 index 0000000..51d41a2 --- /dev/null +++ b/test/Flowchart/whileloop-return/input @@ -0,0 +1,7 @@ +while("arthur") { + "chocolat 1"; + "chocolat 2"; + return "coucou"; +} + +"else" diff --git a/test/Flowchart/whileloop-return/output b/test/Flowchart/whileloop-return/output new file mode 100644 index 0000000..5f959c5 --- /dev/null +++ b/test/Flowchart/whileloop-return/output @@ -0,0 +1,19 @@ + ______ + ╱ ╲ + ____╱ arthur ╲ + │ no ╲ ╱ + │ ╲______╱ + │ │yes + │ ┌─────▽────┐ + │ │chocolat 1│ + │ └─────┬────┘ + │ ┌─────▽────┐ + │ │chocolat 2│ + │ └─────┬────┘ + │ ┌───▽──┐ + │ │coucou│ + │ └──────┘ + │ +┌──▽─┐ +│else│ +└────┘ diff --git a/test/Flowchart/whileloop/output b/test/Flowchart/whileloop/output index 973b3f2..50a4377 100644 --- a/test/Flowchart/whileloop/output +++ b/test/Flowchart/whileloop/output @@ -1,7 +1,7 @@ ______ ╱ ╲ - ____╱ ╲_ - │ no ╲ arthur ╱ │ + ____╱ arthur ╲_ + │ no ╲ ╱ │ │ ╲______╱ │ │ │yes │ │ ┌─────▽────┐ │ diff --git a/test/Flowchart/xkcd-do-you-understand-flowchart-switch/input b/test/Flowchart/xkcd-do-you-understand-flowchart-switch/input deleted file mode 100644 index ad82e74..0000000 --- a/test/Flowchart/xkcd-do-you-understand-flowchart-switch/input +++ /dev/null @@ -1,35 +0,0 @@ -switch ("DO YOU UNDERSTAND FLOW CHARTS?") { - case "YES": - noop; - case "NO": { - switch ("OKAY, YOU SEE THE LINE LABELED \"YES\"?") { - case "YES": - switch ("... AND YOU CAN SEE THE ONES LABELED \"NO\"?") { - case "YES": - "GOOD" case "NO" : { - switch ("BUT YOU JUST FOLLOWED THEM TWICE?") { - case "NO": - noop; - case "YES": - noop; - } - "(THAT WASN'T A QUESTION)"; - "SCREW IT" - } - } - case "NO": - return switch ("BUT YOU SEE THE ONES LABELED \"NO\"?") { - case "YES": - "WAIT, WHAT?"; - case "NO": { - "LISTEN"; - "I HATE YOU"; - } - } - } - } -} - -"LET'S GO DRING"; -"6 DRINKS"; -"HEY, I SHOULD TRY INSTALLING FREEBSD!" diff --git a/test/Flowchart/xkcd-do-you-understand-flowchart-switch/output b/test/Flowchart/xkcd-do-you-understand-flowchart-switch/output deleted file mode 100644 index 1fd0044..0000000 --- a/test/Flowchart/xkcd-do-you-understand-flowchart-switch/output +++ /dev/null @@ -1,13 +0,0 @@ - ┌─────────────┐ - │Unimplemented│ - └──────┬──────┘ - ┌───────▽──────┐ - │LET'S GO DRING│ - └───────┬──────┘ - ┌────▽───┐ - │6 DRINKS│ - └────┬───┘ -┌─────────▽─────────┐ -│HEY, I SHOULD TRY │ -│INSTALLING FREEBSD!│ -└───────────────────┘ diff --git a/test/Flowchart/xkcd-do-you-understand-flowchart/output b/test/Flowchart/xkcd-do-you-understand-flowchart/output index 8ed36d5..e542e4f 100644 --- a/test/Flowchart/xkcd-do-you-understand-flowchart/output +++ b/test/Flowchart/xkcd-do-you-understand-flowchart/output @@ -4,13 +4,13 @@ ╲ 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│ │ │ diff --git a/test/Flowchart/xkcd-local-computer-expert/input b/test/Flowchart/xkcd-local-computer-expert/input index 252616d..7f8c0be 100644 --- a/test/Flowchart/xkcd-local-computer-expert/input +++ b/test/Flowchart/xkcd-local-computer-expert/input @@ -14,6 +14,6 @@ do { if ("DID IT WORK?") return "YOU'RE DONE!" -} while("HAVE YOU BEEN TRYING THIS FOR OVER HALF AN HOUR?") +} while("HAVE YOU BEEN TRYING THIS FOR LESS THAN AN HOUR?") "ASK SOMEONE FOR HELP OR GIVE UP." diff --git a/test/Flowchart/xkcd-local-computer-expert/output b/test/Flowchart/xkcd-local-computer-expert/output index 63111a3..dedec40 100644 --- a/test/Flowchart/xkcd-local-computer-expert/output +++ b/test/Flowchart/xkcd-local-computer-expert/output @@ -1,10 +1,41 @@ - ┌─────┐ - │START│ - └──┬──┘ - ┌──────▽──────┐ - │Unimplemented│ - └──────┬──────┘ -┌────────▽───────┐ -│ASK SOMEONE FOR │ -│HELP OR GIVE UP.│ -└────────────────┘ + ┌─────┐ + │START│ + └──┬──┘ + │ + │◁───────────────────────────────────────╮ + ____________│_____________ │ + ╱ ╲ │ + ╱ FIND A MENU ITEM OR BUTTON ╲ ┌─────────┐│ + ╱ WHICH LOOKS RELATED TO ╲_____________│CLICK IT.││ + ╲ WHAT YOU WANT TO DO. ╱yes └────┬────┘│ + ╲ ╱ │ │ + ╲__________________________╱ │ │ + │no │ │ + ________▽_________ │ │ + ╱ ╲ ┌─────────┐ │ │ + ╱ PICK ON AT RANDOM. ╲_______│CLICK IT.│ │ │ + ╲ ╱yes └────┬────┘ │ │ + ╲__________________╱ │ │ │ + │no │ │ │ +┌──────────────────▽─────────────────┐ │ │ │ +│GOOGLE THE NAME OF THE PROGRAM PLUS │ │ │ │ +│A FEW WORDS RELATED TO WHAT YOU WANT│ │ │ │ +│TO DO. FOLLOW ANY INSTRUCTIONS. │ │ │ │ +└──────────────────┬─────────────────┘ │ │ │ + └─────────┬─────────────┴──────────┘ │ + _____▽______ │ + ╱ ╲ ┌────────────┐ │ + ╱ DID IT WORK? ╲___│YOU'RE DONE!│ │ + ╲ ╱yes└────────────┘ │ + ╲____________╱ │ + │no │ + ____________▽____________ │ + ╱ ╲ │ + ╱ HAVE YOU BEEN TRYING THIS ╲________________│ + ╲ FOR LESS THAN AN HOUR? ╱yes + ╲_________________________╱ + │no + ┌────────▽───────┐ + │ASK SOMEONE FOR │ + │HELP OR GIVE UP.│ + └────────────────┘