Skip to content
Snippets Groups Projects
Select Git revision
  • 6c18ce78d6b238d210cae1a1aa16afba76deed61
  • master default
  • cgnsUnstructured
  • partitioning
  • poppler
  • HighOrderBLCurving
  • gmsh_3_0_4
  • gmsh_3_0_3
  • gmsh_3_0_2
  • gmsh_3_0_1
  • gmsh_3_0_0
  • gmsh_2_16_0
  • gmsh_2_15_0
  • gmsh_2_14_1
  • gmsh_2_14_0
  • gmsh_2_13_2
  • gmsh_2_13_1
  • gmsh_2_12_0
  • gmsh_2_11_0
  • gmsh_2_10_1
  • gmsh_2_10_0
  • gmsh_2_9_3
  • gmsh_2_9_2
  • gmsh_2_9_1
  • gmsh_2_9_0
  • gmsh_2_8_6
26 results

OnelabParser.cpp

Blame
  • Forked from gmsh / gmsh
    Source project has a limited visibility.
    OnelabParser.cpp 49.85 KiB
    #include "OnelabClients.h"
    #include <algorithm>
    #include "mathex.h"
    
    // reserved keywords for the onelab parser
    
    namespace olkey{ 
      static std::string deflabel("onelab.tags");
      static std::string label("OL."), comment("#"), separator(";");
      static std::string line(label+"line");
      static std::string begin(label+"block");
      static std::string end(label+"endblock");
      static std::string include(label+"include");
      static std::string loader(label+"loaderName");
      static std::string message(label+"msg");
      static std::string showParam(label+"show");
      static std::string showGmsh(label+"merge");
      static std::string dump(label+"dump");
      static std::string ifcond(label+"if");
      static std::string iftrue(label+"iftrue"), ifntrue(label+"ifntrue");
      static std::string olelse(label+"else"), olendif(label+"endif");
      static std::string getValue(label+"get");
      static std::string mathex(label+"eval");
      static std::string getRegion(label+"region");
    }
    
    int extractLogic(const std::string &in, std::vector<std::string> &arguments){
      // syntax: ( argument[0], argument[1]\in{<,>,<=,>=,==,!=}, arguments[2])
      size_t pos, cursor;
      arguments.resize(0);
      cursor=0;
      if ( (pos=in.find("(",cursor)) == std::string::npos )
         OLMsg::Error("Syntax error: <%s>",in.c_str());
    
      unsigned int count=1;
      pos++; // skips '('
      cursor=pos; 
      do{
        if(in[pos]=='(') count++;
        if(in[pos]==')') count--;
        if( (in[pos]=='<') || (in[pos]=='=') || (in[pos]=='>') || (in[pos]=='!') ){
          arguments.push_back(removeBlanks(in.substr(cursor,pos-cursor)));
          if(count!=1)
    	OLMsg::Error("Syntax error: <%s>",in.c_str());
          cursor=pos;
          if(in[pos+1]=='='){
    	arguments.push_back(in.substr(cursor,2));
    	pos++;
          }
          else{
          	arguments.push_back(in.substr(cursor,1));
          }
          cursor=pos+1;
        }
        pos++;
      } while( count && (pos!=std::string::npos) );
      // count is 0 when the closing brace is found. 
    
      if(count)
        OLMsg::Error("Syntax error: mismatched parenthesis in <%s>",in.c_str());
      else
        arguments.push_back(removeBlanks(in.substr(cursor,pos-1-cursor)));
    
      if((arguments.size()!=1) && (arguments.size()!=3))
        OLMsg::Error("Syntax error: <%s>",in.c_str());
      return arguments.size();
    }
    
    // Client member functions defined here because they use parser commands