a custom interpeter implementation using Thorsten ball book. https://interpreterbook.com/
clone the project:
git clone https://github.com/ImTheCurse/Quokka-interpeter.git
cd to directory:
cd Quokka-interpeter
compile and run:
cargo run
let add = fn(x,y){
return x + y;
}
add(5,3); // we will get here 8.
Supports if + else but dosent support else if.
if(true){
//do something
}else{
//do alternative
}
Supports +, -, !, / , *, '' operators.
1 + 2 + (3 * 4) - (10 / 5);
!true;
!false;
-5;
'Hello' + ' ' + 'World';
We define variables using the let keyword. Foramt:
let <identifier> = <value>
let x = 5;
returns the value as expected, can be used inside a block / function.
let x = fn(){
return 5;
}
x();
as seen before, we use functions in the following format:
fn (<parameter one>, <parameter two>, ...) { <block statement> };
let x = fn(){
return 5;
}
there are currently 3 data type which are: integer, boolen and strings, but I intend to add more in the near future. Integer:
1;
5;
let y = 7;
Boolen:
true | false
let x = true;
if(x){
//always execute this
}
String:
'<value>'
'hello world!'