Build 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 andbuild
methods are used to parse the blocks of code sequentially. Theeval
method in the above interpreter works similar to pythoneval
method 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:
Condition
in betweenif
andthen
- Statements in between
then
andfi
fi
should be followed by a;
-
While Statement:
Condition
in betweenwhile
anddo
- Statements in between
do
anddone
done
should be followed by a;
-
Print Statement:
- Works same as
python
print statement and can print multiple arguments at once.
- Works same as
-
Println Statement:
println
statement can be used to print a new line character just like Java
-
Good Tutorials 🔖: