<commit_before>#ifndef XQP_SPECIFICATON
#define XQP_SPECIFICATON

#include <vector>
#include <string>

#include <boost/spirit.hpp>
#include <boost/bind.hpp>

using namespace boost::spirit;
using namespace phoenix;
using namespace boost;

class Specification
{
  typedef char char_t;
  typedef file_iterator <char_t> iterator_t;
  typedef scanner<iterator_t> scanner_t;
  typedef rule<scanner_t> rule_t;

public:
  struct Variable {
    bool theInline;
    std::string theVarName, theVarValue;
  };

  Specification() : theInline(false) {}

private:
  bool theInline;
  std::string theVarName, theVarValue;
  std::vector<Variable> theVariables;
  std::vector<std::string> theErrors;

  void setInline(iterator_t, iterator_t) {
    theInline = true;
  }

  void setVarName(iterator_t str, iterator_t end) {
    theVarName = std::string(str, end);
  }

  void setVarValue(iterator_t str, iterator_t end) {
    theVarValue = std::string(str, end);
  }

  void addVariable(iterator_t str, iterator_t end) {
    Variable args = { theInline, theVarName, theVarValue};
    theVariables.push_back(args);
  }

  void addError(iterator_t str, iterator_t end) {
    std::string s(str, end);
    theErrors.push_back(s);
  }

public:
  std::vector<Variable>::const_iterator
  variablesBegin() { return theVariables.begin(); }
  std::vector<Variable>::const_iterator
  variablesEnd()   { return theVariables.end(); }

  std::vector<std::string>::const_iterator
  errorsBegin() { return theErrors.begin(); }
  std::vector<std::string>::const_iterator
  errorsEnd()    { return theErrors.end(); }

  size_t
  variablesSize() { return theVariables.size(); }

  size_t
  errorsSize() { return theErrors.size(); }

  bool
  parseFile(std::string str)
  {
    rule_t props
      = (+(graph_p & ~ch_p(':') & ~ch_p('=')))[bind(&Specification::setVarName, this, _1, _2)]
      >> str_p("=")[bind(&Specification::setInline, this, _1, _2)]
      >> (+graph_p)[bind(&Specification::setVarValue, this, _1, _2)];

    rule_t propsInline
      = (+(graph_p & ~ch_p(':') & ~ch_p('=')))[bind(&Specification::setVarName, this, _1, _2)]
      >> str_p(":=") 
      >> (+graph_p)[bind(&Specification::setVarValue, this, _1, _2)];
    
    rule_t argument 
      =  str_p("Args:") 
      >> +(
            blank_p
         && str_p("-x")
         && blank_p
         && (props | propsInline)[bind(&Specification::addVariable, this, _1, _2)]
         )
      >> !eol_p;

    rule_t error  
      =  str_p("Error:") 
      >> !blank_p
      >> (*print_p)[bind(&Specification::addError, this, _1, _2)] 
      >> !eol_p;

    rule_t defs = *( argument | error );

    iterator_t first(str.c_str());
    if (!first)
      return false;

    iterator_t last = first.make_end();

    return boost::spirit::parse(first, last, defs).full; 
  }
};
#endif
<commit_msg>removed using namespace from header file<commit_after>#ifndef XQP_SPECIFICATON
#define XQP_SPECIFICATON

#include <vector>
#include <string>

#include <boost/spirit.hpp>
#include <boost/bind.hpp>

class Specification
{
  typedef char char_t;
  typedef boost::spirit::file_iterator <char_t> iterator_t;
  typedef boost::spirit::scanner<iterator_t> scanner_t;
  typedef boost::spirit::rule<scanner_t> rule_t;

public:
  struct Variable {
    bool theInline;
    std::string theVarName, theVarValue;
  };

  Specification() : theInline(false) {}

private:
  bool theInline;
  std::string theVarName, theVarValue;
  std::vector<Variable> theVariables;
  std::vector<std::string> theErrors;

  void setInline(iterator_t, iterator_t) {
    theInline = true;
  }

  void setVarName(iterator_t str, iterator_t end) {
    theVarName = std::string(str, end);
  }

  void setVarValue(iterator_t str, iterator_t end) {
    theVarValue = std::string(str, end);
  }

  void addVariable(iterator_t str, iterator_t end) {
    Variable args = { theInline, theVarName, theVarValue};
    theVariables.push_back(args);
  }

  void addError(iterator_t str, iterator_t end) {
    std::string s(str, end);
    theErrors.push_back(s);
  }

public:
  std::vector<Variable>::const_iterator
  variablesBegin() { return theVariables.begin(); }
  std::vector<Variable>::const_iterator
  variablesEnd()   { return theVariables.end(); }

  std::vector<std::string>::const_iterator
  errorsBegin() { return theErrors.begin(); }
  std::vector<std::string>::const_iterator
  errorsEnd()    { return theErrors.end(); }

  size_t
  variablesSize() { return theVariables.size(); }

  size_t
  errorsSize() { return theErrors.size(); }

  bool
  parseFile(std::string str)
  {
    rule_t props
      = (+(boost::spirit::graph_p & ~boost::spirit::ch_p(':') & ~boost::spirit::ch_p('=')))[bind(&Specification::setVarName, this, _1, _2)]
      >> boost::spirit::str_p("=")[bind(&Specification::setInline, this, _1, _2)]
      >> (+boost::spirit::graph_p)[bind(&Specification::setVarValue, this, _1, _2)];

    rule_t propsInline
      = (+(boost::spirit::graph_p & ~boost::spirit::ch_p(':') & ~boost::spirit::ch_p('=')))[bind(&Specification::setVarName, this, _1, _2)]
      >> boost::spirit::str_p(":=") 
      >> (+boost::spirit::graph_p)[bind(&Specification::setVarValue, this, _1, _2)];
    
    rule_t argument 
      =  boost::spirit::str_p("Args:") 
      >> +(
            boost::spirit::blank_p
         && boost::spirit::str_p("-x")
         && boost::spirit::blank_p
         && (props | propsInline)[bind(&Specification::addVariable, this, _1, _2)]
         )
      >> !boost::spirit::eol_p;

    rule_t error  
      =  boost::spirit::str_p("Error:") 
      >> !boost::spirit::blank_p
      >> (*boost::spirit::print_p)[bind(&Specification::addError, this, _1, _2)] 
      >> !boost::spirit::eol_p;

    rule_t defs = *( argument | error );

    iterator_t first(str.c_str());
    if (!first)
      return false;

    iterator_t last = first.make_end();

    return boost::spirit::parse(first, last, defs).full; 
  }
};
#endif

{'fraction_non_alphanumeric': 0.1603311370163879, 'fraction_numerical': 0.004730528805541477, 'mean_word_length': 4.008460236886632, 'pattern_counts': {'":': 2, '<': 29, '<?xml version=': 0, '>': 65, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '892000', 'n_tokens_mistral': 2106, 'n_tokens_neox': 2029, 'n_words': 382}