Skip to content
cedruslang edited this page Mar 3, 2026 · 1 revision

Cedrus Language Documentation

Welcome to the official Cedrus documentation. Cedrus is a medium-level, statically typed language that balances the power of C++ with the modern safety features of Rust.


1. Core Syntax

Variables & Constants

Variables are declared using let and constants using const. Type annotations are required after a colon :.

let x: int = 42;          // Mutable variable (default)
const PI: float = 3.14;   // Immutable constant
let name: string = "Cedrus";
let is_valid: bool = true;

Functions

Functions are declared using the fn keyword. The main function is the entry point of every Cedrus program.

fn main() {
    let result: int = add(10, 5);
    print("Result is:", result);
}

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

2. Type System

Cedrus currently supports the following primitive types:

Type Description Go Equivalent
int Signed 64-bit integer int64
float 64-bit floating point float64
string UTF-8 string string
bool Boolean (true or false) bool
void Empty type (used for return types) (none)

3. Control Flow

If / Else

Cedrus supports standard conditional branching. Conditions must be wrapped in parentheses ().

if (age >= 18) {
    print("Access granted.");
} else {
    print("Access denied.");
}

4. Operators

Arithmetic

  • + (Addition)
  • - (Subtraction)
  • * (Multiplication)
  • / (Division)

Comparison

  • == (Equality)
  • != (Inequality)
  • < (Less than)
  • > (Greater than)
  • <= (Less than or equal)
  • >= (Greater than or equal)

Logical

  • ! (NOT)

5. Built-in Functions

Currently, Cedrus provides basic built-in utilities for I/O:

print(...)

Prints one or more values to the standard output, followed by a newline.

print("Hello", 123, true);

6. Project Structure

A typical Cedrus project consists of .ced files.

  • cmd/cedrus/: Contains the CLI source code.
  • pkg/lexer/: Lexical analysis (tokenization).
  • pkg/parser/: Syntactic analysis (AST generation).
  • pkg/ast/: Abstract Syntax Tree definitions.
  • pkg/compiler/: Transpilation logic (Cedrus -> Go).

7. Future Directions

Cedrus is in early development. Future releases will include:

  • Structs: For custom data models.
  • Loops: for and while constructs.
  • Standard Library: io, os, net, math, and json packages.
  • Error Handling: Safe alternatives to panics.