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
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"
all:
@(cd $(DIR_SRC) && make)
debug:
@(cd $(DIR_TESTS) && make)
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:
*/
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:
/*!
......
......@@ -136,7 +136,7 @@ void ParserEventDecoder::store_event(const Definition &definition, Line &line, T
}
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;
if(!Integer::instantiate(current_value, value)) {
cout << "warning : incompatible value" << endl;
......
CC = 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
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)
$(CC) $(OPT) -o $@ $^
......@@ -13,11 +13,12 @@ test_token: test_token.cpp $(OBJ)
test_parser_definition: test_parser_definition.cpp $(OBJ)
$(CC) $(OPT) -o $@ $^
test_parser_evenement: test_parser_event.cpp $(OBJ)
$(CC) $(OPT) -o $@ $^
test_parser_global: test_parser_global.cpp $(OBJ)
$(CC) $(OPT) -o $@ $^
$(OBJ):%.o: %.cpp %.hpp
$(LD) -c $< $(OPT) -o $@
clean:
$(RM) *.o *.*~ makefile~
......
#include "../src/Line.hpp"
#include "../src/ParserDefinitionDecoder.hpp"
#include "../src/ParserEventDecoder.hpp"
#include "../src/ParserDefinitionDecoder.hpp"
#include "../src/ParserEventDecoder.hpp"
#include "../tests/stub/trace.hpp"
#include <iostream>
#include <fstream>
#include <fstream>
#include <cstdlib>
#define DIE_IF(condition,message) if (condition){ \
cout << message << endl; \
return 0;}
#define DIE_IF(condition,message) if (condition){ \
cout << message << endl; \
return 0;}
using namespace std;
......@@ -16,7 +16,7 @@ using namespace std;
int main(int argc, char **argv){
ParserDefinitionDecoder *parserdefinition = new ParserDefinitionDecoder();
ParserEventDecoder *parserevent = new ParserEventDecoder();
ParserEventDecoder *parserevent = new ParserEventDecoder();
Trace trace;
Line line("trace_to_parse.trace");
......@@ -29,22 +29,22 @@ int main(int argc, char **argv){
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);
;
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);
;
}
}
......
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