2022-07-28 14:31:12 +02:00
2022-07-28 13:20:51 +02:00
2022-07-28 13:20:51 +02:00
2022-07-28 14:29:43 +02:00
2022-07-28 14:29:43 +02:00
2022-07-28 14:29:43 +02:00
2022-07-28 14:29:43 +02:00
2022-07-28 14:29:43 +02:00
2022-07-28 14:19:48 +02:00
2022-07-28 14:29:43 +02:00
2022-07-28 14:31:12 +02:00
2022-07-28 14:29:43 +02:00
2022-07-28 13:20:51 +02:00
2022-06-19 12:34:05 +02:00
2022-06-28 14:26:52 +02:00

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

  1. Requires Windows, Visual Studio and Clang to be installed
  2. Run build.bat
  3. 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.
Readme 1.6 MiB
Languages
C++ 81.5%
C 17.4%
Python 1%