Box is a text-based visual programming language inspired by Unreal Engine blueprint function graphs.
$ cat factorial.box
┌─ƒ(Factorial)───┐ ┌─[Branch]─────┐ ┌─[Set]─┐
│ ►┼─────────────────────┼► True ►┼───────────────────────┼► ►┼─────────┐ ┌─[For Loop]───────────┐ ┌───────┐
│ n ○┼──┐ ┌──┼○ False ►┼──┐ ┌──────────┐ ┌───┼○ │ └─────────┼► Loop body ►┼───────────────────┼► │
└────────────────┘ │ ┌────────┐ │ │ │ │ │ result ○┼──┘ ┌─┼○ │ │ │ ┌──────────┐ ┌────┼○ *= │
┌────┐ └────┼○ >= ○┼─┘ └──────────────┘ │ └──────────┘ │ └───────┘ ┌────┐ │ │ │ result ○┼─┘ ┌─┼○ │
│ 1 ○┼───────┼○ │ │ ┌────┐ │ │ 1 ○┼────┼○ start │ └──────────┘ │ └───────┘
└────┘ └────────┘ │ │ 1 ○┼─────┘ └────┘ │ │ │
│ └────┘ │ index ○┼─────────────────┘
│ ┌────┐ │ │
│ │ n ○┼─┐ ┌───────┐ │ │
│ └────┘ └──┼○ + │ │ │
│ ┌────┐ ┌──┼○ ○┼─────┼○ end │
│ │ 1 ○┼─┘ └───────┘ │ │
│ └────┘ │ │
│ ┌────┐ │ │
│ ┌─[Return]─┐ │ 1 ○┼────┼○ step │
┌────┐ └───┼► │ └────┘ │ Completed ►┼────┐
│ 1 ○┼─────┼○ │ └──────────────────────┘ │ ┌─[Return]─┐
└────┘ └──────────┘ ┌─────────┐ └──┼► │
│ result ○┼──────┼○ │
└─────────┘ └──────────┘
$ box factorial.box -e 5
120
$ box factorial.box -e 5
87178291200
$ box factorial.box -o factorial.py
$ cat factorial.py
def Factorial(n):
if (n >= 1):
result = 1
for index_8b6ee4f2 in range(1, (n + 1), 1):
result *= index_8b6ee4f2
return result
else:
return 1
Getting Started
Install the box interpreter with pip
pip3 install boxlang
Now open your text editor and start drawing your program! Check out existing samples here.
Anatomy of a Box
A Box has 2 types of ports: control flow ports (─►┼─) and data flow ports (─○┼─). These ports can additionally be classified as input or output ports. All ports to the left side of a box are input ports and all ports on the right side of the box are output ports.
Below, you can see a [For Loop] box which is a special type of box that the interpreter can parse - It has 1 input control flow port, 3 input data flow ports (start, end, and step), 2 output control flow ports (the loop body and completed control flows), and 1 output data flow port (the index)
Function Graphs
Box programs are function graphs. Functions have a single entry point designated by a node with the name of the Function containing a single output control flow port.
Here's a simple hello world example. This example declares a Greet() function that prints the string "Hello, World!" to the console. It calls the built-in print function.
Execute the above program with the box interpreter like so:
$ box samples/hello_world.box -e
Hello,World!
Features
- ✅ Function declarations
- ✅ Defining constants and variables
- ✅ Operators - Unary, binary, and assignment operators
- ✅
[Set]- set the value of variables - ✅ Function calls - Call Python built-in functions
- ✅
[Branch]- if-else box - ✅
[For Loop]- Python-style for loop with (start,end,step) - ✅
[While Loop]- Python-style while loop - ✅
[For Each]for iterables - ✅
[Break]and[Continue]boxes - ✅
[Return]box to return values from functions
Gotchas
- The interpreter will likely fail if you have tabs in your file - replace all tabs with the appropriate number of spaces
- There are a number of UNICODE character you'll need for this to work - Just look through the samples and COPY-PASTE (no, seriously)
Contributing
Contributions are welcome, have a look at the CONTRIBUTING.md document for more information.
License
The project is available under the MIT license.
Release files for boxlang 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| boxlang-0.1.1.tar.gz | 19.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| boxlang-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 40.4 kB
Release files / boxlang-0.1.1.tar.gz
| Download URL | boxlang-0.1.1.tar.gz |
|---|---|
| Size | 19.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f0afd1b3c9d766f9f03191e131ab153aa0e5fee035a7f3a09dbf58df4e1a0682
|
|
BLAKE2b-256 checksum How to use checksums |
704f77606973659dae669f0b81c8d4eaa5b729a3fd799f7df106850089af87e5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/4.6.0 pkginfo/1.7.0 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.8.5
|
Release files / boxlang-0.1.1-py3-none-any.whl
| Download URL | boxlang-0.1.1-py3-none-any.whl |
|---|---|
| Size | 21.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ae3fee9a9c2f2ef4f12fae8365b3e7aa641152b2e546c2942ef718cbf058e4f1
|
|
BLAKE2b-256 checksum How to use checksums |
c58795387605561a6debc240b9360764bc874aca57a9d91b2a98b793094c1d72
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/4.6.0 pkginfo/1.7.0 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.8.5
|