Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
PMC-SOG
PN-Parser
Commits
1bae1081
Commit
1bae1081
authored
Jan 23, 2019
by
Jaime Arias
Browse files
Fix CMakeLists files. Add examples folder for test
parent
da3fab70
Changes
9
Show whitespace changes
Inline
Side-by-side
CMakeLists.txt
View file @
1bae1081
...
...
@@ -4,7 +4,12 @@ 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
...
...
src/CMakeLists.txt
View file @
1bae1081
# set minimum cmake version
cmake_minimum_required
(
VERSION 3.5 FATAL_ERROR
)
#
project name and language
#
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 and flex
bison_target
(
rdp_parser RdPMonteur.y
${
CMAKE_CURRENT_BINARY_DIR
}
/parser.c
)
flex_target
(
rdp_scanner RdPMonteur.l
${
CMAKE_CURRENT_BINARY_DIR
}
/lexer.c
)
add_flex_bison_dependency
(
rdp_scanner rdp_parser
)
# 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
set
(
CMAKE_INCLUDE_CURRENT_DIR_IN_INTERFACE ON
)
add_library
(
RdP
STATIC
Net.h
add_library
(
RdP STATIC
${
BISON_RdPMonteurParser_OUTPUTS
}
${
FLEX_RdPMonteurLexer_OUTPUTS
}
Net.h
pp
Net.cpp
RdPMonteur.h
${
BISON_rdp_parser_OUTPUTS
}
${
FLEX_rdp_scanner_OUTPUTS
}
RdPMonteur.hpp
)
src/Net.cpp
View file @
1bae1081
#include "Net.h"
#include "Net.h
pp
"
#include <algorithm>
#include <ext/hash_map>
#include <iomanip>
...
...
src/Net.h
→
src/Net.h
pp
View file @
1bae1081
...
...
@@ -8,7 +8,7 @@
#include <set>
#include <string>
#include <vector>
#include "RdPMonteur.h"
#include "RdPMonteur.h
pp
"
typedef
set
<
int
>
Set
;
class
Node
{
public:
...
...
src/RdPMonteur.h
→
src/RdPMonteur.h
pp
View file @
1bae1081
File moved
src/RdPMonteur.l
View file @
1bae1081
%{
/************* INCLUDES AND EXTERNALS *************************************/
extern "C" int yylex();
#include <stdio.h>
#include <string.h>
#include "RdPMonteur.tab.h"
#include "RdPMonteur.tab.h
pp
"
%}
...
...
src/RdPMonteur.y
View file @
1bae1081
...
...
@@ -4,7 +4,7 @@
#include <string>
#include <stdio.h>
#include "RdPMonteur.h"
#include "RdPMonteur.h
pp
"
static RdPMonteur *R;
static string t;
...
...
tests/CMakeLists.txt
View file @
1bae1081
...
...
@@ -11,5 +11,6 @@ target_link_libraries(RdPtest RdP)
# Add test
add_test
(
NAME tests
WORKING_DIRECTORY
${
EXAMPLES_DIR
}
COMMAND RdPtest
)
tests/test.cpp
View file @
1bae1081
#define CATCH_CONFIG_MAIN
#include "Net.h"
#include "Net.h
pp
"
#include "catch.hpp"
TEST_CASE
(
"Parsing simple file"
,
"[Simple]"
)
{
net
R
(
"../examples/ring2.net"
,
"../examples/Obs2_ring"
,
""
);
net
model
(
"ring2.net"
,
"Obs2_ring"
);
REQUIRE
(
model
.
nbPlace
()
==
16
);
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment