Skip to content
Snippets Groups Projects
Select Git revision
  • 0691b08303c200b69490a1c48b4adf2e944d255e
  • master default protected
  • 6.x protected
  • madysson
  • 5.x protected
  • asm
  • time-varying-information-set
  • 4.6 protected
  • dynare_minreal
  • dragonfly
  • various_fixes
  • 4.5 protected
  • clang+openmp
  • exo_steady_state
  • declare_vars_in_model_block
  • julia
  • error_msg_undeclared_model_vars
  • static_aux_vars
  • slice
  • aux_func
  • penalty
  • 6.4 protected
  • 6.3 protected
  • 6.2 protected
  • 6.1 protected
  • 6.0 protected
  • 6-beta2 protected
  • 6-beta1 protected
  • 5.5 protected
  • 5.4 protected
  • 5.3 protected
  • 5.2 protected
  • 5.1 protected
  • 5.0 protected
  • 5.0-rc1 protected
  • 4.7-beta3 protected
  • 4.7-beta2 protected
  • 4.7-beta1 protected
  • 4.6.4 protected
  • 4.6.3 protected
  • 4.6.2 protected
41 results

csv_parser.cpp

Blame
  • csv_parser.cpp 1017 B
    #include "csv_parser.h"
    #include "parser_exception.h"
    #include "location.h"
    #include "csv_tab.hh"
    #include <cstring>
    
    using namespace ogp;
    
    /** A global symbol for passing info to the CSVParser from
     * csv_parse(). */
    CSVParser* csv_parser;
    
    /** The declaration of functions defined in csv_ll.cc and
     * csv_tab.cc generated from csv.lex and csv.y. */
    void* csv__scan_buffer(char*, unsigned int);
    void csv__destroy_buffer(void*);
    int csv_parse();
    
    extern ogp::location_type csv_lloc;
    
    void CSVParser::csv_error(const char* mes)
    {
    	throw ParserException(mes, csv_lloc.off);
    }
    
    void CSVParser::csv_parse(int length, const char* str)
    {
    	// allocate temporary buffer and parse
    	char* buffer = new char[length+2];
    	strncpy(buffer, str, length);
    	buffer[length] = '\0';
    	buffer[length+1] = '\0';
    	csv_lloc.off = 0;
    	csv_lloc.ll = 0;
    	parsed_string = buffer;
    	void* p = csv__scan_buffer(buffer, (unsigned int)length+2);
    	csv_parser = this;
    	::csv_parse();
    	delete [] buffer;
    	csv__destroy_buffer(p);
    	parsed_string = NULL;
    }