Pyro is a simple interpreted programming language built in Go.
Pyro supports:
- Standard Output (
print) - Function Declarations
- Global Variables
- Arithmetic Expressions (
+,-,*,/,%) - Comparison Operators (
<,<=,>,>=,==,!=) - Logical Operators (
and,or,!) - Control Flow
if/elsewhileloopsforloops
- Blocks & Scoping
- Closures and Lexical Scoping
- Tree-Walk Interpreter Architecture
- Golang (Go 1.18 or later)
To run a .pyro file:
./pyro <filename>.pyroHere’s a sample Pyro program that prints the FizzBuzz sequence:
fun FizzBuzz(n) {
for (var i = 1; i <= n; i = i + 1) {
if (i % 3 == 0) {
if (i % 5 == 0) {
print "FizzBuzz";
} else {
print "Fizz";
}
} else {
if (i % 5 == 0) {
print "Buzz";
} else {
print i;
}
}
}
}
FizzBuzz(15);
Pyro is based on the book Crafting Interpreters by Bob Nystrom.