eebb7e75e1054ee7a983ac96e4c76210e3031fed
The Core Language
A compiled language with Go like type system, Jai like syntax, order indepent declarations using Ion algorithm. Made to practice language development. It has lot's of ideas from modern programming languages that you would not find in any compiler book.
Language example code
#import "Windows.kl"
#import "base.kl"
PAGE_SIZE :: 4096
Memory :: struct
commit : SizeU
reserve: SizeU
data : *U8
reserve :: (size: SizeU): Memory
result := Memory{reserve=align_up(size, PAGE_SIZE)}
result.data = VirtualAlloc(
flProtect = PAGE_READWRITE,
dwSize = result.reserve,
flAllocationType = MEM_RESERVE,
lpAddress = 0)->*U8
return result
commit :: (m: *Memory, size: SizeU): Bool
commit_size := align_up(size, PAGE_SIZE)
total_commit := m.commit + commit_size
clamped_commit := clamp_top_sizeu(total_commit, m.reserve)
adjusted_commit := clamped_commit - m.commit
if adjusted_commit != 0
result := VirtualAlloc(
lpAddress = (m.data + m.commit)->*void,
dwSize = adjusted_commit,
flAllocationType = MEM_COMMIT,
flProtect = PAGE_READWRITE,
)
m.commit += adjusted_commit
return true
return false
Actual examples that explain language features can be found in /examples
Building
- Requires Windows, Visual Studio and Clang to be installed
- Run build.bat
- They lived happily ever after
Description
Core is an experimental systems programming language and compiler I built as one of my first "full" language projects.
Languages
C++
81.5%
C
17.4%
Python
1%