What is "Stack Lang Engine"
SLE (Stack Lang Engine) is a simple tool for creating stack-oriented DSL or even small programming languages.
Usage
Firstly
Of course we need to import a module, and create object with type "StackEngine"
import stack_lang_engine as sle
eng = sle.StackEngine()
Definition of words:
This is how to define/delete words in StackEngine
# Define new word
eng.add_word("print", lambda: print(eng.pop()))
# Delete word
eng.del_word("print")
How to execute text (given as string)
# If you use the default regex pattern,
# it automatically recognizes whether it is a string or a number.
eng.exec('10 20 30 "40"')
How to create stack and APIs for it
# Create new stack, we can use "create_api" option
# to create eng.{name}_push, eng.{name}_pop() methods
# for object
eng.new_stack("stacky", create_api=True)
# now we have eng.stacky_push and eng.stacky_pop
eng.stacky_push(10)
print(eng.stacky)
eng.stacky_pop()
Usefull APIs
# Instead of writing "eng.stack.pop" or more we can use builtin
# methods like eng.(push, pop, clear)
eng.push(10) # For example
Recognizers
# We can create a new regex pattern,
# and both the parser and the interpreter must handle it.
eng.add_recognizer(
name="Test", # Name of recognizer
pattern=r'Test', # Regex pattern
on_regex=lambda val: val, # What parser should get (or do) when it parses it
on_interpret=lambda val: print("Hello, Test!?"), # What interpreter should do when it gets it
)
# and if then we execute it will output
# "Hello, Test!?" when it interprets word
# with "Test" kind
eng.exec("Test 10 20")
print(eng.stack) # It will work correctly, so in stack only 10 and 20
How to write more short code in this engine
# For example we can set words dict instead of creating each
# word over and over
eng = sle.StackEngine(words={
"print": lambda: print(eng.pop())
})
# You can also read the interpreter's code itself on
# GitHub to better understand how it works.
Thanks for reading the documentation!
License
SLE is licensed under GPLv3 License
Release files for stack-lang-engine 0.0.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| stack_lang_engine-0.0.4.tar.gz | 15.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| stack_lang_engine-0.0.4-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 31.1 kB
Release files / stack_lang_engine-0.0.4.tar.gz
| Download URL | stack_lang_engine-0.0.4.tar.gz |
|---|---|
| Size | 15.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
11d6d219ff26c452af4aad83c4ce9125bfce8bbbaf44db7c9bbeb31b68ddeac0
|
|
BLAKE2b-256 checksum How to use checksums |
d7c5ed5e09637fe8e22b1e4f06398271e86533da0a12d81bb09b64a20f2003ac
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 20, 2026.
Transparency logRelease files / stack_lang_engine-0.0.4-py3-none-any.whl
| Download URL | stack_lang_engine-0.0.4-py3-none-any.whl |
|---|---|
| Size | 15.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a389b5e1466fbe87d62c46a716453ea4299718f623a038c9f51373369f3a2a03
|
|
BLAKE2b-256 checksum How to use checksums |
4972d64b3b40f9743961a5e383ad209cd13d7f71869c6cc7adbba706fb2e4208
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 20, 2026.
Transparency log