Commit bede6807 authored by Pascal Noisette's avatar Pascal Noisette
Browse files

Le test du deuximeme parser _compile_. Qq trucs a debuger encore...

parent 95823202
......@@ -12,7 +12,8 @@
#include "../../trace/src/values/Integer.hpp"
#include "../../trace/src/values/Name.hpp"
#include "../../trace/src/values/String.hpp"
#include "../tests/stub/trace.hpp"
#include "../tests/stub/trace.hpp"
/**
* \class ParserEventDecoder
......
......@@ -13,15 +13,20 @@ using namespace std;
static std::string res;
std::string& to_string(const vector<Value*> &opt){
res = "option(" ;
for (int i=0;i<opt.size();i++)
res.append(opt[i]->to_string() + " ");
res.append(")");
return res;
if (opt.size()>0){
res = "option(" ;
for (int i=0;i<opt.size();i++)
res.append(opt[i]->to_string() + " ");
res.append(")");
}
else{
res.assign("\0");
}
return res;
}
void define_container_type(Name alias, ContainerType *container_type_parent, const vector<Value*> &opt){
void Trace::define_container_type(Name alias, ContainerType *container_type_parent, const vector<Value*> &opt){
cout << "define_container_type "
<< alias.to_string()
<< " "
......@@ -33,7 +38,7 @@ void define_container_type(Name alias, ContainerType *container_type_parent, con
void create_container(Date time, Name alias, ContainerType *type, Container *parent, const vector<Value*> &opt){
void Trace::create_container(Date time, Name alias, ContainerType *type, Container *parent, const vector<Value*> &opt){
cout << "create_container "
<< time.to_string()
<< " "
......@@ -49,7 +54,7 @@ void define_container_type(Name alias, ContainerType *container_type_parent, con
void destroy_container(Date time, Name alias, ContainerType *type, const vector<Value*> &opt){
void Trace::destroy_container(Date time, Name alias, ContainerType *type, const vector<Value*> &opt){
cout << "destroy_container "
<< time.to_string()
<< " "
......@@ -62,7 +67,7 @@ void define_container_type(Name alias, ContainerType *container_type_parent, con
}
void define_event_type(Name alias, ContainerType *container_type, const vector<Value*> &opt){
void Trace::define_event_type(Name alias, ContainerType *container_type, const vector<Value*> &opt){
cout << "define_event_type "
<< alias.to_string()
<< " "
......@@ -74,7 +79,7 @@ void define_container_type(Name alias, ContainerType *container_type_parent, con
void define_state_type(Name alias, ContainerType *container_type, const vector<Value*> &opt){
void Trace::define_state_type(Name alias, ContainerType *container_type, const vector<Value*> &opt){
cout << "define_state_type "
<< alias.to_string()
<< " "
......@@ -85,7 +90,7 @@ void define_container_type(Name alias, ContainerType *container_type_parent, con
}
void define_variable_type(Name alias, ContainerType *container_type, const vector<Value*> &opt){
void Trace::define_variable_type(Name alias, ContainerType *container_type, const vector<Value*> &opt){
cout << "define_variable_type "
<< alias.to_string()
<< " "
......@@ -97,7 +102,7 @@ void define_container_type(Name alias, ContainerType *container_type_parent, con
void define_link_type(Name alias, ContainerType *ancestor, ContainerType *source, ContainerType *destination, const vector<Value*> &opt){
void Trace::define_link_type(Name alias, ContainerType *ancestor, ContainerType *source, ContainerType *destination, const vector<Value*> &opt){
cout << "define_link_type "
<< alias.to_string()
<< " "
......@@ -113,7 +118,7 @@ void define_container_type(Name alias, ContainerType *container_type_parent, con
void define_entity_value(Name alias, EntityType *entity_type, const vector<Value*> &opt){
void Trace::define_entity_value(Name alias, EntityType *entity_type, const vector<Value*> &opt){
cout << "define_entity_value "
<< alias.to_string()
<< " "
......@@ -125,7 +130,7 @@ void define_container_type(Name alias, ContainerType *container_type_parent, con
void set_state(Date time, StateType *type, Container *container, EntityValue *value, const vector<Value*> &op){
void Trace::set_state(Date time, StateType *type, Container *container, EntityValue *value, const vector<Value*> &op){
cout << "set_state "
<< time.to_string()
<< " "
......@@ -141,7 +146,7 @@ void set_state(Date time, StateType *type, Container *container, EntityValue *va
void push_state(Date time, StateType *type, Container *container, EntityValue *value, const vector<Value*> &opt){
void Trace::push_state(Date time, StateType *type, Container *container, EntityValue *value, const vector<Value*> &opt){
cout << "push_state "
<< time.to_string()
<< " "
......@@ -157,7 +162,7 @@ void push_state(Date time, StateType *type, Container *container, EntityValue *v
void pop_state(Date time, StateType *type, Container *container, const vector<Value*> &opt){
void Trace::pop_state(Date time, StateType *type, Container *container, const vector<Value*> &opt){
cout << "pop_state "
<< time.to_string()
......@@ -172,7 +177,7 @@ void pop_state(Date time, StateType *type, Container *container, const vector<Va
void new_event(Date time, EventType *type, Container *container, EntityValue *value, const vector<Value*> &opt){
void Trace::new_event(Date time, EventType *type, Container *container, EntityValue *value, const vector<Value*> &opt){
cout << "new_event "
<< time.to_string()
<< " "
......@@ -188,7 +193,7 @@ void new_event(Date time, EventType *type, Container *container, EntityValue *va
void set_variable(Date time, VariableType *type, Container *container, Double value, const vector<Value*> &opt){
void Trace::set_variable(Date time, VariableType *type, Container *container, Double value, const vector<Value*> &opt){
cout << "set_variable "
<< time.to_string()
......@@ -204,7 +209,7 @@ void set_variable(Date time, VariableType *type, Container *container, Double va
}
void add_variable(Date time, VariableType *type, Container *container, Double value, const vector<Value*> &opt){
void Trace::add_variable(Date time, VariableType *type, Container *container, Double value, const vector<Value*> &opt){
cout << "add_variable "
<< time.to_string()
......@@ -221,7 +226,7 @@ void add_variable(Date time, VariableType *type, Container *container, Double va
void sub_variable(Date time, VariableType *type, Container *container, Double value, const vector<Value*> &opt){
void Trace::sub_variable(Date time, VariableType *type, Container *container, Double value, const vector<Value*> &opt){
cout << "sub_variable "
<< time.to_string()
......@@ -237,7 +242,7 @@ void sub_variable(Date time, VariableType *type, Container *container, Double va
}
void start_link(Date time, LinkType *type, Container *ancestor, Container *source, EntityValue value, Integer key, const vector<Value*> &opt){
void Trace::start_link(Date time, LinkType *type, Container *ancestor, Container *source, EntityValue value, Integer key, const vector<Value*> &opt){
cout << "start_link "
<< time.to_string()
......@@ -258,7 +263,7 @@ void start_link(Date time, LinkType *type, Container *ancestor, Container *sourc
void end_link(Date time, LinkType *type, Container *ancestor, Container *destination, EntityValue *value, Integer key, const vector<Value*> &opt){
void Trace::end_link(Date time, LinkType *type, Container *ancestor, Container *destination, EntityValue *value, Integer key, const vector<Value*> &opt){
cout << "start_link "
<< time.to_string()
......@@ -281,14 +286,14 @@ void end_link(Date time, LinkType *type, Container *ancestor, Container *destina
Container *search_container_type(String name)
Container *Trace::search_container_type(String name)
{
res = "search(" + name.to_string() + ")";
return &res;
}
Container *search_container(String name)
Container *Trace::search_container(String name)
{
res = "search(" + name.to_string() + ")";
return &res;
......@@ -296,7 +301,7 @@ void end_link(Date time, LinkType *type, Container *ancestor, Container *destina
Container *search_event_type(String name)
Container *Trace::search_event_type(String name)
{
res = "search(" + name.to_string() + ")";
return &res;
......@@ -304,7 +309,7 @@ void end_link(Date time, LinkType *type, Container *ancestor, Container *destina
Container *search_state_type(String name)
Container *Trace::search_state_type(String name)
{
res = "search(" + name.to_string() + ")";
return &res;
......@@ -313,26 +318,26 @@ void end_link(Date time, LinkType *type, Container *ancestor, Container *destina
Container *search_variable_type(String name) {
Container *Trace::search_variable_type(String name) {
res = "search(" + name.to_string() + ")";
return &res;
}
Container *search_link_type(String name) {
Container *Trace::search_link_type(String name) {
res = "search(" + name.to_string() + ")";
return &res;
}
Container *search_entity_value(String name) {
Container *Trace::search_entity_value(String name) {
res = "search(" + name.to_string() + ")";
return &res;
}
Container *search_entity_type(String name)
Container *Trace::search_entity_type(String name)
{
res = "search(" + name.to_string() + ")";
return &res;
......
......@@ -29,7 +29,7 @@ typedef std::string EntityValue;
typedef std::string EventType;
typedef std::string VariableType;
typedef std::string LinkType;
typedef std::string Container;
class Trace{
......@@ -277,7 +277,7 @@ public :
* \brief search a container type by his name or alias
*
*/
Container *search_container_type(String name) const;
Container *search_container_type(String name) ;
/*!
*
......@@ -285,7 +285,7 @@ public :
* \brief search a container by his name or alias
*
*/
Container *search_container(String name) const;
Container *search_container(String name) ;
/*!
*
......@@ -293,7 +293,7 @@ public :
* \brief search a event type by his name or alias
*
*/
Container *search_event_type(String name) const;
Container *search_event_type(String name) ;
/*!
......@@ -302,7 +302,7 @@ public :
* \brief search a container by his name or alias
*
*/
Container *search_state_type(String name) const;
Container *search_state_type(String name) ;
/*!
......@@ -311,7 +311,7 @@ public :
* \brief search a variable type by his name or alias
*
*/
Container *search_variable_type(String name) const;
Container *search_variable_type(String name) ;
/*!
......@@ -320,16 +320,14 @@ public :
* \brief search a container by his name or alias
*
*/
VariableType *search_link_type(String name) const;
/*!
VariableType *search_link_type(String name); /*!
*
* \fn search_entity_value
* \brief search a container by his name or alias
*
*/
Container *search_entity_value(String name) const;
Container *search_entity_type(String name) const;
Container *search_entity_value(String name) ;
Container *search_entity_type(String name) ;
};//end class
......
#include "../src/Line.hpp"
#include "../src/ParserDefinitionDecoder.hpp"
#include "../src/ParserDefinitionDecoder.hpp"
#include "../tests/stub/trace.hpp"
#include <iostream>
#include <fstream>
......
#include "../src/Line.hpp"
#include "../src/ParserDefinitionDecoder.hpp"
#include "../src/ParserEventDecoder.hpp"
#include "../tests/stub/trace.hpp"
#include <iostream>
#include <fstream>
#define DIE_IF(condition,message) if (condition){ \
cout << message << endl; \
return 0;}
using namespace std;
int main(int argc, char **argv){
ParserDefinitionDecoder *parserdefinition = new ParserDefinitionDecoder();
ParserEventDecoder *parserevent = new ParserEventDecoder();
Trace trace;
Line line("trace_to_parse.trace");
int linecount = 0;
static const string percent = "%";
while(!line.eof()){
line.newline();
if(line.starts_with(percent)){
parserdefinition->store_definition(line);
linecount ++;
}
else{
int event_identity;
string event_identity_string;
DIE_IF(!line.item(0, event_identity_string), "event has no identifier");
DIE_IF(sscanf(event_identity_string.c_str(), "%d", &event_identity) != 1, "expected identifier for a definition");
parserevent->store_event(
parserdefinition->get_definition(event_identity),
line,
trace);
;
}
}
//parserdefinition->print_definitions();
cout << "lu :" << linecount << endl;
delete parserdefinition;
delete parserevent;
return EXIT_SUCCESS;
}
......@@ -27,7 +27,7 @@ public:
*
*/
virtual std::string to_string() const = 0;
virtual ~Value();
//virtual ~Value();
};
#endif // VALUE_HPP
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment