Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

4 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

RezoScript

A modern, feature-rich scripting language interpreter written in C.

Overview

RezoScript is a dynamically-typed scripting language with a focus on simplicity, performance, and extensibility. It supports object-oriented programming, multithreading, networking, and integration with external C libraries.

Features

  • πŸš€ Fast Execution - Efficient interpreter implementation
  • 🧹 Garbage Collection - Automatic and manual memory management
  • 🧡 Multithreading - Native thread support with mutexes
  • 🌐 Networking - TCP and HTTP client/server capabilities
  • πŸ“¦ External Libraries - Load and use C libraries via uselib
  • 🎯 OOP Support - Classes, objects, methods, and inheritance
  • πŸ“š Modules - Modular code organization with use statements
  • πŸ›‘οΈ Exception Handling - Try-catch-finally error handling
  • πŸ“Š Rich Data Types - Arrays, structs, hashmaps, and more
  • πŸ“ File Operations - Comprehensive file and directory manipulation
  • 🎨 F-strings - Python-like string interpolation

Quick Start

Building

make

Running a Script

./rezo script.rzs

Example

use std;

fnc greet(name) {
    return f"Hello, {name}!";
}

var message = greet("RezoScript");
std.println(message);

Documentation

Comprehensive documentation is available in the docs/ directory. See docs/README.md for the full index.

Quick Links

Core Language:

Data Structures:

  • Arrays - Array operations and methods
  • Structs - Structure definitions and usage
  • Hashmaps - Key-value data structures

Advanced Features:

Project Structure

core/
β”œβ”€β”€ src/           # Source code
β”‚   β”œβ”€β”€ interpreter.c    # Main interpreter
β”‚   β”œβ”€β”€ lexer.c          # Lexical analysis
β”‚   β”œβ”€β”€ parser.c         # Syntax parsing
β”‚   β”œβ”€β”€ value.c          # Value representation
β”‚   β”œβ”€β”€ gc.c             # Garbage collector
β”‚   └── stdlib_*.c       # Standard library modules
β”œβ”€β”€ include/        # Header files
β”œβ”€β”€ tests/          # Test scripts
└── docs/           # Documentation

Language Highlights

Variables and Types

var number = 42;
var text = "Hello";
var flag = true;
var empty = null;

Functions

fnc add(a, b) {
    return a + b;
}

var result = add(5, 3);

Control Flow

if (x > 10) {
    std.println("Large");
} else {
    std.println("Small");
}

for (var i = 0; i < 10; i = i + 1) {
    std.println(i);
}

while (condition) {
    // ...
}

Arrays

var arr = [1, 2, 3];
arr.push(4);
std.println(arr.length);  // 4

Structs

struct Point {
    x, y
}

var p = Point { x = 10, y = 20 };
std.println(p.x, p.y);

Classes

class Counter {
    var count = 0;
    
    fnc Counter() {
        this.count = 0;
    }
    
    fnc increment() {
        this.count = this.count + 1;
    }
}

var c = Counter();
c.increment();

Modules

use "math.rzs";
var result = math.sqrt(16);

Threads

fnc worker(id) {
    std.println("Worker", id);
    return id * 10;
}

var t = thread.create(worker, 1);
var result = thread.join(t);

External Libraries

uselib "libs/libraylib.so" as raylib;
raylib.InitWindow(800, 600, "Window");

Requirements

  • GCC or Clang compiler
  • Make
  • POSIX-compliant system (Linux, macOS, WSL)
  • pthread library (for multithreading)
  • dl library (for external library loading)

Known Issues

This section documents known issues and limitations in the current version of RezoScript.

REPL (Read-Eval-Print Loop)

  • Expression result printing is disabled: The REPL currently does not print the results of expressions due to memory management issues (double-free errors). This is a known limitation that will be addressed in a future release.
    • Workaround: Use std.println() to explicitly print values.

Memory Management

  • Double-free protection: Some edge cases in value copying and destruction may cause double-free errors. The garbage collector helps mitigate this, but manual memory management in certain scenarios may still be problematic.

External Libraries (FFI)

  • Limited function signatures: The Foreign Function Interface currently supports a limited set of function signatures:
    • Functions with 0 arguments
    • Functions with 3 arguments (int, int, const char*)
    • More signatures will be added in future versions
  • Type system limitations: Automatic type conversion is limited. Complex types and callbacks are not yet supported.
  • Library loading: Only .so files are supported on Linux/Unix. Windows .dll support may have limitations.

Multithreading

  • Mutex type: A dedicated VALUE_MUTEX type is planned but not yet implemented. Current mutex implementation uses a workaround.

Module System

  • Path resolution: Relative paths with ../ may have issues in some edge cases, especially on Windows.
  • Module caching: Modules are not cached between executions, which may impact performance for large projects.

Error Messages

  • Incomplete error context: Some error messages may not include full context (variable names, function names) in edge cases, though this has been largely addressed.

Platform-Specific Issues

  • Windows console: UTF-8 and color support require Windows 10+ with virtual terminal processing enabled. Older Windows versions may display characters incorrectly.
  • Cross-compilation: Building for Windows from Linux requires MinGW-w64 and may have some limitations.

Performance

  • Garbage collection: The GC may cause noticeable pauses in performance-critical applications. Consider using manual GC mode for such cases.
  • Large arrays: Operations on very large arrays (>100,000 elements) may be slow due to linear search in some operations.

Language Features

  • Exception handling: Exception stack traces may not always be complete.
  • Class inheritance: Full inheritance support is planned but not yet fully implemented.
  • Operator overloading: Not supported yet.

Documentation

  • Some advanced features may have incomplete documentation. Please refer to the source code or test files for examples.

About

dynamically-typed scripting language with a focus on simplicity, performance, and extensibility. It supports object-oriented programming, multithreading, networking, and integration with external C libraries

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages