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

11
CMakeLists.txt Normal file
View File

@@ -0,0 +1,11 @@
cmake_minimum_required(VERSION 2.8)
project(SL++)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -std=c++11")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror=return-type")
include_directories(include definitions)
add_subdirectory(src)
add_subdirectory(test)

34
definitions/keywords.def Normal file
View File

@@ -0,0 +1,34 @@
DEF("namespace", NAMESPACE)
DEF("struct", STRUCT)
DEF("class", CLASS)
DEF("union", UNION)
DEF("enum", ENUM)
DEF("break", BREAK)
DEF("continue", CONTINUE)
DEF("return", RETURN)
DEF("goto", GOTO)
DEF("if", IF)
DEF("else", ELSE)
DEF("switch", SWITCH)
DEF("for", FOR)
DEF("while", WHILE)
DEF("do", DO)
DEF("case", CASE)
DEF("default", DEFAULT)
DEF("try", TRY)
DEF("catch", CATCH)
DEF("template", TEMPLATE)
DEF("using", USING)
DEF("static_assert", STATIC_ASSERT)
DEF("typename", TYPENAME)
DEF("extern", EXTERN)
DEF("asm", ASM)

View File

@@ -0,0 +1,74 @@
/**
* http://en.cppreference.com/w/cpp/language/operator_precedence
*/
// Prefix increment and decrement
UNARY(PLUS_PLUS, 3)
UNARY(MINUS_MINUS, 3)
// Unary plus and minus
UNARY(PLUS, 3)
UNARY(MINUS, 3)
// Logical NOT and bitwise NOT
UNARY(TILDE, 3)
UNARY(EXCLAMATION, 3)
// Multiplication, division, and remainder
BINARY(ASTERISK, 5)
BINARY(SLASH, 5)
BINARY(PERCENT, 5)
// Addition and subtraction
BINARY(PLUS, 6)
BINARY(MINUS, 6)
// Bitwise left shift and right shift
BINARY(LT_LT, 7)
BINARY(GT_GT, 7)
// For relational operators < and ≤ respectively
BINARY(LT, 8)
BINARY(LT_EQUAL, 8)
// For relational operators > and ≥ respectively
BINARY(GT, 8)
BINARY(GT_EQUAL, 8)
// For relational = and ≠ respectively
BINARY(EQUAL_EQUAL, 9)
BINARY(EXCLAMATION_EQUAL, 9)
// Bitwise AND
BINARY(AMPERSAND, 10)
// Bitwise XOR (exclusive or)
BINARY(CIRCUMFLEX, 11)
// Bitwise OR (inclusive or)
BINARY(PIPE, 12)
// Logical AND
BINARY(AMPERSAND_AMPERSAND, 13)
// Logical OR
BINARY(PIPE_PIPE, 14)
// Assignements
BINARY(EQUAL, 15)
BINARY(PLUS_EQUAL, 15)
BINARY(MINUS_EQUAL, 15)
BINARY(ASTERISK_EQUAL, 15)
BINARY(SLASH_EQUAL, 15)
BINARY(PERCENT_EQUAL, 15)
BINARY(LT_LT_EQUAL, 15)
BINARY(GT_GT_EQUAL, 15)
BINARY(AMPERSAND_EQUAL, 15)
BINARY(CIRCUMFLEX_EQUAL, 15)
BINARY(PIPE_EQUAL, 15)
/**
* New operators
*/
// ...

47
definitions/symbols.def Normal file
View File

@@ -0,0 +1,47 @@
// relation operators
DEF("==", EQUAL_EQUAL)
DEF("!=", EXCLAMATION_EQUAL)
DEF("<", LT)
DEF("<=", LT_EQUAL)
DEF(">", GT)
DEF(">=", GT_EQUAL)
// assignement operators
DEF("=", EQUAL)
DEF("+=", PLUS_EQUAL)
DEF("-=", MINUS_EQUAL)
DEF("*=", ASTERISK_EQUAL)
DEF("/=", SLASH_EQUAL)
DEF("%=", PERCENT_EQUAL)
DEF("<<=", LT_LT_EQUAL)
DEF(">>=", GT_GT_EQUAL)
DEF("&=", AMPERSAND_EQUAL)
DEF("^=", CIRCUMFLEX_EQUAL)
DEF("|=", PIPE_EQUAL)
// arithmetic operators
DEF("++", PLUS_PLUS)
DEF("--", MINUS_MINUS)
DEF("+", PLUS)
DEF("-", MINUS)
DEF("*", ASTERISK)
DEF("/", SLASH)
DEF("%", PERCENT)
// bitwise operators
DEF("~", TILDE)
DEF("&", AMPERSAND)
DEF("^", CIRCUMFLEX)
DEF("|", PIPE)
DEF("<<", LT_LT)
DEF(">>", GT_GT)
// logical operators
DEF("!", EXCLAMATION)
DEF("&&", AMPERSAND_AMPERSAND)
DEF("||", PIPE_PIPE)

10
definitions/types.def Normal file
View File

@@ -0,0 +1,10 @@
DEF("char", CHAR)
DEF("uchar", UCHAR)
DEF("short", SHORT)
DEF("ushort", USHORT)
DEF("int", INT)
DEF("uint", UINT)
DEF("long", LONG)
DEF("ulong", ULONG)
DEF("float", FLOAT)
DEF("double", DOUBLE)

213
include/GLSL450Lib.h Normal file
View File

@@ -0,0 +1,213 @@
/*
** Copyright (c) 2015 The Khronos Group Inc.
**
** Permission is hereby granted, free of charge, to any person obtaining a copy
** of this software and/or associated documentation files (the "Materials"),
** to deal in the Materials without restriction, including without limitation
** the rights to use, copy, modify, merge, publish, distribute, sublicense,
** and/or sell copies of the Materials, and to permit persons to whom the
** Materials are furnished to do so, subject to the following conditions:
**
** The above copyright notice and this permission notice shall be included in
** all copies or substantial portions of the Materials.
**
** MODIFICATIONS TO THIS FILE MAY MEAN IT NO LONGER ACCURATELY REFLECTS KHRONOS
** STANDARDS. THE UNMODIFIED, NORMATIVE VERSIONS OF KHRONOS SPECIFICATIONS AND
** HEADER INFORMATION ARE LOCATED AT https://www.khronos.org/registry/
**
** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
** OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
** FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
** THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
** LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
** FROM,OUT OF OR IN CONNECTION WITH THE MATERIALS OR THE USE OR OTHER DEALINGS
** IN THE MATERIALS.
*/
//
// Author: John Kessenich, LunarG
//
namespace GLSL_STD_450 {
enum Entrypoints {
Round = 0,
RoundEven = 1,
Trunc = 2,
Abs = 3,
Sign = 4,
Floor = 5,
Ceil = 6,
Fract = 7,
Radians = 8,
Degrees = 9,
Sin = 10,
Cos = 11,
Tan = 12,
Asin = 13,
Acos = 14,
Atan = 15,
Sinh = 16,
Cosh = 17,
Tanh = 18,
Asinh = 19,
Acosh = 20,
Atanh = 21,
Atan2 = 22,
Pow = 23,
Exp = 24,
Log = 25,
Exp2 = 26,
Log2 = 27,
Sqrt = 28,
InverseSqrt = 29,
Determinant = 30,
MatrixInverse = 31,
Modf = 32, // second argument needs the OpVariable = , not an OpLoad
Min = 33,
Max = 34,
Clamp = 35,
Mix = 36,
Step = 37,
SmoothStep = 38,
FloatBitsToInt = 39,
FloatBitsToUint = 40,
IntBitsToFloat = 41,
UintBitsToFloat = 42,
Fma = 43,
Frexp = 44,
Ldexp = 45,
PackSnorm4x8 = 46,
PackUnorm4x8 = 47,
PackSnorm2x16 = 48,
PackUnorm2x16 = 49,
PackHalf2x16 = 50,
PackDouble2x32 = 51,
UnpackSnorm2x16 = 52,
UnpackUnorm2x16 = 53,
UnpackHalf2x16 = 54,
UnpackSnorm4x8 = 55,
UnpackUnorm4x8 = 56,
UnpackDouble2x32 = 57,
Length = 58,
Distance = 59,
Cross = 60,
Normalize = 61,
Ftransform = 62,
FaceForward = 63,
Reflect = 64,
Refract = 65,
UaddCarry = 66,
UsubBorrow = 67,
UmulExtended = 68,
ImulExtended = 69,
BitfieldExtract = 70,
BitfieldInsert = 71,
BitfieldReverse = 72,
BitCount = 73,
FindLSB = 74,
FindMSB = 75,
InterpolateAtCentroid = 76,
InterpolateAtSample = 77,
InterpolateAtOffset = 78,
Count
};
inline void GetDebugNames(const char** names)
{
for (int i = 0; i < Count; ++i)
names[i] = "Unknown";
names[Round] = "round";
names[RoundEven] = "roundEven";
names[Trunc] = "trunc";
names[Abs] = "abs";
names[Sign] = "sign";
names[Floor] = "floor";
names[Ceil] = "ceil";
names[Fract] = "fract";
names[Radians] = "radians";
names[Degrees] = "degrees";
names[Sin] = "sin";
names[Cos] = "cos";
names[Tan] = "tan";
names[Asin] = "asin";
names[Acos] = "acos";
names[Atan] = "atan";
names[Sinh] = "sinh";
names[Cosh] = "cosh";
names[Tanh] = "tanh";
names[Asinh] = "asinh";
names[Acosh] = "acosh";
names[Atanh] = "atanh";
names[Atan2] = "atan2";
names[Pow] = "pow";
names[Exp] = "exp";
names[Log] = "log";
names[Exp2] = "exp2";
names[Log2] = "log2";
names[Sqrt] = "sqrt";
names[InverseSqrt] = "inverseSqrt";
names[Determinant] = "determinant";
names[MatrixInverse] = "matrixInverse";
names[Modf] = "modf";
names[Min] = "min";
names[Max] = "max";
names[Clamp] = "clamp";
names[Mix] = "mix";
names[Step] = "step";
names[SmoothStep] = "smoothStep";
names[FloatBitsToInt] = "floatBitsToInt";
names[FloatBitsToUint] = "floatBitsToUint";
names[IntBitsToFloat] = "intBitsToFloat";
names[UintBitsToFloat] = "uintBitsToFloat";
names[Fma] = "fma";
names[Frexp] = "frexp";
names[Ldexp] = "ldexp";
names[PackSnorm4x8] = "packSnorm4x8";
names[PackUnorm4x8] = "packUnorm4x8";
names[PackSnorm2x16] = "packSnorm2x16";
names[PackUnorm2x16] = "packUnorm2x16";
names[PackHalf2x16] = "packHalf2x16";
names[PackDouble2x32] = "packDouble2x32";
names[UnpackSnorm2x16] = "unpackSnorm2x16";
names[UnpackUnorm2x16] = "unpackUnorm2x16";
names[UnpackHalf2x16] = "unpackHalf2x16";
names[UnpackSnorm4x8] = "unpackSnorm4x8";
names[UnpackUnorm4x8] = "unpackUnorm4x8";
names[UnpackDouble2x32] = "unpackDouble2x32";
names[Length] = "length";
names[Distance] = "distance";
names[Cross] = "cross";
names[Normalize] = "normalize";
names[Ftransform] = "ftransform";
names[FaceForward] = "faceForward";
names[Reflect] = "reflect";
names[Refract] = "refract";
names[UaddCarry] = "uaddCarry";
names[UsubBorrow] = "usubBorrow";
names[UmulExtended] = "umulExtended";
names[ImulExtended] = "imulExtended";
names[BitfieldExtract] = "bitfieldExtract";
names[BitfieldInsert] = "bitfieldInsert";
names[BitfieldReverse] = "bitfieldReverse";
names[BitCount] = "bitCount";
names[FindLSB] = "findLSB";
names[FindMSB] = "findMSB";
names[InterpolateAtCentroid] = "interpolateAtCentroid";
names[InterpolateAtSample] = "interpolateAtSample";
names[InterpolateAtOffset] = "interpolateAtOffset";
}
}; // end namespace GLSL_STD_450

1304
include/spirv.h Normal file

File diff suppressed because it is too large Load Diff

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)
{
// ...
}

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