Skip to content
Snippets Groups Projects
Commit d1ac46b2 authored by Olivier BICHLER's avatar Olivier BICHLER
Browse files

Removed unused files

parent 316bf5ca
No related branches found
No related tags found
1 merge request!332Add selection mechanism in graph
Pipeline #67000 passed
#ifndef AIDGE_CORE_AST_NODE_H_
#define AIDGE_CORE_AST_NODE_H_
#include <string>
#include <type_traits>
#include <vector>
#include <memory>
#include "aidge/utilsParsing/ParsingToken.hpp"
namespace Aidge{
template <typename EnumType>
class AstNode: public std::enable_shared_from_this<AstNode<EnumType>>
{
static_assert(std::is_enum<EnumType>::value, "AstNode EnumType must be an enum type");
public:
AstNode(std::shared_ptr<ParsingToken<EnumType>> token,std::vector<std::shared_ptr<AstNode<EnumType>>> child ={}):mToken(token),mChild(child){}
/**
* @brief get the type of the token
* @return the type
*/
EnumType getType() const{
return mToken->getType();
}
/**
* @brief get the lexeme of the token
* @return the lexeme
*/
std::string getValue() const{
return mToken->getLexeme();
}
/**
* @brief get the child of the node
* @return child
*/
const std::vector<std::shared_ptr<AstNode>>& getChilds() const {
return mChild;
}
/**
* @brief test if the node is a leaf in the tree
* @return true if a leaf
*/
bool isLeaf() const {
return mChild.size() == 0;
}
/**
* @brief get the number of child
* @return the number of child
*/
std::size_t nbChild() const{
return mChild.size();
}
private:
/**
* @brief the token of the node
*/
const std::shared_ptr<ParsingToken<EnumType>> mToken;
/**
* @brief list of child
*/
const std::vector<std::shared_ptr<AstNode>> mChild;
};
}
#endif //AIDGE_CORE_AST_NODE_H_
/********************************************************************************
* Copyright (c) 2023 CEA-List
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* SPDX-License-Identifier: EPL-2.0
*
********************************************************************************/
#ifndef AIDGE_CORE_PARSING_TOKEN_H_
#define AIDGE_CORE_PARSING_TOKEN_H_
#include <string>
#include <type_traits>
#include <fmt/format.h>
namespace Aidge {
template <typename EnumType>
class ParsingToken: public std::enable_shared_from_this<ParsingToken<EnumType>>
{
static_assert(std::is_enum<EnumType>::value, "ParsingToken EnumType must be an enum type");
public:
/**
* @brief Token container
* @param type one of the token type
* @param lexeme String representing additional information of the token
*/
ParsingToken(const EnumType type , const std::string& lexeme )
: mLexeme(lexeme), mType(type){}
/**
* @brief get the lexeme
* @return std::string
*/
const std::string getLexeme(void) const noexcept {
return mLexeme;
}
/**
* @brief get the token type
*
* @return ParsingToken
*/
const EnumType getType(void) const noexcept {
return mType;
}
/**
* @brief copy the token
* @return deep copy of the token
*/
std::shared_ptr<ParsingToken> copy() const noexcept {
return std::make_shared<ParsingToken<EnumType>>(mType, mLexeme);
}
//TODO
std::string rep(void) const { return fmt::format(" Token ({})\n", mLexeme); }
private:
/**
* @brief additional information of the token
*/
const std::string mLexeme;
/**
* @brief type of the token
* @see ConditionalTokenTypes
*/
const EnumType mType;
};
} // namespace Aidge
#endif //AIDGE_CORE_PARSING_TOKEN_H_
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