#include "ast/ast.hpp" #include namespace fsh { void CommandNode::print(int indent) { std::string t = ""; for (int i = 0; i < indent; i++) { t += "\t"; } std::cout << t << gname() << "\n"; std::cout << t << "\tCommand_Name = " << cmd_name << "\n"; if (flag) std::cout << t << "\tFlagOpt = " << *flag << "\n"; for (const auto& x : args) std::cout << t << "\tArgs: " << x->gvalue() << " " << util::tokens[x->gtoken_type()] << "\n"; if (redirects) { auto out = redirects->goutput(); auto in = redirects->ginput(); if (in) std::cout << t << "\tinput = " << *in << "\n"; if (out) std::cout << t << "\toutput = " << *out << " " << redirects->gappend() << "\n"; } } void PipeLineNode::print(int indent) { std::string t = ""; for (int i = 0; i < indent; i++) { t += "\t"; } std::cout << t << gname() << "\n"; std::cout << "left_cmd:\n"; if (l_command) l_command->print(indent + 1); std::cout << "right_cmd:\n"; if (r_command) r_command->print(indent + 1); } void CommandLineNode::print(int indent) { std::string t = ""; for (int i = 0; i < indent; i++) { t += "\t"; } std::cout << t << gname() << "\n"; if (command) command->print(indent + 1); if (pipe) pipe->print(indent + 1); } }