hawxgamer

Untitled

Nov 25th, 2013
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.33 KB | None | 0 0
  1. //im parserfactory
  2.  
  3. static std::string const grammarfail="";    //added
  4. static unsigned int minimumlength=2;    //added
  5.  
  6. struct TVariable
  7. {
  8.     std::string tvar;
  9.     std::string ttype;
  10. };
  11.  
  12. //parserfactory
  13.  
  14. //im ecsymbolfactory header
  15.  
  16. static std::string const IECTypeName="TYPE";
  17. static std::string const IECVarName="VAR";
  18. TVariable CheckVariable(std::string const & typeline);
  19. //im iecsymbolfactory cpp
  20. TVariable IECSymbolFactory::CheckVariable(std::string const & typeline)
  21. {
  22.     unsigned int found=0;
  23.     unsigned int colonpos=0;
  24.  
  25.     TVariable tvar;
  26.     if(typeline.find(IECVarName) !=typeline.npos && typeline.find(';') !=typeline.npos)
  27.     {
  28.         found=typeline.find_first_of(' ');
  29.         colonpos=typeline.find_first_of(':');
  30.         tvar.ttype=typeline.substr(found+1,colonpos-2);
  31.         tvar.tvar=typeline.substr(colonpos+2, typeline.size()-1);
  32.     }
  33.     else
  34.     {
  35.         tvar.ttype="";
  36.         tvar.tvar="";
  37.     }
  38.  
  39.     return tvar;
  40. }
  41.  
  42. //im javafactory
  43.  
  44. TVariable javafactory::CheckVariable(std::string const & typeline)
  45. {
  46.     unsigned int found=0;
  47.     TVariable tvar;
  48.     if(typeline.find_first_of(' ') == typeline.find_last_of(' ') && typeline.at(typeline.size())==';')
  49.     {
  50.         found=typeline.find_first_of(' ');
  51.         tvar.ttype=typeline.substr(0,found-1);
  52.         tvar.tvar=typeline.substr(found+1, typeline.size()-1);
  53.     }
  54.     else
  55.     {
  56.     tvar.ttype="";
  57.     tvar.tvar="";
  58.     }
  59.  
  60.     return tvar;
  61. }
Advertisement
Add Comment
Please, Sign In to add comment