Files
oraset/README.md
T
JGZ_YES c30eb9b7ad
Build and Package Oraset / build (macos-latest) (push) Waiting to run
Build and Package Oraset / build (ubuntu-latest) (push) Waiting to run
Build and Package Oraset / build (windows-latest) (push) Waiting to run
Build and Package Oraset / release (push) Blocked by required conditions
Oraset B-5: Clean repository with only C implementation
2026-07-23 13:27:04 +08:00

3.3 KiB

Oraset B-5

A modern, C++-style scripting language designed for ease of use and powerful functionality.

Features

Core Language Features

  • Variables: let x = 10;
  • Strings: let name = "Hello World";
  • Arrays: let arr = [1, 2, 3, 4, 5];
  • Functions: proc add(a, b) { return a + b; }
  • Control Flow: if, else, while, for, switch, case, default
  • Loops: do-while, while, for

C++ Style Features

  • Structures: struct Point { x; y; };
  • Enums: enum Color { Red, Green, Blue };
  • Typedef: typedef Point Pnt;
  • Pointers: Support for pointer operations
  • goto: goto label;
  • Dynamic Memory: new, delete, malloc
  • Exception Handling: try, catch, throw

Operators

  • Arithmetic: +, -, *, /, %
  • Bitwise: &, |, ^, ~, <<, >>
  • Comparison: ==, !=, <, >, <=, >=
  • Logical: &&, ||, !
  • Compound: +=, -=, *=, /=, %=
  • Increment/Decrement: ++, --

Built-in Functions

  • Mathematical: abs, sqrt, sin, cos, tan, pow, log, floor, ceil, round
  • String: strcmp, strcpy, strcat, sizeof
  • Array: arrlen, memcpy, memcmp, malloc
  • Utility: echo, input, time, random, exit, assert

Getting Started

Prerequisites

  • GCC compiler (C11 standard)
  • Make (optional)

Compilation

# Windows
gcc -Wall -Wextra -O2 -std=c11 -o bin/oraset src/main.c -lm -lwininet

# Linux/Mac
gcc -Wall -Wextra -O2 -std=c11 -o bin/oraset src/main.c -lm

Or use the Makefile:

make

Running

# Run a script
./oraset script.ora

# REPL mode
./oraset

Example Code

// Hello World
echo("Hello, Oraset!");

// Variables and arithmetic
let x = 10;
let y = 20;
echo("x + y =", x + y);

// Arrays
let arr = [1, 2, 3];
echo("arr[0] =", arr[0]);
echo("array length =", arrlen(arr));

// Functions
proc factorial(n) {
    let result = 1;
    for (let i = 1; i <= n; i++) {
        result *= i;
    }
    return result;
}
echo("5! =", factorial(5));

// Structures
struct Point {
    x;
    y;
};

// Loops
let i = 0;
while (i < 5) {
    echo("i =", i);
    i++;
}

// Switch statement
let color = 2;
switch (color) {
    case 1: echo("Red"); break;
    case 2: echo("Green"); break;
    default: echo("Blue");
}

Syntax Reference

Variables

let name = value;

Arrays

let arr = [1, 2, 3];
arr[0] = 10;
echo(arr[0]);

Functions

proc func_name(param1, param2) {
    // body
    return value;
}

func_name(arg1, arg2);

Control Structures

if (condition) {
    // code
} else if (condition) {
    // code
} else {
    // code
}

while (condition) {
    // code
}

for (let i = 0; i < 10; i++) {
    // code
}

do {
    // code
} while (condition);

switch (value) {
    case 1: // code; break;
    case 2: // code; break;
    default: // code;
}

Structures and Enums

struct Name {
    field1;
    field2;
};

enum Name {
    Value1,
    Value2,
    Value3
};

typedef OriginalType NewTypeName;

Version History

  • B-5: Current version with C++ style features
  • Re+4: Previous version
  • Re+3: Earlier version

License

GNU General Public License v3.0

Contributing

Feel free to fork and contribute!