Zealot is a Dynamically typed Tree-Walking Interpreter designed for simplicity, efficiency, and ease of use.
Zealot is designed to provide a clean and concise syntax while being powerful and easy to learn.
- Java Development Kit (JDK)
- Make (Optional)
- Clone
Zealotofficial repository:
git clone https://github.com/kmr-ankitt/Zealot.git
cd Zealot- Run
ZealotREPL:
zealotYou can also run Zealot using Makefile:
make compile
make repl- Run
.zltfile:
zealot FILE_DIRECTORY/FILE_NAME.zltOr using Makefile:
make run INPUT="FILE_DIRECTORY/FILE_NAME.zlt"Zealot supports only .zlt file extension.
example: main.zlt
A simple hello world program in Zealot:
print "Hello, World!";Semi-colons at the end of every line are mandatory in Zealot.
Zealot has the following datatypes:
Number literals can be both integers and floating-point numbers.
examples: 1, 2.5, 9
String literals are defined inside ".
examples: "Zealot", "Strings are easy"
Boolean literals can be either true or false.
examples: true, false
Zealot has a null datatype. It can be defined using the nill keyword. All uninitialized variables are given the value of nill.
examples: nill
Zealot has the following operators:
= - equals
- - Unary negation
and - logical AND
or - logical OR
! - logical NOT
+ - sum
- - difference
* - product
/ - division
% - mod
== - is equals
!= - is not equals
< - is less than
<= - is less than or equals
> - is greater than
>= - is greater than or equals
Zealot supports both single-line and multi-line comments.
- Single-line comment
// This is a single-line comment.- Multi-line comment
/*This is a multi-line comment in Zealot.*/var num = 15; // number
var name = "radiohead"; // string
var truth = true; // boolean
var lie = false; // boolean
var nullable = nill; // null type!true; // false.
!false; // true.
true and false; // false.
true and true; // true.
false or false; // false.
true or false; // true.var num = 15;
if(num > 0){
print "num is positive";
}else {
print "num is negative";
}for(var i = 0; i < 10; i = i + 1){
print i;
}
var num = 1;
while(num > 0){
print num;
num = num - 1;
}fun add(a, b){
return a + b;
}
print add(5, 10);fun addPair(a, b) {
return a + b;
}
fun identity(a) {
return a;
}
print identity(addPair)(1, 2); // Prints "3".
fun makeCounter(){
var c = 0;
fun counter(){
c = c + 1;
print c;
}
return counter;
}
var counter1 = makeCounter();
var counter2 = makeCounter();
counter1(); // 1
counter2(); // 1Zealot supports object-oriented programming with classes.
- Keywords:
classfor defining a class,thisfor the current context.
class Bacon {
fun eat() {
print "Crunch crunch crunch!";
}
}
Bacon().eat(); // Prints "Crunch crunch crunch!".
class Thing {
fun getCallback() {
fun localFunction() {
print this;
}
return localFunction;
}
}
var callback = Thing().getCallback();
callback();After running Zealot, you may want to clean up compiled files. Use the following commands:
For Linux and macOS:
make cleanFor Windows:
Get-ChildItem -Path .\com\piscan\zealot -Filter *.class -Recurse | Remove-Item -ForceThese commands will remove all compiled .class files, ensuring a clean environment.