Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Docker-in-Docker (DinD) capabilities of public runners deactivated.
More info
Open sidebar
CTA-LAPP
PHOENIX_LIBS
ParserGenerator
Commits
80d22609
Commit
80d22609
authored
Jan 13, 2021
by
Pierre Aubert
Browse files
Add test and avoid generating dead code (for operator essentially)
parent
00129d8a
Pipeline
#99363
passed with stages
in 7 minutes and 25 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
10 deletions
+17
-10
TESTS/TEST_SHADOK_LIST/main_test.cpp
TESTS/TEST_SHADOK_LIST/main_test.cpp
+3
-0
src/CppBackEnd/repr_cpp_operator.cpp
src/CppBackEnd/repr_cpp_operator.cpp
+14
-10
No files found.
TESTS/TEST_SHADOK_LIST/main_test.cpp
View file @
80d22609
...
...
@@ -48,6 +48,9 @@ int printShadokFile(const std::string & fileName){
//We get the parsed internal representation
Source
&
source
=
parser
.
getSourceS
();
std
::
string
sourceStr
(
gSource
(
source
));
std
::
cout
<<
"printShadokFile : source converted to string = '"
<<
sourceStr
<<
"'"
<<
std
::
endl
;
std
::
vector
<
Shadok
>
&
vecShadok
=
Source_getVecShadok
(
source
).
getVecStmt
();
if
(
vecShadok
.
size
()
==
listShadokAge
.
size
()){
...
...
src/CppBackEnd/repr_cpp_operator.cpp
View file @
80d22609
...
...
@@ -53,16 +53,17 @@ std::string repr_cpp_operatorHeader(const PTabGraphToken & tabGraphToken){
//Create all the define
const
PVecOperator
&
vecOperator
=
tabGraphToken
.
getVecOperator
();
for
(
PVecOperator
::
const_iterator
it
(
vecOperator
.
begin
());
it
!=
vecOperator
.
end
();
++
it
){
body
+=
"//Define the priority of the operator "
+
it
->
getValueEnum
()
+
"
\n
"
;
body
+=
"#define OPERATOR_PRIORITY_"
+
repr_cpp_operator_getEnumValue
(
it
->
getValueEnum
())
+
" "
+
convertToString
(
it
->
getOpPriority
())
+
"
\n\n
"
;
if
(
vecOperator
.
size
()
!=
0lu
){
for
(
PVecOperator
::
const_iterator
it
(
vecOperator
.
begin
());
it
!=
vecOperator
.
end
();
++
it
){
body
+=
"//Define the priority of the operator "
+
it
->
getValueEnum
()
+
"
\n
"
;
body
+=
"#define OPERATOR_PRIORITY_"
+
repr_cpp_operator_getEnumValue
(
it
->
getValueEnum
())
+
" "
+
convertToString
(
it
->
getOpPriority
())
+
"
\n\n
"
;
}
body
+=
"
\n
"
;
body
+=
"bool isAnOperator(const PStmt & _op);
\n
"
;
body
+=
"long get_priority_operator(const PStmt & _op);
\n
"
;
body
+=
"PStmt* get_last_operand_of_operator(PStmt & _op);
\n
"
;
body
+=
"PStmt* get_first_operand_of_operator(PStmt & _op);
\n
"
;
}
body
+=
"
\n
"
;
body
+=
"bool isAnOperator(const PStmt & _op);
\n
"
;
body
+=
"long get_priority_operator(const PStmt & _op);
\n
"
;
body
+=
"PStmt* get_last_operand_of_operator(PStmt & _op);
\n
"
;
body
+=
"PStmt* get_first_operand_of_operator(PStmt & _op);
\n
"
;
body
+=
"
\n\n
"
;
body
+=
"#endif
\n\n\n
"
;
return
body
;
...
...
@@ -77,8 +78,11 @@ std::string repr_cpp_operatorSource(const PTabGraphToken & tabGraphToken, const
body
+=
licenceSaveStr
();
body
+=
"#include
\"
"
+
baseFileName
+
".h
\"\n\n
"
;
const
PVecOperator
&
vecOperator
=
tabGraphToken
.
getVecOperator
();
if
(
vecOperator
.
size
()
==
0lu
){
return
body
;}
PMapVecOperator
mapOp
;
repr_cpp_operatorGetClass
(
mapOp
,
tabGraphToken
.
getV
ecOperator
()
);
repr_cpp_operatorGetClass
(
mapOp
,
v
ecOperator
);
body
+=
"///Say if the given PStmt is an operator
\n
"
;
body
+=
"/**
\t
@param _op : PStmt to be checked
\n
"
;
...
...
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