VoidScript is a lightweight, embeddable scripting language designed for simplicity, extensibility, and ease of integration. It provides both a command-line interpreter and a FastCGI-based template engine.
- Simple, dynamically-typed C-like syntax with object-oriented features
- Command-line interpreter (
voidscript) - FastCGI runner (
voidscript-fcgi) for web templates - Template parsing: embed
<?void ... ?>tags inside HTML -
- Print:
print(),printnl(),error(),throw_error() - String utilities (
string_length(),string_substr(), etc.) - Array utilities (
sizeof(), iteration helpers) - File I/O (
file_get_contents(),file_put_contents()etc.) - JSON encode/decode (
json_encode(),json_decode()) - Variable helpers (
typeof()etc.) - Module helpers (
module_list(),module_exists(),module_info())
- Print:
- HTTP header management (FastCGI only):
header() - Dynamic Plugin module support (e.g., CurlModule for HTTP requests)
- Embeddable library (
libvoidscript) - Zero runtime dependencies (except for the optional modules)
- Syntax highlighter and formatter for vscode / codium and vim
- CMake 3.20 or later
- C++20-compatible compiler (GCC 9+, Clang 10+, MSVC 2019+)
- (Optional)
libfcgi-devfor FastCGI support - (Optional)
spawn-fcgifor Nginx integration - (Optional)
libcurl4-openssl-dev|libcurl4-gnutls-devfor HTTP requests
git clone https://github.com/fszontagh/voidscript.git
cd voidscript
mkdir build && cd build
cmake .. [-DBUILD_FASTCGI=ON] [-DBUILD_MODULE_CURL=ON]
cmake --build . -- -j$(nproc)
sudo cmake --install .BUILD_FASTCGI=ONenablesvoidscript-fcgi.BUILD_MODULE_CURL=ONbuilds the CurlModule.
By default, binaries install into /usr/local/bin and the library into your system library directory. Adjust CMAKE_INSTALL_PREFIX as needed.
voidscript [options] [script.vs] [-- args...]Options:
--helpShow help message--versionShow version info--debug[=component]Enable debug output (lexer,parser,interpreter,symboltable)--enable-tagsOnly execute code inside<?void ?>tags--suppress-tags-outsideHide content outside tagsscript.vsScript file (defaults to stdin)-- args...Arguments passed to script ($argc,$argv)
Configure Apache or Nginx as documented in fastcgi/docs/README.md to serve .vs templates. Example template:
<html>
<body>
<?void
header("Content-Type", "application/json");
print(json_encode({"status": "ok"}));
?>
</body>
</html>VoidScript supports classes with access control modifiers. Important: Class properties and methods must be accessed using $this-> syntax within class methods.
class Person {
private:
string $name = "Unknown";
int $age = 0;
public:
// Constructor
function construct(string $name, int $age) {
$this->name = $name; // Correct: Use $this->
$this->age = $age;
}
// Getter methods
function getName() string {
return $this->name; // Correct: Use $this->
}
function getAge() int {
return $this->age; // Correct: Use $this->
}
// Method that modifies properties
function setAge(int $newAge) {
$this->age = $newAge; // Correct: Use $this->
}
function isAdult() bool {
return $this->age >= 18; // Correct: Use $this->
}
}
// Usage
Person $person = new Person("John Doe", 25);
printnl("Name: ", $person->getName());
printnl("Age: ", $person->getAge());
printnl("Is adult: ", $person->isAdult());
- ✅ Correct: Always use
$this->propertyand$this->method()within class methods - ❌ Incorrect: Using bare
this->propertyorthis->method()will produce error messages - Access Control: Classes support
private:andpublic:sections - Constructor: Optional
construct()method for initialization
If you have existing VoidScript code using bare this-> syntax, update it to use $this->:
Before (Old Syntax):
function getName() string {
return this->name; // ❌ Will cause error
}
After (New Syntax):
function getName() string {
return $this->name; // ✅ Correct
}
Include libvoidscript in your CMake project:
find_package(voidscript REQUIRED)
target_link_libraries(your_app PRIVATE voidscript)- Fork the repository
- Create a branch (
git checkout -b feature/foo) - Make changes & tests
- Commit & push
- Open a Pull Request
Please follow established coding conventions when contributing.
This project is licensed under the MIT License - see the LICENSE file for details.