An experimental interpreted programming language written in Python.
Aptly named because barnacles don't do a lot, are rough around the edges, and will cause you pain if you work with them too much.
This codebase makes use of Python 3.10 features.
- Create a Python3 virtual environment with
python3 -m venv <venv name>
. - Activate the newly created virtual environment with
source <venv name>/bin/activate
. - Update pip with
pip install -U pip
. - Install dependencies with
pip install -U -r requirements.txt
. - Run
pip install .
to build and install thebarnacle
Python module.
Follow the "Standard build" instructions above, except when installing dependencies use requirements-dev.txt
instead of requirements.txt
.
- Set
PYTHONPATH
withexport PYTHONPATH=`pwd`/barnacle
. - Run pylint with
pylint barnacle/ test_barnacle/
.
- Run black with
black .
.
- Run isort with
isort .
.
- Set
PYTHONPATH
withexport PYTHONPATH=`pwd`/barnacle
. - Run pytest with
pytest
.
Run python barnacle <script> [<optional args>]
to run the Barnacle interpreter on the specified Barnacle script.
Positional arguments:
<script>
: The file to interpret. If-
is provided, read from standard input instead of a file.
Optional arguments:
-l <level>
or--log-level <level>
: Set the interpreter logging level (default isINFO
).--log-file <file>
: Redirect logs to the specified file instead of standard error.--show-tokens
: Output the tokenized stream for the provided script.--show-ast
: Output the Abstract Syntax Tree (AST) for the provided script.--no-run
: Do not interpret the script (useful when combined with--show-tokens
and/or--show-ast
).
Examples:
python barnacle /example/hello_world.bcl
cat /example/hello_world.bcl | python barnacle -
python barnacle -
(type code directly, to execute use^D
)python barnacle /example/hello_world.bcl --show-ast --no-run
- v0.1.0: Tokenizer experimentation
- v0.2.0: Parser experimentation
- v0.3.0: Interpreter experimentation
- v0.4.0: Command line features
- v0.4.1: Pylint, Black and isort
- v0.5.0: Pytest unit testing, variables as expressions
- v0.6.0: Scoped variable declarations, variable re-assignment
- v0.7.0: While loops
- v0.8.0: Mathematical expressions and operations, string concatenation and subtraction
- v0.9.0: Comparison operators (<, >, <=, >=, !=, ==)
- v0.10.0: Function declaration and function calling
- v0.11.0: Do-While loops
Note that these are in no particular order.
- Boolean logic (and, or, xor, not)
- Console input
- For loops
- File I/O
Thanks to Dmitry Soshnikov for his YouTube videos on parsing!