https://github.com/ujstor/basic-interpreter-in-python
Lexer, parser & interpreter in Python. Test this code in a VM environment.
https://github.com/ujstor/basic-interpreter-in-python
interpreter lexer parser python
Last synced: about 1 month ago
JSON representation
Lexer, parser & interpreter in Python. Test this code in a VM environment.
- Host: GitHub
- URL: https://github.com/ujstor/basic-interpreter-in-python
- Owner: Ujstor
- Created: 2023-07-10T19:29:48.000Z (almost 3 years ago)
- Default Branch: master
- Last Pushed: 2023-11-25T13:04:09.000Z (over 2 years ago)
- Last Synced: 2025-01-22T18:51:53.568Z (over 1 year ago)
- Topics: interpreter, lexer, parser, python
- Language: Jupyter Notebook
- Homepage: https://ujstor.github.io/webvm/
- Size: 52.7 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Basic Interpreter in Python
ShadowScript is a Python-based interpreter designed for a custom scripting language. It provides a versatile environment for executing scripts with various features like variable declarations, arithmetic operations, conditional statements, and loops.
## Installation
To use ShadowScript, simply clone this repository and ensure you have Python installed on your system or test this code in a VM environment, provided in the description of this repository.

## Components
ShadowScript consists of several key components:
- `Lexer`: Tokenizes the input script into meaningful tokens.
- `Parser`: Parses the tokens into an abstract syntax tree (AST).
- `Interpreter`: Interprets the AST and executes the script.
- `Data`: Handles storage and retrieval of variables.
## Examples
### Example 1: Variable Declaration and Arithmetic Operation
```python
ShadowScript: make x = 10
ShadowScript: make y = 20
ShadowScript: x + y
```
This example demonstrates declaring two variables and performing an addition operation.
### Example 2: Conditional Statement
```python
ShadowScript: make a = 5
ShadowScript: make b = 10
ShadowScript: if a < b do a = a + 1
```
This example shows the use of a conditional `if` statement to modify a variable based on a comparison.
### Example 3: While Loop
```python
ShadowScript: make counter = 0
ShadowScript: while counter < 5 do make counter = counter + 1
```
In this example, a `while` loop is used to increment a variable until a certain condition is met.
## Limitations
ShadowScript is a basic interpreter and may not support all features of a fully-fledged programming language. It's primarily for educational and experimental purposes.

# Links for additional learning content
1. [Create a Programming Language and Learn Advanced Python](https://www.youtube.com/watch?v=1WpKsY9LBlY)
2. [Data Structures Easy to Advanced Course - Full Tutorial from a Google Engineer](https://www.youtube.com/watch?v=RBSGKlAvoiM&list=PLkNZMXPAMnwPWawqMHs5Y2Q5B3Sh5Iwbo&index=22&t=14388s)
3. [Data Structures - Computer Science Course for Beginners](https://www.youtube.com/watch?v=zg9ih6SVACc&list=PLkNZMXPAMnwPWawqMHs5Y2Q5B3Sh5Iwbo&index=3&t=115s)
4. [Recursion in Programming](https://www.youtube.com/watch?v=IJDJ0kBx2LM&t=12s)
5. [Big O Notation](https://www.youtube.com/watch?v=Mo4vesaut8g)