tool.cpp

来自「一个语法分析程序,C++写的,内含原码和exe文件. 开发工具:DEV-C」· C++ 代码 · 共 68 行

CPP
68
字号
/*
Some tool functions 
using very simple linear algorithm 
*/
#include "global.h"

void print(list<string>& l)
{
  list<string>::iterator iter = l.begin();
  while(iter != l.end())
   cout << *iter++ << " ";
   cout << endl;
}

void removeDup(list<string>& l)
{
  string hold;
list<string>::iterator sIter,pIter;
  pIter = l.begin();
while(pIter != l.end()){
  hold = *pIter;
  sIter = pIter;
  sIter++;
  while(sIter != l.end())
   if(*sIter == hold)
     l.erase(sIter++);
   else sIter++; 
   pIter++;
}
}

bool isIn(string target,list<string>& s) // to decide whether a symbol is a terminal symbol or 
                                          // non-terminal symbol 
{   // or for something judgement in later procession
   // sequencial search , only for small instance :)
    // I am not quite sophlicated in algorithm 
   list<string>::iterator iter = s.begin();
while(iter != s.end()){
   if(*iter == target)
   return true;
   iter++;
  }      
  return false;
}

void listToString(string& s,list<string> l)
{
// the string has fixed ... 
  list<string>::iterator iter;
  for(iter = l.begin();iter != l.end();iter++){
      s.append(*iter); // append to the string
      s.append(" ");
      }
}
void noRightReserve()
{
// holding for later usage
   cout << "***********************************" << endl;
   cout << "* LL(1) parsing version 0.5 " << endl;
   cout << "***********************************" << endl;
  cout << "\n\n\n*Me aNd FlOwEr ArE LiViG HaPPiLY Now\n";
  cout << "* AnD HoW MuCh We LoVe ThIs WoRlD\n";
  cout << "* Mathematics Worm Association" << endl;
  cout << "           * Math Frog  6.8.2005 " << endl;
  cout << "                @ No Right Reserve" << endl;
  cout << "***********************************" << endl;
  } 

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?