Built on python 😊
-
ver0- Complete (Sample running code in folder)ver1- Complete (Sample running code in folder)ver2- Complete (Sample running code in folder)ver3- Incomplete (Sample code in folder)
-
This interpreter is based on Python Object Oriented Programming and uses autolinking of objects to their functions (saying in lame terms). All the
__init__methods andbuildmethods are used to parse the blocks of code sequentially. Theevalmethod in the above interpreter works similar to pythonevalmethod and evaluates the parsed tree/structure of the code. -
Basic toy language which is parsed and interpreted using python is as follows:
n:=2;
a:=n*2+1;
while n>0 do
while a>0 do
print("yo ",a);
a:=a-1;
done;
n:=n-1;
done;
if a==0 then
print("Machaya");
else
print("Kuch nhi machaya");
fi;
-
Each assignment statement should use
:=for assignment and contains;for termination. -
If-Else Statement:
Conditionin betweenifandthen- Statements in between
thenandfi fishould be followed by a;
-
While Statement:
Conditionin betweenwhileanddo- Statements in between
doanddone doneshould be followed by a;
-
Print Statement:
- Works same as
pythonprint statement and can print multiple arguments at once.
- Works same as
-
Println Statement:
printlnstatement can be used to print a new line character just like Java
-
Good Tutorials 🔖: