Skip to content

Commit

Permalink
-fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Ingenious-c0der committed Feb 14, 2023
1 parent fd3ea74 commit f9cd80d
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions src/components/machine.h
Original file line number Diff line number Diff line change
Expand Up @@ -271,8 +271,16 @@ bool Machine::run()
{
for (int i = 0; i < transitions.size(); i++)
{

if (transitions[i].does_match(currentState, getSymbol(ref_tapes[current_tape_index]->get_current()), *ref_tapes[current_tape_index]))
Symbol current_symbol = getSymbol(ref_tapes[current_tape_index]->get_current());
if (current_symbol.subtype == Subtype::DOLLAR_SYMBOL)
{

completed = true;
rejected = true;
std::cout << "Unexpectedly hit the hard tape end : '$' on tape " << transitions[i].currentTape.name << " while trying to move in " << transitions[i].Direction.name << " direction , to resolve this error refer https://github.com/Ingenious-c0der/Beluga/blob/master/documentation.md#---dollar-symbol " << std::endl;
break;
}
else if (transitions[i].does_match(currentState, current_symbol, *ref_tapes[current_tape_index]))
{
matched = true;
if (ignore_unknowns)
Expand All @@ -282,6 +290,7 @@ bool Machine::run()
else
{
Symbol s = getSymbol(transitions[i].output_symbol.name); // added symbol existence check

if (s.subtype == Subtype::DOLLAR_SYMBOL)
{
completed = true;
Expand Down Expand Up @@ -322,7 +331,7 @@ bool Machine::run()
{
if (relay.relay_to_console_on_reject)
{
std::cout << name << " (Reject) : " << std::endl;
std::cout << name << " (Rejected) : " << std::endl;
for (int i = 0; i < ref_tapes.size(); i++)
{
std::cout << ref_tapes[i]->name << " : " << ref_tapes[i]->display() << std::endl;
Expand All @@ -333,7 +342,7 @@ bool Machine::run()
{
if (relay.relay_to_console_on_accept)
{
std::cout << name << " (Accept) : " << std::endl;
std::cout << name << " (Accepted) : " << std::endl;
for (int i = 0; i < ref_tapes.size(); i++)
{
std::cout << ref_tapes[i]->name << " : " << ref_tapes[i]->display() << std::endl;
Expand Down

0 comments on commit f9cd80d

Please sign in to comment.