<commit_before>#include <string>
#include "compiler/parsetree/parsenodes.h"
#include "parsertestdriverconfig.h" // SRC and BIN dir definitions
#include "compiler/parser/xquery_driver.h"

using namespace zorba;

int
#ifdef _WIN32_WCE
_tmain(int argc, _TCHAR* argv[])
#else
main(int argc, char** argv)
#endif
{
  std::string lQueryFileString;
  xquery_driver lDriver;
  // do initial stuff
  if ( argc == 2 )
  {
    lQueryFileString  = zorba::PARSER_TEST_SRC_DIR +"/Queries/" + argv[1];
    std::string lQueryWithoutSuffix = std::string(argv[1]).substr( 0, std::string(argv[1]).size()-3 );

    std::cout << "parsertest " << lQueryWithoutSuffix << std::endl;
  }
  else
  {
    std::cerr << std::endl << "usage:   parsertestdriver [testfile]" << std::endl;
    return 1;
  }

  // TODO correct Exception handling with try-catch
  try {
    lDriver.parse_file(lQueryFileString.c_str());
  } catch (...) {
    return 2;
  }

  parsenode* lNode = lDriver.get_expr();
  if ( lNode == 0 ) {
    std::cerr << "Query parsed but no parsenode root generated!" << std::endl;
    return 3;
  } else {
    delete lNode;
  }

  return 0;
}<commit_msg>fixing valgrind errors<commit_after>#include <string>
#include "compiler/parsetree/parsenodes.h"
#include "parsertestdriverconfig.h" // SRC and BIN dir definitions
#include "compiler/parser/xquery_driver.h"
#include "system/globalenv.h"

using namespace zorba;

int
#ifdef _WIN32_WCE
_tmain(int argc, _TCHAR* argv[])
#else
main(int argc, char** argv)
#endif
{
  GlobalEnvironment::init(); 
  std::string lQueryFileString;
  xquery_driver lDriver;
  // do initial stuff
  if ( argc == 2 )
  {
    lQueryFileString  = zorba::PARSER_TEST_SRC_DIR +"/Queries/" + argv[1];
    std::string lQueryWithoutSuffix = std::string(argv[1]).substr( 0, std::string(argv[1]).size()-3 );

    std::cout << "parsertest " << lQueryWithoutSuffix << std::endl;
  }
  else
  {
    std::cerr << std::endl << "usage:   parsertestdriver [testfile]" << std::endl;
    return 1;
  }

  // TODO correct Exception handling with try-catch
  try {
    lDriver.parse_file(lQueryFileString.c_str());
  } catch (...) {
    GlobalEnvironment::destroy();
    return 2;
  }

  parsenode* lNode = lDriver.get_expr();
  if ( lNode == 0 ) {
    std::cerr << "Query parsed but no parsenode root generated!" << std::endl;
    GlobalEnvironment::destroy();
    return 3;
  } else {
    delete lNode;
  }

  GlobalEnvironment::destroy();
  return 0;
}
{'fraction_non_alphanumeric': 0.15104379860826853, 'fraction_numerical': 0.010642652476463364, 'mean_word_length': 3.8300395256916997, 'pattern_counts': {'":': 0, '<': 37, '<?xml version=': 0, '>': 5, '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': '3082334', 'n_tokens_mistral': 890, 'n_tokens_neox': 861, 'n_words': 196}