Skip to content
Snippets Groups Projects
Select Git revision
  • c6a065dcd256c450949c5a03c81737d1978667c3
  • 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

GUI_Extras.cpp

Blame
  • Forked from gmsh / gmsh
    Source project has a limited visibility.
    OnelabParser.cpp 43.16 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 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 enclosed(const std::string &in, std::vector<std::string> &arguments,
    	     int &end){
      // syntax: (arguments[Ø], arguments[1], ... , arguments[n])
      // arguments[i] may contain parenthesis
      int pos, cursor;
      arguments.resize(0);
      cursor=0;
      if ( (pos=in.find("(",cursor)) == std::string::npos )
         OLMsg::Fatal("Syntax error: <%s>",in.c_str());
    
      if (pos>0){
        std::cout << pos << in << std::endl;
         OLMsg::Fatal("Syntax error: <%s>",in.c_str());
      }
      unsigned int count=1;
      pos++; // skips '('
      cursor = pos; 
      do{
        if(in[pos]=='(') count++;
        else if(in[pos]==')') count--;
        else if(in[pos]==',' && (count==1)) {
          arguments.push_back(removeBlanks(in.substr(cursor,pos-cursor)));
          if(count!=1)
    	OLMsg::Fatal("Syntax error: mismatched parenthesis <%s>",in.c_str());
          cursor=pos+1; // skips ','
        }
        else if(in[pos]==';') 
    	OLMsg::Fatal("Syntax error: unterminated sentence <%s>",in.c_str());
    
        pos++;
      } while( count && (pos!=std::string::npos) );
      // count is 0 when the closing brace is found. 
    
      if(count)
         OLMsg::Fatal("Syntax error: <%s>",in.c_str());
      else
        arguments.push_back(removeBlanks(in.substr(cursor,pos-1-cursor)));
      end=pos;
      return arguments.size();
    }
    
    int extractLogic(const std::string &in, std::vector<std::string> &arguments){
      // syntax: ( argument[0], argument[1]\in{<,>,<=,>=,==,!=}, arguments[2])
      int pos, cursor;
      arguments.resize(0);