Started implementing AST
This commit is contained in:
@@ -15,10 +15,10 @@ enable_testing()
|
|||||||
add_subdirectory(external/googletest)
|
add_subdirectory(external/googletest)
|
||||||
|
|
||||||
# Adds the sub-directories of all of the binaries #
|
# Adds the sub-directories of all of the binaries #
|
||||||
|
# The order is equivalent to which order they are compiled #
|
||||||
add_subdirectory(lexer)
|
add_subdirectory(lexer)
|
||||||
|
add_subdirectory(ast)
|
||||||
|
|
||||||
# The app subdirectory #
|
# Executable directories #
|
||||||
add_subdirectory(LXC)
|
add_subdirectory(LXC)
|
||||||
|
|
||||||
# Compiles the tests #
|
|
||||||
add_subdirectory(tests)
|
add_subdirectory(tests)
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ add_executable(LXC LXC.cpp)
|
|||||||
|
|
||||||
# Links the other binaries #
|
# Links the other binaries #
|
||||||
target_link_libraries(LXC PRIVATE Lexer)
|
target_link_libraries(LXC PRIVATE Lexer)
|
||||||
|
target_link_libraries(LXC PRIVATE AST)
|
||||||
|
|
||||||
# Creates the precompiled header for the binary #
|
# Creates the precompiled header for the binary #
|
||||||
target_include_directories(LXC PRIVATE ${CMAKE_SOURCE_DIR}/common)
|
target_include_directories(LXC PRIVATE ${CMAKE_SOURCE_DIR}/common)
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
# Fetches all files for in the binary #
|
# Fetches all files for in the binary #
|
||||||
file (GLOB LexerSources src/*.cpp inc/*.h)
|
file (GLOB LexerSources src/*.cpp inc/*.h)
|
||||||
|
|
||||||
add_library(Lexer STATIC ${LexerSources})
|
add_library(Lexer STATIC ${LexerSources})
|
||||||
|
|
||||||
|
# Adds the headers in the current directory #
|
||||||
target_include_directories (
|
target_include_directories (
|
||||||
Lexer PUBLIC
|
Lexer PUBLIC
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/inc
|
${CMAKE_CURRENT_SOURCE_DIR}/inc
|
||||||
|
|||||||
16
ast/CMakeLists.txt
Normal file
16
ast/CMakeLists.txt
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
# Fetches all files for the binary #
|
||||||
|
file (GLOB ASTSources src/*.cpp inc/*.h)
|
||||||
|
add_library(AST STATIC ${ASTSources})
|
||||||
|
|
||||||
|
# Adds the headers in the current directory #
|
||||||
|
target_include_directories (
|
||||||
|
AST PUBLIC
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/inc
|
||||||
|
)
|
||||||
|
|
||||||
|
# Links to the Lexer so it can use tokens as data types #
|
||||||
|
target_link_libraries(AST PUBLIC Lexer)
|
||||||
|
|
||||||
|
# Creates the precompiled header of the binary #
|
||||||
|
target_include_directories(AST PRIVATE ${CMAKE_SOURCE_DIR}/common)
|
||||||
|
target_precompile_headers(AST PRIVATE ${CMAKE_SOURCE_DIR}/common/LXC.h)
|
||||||
35
ast/inc/Node.h
Normal file
35
ast/inc/Node.h
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
#include <LXC.h>
|
||||||
|
|
||||||
|
namespace LXC::AST
|
||||||
|
{
|
||||||
|
enum class NodeType
|
||||||
|
{
|
||||||
|
// General nodes //
|
||||||
|
|
||||||
|
Identifier,
|
||||||
|
Operation,
|
||||||
|
|
||||||
|
// Variable nodes //
|
||||||
|
|
||||||
|
Var_Declare,
|
||||||
|
Var_Assign,
|
||||||
|
Var_Access,
|
||||||
|
|
||||||
|
// Control flow nodes //
|
||||||
|
|
||||||
|
IfBranch,
|
||||||
|
ReturnVal
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
class Node
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Node(NodeType _type)
|
||||||
|
: m_Type(_type)
|
||||||
|
{}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
const NodeType m_Type;
|
||||||
|
};
|
||||||
|
}
|
||||||
1
ast/src/AST.cpp
Normal file
1
ast/src/AST.cpp
Normal file
@@ -0,0 +1 @@
|
|||||||
|
#include <Node.h>
|
||||||
Reference in New Issue
Block a user