Skip to main content

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.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for stack-lang-engine 0.0.3
File Size Uploaded
stack_lang_engine-0.0.3.tar.gz 15.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for stack-lang-engine 0.0.3
File Interpreter ABI Platform
stack_lang_engine-0.0.3-py3-none-any.whl Python 3 none any Details

Total release size: 31.1 kB

Release files / stack_lang_engine-0.0.3.tar.gz

Download URL stack_lang_engine-0.0.3.tar.gz
Size 15.3 kB
Tags Source
SHA-256 checksum
How to use checksums
bf849003c99d2d5db327bbe274e48fb823983bf78b5dadc3b99fb8ae9ebcb685
BLAKE2b-256 checksum
How to use checksums
ecaeea142e8d46324b7d3918b978b78f2c21ee8eb6bd886b5ae56b2e1668983d
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 19, 2026.

Transparency log

Release files / stack_lang_engine-0.0.3-py3-none-any.whl

Download URL stack_lang_engine-0.0.3-py3-none-any.whl
Size 15.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
43627aeb3d927ac812ae168dd165e9a87cd584428f71ceb1c4e770aa6e38fbec
BLAKE2b-256 checksum
How to use checksums
6a212715548a4b7293be3154cbffb50605e78aead5a75957cb7ffa65f3734051
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 19, 2026.

Transparency log

Release history Release notifications | RSS feed

0.0.4

2 release files

This release

0.0.3 This release

2 release files

0.0.2

2 release files

0.0.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page