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
Open sidebar
CTA-LAPP
PHOENIX_LIBS
ParserGenerator
Commits
63a788b6
Commit
63a788b6
authored
Jan 12, 2021
by
Pierre Aubert
Browse files
Remove mathexpr test, not working and replaced by test_operator
parent
dec4bc95
Pipeline
#99134
passed with stages
in 12 minutes and 46 seconds
Changes
5
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
0 additions
and
176 deletions
+0
-176
TESTS/CMakeLists.txt
TESTS/CMakeLists.txt
+0
-1
TESTS/TEST_MATH_EXPR/CMakeLists.txt
TESTS/TEST_MATH_EXPR/CMakeLists.txt
+0
-11
TESTS/TEST_MATH_EXPR/fileAdd.math
TESTS/TEST_MATH_EXPR/fileAdd.math
+0
-4
TESTS/TEST_MATH_EXPR/main_test.cpp
TESTS/TEST_MATH_EXPR/main_test.cpp
+0
-116
TESTS/TEST_MATH_EXPR/math_expr.pdecparser
TESTS/TEST_MATH_EXPR/math_expr.pdecparser
+0
-44
No files found.
TESTS/CMakeLists.txt
View file @
63a788b6
...
...
@@ -13,6 +13,5 @@ add_subdirectory(TEST_SHADOK_LIST)
add_subdirectory
(
TEST_C_ENUM
)
add_subdirectory
(
TEST_VAR_DECL
)
add_subdirectory
(
TEST_VAR_DECL_STRING
)
add_subdirectory
(
TEST_MATH_EXPR
)
add_subdirectory
(
TEST_OPERATOR
)
TESTS/TEST_MATH_EXPR/CMakeLists.txt
deleted
100644 → 0
View file @
dec4bc95
project
(
Phoenix
)
cmake_minimum_required
(
VERSION 3.0
)
# compileLibTestGenerator(test_math_expr_parser "PTestMathExprParser" math_expr.pdecparser)
compileMainTestGenerator
(
test_math_expr_parser
"PTestMathExprParser"
math_expr.pdecparser main_test.cpp
)
# Only when the test will be OK
# compileTestGenerator(test_math_expr_parser "PTestMathExprParser" math_expr.pdecparser main_test.cpp var_decl.txt)
TESTS/TEST_MATH_EXPR/fileAdd.math
deleted
100644 → 0
View file @
dec4bc95
a + b
TESTS/TEST_MATH_EXPR/main_test.cpp
deleted
100644 → 0
View file @
dec4bc95
/***************************************
Auteur : Pierre Aubert
Mail : aubertp7@gmail.com
Licence : CeCILL-C
****************************************/
// For the option parsing
#include "OptionParser.h"
#include "string_utils.h"
// To get the generated parser
#include "PTestMathExprParserFull.h"
using
namespace
std
;
///Create the OptionParser of this program
/** @return OptionParser of this program
*/
OptionParser
createOptionParser
(){
OptionParser
parser
(
true
,
__PROGRAM_VERSION__
);
parser
.
setExampleLongOption
(
"use_parser --input=fileName.shadok"
);
parser
.
setExampleShortOption
(
"use_parser -i fileName.shadok"
);
parser
.
addOption
(
"input"
,
"i"
,
OptionType
::
FILENAME
,
true
,
"input shadok file name"
);
return
parser
;
}
///Test the conversion of and add expression into a string
/** @return true on success, false otherwise
*/
bool
testExprAddToString
(){
PExpr
varA
=
PExpr_default
();
PExpr_setType
(
varA
,
PExprType
::
VAR
);
PExpr_setVarName
(
varA
,
"a"
);
PExpr
varB
=
PExpr_default
();
PExpr_setType
(
varB
,
PExprType
::
VAR
);
PExpr_setVarName
(
varB
,
"b"
);
PExpr
exprAdd
=
PExpr_default
();
PExpr_setType
(
exprAdd
,
PExprType
::
ADD
);
PExpr_getVecOperand
(
exprAdd
).
push_back
(
varA
);
PExpr_getVecOperand
(
exprAdd
).
push_back
(
varB
);
std
::
string
exprStr
=
gExpr
(
exprAdd
);
std
::
cout
<<
"testExprAddToString : exprAdd = '"
<<
exprStr
<<
"'"
<<
std
::
endl
;
return
true
;
}
///Test the conversion of and add expression into a string
/** @return true on success, false otherwise
*/
bool
testExprAdd2ToString
(){
PExpr
varA
=
PExpr_default
();
PExpr_setType
(
varA
,
PExprType
::
VAR
);
PExpr_setVarName
(
varA
,
"a"
);
PExpr
varB
=
PExpr_default
();
PExpr_setType
(
varB
,
PExprType
::
VAR
);
PExpr_setVarName
(
varB
,
"b"
);
PExpr
varC
=
PExpr_default
();
PExpr_setType
(
varC
,
PExprType
::
VAR
);
PExpr_setVarName
(
varC
,
"c"
);
PExpr
exprAdd
=
PExpr_default
();
PExpr_setType
(
exprAdd
,
PExprType
::
ADD
);
PExpr_getVecOperand
(
exprAdd
).
push_back
(
varA
);
PExpr_getVecOperand
(
exprAdd
).
push_back
(
varB
);
PExpr_getVecOperand
(
exprAdd
).
push_back
(
varC
);
std
::
string
exprStr
=
gExpr
(
exprAdd
);
std
::
cout
<<
"testExprAdd2ToString : exprAdd = '"
<<
exprStr
<<
"'"
<<
std
::
endl
;
return
true
;
}
///Print the shadok file
/** @param fileName : file to be parsed
* @return true on success, false otherwise
*/
bool
printVarDeclFile
(
const
std
::
string
&
fileName
){
//We create the parser
PTestMathExprParser
parser
;
if
(
!
parser
.
load
(
fileName
)){
cerr
<<
"printVarDeclFile : can't load file '"
<<
fileName
<<
"'"
<<
endl
;
return
false
;
}
//We get the parsed internal representation
PExpr
&
source
=
parser
.
getPExprE
();
std
::
string
exprStr
=
gExpr
(
source
);
std
::
cout
<<
"printVarDeclFile : exprStr = '"
<<
exprStr
<<
"'"
<<
std
::
endl
;
return
true
;
}
int
main
(
int
argc
,
char
**
argv
){
OptionParser
optionParser
=
createOptionParser
();
optionParser
.
parseArgument
(
argc
,
argv
);
const
OptionMode
&
defaultMode
=
optionParser
.
getDefaultMode
();
std
::
string
fileName
(
""
);
defaultMode
.
getValue
(
fileName
,
"input"
);
bool
b
(
testExprAddToString
());
b
&=
testExprAdd2ToString
();
b
&=
printVarDeclFile
(
fileName
);
if
(
b
){
return
0
;}
else
{
return
-
1
;}
}
TESTS/TEST_MATH_EXPR/math_expr.pdecparser
deleted
100644 → 0
View file @
dec4bc95
///Type of the expression
Enum PExprType{
VAR
ADD
MULT
};
///Describes a simple mathematic expression
Class PExpr{
///Type of the expression
PExprType::PExprType type;
///Name of the variable
String varName[csVariableName];
///Vector of operand
Vector(PExpr) vecOperand;
}
Graph gExprVarName(PExpr e){
e.varName e.type=PExprType::VAR
}
///Parses a mathematic expression
Graph gExpr(PExpr e){
e.vecOperand.pushBack(gExprVarName())
REPEAT{
OR{
"*" e.vecOperand.pushBackFirst(e) e.type=PExprType::MULT e.varName="toto"
OR{
"(" e.vecOperand.pushBack(gExpr()) ")",
e.vecOperand.pushBack(gExpr())
},
"+" e.vecOperand.pushBackFirst(e) e.type=PExprType::ADD e.varName="toto"
OR{
"(" e.vecOperand.pushBack(gExpr()) ")",
e.vecOperand.pushBack(gExpr())
}
}
}
}
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