Python lib for mangle. Exolang that can take any utf8 text as valid code and return some result out of it
Project description
WIP: This is a work in progress, there is nothing working yet
Mangle
An exolang (A scripting programming language just for fun) without any reserved keywords that can run any utf8 compatible with more than 2 space separated words on it.
Installation
cargo install mangle
Python bindings
Python bindings are available for python > 3.7. You can install them with:
pip install mangle
Then you can get started evaluating mangle from python with:
import mangle
mangle.eval("cat is fat")
>> '5'
How it works
There are only labels, variables and operators. All variables are globally scoped, there are no locals, classes or anything fancy. All variables are dynamically typed and shadowed.
Sentences
The only type of scope is sentences. Sentences are like english sentences, any text that comes before the punctuation marks: .,;:?!
. All the other symbols will be interpreted as variable names, operators, labels, strings or numbers.
If a text has none of those punctuation marks it will run as a single sentence.
Sentence Labels
The label of a sentence is the last word before the punctuation mark except by the first sentence. Labels are the way to have subroutines on this language. They define a scope with a body that you can goto
from any other subroutine.
The first sentence on the interpreted code is the equivalent of the main function in another languages, so it has no need for a label. If the first sentence doesn't call any function, all the others labels will execute in the order they are until you exit or jump to another label.
Data Types
The only types are strings, ints and stacks.
Int
The length of a word - 1
define its numerical value. For example "a" evaluates to 0 and "cat" to 2.
Strings
The words themselves can be also interpreted as strings. You can't easily build multiword strings like "a bird" though since that would read as: "a
and bird"
each as individual words.
Stacks
Strings themselves are a stack of ints that the interpreter itself decodes at runtime. You can add ints to a stack by adding to its variable.
WIP...
Operator
Operators are defined by the word's length. Here is the table of operators on this language
Word Length | Operator | syntax | Example | Description |
---|---|---|---|---|
1 | ||||
2 | Assign | OP receiver Value | is cat fat | Assigns variable cat to value 3 |
3 | ||||
4 | ||||
5 | ||||
6 | ||||
7 | ||||
8 | ||||
9 | ||||
10 | ||||
11 |
But then spaces are keywords heh?
Well... In some interpretation yes, I guess I lied then, sorry about it. You can still pass the -F
argument to change the word separator (like field separator in awk) to any other character.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Hashes for mangle-0.0.3-pp37-pypy37_pp73-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 64c94306fdc4b69090b7311b1b76e0c3b9d4fc217eeb1fc48635a552474a536c |
|
MD5 | 768f11089b9eb1145fc5c66c01d76b58 |
|
BLAKE2b-256 | 08701c98e2f7d751581771ec097abf0495c9926971ea7f5f601d10e9a401ae31 |
Hashes for mangle-0.0.3-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7f82cc9fa75a3572e7324fb4b235a1f684aa4cff29222f4dc370e50d98ec295e |
|
MD5 | f9f266daf6e4e26f4ada262ccd6eea39 |
|
BLAKE2b-256 | 7020b0bc2d4df577a63e1200adecf973ef12eff51548484a2a73f1ad6d9fec02 |
Hashes for mangle-0.0.3-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4275c396e955ea3464de2210052568e106d7b5932ce27fbbe58819e3f6e40f4a |
|
MD5 | 2c94e24fd059cf725b64cb739ac83f80 |
|
BLAKE2b-256 | 0664a2f8558661f9b33f1a2cf6b41f38be2a1b9257d2868635677d5356d3ad2e |
Hashes for mangle-0.0.3-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ae551ef0ab4a7a1d5ac611f501a1482673e058314a2a539f99ce4fc306fa128f |
|
MD5 | 7fce39926946b62210546eb5d2efdf82 |
|
BLAKE2b-256 | 951d61c2a0046da054d543f3b1d721a3f588f64e37eefe0e32599b7932eaf4f0 |
Hashes for mangle-0.0.3-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 143d4cc0288edd47b31304af8ffae40e92dd80eda39bc95dae990c60b95d996c |
|
MD5 | 8ebc3317a5a8903c58bf140d46b69f64 |
|
BLAKE2b-256 | 5dbbf743ec38939903500dcae0c57a8322b3a1b9ad16291234a9e5b5e6844add |