Note: This is a learning project created to explore language implementation concepts and as a way to practice Rust programming. While functional, it's not intended for production use and may contain imperfections or unoptimized elements.
Pelin is a lightweight, modular programming language implemented in Rust, designed for extensibility through the "Feather" system.
Pelin is a dynamically typed language with a simple and expressive syntax. The core design principle of Pelin is modularity - standard libraries are implemented as "Feathers" that can be easily imported and extended.
- Simple, clean syntax inspired by modern programming languages
- Dynamically typed with support for numbers, strings, booleans, and null values
- First-class functions with closures
- Modular design through the extensible Feather system
- Seamless integration with Rust for performance-critical code
- Built-in standard library modules for common operations
Pelin supports the following basic types:
num- Floating-point numbersstr- Text stringsbool- Boolean values (true/false)nun- Null value (similar tonullorNonein other languages)any- Generic type for functions that accept any type
Functions are defined using the fn keyword:
fn num add(num a, num b) {
RUST[std_func::add](a, b)
}
Standard modules and custom libraries are imported using the imp keyword:
imp std_num
imp std_io
std_io.print(std_num.add(5, 10))
One of Pelin's powerful features is direct integration with Rust code through the RUST keyword:
RUST[std_func::add](5, 10)
add, subtract, multiply, divide, sqrt
sin, cos
and, not, or, xor
eq, neq, lt, lte, gt, gte
to_num, to_str
print
read_file, write_file
imp std_file
imp std_io
imp std_comp
fn nun write_file(str path, str content) {
std_file.write_file(path, content)
}
write_file("test.txt", "Hello, World!")
std_io.print(std_comp.eq(3, 3))
- Rust 1.50 or higher
- Cargo
cargo build --release./pelin your_program.plcargo testFeathers are Pelin's way of organizing modules and libraries. To create a custom feather:
- Create a
.plfile in thefeathersdirectory or at a custom path - Define your functions using the standard Pelin syntax
- Import your feather using
imp your_feather_name
Pelin can be extended with Rust code for performance-critical operations:
- Create a Rust library with exported functions
- Build the library and place it in the
rust_libsdirectory - Call your Rust functions using the
RUST[your_lib::your_function]syntax
Pelin's architecture consists of several key components:
- Lexer (
lexer.rs): Tokenizes source code - Parser (
parser.rs): Parses tokens into abstract syntax tree - Interpreter (
interpreter.rs): Executes the parsed expressions - FeatherManager (
feather.rs): Manages feather modules and Rust integration
Contributions are welcome! Please feel free to submit a Pull Request.