This commit is contained in:
Karutoh 2025-04-14 00:28:12 -07:00
parent ee8e4d37ff
commit 70d35cf0e3
15 changed files with 236 additions and 4 deletions

View File

@ -36,9 +36,16 @@ add_library(Arctyx SHARED
src/compiler/Compiler.cpp include/arctyx/compiler/Compiler.h
src/compiler/Architecture.cpp include/arctyx/compiler/Architecture.h
src/compiler/Instruction.cpp include/arctyx/compiler/Instruction.h
src/compiler/Language.cpp include/arctyx/compiler/Language.h
src/compiler/Token.cpp include/arctyx/compiler/Token.h
src/Arctyx.cpp include/arctyx/Arctyx.h
src/compiler/Combination.cpp
include/arctyx/compiler/Combination.h
src/compiler/Keyword.cpp
include/arctyx/compiler/Keyword.h
)
add_executable(Tools
add_executable(ArctyxTools
src/main.cpp
)
@ -53,4 +60,4 @@ target_link_directories(Arctyx PUBLIC "${USER_HOME_DIRECTORY}/.local/bin")
target_include_directories(Arctyx PUBLIC "${USER_HOME_DIRECTORY}/.local/include")
target_link_libraries(Arctyx PUBLIC xcb xcb-cursor xcb-xfixes xcb-xinput z asound EHS_Dyn)
target_link_libraries(Tools PRIVATE Arctyx)
target_link_libraries(ArctyxTools PRIVATE Arctyx)

BIN
Main.bin Normal file

Binary file not shown.

10
include/arctyx/Arctyx.h Normal file
View File

@ -0,0 +1,10 @@
#pragma once
#include <ehs/Types.h>
class Arctyx
{
private:
static void Initialize();
static void Uninitialize();
};

View File

@ -11,6 +11,8 @@ private:
ehs::Str_8 name;
ehs::Array<Instruction> instructions;
static ehs::Array<Architecture> architectures;
public:
Architecture();
@ -24,7 +26,7 @@ public:
Architecture &operator=(const Architecture &arc);
ehs::UInt_64 Id() const;
ehs::UInt_64 GetId() const;
ehs::Str_8 GetName() const;
@ -37,4 +39,14 @@ public:
const Instruction *GetInstruction(const ehs::Str_8 &name) const;
bool AddInstruction(Instruction ins);
static bool Has(const ehs::UInt_64 &id);
static bool Has(const ehs::Str_8 &name);
static const Architecture *Get(const ehs::UInt_64 &id);
static const Architecture *Get(const ehs::Str_8 &name);
static bool Add(Architecture arc);
};

View File

@ -0,0 +1,15 @@
#pragma once
#include <ehs/Array.h>
#include "Token.h"
class Combination
{
private:
ehs::Array<TokenType> tokens;
public:
};

View File

@ -0,0 +1,11 @@
#pragma once
#include <ehs/Str.h>
#include "Instruction.h"
class Keyword
{
private:
ehs::Str_8 identifier;
Instruction instruction;
};

View File

@ -0,0 +1,35 @@
#pragma once
#include <ehs/Array.h>
#include <ehs/Str.h>
#include <ehs/Types.h>
#include "Combination.h"
class Language
{
private:
ehs::UInt_64 id;
ehs::Str_8 name;
ehs::Array<ehs::Str_8> keywords;
ehs::Array<ehs::Char_8> separators;
ehs::Array<Combination> interpretations;
public:
Language();
Language(ehs::Str_8 name);
Language(Language &&lang) noexcept;
Language(const Language &lang);
Language &operator=(Language &&lang) noexcept;
Language &operator=(const Language &lang);
ehs::UInt_64 GetId() const;
ehs::Str_8 GetName() const;
};

View File

@ -0,0 +1,36 @@
#pragma once
#include <ehs/Str.h>
enum class TokenType : ehs::UInt_8
{
VALUE,
KEYWORD,
IDENTIFIER,
UNARY_OPERATOR,
COMPOUND_OPERATOR
};
class Token
{
private:
TokenType type;
ehs::Str_8 value;
public:
Token();
Token(TokenType type, ehs::Str_8 value);
Token(Token &&token) noexcept;
Token(const Token &token);
Token &operator=(Token &&token) noexcept;
Token &operator=(const Token &token);
TokenType GetType() const;
ehs::Str_8 GetValue() const;
};

13
src/Arctyx.cpp Normal file
View File

@ -0,0 +1,13 @@
#include "arctyx/Arctyx.h"
#include <ehs/Vector.h>
#include "arctyx/compiler/Token.h"
void Arctyx::Initialize()
{
}
void Arctyx::Uninitialize()
{
}

View File

@ -1,5 +1,7 @@
#include "arctyx/compiler/Architecture.h"
ehs::Array<Architecture> Architecture::architectures;
Architecture::Architecture()
: id(0)
{
@ -44,7 +46,7 @@ Architecture & Architecture::operator=(const Architecture &arc)
return *this;
}
ehs::UInt_64 Architecture::Id() const
ehs::UInt_64 Architecture::GetId() const
{
return id;
}
@ -91,3 +93,41 @@ bool Architecture::AddInstruction(Instruction ins)
return true;
}
bool Architecture::Has(const ehs::UInt_64 &id)
{
for (ehs::UInt_64 i = 0; i < architectures.Size(); ++i)
if (architectures[i].GetId() == id)
return true;
return false;
}
bool Architecture::Has(const ehs::Str_8 &name)
{
return Has(name.Hash_64());
}
const Architecture *Architecture::Get(const ehs::UInt_64 &id)
{
for (ehs::UInt_64 i = 0; i < architectures.Size(); ++i)
if (architectures[i].GetId() == id)
return &architectures[i];
return nullptr;
}
const Architecture *Architecture::Get(const ehs::Str_8 &name)
{
return Get(name.Hash_64());
}
bool Architecture::Add(Architecture arc)
{
if (Has(arc.GetId()))
return false;
architectures.Push((Architecture &&)arc);
return true;
}

View File

@ -0,0 +1 @@
#include "arctyx/compiler/Combination.h"

1
src/compiler/Keyword.cpp Normal file
View File

@ -0,0 +1 @@
#include "arctyx/compiler/Keyword.h"

View File

@ -0,0 +1 @@
#include "arctyx/compiler/Language.h"

37
src/compiler/Token.cpp Normal file
View File

@ -0,0 +1,37 @@
#include "arctyx/compiler/Token.h"
Token::Token()
{
}
Token::Token(TokenType type, ehs::Str_8 value)
{
}
Token::Token(Token &&token) noexcept
{
}
Token::Token(const Token &token)
{
}
Token & Token::operator=(Token &&token) noexcept
{
return *this;
}
Token & Token::operator=(const Token &token)
{
return *this;
}
TokenType Token::GetType() const
{
return type;
}
ehs::Str_8 Token::GetValue() const
{
return {};
}

View File

@ -5,6 +5,19 @@
#include <ehs/io/Console.h>
#include <ehs/io/File.h>
struct Foo
{
bool a;
ehs::UInt_64 b;
ehs::UInt_16 c;
};
struct Bar
{
Foo a;
ehs::Char_8 b[128];
};
int main()
{
ehs::Initialize("Arctyx", "Alpha", {1, 0, 0});