Skip to content
Snippets Groups Projects
Commit e9e7c586 authored by Cyril Moineau's avatar Cyril Moineau
Browse files

[GraphRegex] Update defines to follow convention.

parent c7c9214e
No related branches found
No related tags found
No related merge requests found
Showing
with 259 additions and 259 deletions
#ifndef __AIDGE_GRAPH_FSM_INTERPRETER_H__
#define __AIDGE_GRAPH_FSM_INTERPRETER_H__
#ifndef AIDGE_CORE_GRAPH_FSM_INTERPRETER_H_
#define AIDGE_CORE_GRAPH_FSM_INTERPRETER_H_
#include <string>
#include <memory>
......@@ -27,19 +27,19 @@ namespace Aidge {
std::shared_ptr<FsmGraph> interpret(void);
private:
std::shared_ptr<FsmGraph> visit(std::shared_ptr<AstNode<gRegexTokenTypes>> AstTree);
/**
* @defgroup graphFsmInterpreterF Functions for interpreting AST nodes
* @defgroup graphFsmInterpreterF Functions for interpreting AST nodes
* @brief For each node type in the AST, define how build the FsmGraph
*/
/**
* @ingroup graphFsmInterpreterF
* @brief leaf of fsm make the fsm for test one transition
* @brief leaf of fsm make the fsm for test one transition
*/
std::shared_ptr<FsmGraph> keyF(std::shared_ptr<AstNode<gRegexTokenTypes>> AstNode);
/**
......@@ -70,4 +70,4 @@ namespace Aidge {
}
#endif //__AIDGE_GRAPH_STM_INTERPRETER_H__
\ No newline at end of file
#endif // AIDGE_CORE_GRAPH_FSM_INTERPRETER_H_
#ifndef __AIDGE_GRAPH_LEXER_H__
#define __AIDGE_GRAPH_LEXER_H__
#ifndef AIDGE_CORE_GRAPH_LEXER_H_
#define AIDGE_CORE_GRAPH_LEXER_H_
#include <string>
#include <memory>
......@@ -20,33 +20,33 @@ namespace Aidge {
/**
* @brief Get the next token on the gRegexExpressions
* @return ConditionalToken
* @return ConditionalToken
*/
std::shared_ptr<ParsingToken<gRegexTokenTypes>> getNextToken(void);
/**
* @brief Restart at the start of the gRegexExpressions
*
* @brief Restart at the start of the gRegexExpressions
*
*/
void rstPosition(void);
/**
* @brief Test if the string is completely read
* @return bool
* @brief Test if the string is completely read
* @return bool
*/
bool isEnd(void);
/**
* @brief Get the representation of the class
* @return string
* @return string
*/
const std::string rep();
private:
/**
* @brief Constructs an error message to display the character not understood by the lexer
* @return error mesage
* @brief Constructs an error message to display the character not understood by the lexer
* @return error mesage
*/
std::runtime_error badTokenError(const std::string& currentChars,std::size_t position);
......@@ -65,4 +65,4 @@ namespace Aidge {
#endif //__AIDGE_GRAPH_LEXER_H__
\ No newline at end of file
#endif //AIDGE_CORE_GRAPH_LEXER_H_
#ifndef _AIDGE_GRAPH_PARSER_H_
#define _AIDGE_GRAPH_PARSER_H_
#ifndef AIDGE_CORE_GRAPH_PARSER_H_
#define AIDGE_CORE_GRAPH_PARSER_H_
#include <memory> // for shared_ptr
......@@ -10,13 +10,13 @@
namespace Aidge{
/**
* @brief this class uses the lexer to create an AST according to a set of gramer rules
* @brief this class uses the lexer to create an AST according to a set of gramer rules
*/
class GraphParser{
public:
/**
* @brief AST graph creation function
* @brief AST graph creation function
* @param gRegexExpressions String representing the logical fuction to be performed
*/
GraphParser(const std::string gRegexExpressions);
......@@ -24,8 +24,8 @@ class GraphParser{
virtual ~GraphParser() = default;
/**
* @brief AST graph creation function
* @return The AST tree
* @brief AST graph creation function
* @return The AST tree
*/
std::shared_ptr<AstNode<gRegexTokenTypes>> parse(void);
......@@ -35,7 +35,7 @@ class GraphParser{
* @brief restart at the start of the ConditionalExpressions for LEXER and restart mCurrentToken
*/
void rstParser(void);
//////////////////
/**
......@@ -45,37 +45,37 @@ class GraphParser{
/**
* @ingroup ParsingFunctions
* @brief Token reading and verification function
*
* @brief Token reading and verification function
*
*/
void ackToken(gRegexTokenTypes tokenType);
//TODO TODO
/**
* @ingroup ParsingFunctions
* @brief Function of grammar rules for key : KEY(QOM | QZM)? | CKEY
* @return AST node
* @brief Function of grammar rules for key : KEY(QOM | QZM)? | CKEY
* @return AST node
*/
std::shared_ptr<AstNode<gRegexTokenTypes>> constructAstExp(void);
/**
* @ingroup ParsingFunctions
* @brief Function of grammar rules for sequence : seq :exp (NEXT seq)*
* @return AST node
* @brief Function of grammar rules for sequence : seq :exp (NEXT seq)*
* @return AST node
*/
std::shared_ptr<AstNode<gRegexTokenTypes>> constructAstSeq(void);
/**
* @ingroup ParsingFunctions
* @brief Function of grammar rules for domain : (seq NEXT domain)? | LPAREN domain RPAREN (QOM | QZM) (NEXT domain)?
* @return AST node
* @brief Function of grammar rules for domain : (seq NEXT domain)? | LPAREN domain RPAREN (QOM | QZM) (NEXT domain)?
* @return AST node
*/
std::shared_ptr<AstNode<gRegexTokenTypes>> constructAstDomain(void);
/**
* @ingroup ParsingFunctions
* @brief Function of grammar rules for multiple exepresion : allExpr: domain (SEP allExpr)*
* @return AST node
* @return AST node
*/
std::shared_ptr<AstNode<gRegexTokenTypes>> constructAstAllExpr(void);
......@@ -95,4 +95,4 @@ class GraphParser{
}
#endif //_AIDGE_GRAPH_PARSER_H_
#endif //AIDGE_CORE_GRAPH_PARSER_H_
#ifndef __AIDGE_GREGEX_TOKEN_TYPES_H__
#define __AIDGE_GREGEX_TOKEN_TYPES_H__
#ifndef AIDGE_CORE_GREGEX_TOKEN_TYPES_H_
#define AIDGE_CORE_GREGEX_TOKEN_TYPES_H_
namespace Aidge {
/**
* @brief enum for all types of token use in the of the regex
* @brief enum for all types of token use in the of the regex
* 7-5 type
* 4-0 id
*/
enum class gRegexTokenTypes
{
NEXT = (1 << 4)+1, /**< -> */
STOP,
NEXT, /**< -> */
QOM = (1 << 5)+1, /**< + */
QZM = (1 << 5)+2, /**< * */
QOM, /**< + */
QZM, /**< * */
KEY = (1 << 6)+2, /**< [A-Za-z_0-9]+ */
CKEY = (1 << 6)+1, /**< [A-Za-z_0-9]+#[0-9]* */
SEP = (1<<7) +1, /**< \( */
LPAREN = (1<<7) +2, /**< \( */
RPAREN = (1<<7) +3, /**< \) */
STOP = 0,
KEY, /**< [A-Za-z_0-9]+ */
CKEY, /**< [A-Za-z_0-9]+#[0-9]* */
SEP, /**< \( */
LPAREN, /**< \( */
RPAREN, /**< \) */
};
}
#endif //__AIDGE_GREGEX_TOKEN_TYPES_H__
\ No newline at end of file
#endif //AIDGE_CORE_GREGEX_TOKEN_TYPES_H_
#ifndef __AIDGE_GRAPH_FSM_INTERPRETER_H__
#define __AIDGE_GRAPH_FSM_INTERPRETER_H__
#ifndef AIDGE_CORE_GRAPH_FSM_INTERPRETER_H_
#define AIDGE_CORE_GRAPH_FSM_INTERPRETER_H_
#include <iostream>
#include <sstream>
......@@ -27,7 +27,7 @@ namespace Aidge {
std::string interpret(void);
private:
std::string visit(std::shared_ptr<AstNode<gRegexTokenTypes>> AstTree);
};
......@@ -37,4 +37,4 @@ namespace Aidge {
}
#endif //__AIDGE_GRAPH_STM_INTERPRETER_H__
\ No newline at end of file
#endif //AIDGE_CORE_GRAPH_FSM_INTERPRETER_H_
#ifndef __AIDGE_FSM_EDGE_H__
#define __AIDGE_FSM_EDGE_H__
#ifndef AIDGE_CORE_FSM_EDGE_H_
#define AIDGE_CORE_FSM_EDGE_H_
#include <memory>
#include <set>
#include <string>
//#include "graphRegex/matchFsm/FsmNode.hpp"
#include "aidge/nodeTester/ConditionalInterpreter.hpp"
//#include "graphRegex/matchFsm/FsmRunTimeContext.hpp"
namespace Aidge{
......@@ -21,15 +19,15 @@ namespace Aidge{
};
/**
* @brief virtual class use test the node on the node to validate
* @brief virtual class use test the node on the node to validate
*/
class FsmEdge: public std::enable_shared_from_this<FsmEdge>
{
private:
/**
* @brief the relative position to this test relative to all the const key
* firse is common id , segond is the relative position
* first is common id, second is the relative position
*/
std::map<size_t,int> mRelativePos;
/**
......@@ -54,8 +52,8 @@ namespace Aidge{
/**
* @brief test is the validation of the node , it must be deffine for all types of edge
* it takes as argument an FSM traversal context and returns a set of next nodes
* @brief test is the validation of the node, it must be defined for all types of edge
* it takes as argument an FSM traversal context and returns a set of next nodes
* @return set of next node or nullptr if not next
*/
......@@ -77,7 +75,7 @@ namespace Aidge{
*/
const std::map<size_t,int>& getRelative(void);
/**
* @brief add new relative position
* @brief add new relative position
*/
void updateRelative( const std::map<size_t,int>& relativePos );
/**
......@@ -101,12 +99,12 @@ namespace Aidge{
*/
void reSetDestNode(const std::shared_ptr<FsmNode>& newDest);
/**
* @brief propagate the edge mRelativePos to the others Edge and recalcul the relative position
* @brief propagate the edge mRelativePos to the others Edge and recalcul the relative position
*/
void propagateRelativePos(void);
/**
* @brief test to make on the node to validate
* @brief test to make on the node to validate
* @see ConditionalInterpreter
*/
const std::shared_ptr<ConditionalInterpreter> mToTest;
......@@ -137,18 +135,18 @@ namespace Aidge{
private:
/**
* @brief the map that defind the ralation between the commonKey find by the lexer and a unique id use to refer to the common node
* @brief the map that defind the ralation between the commonKey find by the lexer and a unique id use to refer to the common node
*/
static std::map<std::string,int> mCommonIdxMap;
/**
* @brief the common id test in this transition
* @brief the common id test in this transition
*/
int mCommonIdx;
public:
/**
* @brief constructor commun node ,
* @details during construction,
* @details during construction,
* the node key found by the lexer is converted to a unique id and the relative positions are updated.
*/
FsmEdgeCommon(std::shared_ptr<FsmNode>& source,std::shared_ptr<FsmNode>& dest, const std::shared_ptr<ConditionalInterpreter> toTest, const std::string commonKey);
......@@ -157,11 +155,11 @@ namespace Aidge{
bool isCommon(void) override;
};
/**
* @brief class spesialisation for ref transition
* @brief class spesialisation for ref transition
* @see FsmEdge
*/
class FsmEdgeRef:public FsmEdge
......@@ -179,11 +177,11 @@ namespace Aidge{
FsmEdgeRef(std::shared_ptr<FsmNode>& source,std::shared_ptr<FsmNode>& dest, const size_t refCommonIdx,const int deltaCommonIdx);
//~FsmEdgeRef() override {}
const EdgeTestResult test(const std::shared_ptr<FsmRunTimeContext> stmContext) override;
};
/**
* @brief class spesialisation for ref empty transition
* @brief class spesialisation for ref empty transition
* @see FsmEdge
*/
class FsmEdgeEmpty:public FsmEdge
......@@ -193,7 +191,7 @@ namespace Aidge{
FsmEdgeEmpty(std::shared_ptr<FsmNode> source,std::shared_ptr<FsmNode> dest);
//~FsmEdgeEmpty() override {}
const EdgeTestResult test(const std::shared_ptr<FsmRunTimeContext> stmContext) override;
};
......@@ -216,15 +214,15 @@ class FsmEdgeFactory {
* @brief factory for making edge and read the info in the lexeme of the token
* @param source source node of the edge
* @param dest Dest node of the edge
* @param type type of the edge
* @param type type of the edge
* @param lexeme the additional information to build the edge
* @return s prt of the edge
*/
static std::shared_ptr<FsmEdge> make(std::shared_ptr<FsmNode> source, std::shared_ptr<FsmNode> dest,
static std::shared_ptr<FsmEdge> make(std::shared_ptr<FsmNode> source, std::shared_ptr<FsmNode> dest,
FsmEdgeTypes type,std::map<std::string, std::shared_ptr<ConditionalInterpreter>> allTest,
const std::string lexeme = "");
};
}
#endif //__AIDGE_FSM_EDGE_H__
\ No newline at end of file
#endif //AIDGE_CORE_FSM_EDGE_H_
#ifndef __AIDGE_FSM_GRAPH_H__
#define __AIDGE_FSM_GRAPH_H__
#ifndef AIDGE_CORE_FSM_GRAPH_H_
#define AIDGE_CORE_FSM_GRAPH_H_
#include <set>
#include <vector>
......@@ -18,7 +18,7 @@ class FsmGraph
{
private:
/**
* @brief all node origine
* @brief all node origine
*/
std::set<std::size_t> mAllOrigine;
std::set<std::shared_ptr<FsmEdge>> mEdges;
......@@ -37,13 +37,13 @@ const std::set<std::shared_ptr<FsmEdge>>& getEdge(void);
void addEdge(std::shared_ptr<FsmEdge>& edge);
/**
* @brief get the liste of the starting states
* @brief get the liste of the starting states
* @details we need to use a vector because the order of the nodes is important for start node initialization \ref test()
*/
const std::vector<std::shared_ptr<FsmNode>> getStartNodes(void);
/**
* @brief get the set of the valide states
* @brief get the set of the valide states
* @return set of valide state
*/
const std::set<std::shared_ptr<FsmNode>> getValidNodes(void);
......@@ -61,14 +61,14 @@ void setGroupe(std::size_t groupeIdx);
/**
* @brief make the union beteen this graph and an input graph
* @param fsmGraph graph to union
* @param fsmGraph graph to union
*/
void unionG(const std::shared_ptr<FsmGraph> fsmGraph);
/**
* @brief make the union beteen this graph and an input graph and merge the valide state to the start state
* @param fsmGraph graph to merge
* @brief make the union beteen this graph and an input graph and merge the valide state to the start state
* @param fsmGraph graph to merge
*/
void mergeOneStartOneValid(const std::shared_ptr< FsmGraph> fsmGraph);
/**
......@@ -86,7 +86,7 @@ void incOrigineAllNodeBy(std::size_t incr);
private:
/**
* @brief merge tow node of the graph
* @brief merge tow node of the graph
* @param node
*/
void _mergeNode(std::shared_ptr<FsmNode> source,std::shared_ptr<FsmNode> dest);
......@@ -95,4 +95,4 @@ void _mergeNode(std::shared_ptr<FsmNode> source,std::shared_ptr<FsmNode> dest);
}
#endif //__AIDGE_FSM_GRAPH_H__
\ No newline at end of file
#endif //AIDGE_CORE_FSM_GRAPH_H_
#ifndef __AIDGE_FSM_NODE_H__
#define __AIDGE_FSM_NODE_H__
#ifndef AIDGE_CORE_FSM_NODE_H_
#define AIDGE_CORE_FSM_NODE_H_
#include <set>
#include <vector>
......@@ -22,8 +22,8 @@ namespace Aidge{
struct lex_compare {
bool operator() (const std::weak_ptr<T> &lhs, const std::weak_ptr<T> &rhs)const {
auto lptr = lhs.lock(), rptr = rhs.lock();
if (!rptr) return false; // nothing after expired pointer
if (!lptr) return true;
if (!rptr) return false; // nothing after expired pointer
if (!lptr) return true;
return lptr < rptr;
}
};
......@@ -45,7 +45,7 @@ namespace Aidge{
*/
std::set<std::weak_ptr<FsmEdge>,lex_compare<FsmEdge>> mEdges;
/**
* @brief the parent of the node
* @brief the parent of the node
*/
std::set<std::weak_ptr<FsmNode>,lex_compare<FsmNode>> mParents;
......@@ -59,7 +59,7 @@ namespace Aidge{
FsmNode(bool isAValid,bool isAStart );
virtual ~FsmNode() = default;
/**
* @brief use to MAG the actual context , and return all the posible new context
* @brief use to MAG the actual context , and return all the posible new context
* @details one input context can generate a multitude of contexts because a graph node
* can have more than one child, and each traversal possibility is a new context.
* @param actContext the actual context
......@@ -96,4 +96,4 @@ namespace Aidge{
};
}
#endif //__AIDGE_FSM_NODE_H__
\ No newline at end of file
#endif //AIDGE_CORE_FSM_NODE_H_
#ifndef __AIDGE_FSM_RUN_TIME_CONTEXT_H__
#define __AIDGE_FSM_RUN_TIME_CONTEXT_H__
#ifndef AIDGE_CORE_FSM_RUN_TIME_CONTEXT_H_
#define AIDGE_CORE_FSM_RUN_TIME_CONTEXT_H_
#include <memory>
#include <vector>
......@@ -25,7 +25,7 @@ namespace Aidge{
{
private:
/**
* @brief the list of node rejected for all the context
* @brief the list of node rejected for all the context
*/
static std::vector<std::set<NodePtr>> mRejectedNodes;
/**
......@@ -37,8 +37,8 @@ namespace Aidge{
*/
NodePtr mActOpNode;
/**
* @brief the map of the node consider as common and the common ID
* @details we need to store what node it's consider as common because of the end
* @brief the map of the node consider as common and the common ID
* @details we need to store what node it's consider as common because of the end
* resolution of the matching, all node consider as common need to be the same in all context
*/
std::map<NodePtr,std::size_t> mCommonNodes;
......@@ -47,13 +47,13 @@ namespace Aidge{
*/
std::map<std::shared_ptr<ConditionalInterpreter>,std::set<NodePtr>> mValidNodes;
/**
* @brief the index in the rejected node of this context
* @brief the index in the rejected node of this context
*/
std::size_t mLocalIdxRejeced;
public:
/**
* @brief constructor
* @param actState the actual state in the FSM
* @brief constructor
* @param actState the actual state in the FSM
* @param actOpNode the actual node in the graph
* @param idxRejeced the idx in the global regected node vector init max() as sentinel value of undefind
*/
......@@ -81,7 +81,7 @@ namespace Aidge{
/**
* @defgroup FsmRunTimeContextTest Function for test the context
* @defgroup FsmRunTimeContextTest Function for test the context
*/
/**
......@@ -93,57 +93,57 @@ namespace Aidge{
/**
* @ingroup FsmRunTimeContextTest
* @brief test if the node is considered as common in this context
* @param node node to test
* @param node node to test
* @return bool
*/
bool isCommonDefined(NodePtr node);
/**
* @ingroup FsmRunTimeContextTest
* @brief test if has already validated in this context
* @param node node to test
* @param node node to test
* @return bool
*/
bool isAlreadyValid(NodePtr node);
/**
* @ingroup FsmRunTimeContextTest
* @brief test if this context is compatible with an others
* @brief test if this context is compatible with an others
* @details to say that two contexts are compatible is to check :
* that the contexts do not validate the same nodes (other than the common ones)
* that the contexts do not validate the same nodes (other than the common ones)
* and that the common ones have the same idx
* @param fsmContext the others context
* @param fsmContext the others context
* @return bool
*/
bool areCompatible(std::shared_ptr<FsmRunTimeContext> fsmContext);
/**
* @ingroup FsmRunTimeContextTest
* @brief test if this context is strictly equal with an others
* @param fsmContext the others context
* @brief test if this context is strictly equal with an others
* @param fsmContext the others context
* @return bool
*/
bool areEqual(std::shared_ptr<FsmRunTimeContext> fsmContext);
/**
* @defgroup FsmRunTimeContextSet Function set context
* @defgroup FsmRunTimeContextSet Function set context
*/
void setCommon(NodePtr node,std::size_t commonIdx);
void setValid(NodePtr node,std::shared_ptr<ConditionalInterpreter> tag);
/**
* @defgroup FsmRunTimeContextGet Function get context
* @defgroup FsmRunTimeContextGet Function get context
*/
/**
* @ingroup FsmRunTimeContextGet
* @brief get the sub idx state
* @brief get the sub idx state
* @return bool
*/
std::size_t getSubStmId(void);
NodePtr getCommonNodeFromIdx(std::size_t commonIdx);
std::size_t getCommonNodeIdx(NodePtr node);
std::set<NodePtr> getCommonNodes(void);
......@@ -158,16 +158,16 @@ namespace Aidge{
NodePtr getActNode(void);
std::shared_ptr<FsmNode> getActState(void);
/**
* @defgroup FsmRunTimeContextMem
* @defgroup FsmRunTimeContextMem
*/
void rst(void);
};
}
#endif //__AIDGE_FSM_RUN_TIME_CONTEXT_H__
\ No newline at end of file
#endif //AIDGE_CORE_FSM_RUN_TIME_CONTEXT_H_
#ifndef __AIDGE_MATCH_RESULT_H__
#define __AIDGE_MATCH_RESULT_H__
#ifndef AIDGE_CORE_MATCH_RESULT_H_
#define AIDGE_CORE_MATCH_RESULT_H_
#include <memory>
#include <vector>
......@@ -13,7 +13,7 @@ namespace Aidge{
/**
* @brief class that old the result of a matching
* give acess to all node ant there tag in the expression
* give acess to all node ant there tag in the expression
*/
class MatchResult
{
......@@ -22,7 +22,7 @@ private:
std::vector<std::shared_ptr<FsmRunTimeContext>> mAllValid;
/*
the Run time of eatch sub FSM , to have a valide match we need a set of one run time per FSM compatible
the Run time of eatch sub FSM , to have a valide match we need a set of one run time per FSM compatible
the id must be contigue
*/
std::vector<std::vector<std::shared_ptr<FsmRunTimeContext>>> mIdToRunTime;
......@@ -37,8 +37,8 @@ public:
virtual ~MatchResult() = default;
/**
* @brief get the set of the node match for une expression
* @return the set of node of the graph that corresponding to an expression
* @brief get the set of the node match for une expression
* @return the set of node of the graph that corresponding to an expression
*/
std::set<NodePtr> getBiggerSolution(void);
......@@ -57,4 +57,4 @@ void _generateCombinationd( std::size_t idxSubStm, std::vector<std::shared_ptr<F
}
#endif //__AIDGE_MATCH_RESULT_H__
\ No newline at end of file
#endif //AIDGE_CORE_MATCH_RESULT_H_
#ifndef _AIDGE_CONDITIONAL_DATA_H_
#define _AIDGE_CONDITIONAL_DATA_H_
#ifndef AIDGE_CORE_CONDITIONAL_DATA_H_
#define AIDGE_CORE_CONDITIONAL_DATA_H_
#include <vector>
#include <string>
#include <string>
#include <stdexcept> //error
#include <memory>
#include <map>
......@@ -12,7 +12,7 @@ namespace Aidge{
/////////////////////////
// the data type in AST Intepretation
// The data type in AST Intepretation
////////////////////////
class BaseConditionalValue {
......@@ -30,7 +30,7 @@ public:
struct ConditionalData {
/**
* @brief generic type to propagete all the different values in the AST interpretation
* @brief generic type to propagate all the different values in the AST interpretation
*/
//void* value;
std::unique_ptr<BaseConditionalValue> value;
......@@ -40,7 +40,7 @@ struct ConditionalData {
//
////////////////////////////////
/**
* @brief set a value
* @brief set a value
*/
template <typename T>
void setValue(const T& newValue) {
......@@ -51,10 +51,10 @@ struct ConditionalData {
}
/**
* @brief get the actual value
* @details recaste the value to the templaited type and checks that the conversion type is compatible with type
* @tparam the type of the return value
* @return the value
* @brief get the actual value
* @details recaste the value to the templaited type and checks that the conversion type is compatible with type
* @tparam the type of the return value
* @return the value
*/
template <typename T>
T getValue() const {
......@@ -73,7 +73,7 @@ struct ConditionalData {
std::string getType() const {
return type ? type->name() : "nullptr";
}
template <typename T>
bool isTypeEqualTo() const {
......@@ -87,7 +87,7 @@ struct ConditionalData {
}
}
~ConditionalData() { // TODO best can we have a liste of type supported ?
~ConditionalData() { // TODO best can we have a list of type supported ?
deleteValue();
}
};
......@@ -95,4 +95,4 @@ struct ConditionalData {
}
#endif //_AIDGE_CONDITIONAL_DATA_H_
\ No newline at end of file
#endif //AIDGE_CORE_CONDITIONAL_DATA_H_
#ifndef _AIDGE_CONDITIONAL_INTERPRETER_H_
#define _AIDGE_CONDITIONAL_INTERPRETER_H_
#ifndef AIDGE_CORE_CONDITIONAL_INTERPRETER_H_
#define AIDGE_CORE_CONDITIONAL_INTERPRETER_H_
#include "aidge/nodeTester/ConditionalParser.hpp"
#include "aidge/nodeTester/ConditionalData.hpp"
......@@ -21,8 +21,8 @@ namespace Aidge{
//
/////////////////////////////
/**
* @brief class used to register any lambda function without context,
* it encapsulates the source lambda in a lambda which takes as argument ConditionalData* which are any type.
* @brief class used to register any lambda function without context,
* it encapsulates the source lambda in a lambda which takes as argument ConditionalData* which are any type.
* @see ConditionalData
*/
class ConditionalRegisterFunction {
......@@ -31,8 +31,8 @@ class ConditionalRegisterFunction {
//////////////////////////
/**
* @brief recaste the ConditionalData* to the argument type of the lambda
* @tparam T type of the lambda argument
* @brief recast the ConditionalData* to the argument type of the lambda
* @tparam T type of the lambda argument
* @see ConditionalData
*/
template <typename T>
......@@ -43,29 +43,29 @@ class ConditionalRegisterFunction {
}else{
throw std::invalid_argument( "incompatible input type " + data->getType() +" "+ typeid(T).name() );
}
}
/**
* @brief recaste the output of the lambda to a ConditionalData*
* @tparam T type of the lambda return
* @brief recaste the output of the lambda to a ConditionalData*
* @tparam T type of the lambda return
* @see ConditionalData
*/
template <typename T>
ConditionalData* safeCastOutput(T data) {
ConditionalData* out = new ConditionalData;
out->setValue<T>(data);
return out;
}
//////////////////////
// get all the type of the function
// get all the type of the function
//////////////////////
/**
......@@ -74,7 +74,7 @@ class ConditionalRegisterFunction {
*/
template <typename T>
struct function_traits;
/**
* @brief Specialization of function_traits for function pointers.
......@@ -85,7 +85,7 @@ class ConditionalRegisterFunction {
struct function_traits<R (*)(Args...)> {
using return_type = R;
static constexpr std::size_t arity = sizeof...(Args);
template <std::size_t N>
struct argument {
static_assert(N < arity, "Index out of range.");
......@@ -102,18 +102,18 @@ class ConditionalRegisterFunction {
struct function_traits<std::function<R(Args...)>> {
using return_type = R;
static constexpr std::size_t arity = sizeof...(Args);
template <std::size_t N>
struct argument {
static_assert(N < arity, "Index out of range.");
using type = typename std::tuple_element<N, std::tuple<Args...>>::type;
};
};
/////////////////////
//change the function to ConditionalData*(std::vector<ConditionalData*>)
/////////////////////
/**
* @brief Converts a function to a ConditionalData*(std::vector<ConditionalData*>).
* @tparam F The type of the function to convert.
......@@ -128,19 +128,19 @@ class ConditionalRegisterFunction {
if (args.size() != sizeof...(ParamsIdx)){
std::ostringstream errorMessage;
errorMessage << "bad Number of argument: get " << args.size() << " need " << sizeof...(ParamsIdx) << "\n";
throw std::runtime_error(errorMessage.str());
throw std::runtime_error(errorMessage.str());
}
//assert(args.size() == sizeof...(ParamsIdx));//the size of the vector valide
//assert(args.size() == sizeof...(ParamsIdx));//the size of the vector valide
using FuncTraits = function_traits<decltype(f)>;
using outType = typename FuncTraits::return_type;
outType result = f(safeCastInput<typename FuncTraits::template argument<ParamsIdx>::type>(args[ParamsIdx])...);
//typename
//typename
return safeCastOutput<outType>(result);
};
}
/**
* @brief Converts a function pointer to a ConditionalData*(std::vector<ConditionalData*>).
* @tparam R The return type of the function.
......@@ -164,20 +164,20 @@ class ConditionalRegisterFunction {
auto funcPointer(std::function<R(Params...)> f) {
return funcPointer(f, std::index_sequence_for<Params...>{});
}
///////////////////
// interface
///////////////////
public:
/**
* @brief Default constructor
* @brief Default constructor
*/
ConditionalRegisterFunction(){}
/**
* @brief Inserts a function into the map with the provided key.
* @tparam T The function type.
......@@ -188,8 +188,8 @@ class ConditionalRegisterFunction {
void insert(const std::string key,T f){
mWlambda.insert({ key, funcPointer(f)});
}
/**
* @brief Runs the function associated with the given key, using the provided vector of input data.
* @param key The key of the function to run.
......@@ -197,7 +197,7 @@ class ConditionalRegisterFunction {
* @return A pointer to the output ConditionalData object.
*/
ConditionalData* run(const std::string key,std::vector<ConditionalData*> & datas);
private:
/// @brief map of name and the converted function.
std::map<const std::string, std::function<ConditionalData*(std::vector<ConditionalData*> &)>> mWlambda;
......@@ -207,8 +207,8 @@ class ConditionalRegisterFunction {
//AST tree node
// ////////////////
/**
* @brief this class interprets AST to generate a test on a graph node. For each AST node,
* it generates an interpretation and registers lambda functions that can be used in the test expression.
* @brief this class interprets AST to generate a test on a graph node. For each AST node,
* it generates an interpretation and registers lambda functions that can be used in the test expression.
* there are two lambda control mechanisms:
* - A cpp mechanism which allows any lambda to be inserted into the constructor that use templaite
* - A user mechanism limited to lambda bool(NodePtr)
......@@ -236,24 +236,24 @@ class ConditionalInterpreter
for (std::size_t i = 0; i < mResolution.size(); ++i) {
delete mResolution[i];
}
}
mResolution.clear();
}
public:
/**
* @brief Constructor
* @brief Constructor
* @param ConditionalExpressions The expression of the test to be performed on the nodes
*/
ConditionalInterpreter(const std::string ConditionalExpressions);
~ConditionalInterpreter(){clearRes();}
/**
* @brief Test a node depending of the ConditionalExpressions
* @details the AST is visit using \ref visit() whith the $ init whit the nodeOp
* @return bool the match node has the initialized expresion
* @return bool the match node has the initialized expresion
* @see visit() This function uses the visit() function to perform the evaluation.
*/
bool test( const NodePtr nodeOp);
......@@ -262,7 +262,7 @@ class ConditionalInterpreter
* @brief Interface for inserting custom lambda bool(NodePtr) functions in AST interpretation,
* it will be available in the ConditionalExpressions expretion as : key($)
* @param key The key that will be used to call the function in the expression
* @param f The pointer to function
* @param f The pointer to function
*/
void insertLambda(const std::string key,std::function<bool(Aidge::NodePtr)> f);
......@@ -273,15 +273,15 @@ class ConditionalInterpreter
/**
* @brief Recursive AST traversal function, using the for interpreting AST nodes function,
* using \ref ASTnodeInterpreterF fuctions
* @param NodeOp The node currently being tested
* @param nodes The AST given by the parsing process
* @param NodeOp The node currently being tested
* @param nodes The AST given by the parsing process
*/
std::vector<ConditionalData*> visit(const ASTNodeCh& nodes, const NodePtr NodeOp );
/**
* @defgroup ASTnodeInterpreterF Functions for interpreting AST nodes
* @brief For each node type in the AST, function defines the processing to be performed
* they return a std::vector<ConditionalData*> which corresponds to the value(s) obtained
* @defgroup ASTnodeInterpreterF Functions for interpreting AST nodes
* @brief For each node type in the AST, function defines the processing to be performed
* they return a std::vector<ConditionalData*> which corresponds to the value(s) obtained
*/
/**
......@@ -307,28 +307,28 @@ class ConditionalInterpreter
/**
* @ingroup ASTnodeInterpreterF
* @brief makes the == operation between two previously converted ConditionalData*
* @brief makes the == operation between two previously converted ConditionalData*
*/
void fEq(void);
/**
* @ingroup ASTnodeInterpreterF
* @brief makes the != operation between two previously converted ConditionalData*
* @brief makes the != operation between two previously converted ConditionalData*
*/
void fNeq(void);
/**
* @ingroup ASTnodeInterpreterF
* @brief makes the && operation between two previously converted ConditionalData* in bool
* @brief makes the && operation between two previously converted ConditionalData* in bool
*/
void fAnd(void);
/**
* @ingroup ASTnodeInterpreterF
* @brief makes the || operation between two previously converted ConditionalData* in bool
* @brief makes the || operation between two previously converted ConditionalData* in bool
*/
void fOr(void);
/**
* @ingroup ASTnodeInterpreterF
* @brief makes the ! operation
* @brief makes the ! operation
*/
void fNot(void);
};
......@@ -336,4 +336,4 @@ class ConditionalInterpreter
}
#endif //_AIDGE_CONDITIONAL_INTERPRETER_H_
#endif //AIDGE_CORE_CONDITIONAL_INTERPRETER_H_
/**
* @file
* @brief
* @brief
* @version file 1.0.0
* @author vl241552
* @copyright
......@@ -10,8 +10,8 @@
#ifndef _AIDGE_CONDITIONAL_LEXER_H_
#define _AIDGE_CONDITIONAL_LEXER_H_
#ifndef AIDGE_CORE_CONDITIONAL_LEXER_H_
#define AIDGE_CORE_CONDITIONAL_LEXER_H_
#include <string>
#include <regex>
......@@ -37,25 +37,25 @@ ConditionalLexer( const std::string ConditionalExpressions );
/**
* @brief Get the next token on the ConditionalExpressions
* @return ParsingToken<ConditionalTokenTypes>
* @return ParsingToken<ConditionalTokenTypes>
*/
std::shared_ptr<ParsingToken<ConditionalTokenTypes>> getNextToken(void);
/**
* @brief Restart at the start of the ConditionalExpressions
*
* @brief Restart at the start of the ConditionalExpressions
*
*/
void rstPosition(void);
/**
* @brief Test if the string is completely read
* @return bool
* @brief Test if the string is completely read
* @return bool
*/
bool isEnd(void);
/**
* @brief Get the representation of the class
* @return string
* @return string
*/
const std::string rep(){
return mConditionalExpressions;
......@@ -64,8 +64,8 @@ const std::string rep(){
private:
/**
* @brief Constructs an error message to display the character not understood by the lexer
* @return error mesage
* @brief Constructs an error message to display the character not understood by the lexer
* @return error mesage
*/
std::runtime_error badTokenError(const std::string& currentChars,std::size_t position);
......@@ -85,4 +85,4 @@ std::size_t mPosition;
}
#endif //_AIDGE_CONDITIONAL_LEXER_H_
\ No newline at end of file
#endif //AIDGE_CORE_CONDITIONAL_LEXER_H_
#ifndef _AIDGE_CONDITIONAL_PARSER_H_
#define _AIDGE_CONDITIONAL_PARSER_H_
#ifndef AIDGE_CORE_CONDITIONAL_PARSER_H_
#define AIDGE_CORE_CONDITIONAL_PARSER_H_
#include <memory> // for shared_ptr
......@@ -22,26 +22,26 @@ const std::map<ConditionalTokenTypes, std::size_t> ConditionalPrec{
};
using ASTNodeCh = std::vector<std::shared_ptr<AstNode<ConditionalTokenTypes>>>;
/**
* @brief this class uses the lexer to create an AST according to a set of gramer rules
* @brief this class uses the lexer to create an AST according to a set of gramer rules
*/
class ConditionalParser{
public:
/**
* @brief AST graph creation function
* @brief AST graph creation function
* @param ConditionalExpressions String representing the logical fuction to be performed
*/
ConditionalParser(const std::string ConditionalExpressions);
virtual ~ConditionalParser() = default;
/**
* @brief AST graph creation function
* @return The AST tree
* @brief AST graph creation function
* @return The AST tree
*/
std::shared_ptr<AstNode<ConditionalTokenTypes>> parse(void);
......@@ -51,7 +51,7 @@ class ConditionalParser{
* @brief restart at the start of the ConditionalExpressions for LEXER and restart mCurrentToken
*/
void rstParser(void);
//////////////////
/**
......@@ -61,33 +61,33 @@ class ConditionalParser{
/**
* @ingroup ParsingFunctions
* @brief Token reading and verification function
*
* @brief Token reading and verification function
*
*/
void ackToken(ConditionalTokenTypes tokenType);
/**
* @ingroup ParsingFunctions
* @brief Function of grammar rules for values : (KEY|INTEGER|FOAT|STRING|LAMBDA lambda)
* @return AST node
* @return AST node
*/
std::shared_ptr<AstNode<ConditionalTokenTypes>> constructAstVal(void);
/**
* @ingroup ParsingFunctions
* @brief Function of grammar rules for comparison : val (EQ|NEQ) val | LPAREN expr RPAREN
* @return AST node
* @return AST node
*/
std::shared_ptr<AstNode<ConditionalTokenTypes>> constructAstCmpr(void);
/**
* @ingroup ParsingFunctions
* @brief Function of grammar rules for arguments of a lambda : LAMBDA val (ARGSEP val)* RPAREN
* @return AST node
* @return AST node
*/
std::shared_ptr<AstNode<ConditionalTokenTypes>> constructAstLambda(void);
/**
* @ingroup ParsingFunctions
* @brief Function of grammar rules for a expresion : cmpr ((AND | OR) cmpr)*
* @return AST node
* @return AST node
*/
std::shared_ptr<AstNode<ConditionalTokenTypes>> constructAstExpr(std::size_t precLimit = 0);
......@@ -106,4 +106,4 @@ class ConditionalParser{
}
#endif //_AIDGE_CONDITIONAL_PARSER_H_
#endif //AIDGE_CORE_CONDITIONAL_PARSER_H_
#ifndef _AIDGE_CONDITIONAL_TYPES_H_
#define _AIDGE_CONDITIONAL_TYPES_H_
#ifndef AIDGE_CORE_CONDITIONAL_TYPES_H_
#define AIDGE_CORE_CONDITIONAL_TYPES_H_
namespace Aidge{
/**
* @brief enum for all types of token use in the parsing
* @brief enum for all types of token use in the parsing
* 7-5 type
* 4-0 id
*/
enum class ConditionalTokenTypes
{
NOT = (1 << 4)+3, /**< ! */
AND = (1 << 4)+2, /**< && */
OR = (1 << 4)+1, /**< || */
STOP,
EQ = (1 << 5)+1, /**< == */
NEQ = (1 << 5)+2, /**< != */
NOT, /**< ! */
AND, /**< && */
OR, /**< || */
KEY = (1 << 6) +1 , /**< [A-Za-z][A-Za-z0-9_]* */
INTEGER = (1 << 6) +2 , /**< [0-9]+ */
FLOAT = (1 << 6) +3 , /**< [0-9]+\.[0-9]* */
STRING = (1 << 6) +4 , /**< \'.*\' */
BOOL = (1 << 6) +5 , /**< true|false */
NODE = (1 << 6) +6 , /**< \$ */
LAMBDA = (1 << 6) +7 , /**< [A-Za-z][A-Za-z0-9_]*\( */
EQ, /**< == */
NEQ, /**< != */
KEY, /**< [A-Za-z][A-Za-z0-9_]* */
INTEGER, /**< [0-9]+ */
FLOAT, /**< [0-9]+\.[0-9]* */
STRING , /**< \'.*\' */
BOOL, /**< true|false */
NODE, /**< \$ */
LAMBDA , /**< [A-Za-z][A-Za-z0-9_]*\( */
ARGSEP, /**< , */
LPAREN, /**< \( */
RPAREN, /**< \) */
ARGSEP = (1<<7) +1, /**< , */
LPAREN = (1<<7) +2, /**< \( */
RPAREN = (1<<7) +3, /**< \) */
STOP = 0,
};
}
#endif
\ No newline at end of file
#endif // AIDGE_CORE_CONDITIONAL_TYPES_H_
#ifndef _AIDGE_AST_NODE_H_
#define _AIDGE_AST_NODE_H_
#ifndef AIDGE_CORE_AST_NODE_H_
#define AIDGE_CORE_AST_NODE_H_
#include <string>
#include <type_traits>
......@@ -41,7 +41,7 @@ namespace Aidge{
}
/**
* @brief test if the node is a leaf in the tree
* @return true if a leaf
* @return true if a leaf
*/
bool isLeaf() const {
return mChild.size() == 0;
......@@ -66,4 +66,4 @@ namespace Aidge{
};
}
#endif //_AIDGE_AST_NODE_H_
#endif //AIDGE_CORE_AST_NODE_H_
#ifndef _AIDGE_PARSING_TOKEN_H_
#define _AIDGE_PARSING_TOKEN_H_
#ifndef AIDGE_CORE_PARSING_TOKEN_H_
#define AIDGE_CORE_PARSING_TOKEN_H_
#include <string>
#include <type_traits>
......@@ -22,7 +22,7 @@ namespace Aidge{
/**
* @brief get the lexeme
* @return std::string
* @return std::string
*/
const std::string getLexeme(void){
return mLexeme;
......@@ -30,8 +30,8 @@ namespace Aidge{
/**
* @brief get the token type
*
* @return ParsingToken
*
* @return ParsingToken
*/
const EnumType getType(void){
return mType;
......@@ -69,4 +69,4 @@ namespace Aidge{
};
}
#endif //_AIDGE_PARSING_TOKEN_H_
\ No newline at end of file
#endif //AIDGE_CORE_PARSING_TOKEN_H_
......@@ -27,11 +27,11 @@ TEST_CASE("FsmMatch") {
std::shared_ptr<FsmGraph> fsm = fsmGenerator->interpret();
//REQUIRE(fsm->getNodes().size() == 3);
//REQUIRE(fsm->getStartNodes().size() == 1);
std::shared_ptr<GraphView> g1 = std::make_shared<GraphView>("TestGraph");
std::shared_ptr<Node> conv = GenericOperator("Conv", 1, 1, 1, "c");
......@@ -62,7 +62,7 @@ TEST_CASE("FsmMatch") {
g1->add(conv);
g1->addChild(conv1,conv);
g1->addChild(conv2,conv);
REQUIRE(g1->getNodes() == std::set<std::shared_ptr<Node>>({conv,conv1,conv2}));
REQUIRE(g1->inputNodes() == std::set<std::shared_ptr<Node>>({conv}));
REQUIRE(g1->outputNodes() == std::set<std::shared_ptr<Node>>({conv1,conv2}));
......@@ -86,4 +86,4 @@ TEST_CASE("FsmMatch") {
}
}
\ No newline at end of file
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment