Add sources

This commit is contained in:
2018-06-05 22:30:22 +02:00
parent e28912dc5e
commit 9b56ec979d
143 changed files with 8636 additions and 0 deletions

17
src/AST/Declaration.cpp Normal file
View File

@@ -0,0 +1,17 @@
#include "Declaration.h"
/**
* @brief AST::Declaration::Declaration
*/
AST::Declaration::Declaration(void)
{
// ...
}
/**
* @brief AST::Declaration::~Declaration
*/
AST::Declaration::~Declaration(void)
{
// ...
}

40
src/AST/Declaration.h Normal file
View File

@@ -0,0 +1,40 @@
#pragma once
#include "../Node.h"
namespace AST
{
class Declaration : public Node
{
public:
enum EDeclarationType
{
SIMPLE,
NAMESPACE,
STRUCTURE,
CLASS,
FUNCTION,
EMPTY, // created by empty-declaration
ATTRIBUTE, // created be attribute-declaration
ASM, // created by asm-definition
TEMPLATE, // created by template-declaration
EXPLICIT_INSTANTIATION, // created by explicit-instantiation
EXPLICIT_SPECIALIZATION, // created by explicit-specialization
};
explicit Declaration (void);
virtual ~Declaration (void);
virtual ENodeType getNodeType (void) const { return(DECLARATION); }
virtual EDeclarationType getDeclarationType (void) const = 0;
private:
// ...
};
}

View File

@@ -0,0 +1,18 @@
#include "AssemblerDefinition.h"
/**
* @brief AST::AssemblerDefinition::AssemblerDefinition
*/
AST::AssemblerDefinition::AssemblerDefinition(const char * instructions)
: m_strInstructions(instructions)
{
// ...
}
/**
* @brief AST::AssemblerDefinition::~AssemblerDefinition
*/
AST::AssemblerDefinition::~AssemblerDefinition()
{
// ...
}

View File

@@ -0,0 +1,26 @@
#pragma once
#include "../Declaration.h"
#include <string>
namespace AST
{
class AssemblerDefinition : public Declaration
{
public:
explicit AssemblerDefinition (const char * instructions);
virtual ~AssemblerDefinition (void);
virtual EDeclarationType getDeclarationType (void) const { return(ASM); }
private:
std::string m_strInstructions;
};
}

View File

@@ -0,0 +1,17 @@
#include "AttributeDeclaration.h"
/**
* @brief AST::AttributeDeclaration::AttributeDeclaration
*/
AST::AttributeDeclaration::AttributeDeclaration(void)
{
// ...
}
/**
* @brief AST::AttributeDeclaration::~AttributeDeclaration
*/
AST::AttributeDeclaration::~AttributeDeclaration()
{
// ...
}

View File

@@ -0,0 +1,26 @@
#pragma once
#include "../Declaration.h"
#include <string>
namespace AST
{
class AttributeDeclaration : public Declaration
{
public:
explicit AttributeDeclaration (void);
virtual ~AttributeDeclaration (void);
virtual EDeclarationType getDeclarationType (void) const { return(ATTRIBUTE); }
private:
// ...
};
}

View File

@@ -0,0 +1,19 @@
#include "Class.h"
/**
* @brief AST::Class::Class
* @param pName
*/
AST::Class::Class(const char * pName)
: m_strName(pName)
{
// ...
}
/**
* @brief AST::Class::~Class
*/
AST::Class::~Class()
{
// ...
}

View File

@@ -0,0 +1,43 @@
#pragma once
#include "../Declaration.h"
#include <string>
#include <vector>
namespace AST
{
class Class : public Declaration
{
public:
explicit Class (const char * pName);
virtual ~Class (void);
virtual EDeclarationType getDeclarationType (void) const { return(CLASS); }
void addNode (const Node * pNode)
{
m_aNodes.push_back(pNode);
}
const std::vector<const Node *> & getNodes (void) const
{
return(m_aNodes);
}
const std::string & getName(void) const
{
return(m_strName);
}
private:
std::string m_strName;
std::vector<const Node *> m_aNodes;
};
}

View File

@@ -0,0 +1,17 @@
#include "EmptyDeclaration.h"
/**
* @brief AST::EmptyDeclaration::EmptyDeclaration
*/
AST::EmptyDeclaration::EmptyDeclaration(void)
{
// ...
}
/**
* @brief AST::EmptyDeclaration::~EmptyDeclaration
*/
AST::EmptyDeclaration::~EmptyDeclaration()
{
// ...
}

View File

@@ -0,0 +1,26 @@
#pragma once
#include "../Declaration.h"
#include <string>
namespace AST
{
class EmptyDeclaration : public Declaration
{
public:
explicit EmptyDeclaration (void);
virtual ~EmptyDeclaration (void);
virtual EDeclarationType getDeclarationType (void) const { return(EMPTY); }
private:
// ...
};
}

View File

@@ -0,0 +1,18 @@
#include "ExplicitInstantiation.h"
/**
* @brief AST::ExplicitInstantiation::ExplicitInstantiation
*/
AST::ExplicitInstantiation::ExplicitInstantiation(const Declaration * pDeclaration)
: m_pDeclaration(pDeclaration)
{
// ...
}
/**
* @brief AST::ExplicitInstantiation::~ExplicitInstantiation
*/
AST::ExplicitInstantiation::~ExplicitInstantiation()
{
// ...
}

View File

@@ -0,0 +1,26 @@
#pragma once
#include "../Declaration.h"
#include <string>
namespace AST
{
class ExplicitInstantiation : public Declaration
{
public:
explicit ExplicitInstantiation (const Declaration * pDeclaration);
virtual ~ExplicitInstantiation (void);
virtual EDeclarationType getDeclarationType (void) const { return(EXPLICIT_INSTANTIATION); }
private:
const Declaration * m_pDeclaration;
};
}

View File

@@ -0,0 +1,18 @@
#include "ExplicitSpecialization.h"
/**
* @brief AST::ExplicitSpecialization::ExplicitSpecialization
*/
AST::ExplicitSpecialization::ExplicitSpecialization(const Declaration * pDeclaration)
: m_pDeclaration(pDeclaration)
{
// ...
}
/**
* @brief AST::ExplicitSpecialization::~ExplicitSpecialization
*/
AST::ExplicitSpecialization::~ExplicitSpecialization()
{
// ...
}

View File

@@ -0,0 +1,26 @@
#pragma once
#include "../Declaration.h"
#include <string>
namespace AST
{
class ExplicitSpecialization : public Declaration
{
public:
explicit ExplicitSpecialization (const Declaration * pDeclaration);
virtual ~ExplicitSpecialization (void);
virtual EDeclarationType getDeclarationType (void) const { return(EXPLICIT_SPECIALIZATION); }
private:
const Declaration * m_pDeclaration;
};
}

View File

@@ -0,0 +1,22 @@
#include "FunctionDefinition.h"
/**
* @brief AST::Function::Function
* @param pName
* @param pReturnType
*/
AST::FunctionDefinition::FunctionDefinition(const char * pName, const char * pReturnType, const std::vector<const AST::Declaration*> & params)
: m_strName(pName)
, m_strReturnType(pReturnType)
, m_aParameters(params)
{
// ...
}
/**
* @brief AST::Function::~Function
*/
AST::FunctionDefinition::~FunctionDefinition(void)
{
// ...
}

View File

@@ -0,0 +1,54 @@
#pragma once
#include "../Declaration.h"
#include <string>
#include <vector>
namespace AST
{
class FunctionDefinition : public Declaration
{
public:
explicit FunctionDefinition (const char * pName, const char * pReturnType, const std::vector<const AST::Declaration*> & params);
virtual ~FunctionDefinition (void);
virtual EDeclarationType getDeclarationType (void) const { return(FUNCTION); }
const std::string & getReturnType (void) const
{
return(m_strReturnType);
}
const std::vector<const AST::Declaration*> & getParameters (void) const
{
return(m_aParameters);
}
void addNode (const Node * pNode)
{
m_aNodes.push_back(pNode);
}
const std::vector<const Node *> & getNodes (void) const
{
return(m_aNodes);
}
const std::string & getName(void) const
{
return(m_strName);
}
private:
std::string m_strName;
std::string m_strReturnType;
std::vector<const AST::Declaration*> m_aParameters;
std::vector<const Node *> m_aNodes;
};
}

View File

@@ -0,0 +1,20 @@
#include "NamespaceDefinition.h"
/**
* @brief AST::Namespace::Namespace
* @param pName
*/
AST::NamespaceDefinition::NamespaceDefinition(const char * pName, const std::vector<const Node *> & children)
: m_strName(pName)
, m_aNodes(children)
{
// ...
}
/**
* @brief AST::Namespace::~Namespace
*/
AST::NamespaceDefinition::~NamespaceDefinition()
{
// ...
}

View File

@@ -0,0 +1,38 @@
#pragma once
#include "../Declaration.h"
#include <string>
#include <vector>
namespace AST
{
class NamespaceDefinition : public Declaration
{
public:
explicit NamespaceDefinition (const char * pName, const std::vector<const Node *> & children);
virtual ~NamespaceDefinition (void);
virtual EDeclarationType getDeclarationType (void) const { return(NAMESPACE); }
const std::vector<const Node *> & getNodes (void) const
{
return(m_aNodes);
}
const std::string & getName(void) const
{
return(m_strName);
}
private:
std::string m_strName;
std::vector<const Node *> m_aNodes;
};
}

View File

@@ -0,0 +1,20 @@
#include "SimpleDeclaration.h"
/**
* @brief AST::SimpleDeclaration::SimpleDeclaration
*/
AST::SimpleDeclaration::SimpleDeclaration(const char * pType, const char * pName, const Expression * pExpression)
: m_strType(pType)
, m_strName(pName)
, m_pExpression(pExpression)
{
// ...
}
/**
* @brief AST::SimpleDeclaration::~SimpleDeclaration
*/
AST::SimpleDeclaration::~SimpleDeclaration()
{
// ...
}

View File

@@ -0,0 +1,33 @@
#pragma once
#include "../Declaration.h"
#include <string>
namespace AST
{
class Expression;
class SimpleDeclaration : public Declaration
{
public:
explicit SimpleDeclaration (const char * pType, const char * pName, const Expression * pExpression = nullptr);
virtual ~SimpleDeclaration (void);
virtual EDeclarationType getDeclarationType (void) const { return(SIMPLE); }
const std::string & getVariableType (void) const { return(m_strType); }
const std::string & getVariableName (void) const { return(m_strName); }
const Expression * getExpression (void) const { return(m_pExpression); }
private:
std::string m_strType;
std::string m_strName;
const Expression * m_pExpression;
};
}

View File

@@ -0,0 +1,18 @@
#include "StaticAssertDeclaration.h"
/**
* @brief AST::StaticAssertDeclaration::StaticAssertDeclaration
*/
AST::StaticAssertDeclaration::StaticAssertDeclaration(const Expression * pExpression)
: m_pExpression(pExpression)
{
// ...
}
/**
* @brief AST::StaticAssertDeclaration::~StaticAssertDeclaration
*/
AST::StaticAssertDeclaration::~StaticAssertDeclaration(void)
{
// ...
}

View File

@@ -0,0 +1,28 @@
#pragma once
#include "../Declaration.h"
#include <string>
namespace AST
{
class Expression;
class StaticAssertDeclaration : public Declaration
{
public:
explicit StaticAssertDeclaration (const Expression * pExpression);
virtual ~StaticAssertDeclaration (void);
virtual EDeclarationType getDeclarationType (void) const { return(EMPTY); }
private:
const Expression * m_pExpression;
};
}

View File

@@ -0,0 +1,19 @@
#include "Structure.h"
/**
* @brief AST::Structure::Structure
* @param pName
*/
AST::Structure::Structure(const char * pName)
: m_strName(pName)
{
// ...
}
/**
* @brief AST::Structure::~Structure
*/
AST::Structure::~Structure()
{
// ...
}

View File

@@ -0,0 +1,43 @@
#pragma once
#include "../Declaration.h"
#include <string>
#include <vector>
namespace AST
{
class Structure : public Declaration
{
public:
explicit Structure (const char * pName);
virtual ~Structure (void);
virtual EDeclarationType getDeclarationType (void) const { return(STRUCTURE); }
void addNode (const Node * pNode)
{
m_aNodes.push_back(pNode);
}
const std::vector<const Node *> & getNodes (void) const
{
return(m_aNodes);
}
const std::string & getName(void) const
{
return(m_strName);
}
private:
std::string m_strName;
std::vector<const Node *> m_aNodes;
};
}

View File

@@ -0,0 +1,18 @@
#include "TemplateDeclaration.h"
/**
* @brief AST::TemplateDeclaration::TemplateDeclaration
*/
AST::TemplateDeclaration::TemplateDeclaration(const Declaration * pDeclaration)
: m_pDeclaration(pDeclaration)
{
// ...
}
/**
* @brief AST::TemplateDeclaration::~TemplateDeclaration
*/
AST::TemplateDeclaration::~TemplateDeclaration()
{
// ...
}

View File

@@ -0,0 +1,26 @@
#pragma once
#include "../Declaration.h"
#include <string>
namespace AST
{
class TemplateDeclaration : public Declaration
{
public:
explicit TemplateDeclaration (const Declaration * pDeclaration);
virtual ~TemplateDeclaration (void);
virtual EDeclarationType getDeclarationType (void) const { return(TEMPLATE); }
private:
const Declaration * m_pDeclaration;
};
}

17
src/AST/Expression.cpp Normal file
View File

@@ -0,0 +1,17 @@
#include "Expression.h"
/**
* @brief AST::Expression::Expression
*/
AST::Expression::Expression(void)
{
// ...
}
/**
* @brief AST::Expression::~Expression
*/
AST::Expression::~Expression(void)
{
// ...
}

31
src/AST/Expression.h Normal file
View File

@@ -0,0 +1,31 @@
#pragma once
#include "../Node.h"
namespace AST
{
class Expression : public Node
{
public:
enum EExpressionType
{
VARIABLE,
CONSTANT,
CALL,
UNARY,
BINARY
};
explicit Expression (void);
virtual ~Expression (void);
virtual ENodeType getNodeType (void) const { return(EXPRESSION); }
virtual EExpressionType getExpressionType (void) const = 0;
};
}

View File

@@ -0,0 +1,20 @@
#include "Addition.h"
/**
* @brief AST::Addition::Addition
* @param lhs
* @param rhs
*/
AST::Addition::Addition(const Expression * lhs, const Expression * rhs)
: Binary(lhs, rhs)
{
// ...
}
/**
* @brief AST::Addition::~Addition
*/
AST::Addition::~Addition(void)
{
// ...
}

View File

@@ -0,0 +1,20 @@
#pragma once
#include "../Binary.h"
namespace AST
{
class Addition : public Binary
{
public:
explicit Addition (const Expression * lhs, const Expression * rhs);
virtual ~Addition (void);
virtual EBinaryType getBinaryType (void) const { return(Binary::ADDITION); }
};
}

View File

@@ -0,0 +1,20 @@
#include "Division.h"
/**
* @brief AST::Division::Division
* @param lhs
* @param rhs
*/
AST::Division::Division(const Expression * lhs, const Expression * rhs)
: Binary(lhs, rhs)
{
// ...
}
/**
* @brief AST::Division::~Division
*/
AST::Division::~Division(void)
{
// ...
}

View File

@@ -0,0 +1,20 @@
#pragma once
#include "../Binary.h"
namespace AST
{
class Division : public Binary
{
public:
explicit Division (const Expression * lhs, const Expression * rhs);
virtual ~Division (void);
virtual EBinaryType getBinaryType (void) const { return(Binary::DIVISION); }
};
}

View File

@@ -0,0 +1,20 @@
#include "Modulo.h"
/**
* @brief AST::Modulo::Modulo
* @param lhs
* @param rhs
*/
AST::Modulo::Modulo(const Expression * lhs, const Expression * rhs)
: Binary(lhs, rhs)
{
// ...
}
/**
* @brief AST::Modulo::~Modulo
*/
AST::Modulo::~Modulo(void)
{
// ...
}

View File

@@ -0,0 +1,20 @@
#pragma once
#include "../Binary.h"
namespace AST
{
class Modulo : public Binary
{
public:
explicit Modulo (const Expression * lhs, const Expression * rhs);
virtual ~Modulo (void);
virtual EBinaryType getBinaryType (void) const { return(Binary::MODULO); }
};
}

View File

@@ -0,0 +1,20 @@
#include "Multiplication.h"
/**
* @brief AST::Multiplication::Multiplication
* @param lhs
* @param rhs
*/
AST::Multiplication::Multiplication(const Expression * lhs, const Expression * rhs)
: Binary(lhs, rhs)
{
// ...
}
/**
* @brief AST::Multiplication::~Multiplication
*/
AST::Multiplication::~Multiplication(void)
{
// ...
}

View File

@@ -0,0 +1,20 @@
#pragma once
#include "../Binary.h"
namespace AST
{
class Multiplication : public Binary
{
public:
explicit Multiplication (const Expression * lhs, const Expression * rhs);
virtual ~Multiplication (void);
virtual EBinaryType getBinaryType (void) const { return(Binary::MULTIPLICATON); }
};
}

View File

@@ -0,0 +1,20 @@
#include "Subtraction.h"
/**
* @brief AST::Subtraction::Subtraction
* @param lhs
* @param rhs
*/
AST::Subtraction::Subtraction(const Expression * lhs, const Expression * rhs)
: Binary(lhs, rhs)
{
// ...
}
/**
* @brief AST::Subtraction::~Subtraction
*/
AST::Subtraction::~Subtraction(void)
{
// ...
}

View File

@@ -0,0 +1,20 @@
#pragma once
#include "../Binary.h"
namespace AST
{
class Subtraction : public Binary
{
public:
explicit Subtraction (const Expression * lhs, const Expression * rhs);
virtual ~Subtraction (void);
virtual EBinaryType getBinaryType (void) const { return(Binary::SUBTRACTION); }
};
}

View File

@@ -0,0 +1,20 @@
#include "UnaryMinus.h"
/**
* @brief AST::UnaryMinus::UnaryMinus
* @param pExpr
*/
AST::UnaryMinus::UnaryMinus(const AST::Expression * pExpr)
: Unary(pExpr)
{
// ...
}
/**
* @brief AST::UnaryMinus::~UnaryMinus
*/
AST::UnaryMinus::~UnaryMinus(void)
{
// ...
}

View File

@@ -0,0 +1,20 @@
#pragma once
#include "../Unary.h"
namespace AST
{
class UnaryMinus : public Unary
{
public:
explicit UnaryMinus (const Expression * pExpr);
virtual ~UnaryMinus (void);
virtual EUnaryType getUnaryType (void) const { return(Unary::MINUS); }
};
}

View File

@@ -0,0 +1,19 @@
#include "UnaryPlus.h"
/**
* @brief AST::UnaryPlus::UnaryPlus
* @param pExpr
*/
AST::UnaryPlus::UnaryPlus(const AST::Expression * pExpr)
: Unary(pExpr)
{
// ...
}
/**
* @brief AST::UnaryPlus::~UnaryPlus
*/
AST::UnaryPlus::~UnaryPlus(void)
{
// ...
}

View File

@@ -0,0 +1,20 @@
#pragma once
#include "../Unary.h"
namespace AST
{
class UnaryPlus : public Unary
{
public:
explicit UnaryPlus (const Expression * pExpr);
virtual ~UnaryPlus (void);
virtual EUnaryType getUnaryType (void) const { return(Unary::PLUS); }
};
}

View File

@@ -0,0 +1,20 @@
#include "AdditionAssignment.h"
/**
* @brief AST::AdditionAssignment::AdditionAssignment
* @param lhs
* @param rhs
*/
AST::AdditionAssignment::AdditionAssignment(const Expression * lhs, const Expression * rhs)
: Binary(lhs, rhs)
{
// ...
}
/**
* @brief AST::AdditionAssignment::~AdditionAssignment
*/
AST::AdditionAssignment::~AdditionAssignment(void)
{
// ...
}

View File

@@ -0,0 +1,20 @@
#pragma once
#include "../Binary.h"
namespace AST
{
class AdditionAssignment : public Binary
{
public:
explicit AdditionAssignment (const Expression * lhs, const Expression * rhs);
virtual ~AdditionAssignment (void);
virtual EBinaryType getBinaryType (void) const { return(Binary::ADDITION_ASSIGNMENT); }
};
}

View File

@@ -0,0 +1,20 @@
#include "BasicAssignment.h"
/**
* @brief AST::BasicAssignment::BasicAssignment
* @param lhs
* @param rhs
*/
AST::BasicAssignment::BasicAssignment(const Expression * lhs, const Expression * rhs)
: Binary(lhs, rhs)
{
// ...
}
/**
* @brief AST::BasicAssignment::~BasicAssignment
*/
AST::BasicAssignment::~BasicAssignment(void)
{
// ...
}

View File

@@ -0,0 +1,20 @@
#pragma once
#include "../Binary.h"
namespace AST
{
class BasicAssignment : public Binary
{
public:
explicit BasicAssignment (const Expression * lhs, const Expression * rhs);
virtual ~BasicAssignment (void);
virtual EBinaryType getBinaryType (void) const { return(Binary::BASIC_ASSIGNMENT); }
};
}

View File

@@ -0,0 +1,20 @@
#include "DivisionAssignment.h"
/**
* @brief AST::DivisionAssignment::DivisionAssignment
* @param lhs
* @param rhs
*/
AST::DivisionAssignment::DivisionAssignment(const Expression * lhs, const Expression * rhs)
: Binary(lhs, rhs)
{
// ...
}
/**
* @brief AST::DivisionAssignment::~DivisionAssignment
*/
AST::DivisionAssignment::~DivisionAssignment(void)
{
// ...
}

View File

@@ -0,0 +1,20 @@
#pragma once
#include "../Binary.h"
namespace AST
{
class DivisionAssignment : public Binary
{
public:
explicit DivisionAssignment (const Expression * lhs, const Expression * rhs);
virtual ~DivisionAssignment (void);
virtual EBinaryType getBinaryType (void) const { return(Binary::DIVISION_ASSIGNMENT); }
};
}

View File

@@ -0,0 +1,20 @@
#include "ModuloAssignment.h"
/**
* @brief AST::ModuloAssignment::ModuloAssignment
* @param lhs
* @param rhs
*/
AST::ModuloAssignment::ModuloAssignment(const Expression * lhs, const Expression * rhs)
: Binary(lhs, rhs)
{
// ...
}
/**
* @brief AST::ModuloAssignment::~ModuloAssignment
*/
AST::ModuloAssignment::~ModuloAssignment(void)
{
// ...
}

View File

@@ -0,0 +1,20 @@
#pragma once
#include "../Binary.h"
namespace AST
{
class ModuloAssignment : public Binary
{
public:
explicit ModuloAssignment (const Expression * lhs, const Expression * rhs);
virtual ~ModuloAssignment (void);
virtual EBinaryType getBinaryType (void) const { return(Binary::MODULO_ASSIGNMENT); }
};
}

View File

@@ -0,0 +1,20 @@
#include "MultiplicationAssignment.h"
/**
* @brief AST::MultiplicationAssignment::MultiplicationAssignment
* @param lhs
* @param rhs
*/
AST::MultiplicationAssignment::MultiplicationAssignment(const Expression * lhs, const Expression * rhs)
: Binary(lhs, rhs)
{
// ...
}
/**
* @brief AST::MultiplicationAssignment::~MultiplicationAssignment
*/
AST::MultiplicationAssignment::~MultiplicationAssignment(void)
{
// ...
}

View File

@@ -0,0 +1,20 @@
#pragma once
#include "../Binary.h"
namespace AST
{
class MultiplicationAssignment : public Binary
{
public:
explicit MultiplicationAssignment (const Expression * lhs, const Expression * rhs);
virtual ~MultiplicationAssignment (void);
virtual EBinaryType getBinaryType (void) const { return(Binary::MULTIPLICATION_ASSIGNMENT); }
};
}

View File

@@ -0,0 +1,20 @@
#include "SubtractionAssignment.h"
/**
* @brief AST::SubtractionAssignment::SubtractionAssignment
* @param lhs
* @param rhs
*/
AST::SubtractionAssignment::SubtractionAssignment(const Expression * lhs, const Expression * rhs)
: Binary(lhs, rhs)
{
// ...
}
/**
* @brief AST::SubtractionAssignment::~SubtractionAssignment
*/
AST::SubtractionAssignment::~SubtractionAssignment(void)
{
// ...
}

View File

@@ -0,0 +1,20 @@
#pragma once
#include "../Binary.h"
namespace AST
{
class SubtractionAssignment : public Binary
{
public:
explicit SubtractionAssignment (const Expression * lhs, const Expression * rhs);
virtual ~SubtractionAssignment (void);
virtual EBinaryType getBinaryType (void) const { return(Binary::SUBTRACTION_ASSIGNMENT); }
};
}

View File

@@ -0,0 +1,19 @@
#include "Binary.h"
/**
* @brief AST::Binary::Binary
*/
AST::Binary::Binary(const Expression * pLeftExpr, const Expression * pRightExpr)
: m_pLeftExpr(pLeftExpr)
, m_pRightExpr(pRightExpr)
{
// ...
}
/**
* @brief AST::Binary::~Binary
*/
AST::Binary::~Binary(void)
{
// ...
}

View File

@@ -0,0 +1,53 @@
#pragma once
#include "../Expression.h"
namespace AST
{
class Binary : public Expression
{
public:
enum EBinaryType
{
// Arithmetic
ADDITION,
SUBTRACTION,
MULTIPLICATON,
DIVISION,
MODULO,
// Relational
EQ,
NEQ,
GT,
GEQ,
LT,
LEQ,
// Assignment
BASIC_ASSIGNMENT,
ADDITION_ASSIGNMENT,
SUBTRACTION_ASSIGNMENT,
MULTIPLICATION_ASSIGNMENT,
DIVISION_ASSIGNMENT,
MODULO_ASSIGNMENT,
};
explicit Binary (const Expression * pLeftExpr, const Expression * pRightExpr);
virtual ~Binary (void);
virtual EExpressionType getExpressionType (void) const { return(BINARY); }
const Expression * getLeftExpression() const { return(m_pLeftExpr); }
const Expression * getRightExpression() const { return(m_pRightExpr); }
virtual EBinaryType getBinaryType (void) const = 0;
private:
const Expression * m_pLeftExpr;
const Expression * m_pRightExpr;
};
}

View File

@@ -0,0 +1,19 @@
#include "Call.h"
/**
* @brief AST::Call::Call
*/
AST::Call::Call(const char * pName, const std::vector<const Expression *> & arguments)
: m_strFunctionName(pName)
, m_aArguments(arguments)
{
// ...
}
/**
* @brief AST::Call::~Call
*/
AST::Call::~Call(void)
{
// ...
}

View File

@@ -0,0 +1,31 @@
#pragma once
#include "../Expression.h"
#include <string>
#include <vector>
namespace AST
{
class Call : public Expression
{
public:
explicit Call (const char * pName, const std::vector<const Expression *> & arguments);
virtual ~Call (void);
virtual EExpressionType getExpressionType (void) const { return(CALL); }
const std::string & getFunctionName(void) const { return(m_strFunctionName); }
const std::vector<const Expression *> & getArguments(void) const { return(m_aArguments); }
private:
std::string m_strFunctionName;
std::vector<const Expression *> m_aArguments;
};
}

View File

@@ -0,0 +1,59 @@
#include "Constant.h"
/**
* @brief AST::Constant::Constant
* @param c
*/
AST::Constant::Constant(char c)
: m_eType(CHAR)
{
m_nValue.as_char = c;
}
/**
* @brief AST::Constant::Constant
* @param s
*/
AST::Constant::Constant(short s)
: m_eType(SHORT)
{
m_nValue.as_short = s;
}
/**
* @brief AST::Constant::Constant
* @param i
*/
AST::Constant::Constant(int i)
: m_eType(INTEGER)
{
m_nValue.as_int = i;
}
/**
* @brief AST::Constant::Constant
* @param f
*/
AST::Constant::Constant(float f)
: m_eType(FLOAT)
{
m_nValue.as_float = f;
}
/**
* @brief AST::Constant::Constant
* @param d
*/
AST::Constant::Constant(double d)
: m_eType(DOUBLE)
{
m_nValue.as_double = d;
}
/**
* @brief AST::Constant::~Constant
*/
AST::Constant::~Constant(void)
{
// ...
}

View File

@@ -0,0 +1,54 @@
#pragma once
#include "../Expression.h"
namespace AST
{
class Constant : public Expression
{
public:
enum ENumberType
{
CHAR,
SHORT,
INTEGER,
FLOAT,
DOUBLE
};
explicit Constant (char c);
explicit Constant (short s);
explicit Constant (int i);
explicit Constant (float f);
explicit Constant (double d);
virtual ~Constant (void);
virtual EExpressionType getExpressionType (void) const { return(CONSTANT); }
ENumberType getNumberType(void) const { return(m_eType); }
char getValueAsChar (void) const { return(m_nValue.as_char); }
short getValueAsShort (void) const { return(m_nValue.as_short); }
int getValueAsInt (void) const { return(m_nValue.as_int); }
float getValueAsFloat (void) const { return(m_nValue.as_float); }
double getValueAsDouble(void) const { return(m_nValue.as_double); }
private:
union Number
{
char as_char;
short as_short;
int as_int;
float as_float;
double as_double;
};
ENumberType m_eType;
Number m_nValue;
};
}

View File

@@ -0,0 +1,20 @@
#include "EqualTo.h"
/**
* @brief AST::EqualTo::EqualTo
* @param lhs
* @param rhs
*/
AST::EqualTo::EqualTo(const Expression * lhs, const Expression * rhs)
: Binary(lhs, rhs)
{
// ...
}
/**
* @brief AST::EqualTo::~EqualTo
*/
AST::EqualTo::~EqualTo(void)
{
// ...
}

View File

@@ -0,0 +1,20 @@
#pragma once
#include "../Binary.h"
namespace AST
{
class EqualTo : public Binary
{
public:
explicit EqualTo (const Expression * lhs, const Expression * rhs);
virtual ~EqualTo (void);
virtual EBinaryType getBinaryType (void) const { return(Binary::EQ); }
};
}

View File

@@ -0,0 +1,20 @@
#include "GreaterThan.h"
/**
* @brief AST::GreaterThan::GreaterThan
* @param lhs
* @param rhs
*/
AST::GreaterThan::GreaterThan(const Expression * lhs, const Expression * rhs)
: Binary(lhs, rhs)
{
// ...
}
/**
* @brief AST::GreaterThan::~GreaterThan
*/
AST::GreaterThan::~GreaterThan(void)
{
// ...
}

View File

@@ -0,0 +1,20 @@
#pragma once
#include "../Binary.h"
namespace AST
{
class GreaterThan : public Binary
{
public:
explicit GreaterThan (const Expression * lhs, const Expression * rhs);
virtual ~GreaterThan (void);
virtual EBinaryType getBinaryType (void) const { return(Binary::GT); }
};
}

View File

@@ -0,0 +1,20 @@
#include "GreaterThanOrEqualTo.h"
/**
* @brief AST::GreaterThanOrEqualTo::GreaterThanOrEqualTo
* @param lhs
* @param rhs
*/
AST::GreaterThanOrEqualTo::GreaterThanOrEqualTo(const Expression * lhs, const Expression * rhs)
: Binary(lhs, rhs)
{
// ...
}
/**
* @brief AST::GreaterThanOrEqualTo::~GreaterThanOrEqualTo
*/
AST::GreaterThanOrEqualTo::~GreaterThanOrEqualTo(void)
{
// ...
}

View File

@@ -0,0 +1,20 @@
#pragma once
#include "../Binary.h"
namespace AST
{
class GreaterThanOrEqualTo : public Binary
{
public:
explicit GreaterThanOrEqualTo (const Expression * lhs, const Expression * rhs);
virtual ~GreaterThanOrEqualTo (void);
virtual EBinaryType getBinaryType (void) const { return(Binary::GEQ); }
};
}

View File

@@ -0,0 +1,20 @@
#include "LessThan.h"
/**
* @brief AST::LessThan::LessThan
* @param lhs
* @param rhs
*/
AST::LessThan::LessThan(const Expression * lhs, const Expression * rhs)
: Binary(lhs, rhs)
{
// ...
}
/**
* @brief AST::LessThan::~LessThan
*/
AST::LessThan::~LessThan(void)
{
// ...
}

View File

@@ -0,0 +1,20 @@
#pragma once
#include "../Binary.h"
namespace AST
{
class LessThan : public Binary
{
public:
explicit LessThan (const Expression * lhs, const Expression * rhs);
virtual ~LessThan (void);
virtual EBinaryType getBinaryType (void) const { return(Binary::LT); }
};
}

View File

@@ -0,0 +1,20 @@
#include "LessThanOrEqualTo.h"
/**
* @brief AST::LessThanOrEqualTo::LessThanOrEqualTo
* @param lhs
* @param rhs
*/
AST::LessThanOrEqualTo::LessThanOrEqualTo(const Expression * lhs, const Expression * rhs)
: Binary(lhs, rhs)
{
// ...
}
/**
* @brief AST::LessThanOrEqualTo::~LessThanOrEqualTo
*/
AST::LessThanOrEqualTo::~LessThanOrEqualTo(void)
{
// ...
}

View File

@@ -0,0 +1,20 @@
#pragma once
#include "../Binary.h"
namespace AST
{
class LessThanOrEqualTo : public Binary
{
public:
explicit LessThanOrEqualTo (const Expression * lhs, const Expression * rhs);
virtual ~LessThanOrEqualTo (void);
virtual EBinaryType getBinaryType (void) const { return(Binary::LEQ); }
};
}

View File

@@ -0,0 +1,20 @@
#include "NotEqualTo.h"
/**
* @brief AST::NotEqualTo::NotEqualTo
* @param lhs
* @param rhs
*/
AST::NotEqualTo::NotEqualTo(const Expression * lhs, const Expression * rhs)
: Binary(lhs, rhs)
{
// ...
}
/**
* @brief AST::NotEqualTo::~NotEqualTo
*/
AST::NotEqualTo::~NotEqualTo(void)
{
// ...
}

View File

@@ -0,0 +1,20 @@
#pragma once
#include "../Binary.h"
namespace AST
{
class NotEqualTo : public Binary
{
public:
explicit NotEqualTo (const Expression * lhs, const Expression * rhs);
virtual ~NotEqualTo (void);
virtual EBinaryType getBinaryType (void) const { return(Binary::NEQ); }
};
}

View File

@@ -0,0 +1,18 @@
#include "Unary.h"
/**
* @brief AST::Unary::Unary
*/
AST::Unary::Unary(const Expression * pExpr)
: m_pExpr(pExpr)
{
// ...
}
/**
* @brief AST::Call::~Call
*/
AST::Unary::~Unary(void)
{
// ...
}

View File

@@ -0,0 +1,33 @@
#pragma once
#include "../Expression.h"
namespace AST
{
class Unary : public Expression
{
public:
enum EUnaryType
{
PLUS,
MINUS
};
explicit Unary (const Expression * pExpr);
virtual ~Unary (void);
virtual EExpressionType getExpressionType (void) const { return(UNARY); }
const Expression * getExpression() const { return(m_pExpr); }
virtual EUnaryType getUnaryType (void) const = 0;
private:
const Expression * m_pExpr;
};
}

View File

@@ -0,0 +1,19 @@
#include "Variable.h"
/**
* @brief AST::Variable::Variable
* @param pName
*/
AST::Variable::Variable(const char * pName)
: m_strName(pName)
{
// ...
}
/**
* @brief AST::Variable::~Variable
*/
AST::Variable::~Variable(void)
{
// ...
}

View File

@@ -0,0 +1,30 @@
#pragma once
#include "../Expression.h"
#include <string>
namespace AST
{
class Variable : public Expression
{
public:
explicit Variable (const char * pName);
virtual ~Variable (void);
virtual EExpressionType getExpressionType (void) const { return(VARIABLE); }
const std::string & getName (void) const
{
return(m_strName);
}
private:
std::string m_strName;
};
}

17
src/AST/Statement.cpp Normal file
View File

@@ -0,0 +1,17 @@
#include "Statement.h"
/**
* @brief AST::Statement::Statement
*/
AST::Statement::Statement(void)
{
// ...
}
/**
* @brief AST::Statement::~Statement
*/
AST::Statement::~Statement()
{
// ...
}

40
src/AST/Statement.h Normal file
View File

@@ -0,0 +1,40 @@
#pragma once
#include "../Node.h"
namespace AST
{
class Statement : public Node
{
public:
enum EStatementType
{
BLOCK,
IF,
WHILE,
DO,
FOR,
EXPRESSION_LIST,
DECLARATION_LIST,
RETURN,
SELECTION,
ITERATION,
JUMP,
};
explicit Statement (void);
virtual ~Statement (void);
virtual ENodeType getNodeType (void) const { return(STATEMENT); }
virtual EStatementType getStatementType (void) const = 0;
private:
// ...
};
}

View File

@@ -0,0 +1,18 @@
#include "CompoundStatement.h"
/**
* @brief AST::Block::Block
*/
AST::CompoundStatement::CompoundStatement(const std::vector<const Statement *> & children)
: m_aChild(children)
{
// ...
}
/**
* @brief AST::Block::~Block
*/
AST::CompoundStatement::~CompoundStatement(void)
{
// ...
}

View File

@@ -0,0 +1,27 @@
#pragma once
#include "../Statement.h"
#include <vector>
namespace AST
{
class CompoundStatement : public Statement
{
public:
explicit CompoundStatement (const std::vector<const Statement *> & children);
virtual ~CompoundStatement (void);
virtual EStatementType getStatementType (void) const { return(BLOCK); }
const std::vector<const Statement *> & getChildren (void) const { return(m_aChild); }
private:
std::vector<const Statement *> m_aChild;
};
}

View File

@@ -0,0 +1,17 @@
#include "DeclarationList.h"
/**
* @brief AST::DeclarationList::DeclarationList
*/
AST::DeclarationList::DeclarationList(const Declaration * pDecl)
{
m_aDeclarations.push_back(pDecl);
}
/**
* @brief AST::DeclarationList::~DeclarationList
*/
AST::DeclarationList::~DeclarationList(void)
{
// ...
}

View File

@@ -0,0 +1,29 @@
#pragma once
#include "../Statement.h"
#include <vector>
namespace AST
{
class Declaration;
class DeclarationList : public Statement
{
public:
explicit DeclarationList (const Declaration * pExpr);
virtual ~DeclarationList (void);
virtual EStatementType getStatementType (void) const { return(DECLARATION_LIST); }
const std::vector<const Declaration *> & getDeclaration(void) const { return(m_aDeclarations); }
private:
std::vector<const Declaration *> m_aDeclarations;
};
}

View File

@@ -0,0 +1,17 @@
#include "ExpressionList.h"
/**
* @brief AST::ExpressionList::ExpressionList
*/
AST::ExpressionList::ExpressionList(const Expression * pExpr)
{
m_aExpressions.push_back(pExpr);
}
/**
* @brief AST::ExpressionList::~ExpressionList
*/
AST::ExpressionList::~ExpressionList(void)
{
// ...
}

View File

@@ -0,0 +1,29 @@
#pragma once
#include "../Statement.h"
#include <vector>
namespace AST
{
class Expression;
class ExpressionList : public Statement
{
public:
explicit ExpressionList (const Expression * pExpr);
virtual ~ExpressionList (void);
virtual EStatementType getStatementType (void) const { return(EXPRESSION_LIST); }
const std::vector<const Expression *> & getExpressions(void) const { return(m_aExpressions); }
private:
std::vector<const Expression *> m_aExpressions;
};
}

View File

@@ -0,0 +1,18 @@
#include "IterationStatement.h"
/**
* @brief AST::IterationStatement::IterationStatement
*/
AST::IterationStatement::IterationStatement(EIterationStatementType type)
: m_eType(type)
{
// ...
}
/**
* @brief AST::IterationStatement::~IterationStatement
*/
AST::IterationStatement::~IterationStatement(void)
{
// ...
}

View File

@@ -0,0 +1,30 @@
#pragma once
#include "../Statement.h"
namespace AST
{
class IterationStatement : public Statement
{
public:
enum EIterationStatementType
{
WHILE,
DO,
FOR,
};
explicit IterationStatement (EIterationStatementType type);
virtual ~IterationStatement (void);
virtual EStatementType getStatementType (void) const { return(ITERATION); }
private:
EIterationStatementType m_eType;
};
}

View File

@@ -0,0 +1,19 @@
#include "DoWhile.h"
/**
* @brief AST::DoWhile::DoWhile
*/
AST::DoWhile::DoWhile(const Expression * pCondition, const Statement * stmt)
: m_pCondition(pCondition)
, m_pChild(stmt)
{
// ...
}
/**
* @brief AST::DoWhile::~DoWhile
*/
AST::DoWhile::~DoWhile()
{
// ...
}

View File

@@ -0,0 +1,29 @@
#pragma once
#include "../IterationStatement.h"
namespace AST
{
class Expression;
class DoWhile : public Statement
{
public:
explicit DoWhile (const Expression * pCondition, const Statement * stmt);
virtual ~DoWhile (void);
virtual EStatementType getStatementType (void) const { return(DO); }
const Expression * getCondition (void) const { return(m_pCondition); }
const Statement * getChild (void) const { return(m_pChild); }
private:
const Expression * m_pCondition;
const Statement * m_pChild;
};
}

View File

@@ -0,0 +1,21 @@
#include "For.h"
/**
* @brief AST::For::For
*/
AST::For::For(const Node * pInit, const Expression * pCondition, const Expression * pUpdate, const Statement * stmt)
: m_pInit(pInit)
, m_pCondition(pCondition)
, m_pUpdate(pUpdate)
, m_pChild(stmt)
{
// ...
}
/**
* @brief AST::For::~For
*/
AST::For::~For()
{
// ...
}

View File

@@ -0,0 +1,37 @@
#pragma once
#include "../IterationStatement.h"
#include <vector>
namespace AST
{
class Expression;
class For : public Statement
{
public:
explicit For (const Node * pInit, const Expression * pCondition, const Expression * pUpdate, const Statement * stmt);
virtual ~For (void);
virtual EStatementType getStatementType (void) const { return(FOR); }
const Node * getInit (void) const { return(m_pInit); }
const Expression * getCondition (void) const { return(m_pCondition); }
const Expression * getUpdate (void) const { return(m_pUpdate); }
const Statement * getChild (void) const { return(m_pChild); }
private:
const Node * m_pInit;
const Expression * m_pCondition;
const Expression * m_pUpdate; // ExpressionList
const Statement * m_pChild;
};
}

View File

@@ -0,0 +1,19 @@
#include "While.h"
/**
* @brief AST::While::While
*/
AST::While::While(const Expression * pCondition, const Statement * stmt)
: m_pCondition(pCondition)
, m_pChild(stmt)
{
// ...
}
/**
* @brief AST::While::~While
*/
AST::While::~While()
{
// ...
}

View File

@@ -0,0 +1,29 @@
#pragma once
#include "../IterationStatement.h"
namespace AST
{
class Expression;
class While : public Statement
{
public:
explicit While (const Expression * pCondition, const Statement * stmt);
virtual ~While (void);
virtual EStatementType getStatementType (void) const { return(WHILE); }
const Expression * getCondition (void) const { return(m_pCondition); }
const Statement * getChild (void) const { return(m_pChild); }
private:
const Expression * m_pCondition;
const Statement * m_pChild;
};
}

View File

@@ -0,0 +1,18 @@
#include "JumpStatement.h"
/**
* @brief AST::JumpStatement::JumpStatement
*/
AST::JumpStatement::JumpStatement(EJumpStatementType type)
: m_eType(type)
{
// ...
}
/**
* @brief AST::JumpStatement::~JumpStatement
*/
AST::JumpStatement::~JumpStatement(void)
{
// ...
}

View File

@@ -0,0 +1,31 @@
#pragma once
#include "../Statement.h"
namespace AST
{
class JumpStatement : public Statement
{
public:
enum EJumpStatementType
{
BREAK,
CONTINUE,
RETURN,
GOTO
};
explicit JumpStatement (EJumpStatementType type);
virtual ~JumpStatement (void);
virtual EStatementType getStatementType (void) const { return(JUMP); }
private:
EJumpStatementType m_eType;
};
}

View File

@@ -0,0 +1,18 @@
#include "Return.h"
/**
* @brief AST::Return::Return
*/
AST::Return::Return(const AST::Expression * pReturnExpr)
: m_pReturnExpression(pReturnExpr)
{
// ...
}
/**
* @brief AST::Return::~Return
*/
AST::Return::~Return(void)
{
// ...
}

View File

@@ -0,0 +1,25 @@
#pragma once
#include "../JumpStatement.h"
namespace AST
{
class Expression;
class Return : public Statement
{
public:
explicit Return (const AST::Expression * pReturnExpr);
virtual ~Return (void);
virtual EStatementType getStatementType (void) const { return(RETURN); }
private:
const AST::Expression * m_pReturnExpression;
};
}

View File

@@ -0,0 +1,18 @@
#include "SelectionStatement.h"
/**
* @brief AST::SelectionStatement::SelectionStatement
*/
AST::SelectionStatement::SelectionStatement(ESelectionStatementType type)
: m_eType(type)
{
// ...
}
/**
* @brief AST::SelectionStatement::~SelectionStatement
*/
AST::SelectionStatement::~SelectionStatement(void)
{
// ...
}

View File

@@ -0,0 +1,29 @@
#pragma once
#include "../Statement.h"
namespace AST
{
class SelectionStatement : public Statement
{
public:
enum ESelectionStatementType
{
IF,
SWITCH,
};
explicit SelectionStatement (ESelectionStatementType type);
virtual ~SelectionStatement (void);
virtual EStatementType getStatementType (void) const { return(ITERATION); }
private:
ESelectionStatementType m_eType;
};
}

View File

@@ -0,0 +1,19 @@
#include "If.h"
/**
* @brief AST::If::If
*/
AST::If::If(const Expression * pCondition, const Statement * stmt)
: m_pCondition(pCondition)
, m_pChild(stmt)
{
// ...
}
/**
* @brief AST::If::~If
*/
AST::If::~If()
{
// ...
}

View File

@@ -0,0 +1,29 @@
#pragma once
#include "../SelectionStatement.h"
namespace AST
{
class Expression;
class If : public Statement
{
public:
explicit If (const Expression * pCondition, const Statement * stmt);
virtual ~If (void);
virtual EStatementType getStatementType (void) const { return(IF); }
const Expression * getCondition (void) const { return(m_pCondition); }
const Statement * getChild (void) const { return(m_pChild); }
private:
const Expression * m_pCondition;
const Statement * m_pChild;
};
}

Some files were not shown because too many files have changed in this diff Show More