//Prompt the user for a file, create a finite automaton Map, and print it. //Prompt the user for a file containing any number of simulation descriptions // for the finite automaton to process, one description per line; each // description contains a start state followed by its inputs, all separated by // semicolons. //Repeatedly read a description, print that description, put each input in a // Queue, process the Queue and print the results in a nice form. int main() { try { std::ifstream fa_file; ics::safe_open(fa_file,"Enter the name of a file with a Finite Automaton","faparity.txt"); std::cout << std::endl; const FA fa = read_fa(fa_file); print_fa(fa); std::cout << std::endl; std::ifstream inputs_file; std::string line; ics::safe_open(inputs_file,"Enter the name of a file with the start-state and input","fainputparity.txt"); while (getline(inputs_file, line)){ std::cout << std::endl; InputsQueue inputsQueue; std::vector<std::string> words = ics::split(line, ";"); const std::string& startState = words[0]; std::cout << "Starting new simulation with description: " << line; for (auto i = words.begin() + 1; i != words.end(); i++) { inputsQueue.enqueue(*i); } TransitionQueue transitionQueue = process(fa, startState, inputsQueue); interpret(transitionQueue); } } catch (ics::IcsError& e) { std::cout << e.what() << std::endl; } return 0; }
int main () { //Prompt the user for a file, create a finite automaton Map, and print it. //Prompt the user for a file containing any number of simulation descriptions // for the finite automaton to process, one description per line; each // description contains a start state followed by inputs, all separated by // semicolons. //Repeatedly read a description, print that description, put each input in a // Queue, process the Queue and print the results in a nice form. try { std::ifstream file; ics::safe_open(file, "Enter file name of Finite Automaton", "faparity.txt"); FA fa = read_fa(file); print_fa(fa); std::ifstream inputs_file; ics::safe_open(inputs_file, "\nEnter file name of start-states and inputs", "fainputparity.txt"); std::string line; while (getline(inputs_file, line)) { std::vector<std::string> line_as_vector = ics::split(line, ";"); State state = line_as_vector[0]; InputsQueue iq; for (std::vector<std::string>::iterator it = line_as_vector.begin()+1; it != line_as_vector.end(); ++it) iq.enqueue(*it); TransitionQueue tq = process(fa, state, iq); std::cout << "\nStarting new simulation with description: " << line << std::endl; interpret(tq); } } catch (ics::IcsError& e) { std::cout << e.what() << std::endl; } return 0; }