A Tiny Interpreted language written in Rust, featuring variable declarations, arithmetic operations, conditional statements, and control flow. This project includes a lexer, parser, and interpreter. The name Poo originates from Guinea Pig translated from Burmese.
- Arithmetic Expressions: Supports addition, subtraction, multiplication, and division with correct operator precedence.
- Variable Declarations: Uses
pookeyword for variable declarations. - Mutable Variables: Like in Rust, all variables are immutable by default. Uses
mutfor mutable variables. - Conditional Statements: Includes
if,else, andeliffor branching. - Control Flow: Supports
whileandfor inloops andreturnstatements. - Custom Operators:
- Assignment operator:
<< - Arrow operator:
>>
- Assignment operator:
- Lexer, Parser, and Interpreter: A full pipeline from tokenizing source code to executing it.
- Rust and Cargo installed. If you don't have them installed, follow the Rust installation guide.
-
Clone the repository:
git clone https://github.com/shayyz-code/poolang.git cd poolang -
Build the project:
cargo build
-
Run tests:
cargo test
You can use the interpreter to run files containing your custom language code.
To run the interpreter on a source file:
cargo run <path_to_your_source_file>Example:
cargo run app.pooThe language features basic syntax for arithmetic, variable declarations, and control flow:
poo x << 10;
poo mut y << 5 + 2 * 3;
poo result << x + y * 2 - 10 / 2;
if x > y {
return x;
} else {
return y;
}
use std::pout;
poo mut count << 0;
while count < 10 {
count << count + 1;
}
for i in 0..3 {
pout("Hello, World ", i);
}
use std::pout;
poof getName () >> string {
poo name << "Shayy";
return name;
}
pout(getName());
Here is a sample program in my PooLang:
use std::pout;
poo a << 5.0 * 1.0 - 1.0 * 3.0;
poo b << 2 / 2;
poo mut d << true;
d << false;
poof getHelloWorld () >> string {
return "Hello, World!";
}
for i in 0..2 {
pout("Hello, Poo!", i);
}
pout(getHelloWorld());
Expected Output:
Hello, Poo!0
Hello, Poo!1
Hello, World!
.
├── src
│ ├── lexer.rs # Lexical analysis (tokenizer)
│ ├── parser.rs # Parsing logic
│ ├── interpreter.rs # Interpreter for executing code
│ ├── ast.rs # Abstract Syntax Tree (AST) definitions
│ └── main.rs # Entry point
├── examples # Sample code
│ ├── donut.poo
│ └── app.poo
└── Cargo.toml # Project configuration
Contributions are welcome! Please feel free to submit a Pull Request or open an Issue if you find a bug or have a feature request.
- Fork the repository.
- Create a new branch:
git checkout -b feature/your-feature-name
- Make your changes and commit them:
git commit -m "Add your feature description" - Push to the branch:
git push origin feature/your-feature-name
- Open a Pull Request.
If you have any questions or feedback, feel free to reach out or open an issue in the repository.
Happy Coding! 🎉
