Commit c6e0aca0 authored by Johnny Jazeix's avatar Johnny Jazeix
Browse files

Makefile propre (pas besoin d'avoir 15 pour faire ca ^^)

parent 57b8c607
DIR_SRC = src
DIR_TESTS = tests
parser: ./tests/stub/trace.cpp ./tests/test_parser_event.cpp all:
cd ../trace/src/values && make && cd ../../../parser @(cd $(DIR_SRC) && make)
cd ./src && make && cd ../
g++ -c ./tests/stub/trace.cpp -g -Wall -o trace.o debug:
g++ -c ./tests/test_parser_event.cpp -Wall -o event_test.o @(cd $(DIR_TESTS) && make)
g++ -o ./tests/event_test event_test.o trace.o ../trace/src/values/*.o ./src/*.o
echo "event_test fait" clean:
@(cd $(DIR_SRC) && make clean)
@(cd $(DIR_TESTS) && make clean)
rm -rf makefile~ *.*~
#parser: ./tests/stub/trace.cpp ./tests/test_parser_event.cpp
# cd ../trace/src/values && make && cd ../../../parser
# cd ./src && make && cd ../
# g++ -c ./tests/stub/trace.cpp -g -Wall -o trace.o
# g++ -c ./tests/test_parser_event.cpp -Wall -o event_test.o
# g++ -o ./tests/event_test event_test.o trace.o ../trace/src/values/*.o ./src/*.o
# echo "event_test fait"
...@@ -31,6 +31,14 @@ private: ...@@ -31,6 +31,14 @@ private:
*/ */
int typetoint(std::string); int typetoint(std::string);
/*!
* \fn valid_type(std::string &type_name)
* \brief Check if the type_name is a real type.
* \param name : the name we want to check.
* \return true if the type exists.
*/
bool is_valid_type(const std::string &type_name) const;
public: public:
/*! /*!
......
...@@ -136,7 +136,7 @@ void ParserEventDecoder::store_event(const Definition &definition, Line &line, T ...@@ -136,7 +136,7 @@ void ParserEventDecoder::store_event(const Definition &definition, Line &line, T
} }
extra_fields.push_back(&value); extra_fields.push_back(&value);
} }
else if(fields[i-1]._type == "integer" || fields[i-1]._type == "int") { else if(fields[i-1]._type == "int") {
Integer value; Integer value;
if(!Integer::instantiate(current_value, value)) { if(!Integer::instantiate(current_value, value)) {
cout << "warning : incompatible value" << endl; cout << "warning : incompatible value" << endl;
......
CC = g++ CC = g++
LD = g++ LD = g++
OBJ = ../src/Line.o ../src/ParserDefinitionDecoder.o ../src/Definition.o ../src/TokenSource.o ../src/ParserEventDecoder.o ../src/ParserPaje.o OBJ = ../../trace/src/values/*.o stub/*.o ../src/*.o
OPT = -g -Wall -W OPT = -g -Wall -W
all: test_token test_parser_definition test_parser_global all: test_token test_parser_definition test_parser_global test_parser_evenement
test_token: test_token.cpp $(OBJ) test_token: test_token.cpp $(OBJ)
$(CC) $(OPT) -o $@ $^ $(CC) $(OPT) -o $@ $^
...@@ -13,11 +13,12 @@ test_token: test_token.cpp $(OBJ) ...@@ -13,11 +13,12 @@ test_token: test_token.cpp $(OBJ)
test_parser_definition: test_parser_definition.cpp $(OBJ) test_parser_definition: test_parser_definition.cpp $(OBJ)
$(CC) $(OPT) -o $@ $^ $(CC) $(OPT) -o $@ $^
test_parser_evenement: test_parser_event.cpp $(OBJ)
$(CC) $(OPT) -o $@ $^
test_parser_global: test_parser_global.cpp $(OBJ) test_parser_global: test_parser_global.cpp $(OBJ)
$(CC) $(OPT) -o $@ $^ $(CC) $(OPT) -o $@ $^
$(OBJ):%.o: %.cpp %.hpp
$(LD) -c $< $(OPT) -o $@
clean: clean:
$(RM) *.o *.*~ makefile~ $(RM) *.o *.*~ makefile~
......
#include "../src/Line.hpp" #include "../src/Line.hpp"
#include "../src/ParserDefinitionDecoder.hpp" #include "../src/ParserDefinitionDecoder.hpp"
#include "../src/ParserEventDecoder.hpp" #include "../src/ParserEventDecoder.hpp"
#include "../tests/stub/trace.hpp" #include "../tests/stub/trace.hpp"
#include <iostream> #include <iostream>
#include <fstream> #include <fstream>
#include <cstdlib> #include <cstdlib>
#define DIE_IF(condition,message) if (condition){ \ #define DIE_IF(condition,message) if (condition){ \
cout << message << endl; \ cout << message << endl; \
return 0;} return 0;}
using namespace std; using namespace std;
...@@ -16,7 +16,7 @@ using namespace std; ...@@ -16,7 +16,7 @@ using namespace std;
int main(int argc, char **argv){ int main(int argc, char **argv){
ParserDefinitionDecoder *parserdefinition = new ParserDefinitionDecoder(); ParserDefinitionDecoder *parserdefinition = new ParserDefinitionDecoder();
ParserEventDecoder *parserevent = new ParserEventDecoder(); ParserEventDecoder *parserevent = new ParserEventDecoder();
Trace trace; Trace trace;
Line line("trace_to_parse.trace"); Line line("trace_to_parse.trace");
...@@ -29,22 +29,22 @@ int main(int argc, char **argv){ ...@@ -29,22 +29,22 @@ int main(int argc, char **argv){
if(line.starts_with(percent)){ if(line.starts_with(percent)){
parserdefinition->store_definition(line); parserdefinition->store_definition(line);
linecount ++; linecount ++;
} }
else{ else{
int event_identity; int event_identity;
string event_identity_string; string event_identity_string;
DIE_IF(!line.item(0, event_identity_string), "event has no identifier"); 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"); DIE_IF(sscanf(event_identity_string.c_str(), "%d", &event_identity) != 1, "expected identifier for a definition");
parserevent->store_event( parserevent->store_event(
parserdefinition->get_definition(event_identity), parserdefinition->get_definition(event_identity),
line, line,
trace); trace);
; ;
} }
} }
......
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