skift/luna
4
2
Fork
You've already forked luna
0
A language for puppies, cats, and all Frieren owl pet things !
  • C++ 100%
2026年07月08日 20:52:14 +02:00
src meta: Update karm. 2026年07月08日 20:52:14 +02:00
.gitignore Initial commit. 2026年01月13日 09:34:58 +01:00
project.json meta: Update manifests. 2026年06月25日 22:02:03 +02:00
project.lock meta: Updare karm. 2026年04月06日 00:34:16 +02:00
readme.md Update readme. 2026年01月13日 09:43:07 +01:00

Luna

Luna is an interpreted, dynamically typed scripting language implemented as a C++20 module. It uses a recursive descent parser and an AST-walking interpreter.

Type System

Luna supports the following value types:

Type Description Example
None Represents the absence of value none
Boolean Logical true or false true, false
Integer 64-bit signed integer 42
Number 64-bit floating point 3.14159
Symbol Interned identifier string #identifier
String Text sequence "hello"
List Ordered generic collection [1, 2, "a"]
Table Key-value associative array { x: 10, y: 20 }

Syntax

Variable Declaration

Variables are declared using the var keyword.

var x = 100;
var message = "Hello";

Control Flow

Luna provides standard branching and looping constructs.

// Conditional
if (x > 50) {
 x = x - 1;
} else {
 x = x + 1;
}
// Loop
while (x > 0) {
 if (x == 10) break;
 if (x == 20) continue;
 x = x - 1;
}

Functions

Functions are first-class citizens. They support optional parameters with default values.

fn add(a, b: 1) {
 return a + b;
}
// Usage
var result = add(10); // b defaults to 1

Error Handling

Errors are structural exceptions that propagate up the call stack.

try {
 throw "An error occurred";
} catch (e) {
 // 'e' contains the thrown value
}

Reflection and Casting

The language includes operators for runtime type inspection and conversion.

var x = 10;
// Type Check
if (x is integer) {
 // Conversion
 var s = x as string;
}
// Type Query
var t = typeof(x); // returns #integer