Welcome to the Python Interpreter repository, a code that was written as part of the Magshimim Cyber Program. The interpreter is written in C++ and can interpret a subset of the Python language. The code had five steps:
- Basic structure.
- Types.
- Variables.
- Lists.
- Variables manipulation.
I was able to finish 4 of the five steps - which means you can now create and manipulate variables including lists, call methods on lists, and print their values. The code supports deep copying of variables and nested data structures.
I was able to finish the first three steps in the span of the 4 hours we worked on the project in class and the rest in an hour at home.
- Basic Structure: The interpreter has a basic structure to handle input and output.
- Types: Supports basic types such as integers, booleans, strings, and lists.
- Variables: Allows creating variables, assigning values to them, and printing their values.
- Lists: Supports creating, nesting, and manipulating lists with methods.
- Methods: Implement list methods like the append.
- Deep Copying: Variables are properly deep-copied to avoid reference issues.
To use the interpreter, follow these steps:
-
Clone the repository:
git clone https://github.com/yourusername/python-interpreter.git cd python-interpreter -
Open the solution in Visual Studio: Open the
Python Interpreter.slnfile in Visual Studio. -
Build the project: Build the project using the
DebugorReleaseconfiguration. -
Run the interpreter: Run the project. You will see a welcome message and a prompt (
>>>) where you can enter your commands. -
Commands:
- Create a variable:
x = 5 - Print a variable:
x - Reassign a variable:
x = 10 - Create a list:
x = [1, 2, "hello", True] - Append to a list:
x.append(3) - Quit the interpreter:
quit()
- Create a variable:
Welcome to Magshimim Python Interpreter version 1.0 by Ofek Carpassi
>>> x = 5
>>> x
5
>>> y = "Hello"
>>> y
'Hello'
>>> z = [1, 2, 3]
>>> z
[1, 2, 3]
>>> z.append(4)
>>> z
[1, 2, 3, 4]
>>> quit()