Boomerang is a programming language written in Python. The syntax was inspired by Haskell and Python (see the language specs for more information on the language).
Some defining characteristics of Boomerang are:
- Interpreted: code executes in the runtime of another language (in this case, Python).
- Procedural: commands are executed in the order they are defined.
- Dynamically Typed: types are not declared explicitly (unlike languages like C++ or Java); rather, types are inferred from values (for example,
1
and3.14159
are numbers,"hello world!"
is a string,true
andfalse
are booleans, etc.). - Strongly Typed: there are strict rules for how different types interact (e.g.
1 + 1
or1 + 1.5
are valid, but1 + "hello world!"
is invalid). - Immutable: data is immutable, and operations return new data instead of modifying existing data.
- Download and install Python 3.11+
pip install -r requirements.txt
- May need to run
python -m pip install -r requirements.txt
- May need to run
- Install graphviz
- Optional: this project uses lefthook for pre-commit verification. Follow the installation and setup process here.
NOTE: you may need to replace python
with python3
, though throughout the rest of the setup guide, I simply use python
.
- To run the REPL, run
python main.py
- To run a Boomerang file, run
python main.py [path to file]
. Boomerang files end with.bng
. - When running a Boomerang file, create an AST visualization with the
-v
/--visualize
flag, which will save a graphical representation of the AST to a pdf file. AST visualization is not supported for the REPL.
Boomerang has a web interface that will allow for executing code directly in the browser!
-
From this project's root directory, run the following code to create a
.env
file withSECRET_KEY
:import secrets key = secrets.token_hex() with open(".env", "w") as file: file.write(f"export SECRET_KEY={key}")
-
Download and install Docker Desktop.
-
With Docker Desktop running, run the following command from the root directory:
docker compose up --build
-
The app should now be running at http://localhost:8000/.
When you're ready, start your application by running:
docker compose up --build
.
Your application will be available at http://localhost:8000.
First, build your image, e.g.: docker build -t myapp .
.
If your cloud uses a different CPU architecture than your development
machine (e.g., you are on a Mac M1 and your cloud provider is amd64),
you'll want to build the image for that platform, e.g.:
docker build --platform=linux/amd64 -t myapp .
.
Then, push it to your registry, e.g. docker push myregistry.com/myapp
.
Consult Docker's getting started docs for more detail on building and pushing.
- Make sure you have signed up for a free PythonAnywhere account, and you’re logged in.
- Go to the Web menu item and then press the Add new web app button.
- Click Next, then click on Flask and click on the latest version of Python that you see there. Then click Next again to accept the project path.
- In the Code section of the Web menu page click on Go to Directory next to Source Code.
- Click "Open Bash console here" at top of page.
- Replaced the content of
mysite
with this repo:git clone https://github.com/johneastman/boomerang.git mysite
- You may need to delete (
rm -rf mysite
) or rename (cp -r mysite/ mysite2/
) existingmysite
directory.
- You may need to delete (
- Edit last line of
jeastman_pythonanywhere_com_wsgi.py
file, replacingfrom flask_app import app as application
withfrom flask_app.app import app as application
(add.app
afterflast_app
). - Back on the web app configuration page, I clicked
Reload jeastman.pythonanywhere.com
- Steps 1 - 4 source: https://pythonhow.com/python-tutorial/flask/deploy-flask-web-app-pythonanywhere/
- Additional resources: https://help.pythonanywhere.com/pages/UploadingAndDownloadingFiles
The following information is for contributing to this project.
To disable lefthook, add LEFTHOOK=0
before your command. More information, as well as other usage information, can be found here.
There are two types of exceptions: Language Exceptions and Program Exceptions.
These are errors introduced by users into Boomerang code (syntax errors, index out of range, invalid token, etc). The interpreter will catch these errors and display them to the user.
To raise a language exception, call the raise_error
method in utils.py
, which raises a LanguageRuntimeException
exception.
These are errors with the Python code itself and exist to aid the development process. To raise a program exception, raise any valid Python exception (e.g., raise ValueError
, raise Exception
, raise RuntimeError
, etc.).
The language specs can be found here.
This project is licenced under the MIT License.