Beispiel #1
0
void turing_t::simuliraj()
{
  string curr = Q0;
  triple prijelaz;
  tuple QT;

  while (1) {
    QT.first = curr;  QT.second = traka.at( head );

    if (delta.find( QT ) == delta.end()) {
      break;
    } else {
      prijelaz = delta[ QT ];

      if ( (head == MIN && prijelaz.third == "L") || ( head == MAX && prijelaz.third == "R" ) ) {
        break;
      }

      curr = prijelaz.first;
      traka[ head ] = prijelaz.second;
      head += prijelaz.third == "R" ? +1 : -1;

    }
  }

  printf("%s|%d|", curr.c_str(), head);

  for ( vit it = traka.begin(); it != traka.end(); ++it ) {
    printf("%s", it->c_str());
  }

  printf("|%d\n", (int)F.count( curr ));

  return;
}
Beispiel #2
0
constr vStrToStr(const vstr& vec_str, int spos) //spos = start position
{
    str str = "";

    for(uint i=spos; i<vec_str.size(); i++)
    {
        str += " " + vec_str.at(i); //space to show where tokens start and end
    }

    return str;
}