Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
9fbc0f9
Merge pull request #24 from ThomasNotTom/develop
ThomasNotTom Jun 30, 2026
adf112f
Handle uint16
ThomasNotTom Jul 20, 2026
04fa107
Include name parameter
ThomasNotTom Jul 20, 2026
99d22b7
Create uint16 type
ThomasNotTom Jul 30, 2026
9a2982b
Inherit from builder uint primitive
ThomasNotTom Jul 30, 2026
78e1350
Handle uint16 token
ThomasNotTom Jul 30, 2026
6ead6a5
Create uint16 token
ThomasNotTom Jul 30, 2026
102fb5d
Create builder primitive
ThomasNotTom Jul 30, 2026
62e49f9
Create builder primitive type
ThomasNotTom Jul 30, 2026
338ce31
Handle uint16 token printing
ThomasNotTom Jul 30, 2026
0f9f910
Create add uint16 method
ThomasNotTom Jul 31, 2026
f5ad91d
Create builder uint type enum
ThomasNotTom Jul 31, 2026
0e3d5cc
Create builder uint primitive
ThomasNotTom Jul 31, 2026
194565f
Add uint16 primitive type
ThomasNotTom Jul 31, 2026
5752ba3
Handle uint16 primitive type
ThomasNotTom Jul 31, 2026
1bfaf99
Handle uint16 printing
ThomasNotTom Jul 31, 2026
d298b80
Create uint16 statement primitive type
ThomasNotTom Jul 31, 2026
2714197
Include uint16 type
ThomasNotTom Jul 31, 2026
5a13663
Compile for uint64
ThomasNotTom Aug 1, 2026
21cb99e
Create method for making const uint64
ThomasNotTom Aug 1, 2026
64deb49
Create builder uint64
ThomasNotTom Aug 1, 2026
135ed19
Create builder uint32
ThomasNotTom Aug 1, 2026
274dba4
Add uint64 enum type
ThomasNotTom Aug 1, 2026
f33cb6f
Handle uint64 keyword
ThomasNotTom Aug 1, 2026
d9161e6
Create add method for uint64
ThomasNotTom Aug 1, 2026
cbd92cd
Create print for uint64
ThomasNotTom Aug 1, 2026
e9361c7
Add uint64 enum type
ThomasNotTom Aug 1, 2026
79ec090
Create uint32 token
ThomasNotTom Aug 1, 2026
9ec1cb7
Create uint64 token
ThomasNotTom Aug 1, 2026
cdc5b78
Print uint64
ThomasNotTom Aug 1, 2026
83beeec
Add uint64 to conversion
ThomasNotTom Aug 1, 2026
49777fe
Add uint64 enum type
ThomasNotTom Aug 1, 2026
9592237
Create integer primitive example
ThomasNotTom Aug 1, 2026
0c427ad
Include uint64 in primitives list
ThomasNotTom Aug 1, 2026
7c107cc
Merge pull request #26 from ThomasNotTom/feat/add-uint-primitives
ThomasNotTom Aug 1, 2026
4913afb
Create print statement
ThomasNotTom Aug 1, 2026
6a69e4b
Handle printing of print statement
ThomasNotTom Aug 1, 2026
88be08c
Create print token
ThomasNotTom Aug 1, 2026
44293f0
Handle print printing
ThomasNotTom Aug 1, 2026
7abfca5
Parse print token
ThomasNotTom Aug 1, 2026
2743a4d
Create print token
ThomasNotTom Aug 1, 2026
2e7179e
Create print lexer token
ThomasNotTom Aug 1, 2026
c4b4f88
Create print statements
ThomasNotTom Aug 1, 2026
19cf867
Create print statement
ThomasNotTom Aug 1, 2026
4ecd660
Change to unsigned long long
ThomasNotTom Aug 1, 2026
89961f2
Create create call method
ThomasNotTom Aug 1, 2026
4fa9abd
Handle print statement
ThomasNotTom Aug 1, 2026
4036f9d
Change to unsigned long long
ThomasNotTom Aug 1, 2026
4fd6632
Rename string to int conversion method
ThomasNotTom Aug 1, 2026
404f6da
Create print example
ThomasNotTom Aug 1, 2026
5c6ee4f
Merge pull request #28 from ThomasNotTom/feat/print-to-standard-out
ThomasNotTom Aug 1, 2026
70ea500
Create lexer test
ThomasNotTom Aug 1, 2026
f54ec6b
Create test for singular variable declaration
ThomasNotTom Aug 2, 2026
4463cf9
Create lexer tests
ThomasNotTom Aug 2, 2026
060ad2c
Merge pull request #30 from ThomasNotTom/feat/test-suite
ThomasNotTom Aug 2, 2026
916c169
Create ci file
ThomasNotTom Aug 2, 2026
3148067
Create cmake file
ThomasNotTom Aug 2, 2026
cefd5c6
Run CI on every PR
ThomasNotTom Aug 2, 2026
48eb01e
Update install step
ThomasNotTom Aug 2, 2026
537851b
Update install step
ThomasNotTom Aug 2, 2026
5aacf37
Update install step
ThomasNotTom Aug 2, 2026
9e9cec1
Update install step
ThomasNotTom Aug 2, 2026
a959e90
Downgrade cmake version
ThomasNotTom Aug 2, 2026
e0e7bd8
Include make step
ThomasNotTom Aug 2, 2026
50d823e
Update import
ThomasNotTom Aug 2, 2026
5b978f0
Update import
ThomasNotTom Aug 2, 2026
41b6a35
Change to llvm 22
ThomasNotTom Aug 2, 2026
5cc5e94
Change run path
ThomasNotTom Aug 2, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: CI

on:
push:
branches:
- "**"
- "!main"
pull_request:
branches:
- "**"

jobs:
build-and-test:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y wget lsb-release software-properties-common gnupg catch2

wget https://apt.llvm.org/llvm.sh
chmod +x llvm.sh
sudo ./llvm.sh 22

echo "LLVM_DIR=/usr/lib/llvm-22/lib/cmake/llvm" >> $GITHUB_ENV

- name: Build and Test
run: |
cmake .
make
./bin/tests
74 changes: 74 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
cmake_minimum_required(VERSION 3.31.6)

project(alpha)


set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

include_directories(${CMAKE_SOURCE_DIR}/src)

find_package(LLVM REQUIRED CONFIG)

add_definitions(${LLVM_DEFINITIONS})
llvm_map_components_to_libnames(llvm_libs
core
support
irreader
codegen
asmprinter
target
native
TargetParser
)


file(GLOB_RECURSE ALL_SRC_CPP CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp")
list(FILTER ALL_SRC_CPP EXCLUDE REGEX ".*main\\.cpp$")

file(GLOB_RECURSE ALL_SRC_HPP CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/src/*.hpp")

add_library(alpha_lib STATIC ${ALL_SRC_CPP} ${ALL_SRC_HPP})

target_include_directories(alpha_lib PUBLIC
${CMAKE_SOURCE_DIR}/src
${LLVM_INCLUDE_DIRS}
)
target_link_libraries(alpha_lib PUBLIC ${llvm_libs})

# Main compiler

add_executable(main src/main.cpp)

target_link_libraries(main PRIVATE alpha_lib)

set_target_properties(main PROPERTIES
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin
)

# Tests
find_package(Catch2 3 REQUIRED)

enable_testing()
file(GLOB_RECURSE ALL_TEST_CPP CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/tests/*.cpp")


add_executable(tests
${ALL_TEST_CPP}
)

target_link_libraries(tests PRIVATE
alpha_lib
Catch2::Catch2WithMain
)

get_target_property(Catch2_INCLUDE_DIR Catch2::Catch2 INTERFACE_INCLUDE_DIRECTORIES)
target_include_directories(tests PRIVATE ${Catch2_INCLUDE_DIR})

include(Catch)
catch_discover_tests(tests)

set_target_properties(tests PROPERTIES
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin
)
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,12 @@ The goal of this langauge is to allow for the build up highly nested types, and

The primitves aim to be informative to ensure that there is no ambiguity on how the primitive will function.

| Keyword | Full Name | Size |
| ------- | ----------------------- | -------- |
| `uint8` | Unsigned Integer 8-bits | `1 byte` |
| Keyword | Full Name | Size (bytes) |
| -------- | ------------------------ | ------------ |
| `uint8` | Unsigned Integer 8-bits | `1` |
| `uint16` | Unsigned Integer 16-bits | `2` |
| `uint32` | Unsigned Integer 32-bits | `4` |
| `uint64` | Unsigned Integer 64-bits | `8` |

# Syntax

Expand Down
4 changes: 4 additions & 0 deletions examples/integer_primitives.lang
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
uint8 a = 255;
uint16 b = 65535;
uint32 c = 4294967295;
uint64 d = 18446744073709551615;
4 changes: 4 additions & 0 deletions examples/print.lang
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
print 1;

uint8 a = 2;
print a;
29 changes: 25 additions & 4 deletions src/generation/builder/builder.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "llvm/IR/BasicBlock.h"
#include "llvm/IR/Constants.h"
#include "llvm/IR/DerivedTypes.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/IRBuilder.h"
#include "llvm/IR/Instruction.h"
#include "llvm/IR/Instructions.h"
Expand All @@ -24,6 +25,9 @@ class Builder {
}

llvm::IntegerType* getUint8() const { return llvm::Type::getInt8Ty(context); }
llvm::PointerType* getUint8Ptr() const {
return llvm::PointerType::get(this->context, 0);
}

llvm::ConstantInt* createConst8(uint8_t value) {
return llvm::ConstantInt::get(this->getUint8(), value);
Expand All @@ -45,6 +49,14 @@ class Builder {
return llvm::ConstantInt::get(this->getUint32(), value);
};

llvm::IntegerType* getUint64() const {
return llvm::Type::getInt64Ty(context);
}

llvm::ConstantInt* createConst64(uint64_t value) {
return llvm::ConstantInt::get(this->getUint64(), value);
};

llvm::ReturnInst* createReturn(llvm::Value* value) {
return this->irBuilder.CreateRet(value);
};
Expand All @@ -57,15 +69,24 @@ class Builder {
return this->irBuilder.CreateStore(value, out);
};

llvm::LoadInst* load(llvm::Type* type, llvm::Value* value) {
return this->irBuilder.CreateLoad(type, value);
llvm::LoadInst* load(llvm::Type* type, llvm::Value* value, std::string name) {
return this->irBuilder.CreateLoad(type, value, name);
};

llvm::Value* add(llvm::Value* lhs, llvm::Value* rhs) {
return this->irBuilder.CreateAdd(lhs, rhs);
llvm::Value* add(llvm::Value* lhs, llvm::Value* rhs, std::string name) {
return this->irBuilder.CreateAdd(lhs, rhs, name);
};

llvm::Value* zext(llvm::Value* in, llvm::Type* outType) {
return this->irBuilder.CreateZExt(in, outType);
};

llvm::Value* createGlobalStringPtr(std::string str) {
return this->irBuilder.CreateGlobalString(str);
};

llvm::CallInst* createCall(llvm::Function* function,
std::vector<llvm::Value*> args) {
return this->irBuilder.CreateCall(function, args);
}
};
Loading
Loading