It is the school project done in the second semester. It's a language interpreter, written on Python with the help of Visitor pattern. This language can execute programm which is represented as an abstract syntax tree.
The abstract tree can contain these commands:
- Arythmetic expression
- Conditional expression (represented as a
Conditionalobject) - Function definition (represented as a
FunctionDefinitionobject) - Print construction (represented as a
Printobject) - Read construction (represented as a
Readobject)
An arithmetic expression is one of the following list:
- Number (represented as a
Numberobject) - Name (represented as a
Referenceobject) - Binary operation (represented as
BinaryOperation), the arguments of which are arithmetic expressions - Unary operation (represented as
UnaryOperation), the argument of which is an arithmetic expression - Function call (represented as
FunctionCall)
Also this tree can be reduced(class ConstantFolder) to not include operations of the form:
BinaryOperation (Number, AnyBinOp, Number), whereNumberis any object of theNumberclass, andAnyBinOpis any binary operation from the list of valid binary operationsUnaryOperation (AnyUnOp, Number), whereAnyUnOpis any operation from the list of valid unary operationsBinaryOperation (Number (0), '*', Reference), whereNumber (0)is an object of theNumberclass, which contains the value0, andReferenceis any object of theReferenceclassBinaryOperation (Reference, '*', Number (0))BinaryOperation (Reference (name),‘ - ’, Reference (name)), whereReference (name)is an object of the Reference class containing the namename