This repository has been archived on 2022-11-26. You can view files and clone it, but cannot push or open issues or pull requests.
turing/utils/print.cpp
2022-11-26 05:03:22 +01:00

18 lines
No EOL
577 B
C++

#include <iostream>
#include "../turing.cpp"
/**
* @brief Prints debug-like information about provided machine
*/
template <typename S, typename V>
void print(Turing::Machine<S, V>* machine) {
machine->ensure();
std::cout << "rc:" << machine->runCount << ", st:" << machine->getState() << '\n';
for (int i = machine->getMemoryStart(); i < machine->getMemoryEnd(); i++)
std::cout << (machine->at(i));
std::cout << '\n';
for (int i = machine->getMemoryStart(); i < machine->getPosition(); i++)
std::cout << ' ';
std::cout << "^\n\n";
}