Skip to content
/ Pallas Public

A simple programming language written in C

License

Notifications You must be signed in to change notification settings

kauht/Pallas

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

42 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Pallas

A modern systems language you actually want to use.


Build Status License Platform

Don't sacrifice beauty for control.



Overview

Pallas is a systems programming language that combines low-level control with a safer, modern language design. This is a personal project inspired by my friend Lily's programming language, ADAN and many ideas inspired by languages like C/C++, Go, Rust and Zig.

What Pallas gives you:

  • Explicit behavior
  • Manual memory management
  • Structs and classes
  • Pattern matching
  • Familiar syntax

Community

Pallas is a personal project - Though I'd appreciate any contributions and feedback.


Index

General Language Reference

Quick Start

Prerequisites

  • CMake
  • A C++17 compatible compiler
  • LLVM v14+

Build

cmake -S . -B build
cmake --build build

Run

build/palc --help

Language Reference

Types

Pallas uses explicitly-sized types. No implicit numeric conversions.

Type Description
i8, i16, i32, i64, i128 Signed
u8, u16, u32, u64, i128 Unsigned
f32, f64 Floating point
bool Boolean
char Character
string String
void No Type

Type aliases:

Alias Equals
int i64
uint u64
float f32
double f64

Pointers and Arrays:

  • T* - pointer to T
  • T** - pointer to pointer
  • T[n] - array of n size

Variables and Functions

x: i32 = 42;
const PI: f32 = 3.14159;

square(n: i32): i32 {
    return n * n;
}

Structs and Classes

Structs only support data. Classes support methods, constructors, and destructors.

struct Vector3 {
    x: f32;
    y: f32;
    z: f32;
}

class Person {
    public:
        name: string;
        age: i32;

        Person(n: string, a: i32) {
            name = n;
            age = a;
        }

        ~Person() {
            // destructor
        }

        greet(): void {
            println("Hello, ${name}, you are ${age} years old!");
        }

    private:
        ssn: string;
}

Control Flow

if (x > 10) {
    println("large");
} else {
    println("small");
}

for (i: i32 = 0; i < 10; i++) {
    println("${i}");
}

counter: i32 = 0;
while (counter < n) {
    counter++;
}

Pattern Matching

match (x) {
    0 => { println("zero"); }
    1 => { println("one"); }
    42 => { println("rahh"); }
    _ => { println("something else"); }
}

Pointers and Memory

Manual memory management with new and delete.

x: i32 = 5;
p: i32* = &x;
*p = 10;

arr: i32* = new i32[10];
arr[0] = 1;
delete arr;

Type Casting

No implicit conversions, besides when using literals.

x: i32 = 5; // OK
y: f32 = 5; // OK
z: f32 = (f32)x; // OK

a: f32 = x; // ERROR

Examples

Function

add(a: i32, b: i32): i32 {
    return a + b;
}

Using a Class

main(): void {
    p: Person* = new Person("Sammy", 17);
    p.greet();
    delete p;
}

Roadmap

Goals:

  • Finish language spec
  • Complete Scanner(pretty much done)
  • Complete Parser
  • Complete Semantic
  • Integrate LLVM
  • Complete IR
  • Complete Codegen
  • Add tests for parser, semantics, and codegen
  • Write LSP and formatter (VSCode/Zed/Neovim)

Contributing

Contributions are always welcome, check out CONTRIBUTING.md for more information.


License

Pallas uses MIT licensed - see LICENSE.

Influences

Pallas is heavily inspired by the following projects


More Documentation

About

A simple programming language written in C

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •