Commit 4791bc3d authored by Jaime Arias's avatar Jaime Arias
Browse files

Merge branch 'develop'

parents 75c351a1 c9843701
......@@ -41,3 +41,22 @@
*.tab.h
# End of https://www.gitignore.io/api/c++
# Created by https://www.gitignore.io/api/cmake
# Edit at https://www.gitignore.io/?templates=cmake
### CMake ###
CMakeLists.txt.user
CMakeCache.txt
CMakeFiles
CMakeScripts
Testing
Makefile
cmake_install.cmake
install_manifest.txt
compile_commands.json
CTestTestfile.cmake
build
# End of https://www.gitignore.io/api/cmake
# set minimum cmake version
cmake_minimum_required(VERSION 3.5 FATAL_ERROR)
# project name and language
project(pn-parser LANGUAGES CXX)
# variables
set(SRC_DIR "${PROJECT_SOURCE_DIR}/src")
set(EXAMPLES_DIR "${PROJECT_SOURCE_DIR}/examples")
# add source folder
include_directories (${SRC_DIR})
add_subdirectory(src)
# add tests
enable_testing()
add_subdirectory(tests)
# PN-Parser
# Build
```
mkdir build && cd build
cmake ..
make
```
# Dependencies
- `flex`
......
# set minimum cmake version
cmake_minimum_required(VERSION 3.5 FATAL_ERROR)
# compilator flags
project(pn-parser-src LANGUAGES CXX)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3 -Wall")
# dependencies
find_package(BISON REQUIRED)
find_package(FLEX REQUIRED)
# execute bison
BISON_TARGET(
RdPMonteurParser
RdPMonteur.y ${CMAKE_CURRENT_BINARY_DIR}/RdPMonteur.tab.cpp
)
# execute flex
FLEX_TARGET(
RdPMonteurLexer
RdPMonteur.l ${CMAKE_CURRENT_BINARY_DIR}/RdPMonteur.lex.cpp
)
ADD_FLEX_BISON_DEPENDENCY(RdPMonteurLexer RdPMonteurParser)
# generate a the library from sources
add_library(RdP STATIC
${BISON_RdPMonteurParser_OUTPUTS}
${FLEX_RdPMonteurLexer_OUTPUTS}
Net.hpp
Net.cpp
RdPMonteur.hpp
)
LIB = libRdP.a
FILES = Net.cpp RdPMonteur.tab.cpp RdPMonteur.lex.c
CCFILES =$(filter %.c,$(FILES))
CPPFILES =$(filter %.cpp,$(FILES))
OBJS = $(CPPFILES:.cpp=.o) $(CCFILES:.c=.o)
DEPS = $(CPPFILES:.cpp=.d) $(CCFILES:.c=.d)
CC =gcc
CXX = g++
CXXFLAGS= -O3 -Wall
all: $(LIB)
$(LIB): $(OBJS)
ar ru $(LIB) $(OBJS)
ranlib $(LIB)
# implicit rules
.cpp.o: RdPMonteur.tab.cpp RdPMonteur.lex.c
$(CXX) -c $(CXXFLAGS) $<
.c.o: RdPMonteur.tab.cpp RdPMonteur.lex.c
$(CC) -c $(CXXFLAGS) $<
clean:
rm -f $(LIB) *.o *.d *~ *.tab.h *.tab.cpp *.lex.c
%.d: %.cpp RdPMonteur.tab.cpp RdPMonteur.lex.c
@$(SHELL) -ec '$(CXX) -M $(CXXFLAGS) $(INCLUDES) $< \
| sed '\''s/\($*\)\.o[ :]*/\1.o $@ : /g'\'' > $@; \
[ -s $@ ] || rm -f $@'
%.d: %.c RdPMonteur.tab.cpp RdPMonteur.lex.c
@$(SHELL) -ec '$(CC) -M $(CXXFLAGS) $(INCLUDES) $< \
| sed '\''s/\($*\)\.o[ :]*/\1.o $@ : /g'\'' > $@; \
[ -s $@ ] || rm -f $@'
%.tab.cpp: %.y
bison -d $<
mv $*.tab.c $*.tab.cpp
%.lex.c: %.l %.tab.cpp
flex -o$*.lex.c $<
-include $(DEPS)
#include "Net.h"
#include "Net.hpp"
#include <algorithm>
#include <ext/hash_map>
#include <iomanip>
......
......@@ -8,7 +8,7 @@
#include <set>
#include <string>
#include <vector>
#include "RdPMonteur.h"
#include "RdPMonteur.hpp"
typedef set<int> Set;
class Node {
public:
......
%{
/************* INCLUDES AND EXTERNALS *************************************/
extern "C" int yylex();
#include <stdio.h>
#include <string.h>
#include "RdPMonteur.tab.h"
#include "RdPMonteur.tab.hpp"
%}
......
......@@ -4,7 +4,7 @@
#include <string>
#include <stdio.h>
#include "RdPMonteur.h"
#include "RdPMonteur.hpp"
static RdPMonteur *R;
static string t;
......
# set minimum cmake version
cmake_minimum_required(VERSION 3.5 FATAL_ERROR)
# project name and language
project(pn-parser-test LANGUAGES CXX)
# testing library
add_executable(RdPtest test.cpp)
target_link_libraries(RdPtest RdP)
# Add test
add_test(
NAME tests
WORKING_DIRECTORY ${EXAMPLES_DIR}
COMMAND RdPtest
)
This source diff could not be displayed because it is too large. You can view the blob instead.
#define CATCH_CONFIG_MAIN
#include "Net.hpp"
#include "catch.hpp"
TEST_CASE("Parsing simple file", "[Simple]") {
net model("ring2.net", "Obs2_ring");
REQUIRE(model.nbPlace() == 16);
REQUIRE(model.nbTransition() == 16);
}
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