No project description provided
Project description
S3 - Simple Stack Script
S3 (Simple Stack Script) is a lightweight, stack-based programming language designed for simplicity and power. It combines stack-based execution with variable support, making it an excellent choice for scripting, automation, and embedded systems.
Important: We are now an officially published Python package!!!
🚀 Features
- Stack-Based Execution: Operates on a Last-In-First-Out (LIFO) stack.
- Named Variables: Store and retrieve values easily.
- Concise Syntax: Readable and intuitive for programmers.
- Control Flow: Supports conditionals and loops.
- Function Support: Define and reuse stack-based functions.
- Minimal & Fast: Designed for lightweight execution.
- Published Python Package: You can find our package as simplestackscript on PyPI.
📥 Installation
If you are reading this on PyPI, please use the first installation choice below:
pip install simplestackscript
This is the easiest way to install S3. pip will automatically download and install the latest version from PyPI. If you would rather install from source, follow the instructions below:
-
Clone the repository:
git clone [https://github.com/CaptioDev/simplestackscript.git](https://github.com/CaptioDev/simplestackscript.git) cd simplestackscript
-
Install the interpreter:
pip install . # Installs the s3 command
-
Run an S3 program:
s3 my_program.s3
📖 Language Reference
S3 uses a stack-based architecture, where most operations manipulate a stack of values. Instructions are processed sequentially.
Stack Manipulation
PUSH <number>: Pushes the given<number>onto the top of the stack.POP: Removes the top element from the stack.DUP: Duplicates the top element of the stack and pushes the copy onto the stack.SWAP: Swaps the top two elements on the stack.OVER: Copies the second element from the top of the stack and pushes it onto the top.ROT: Rotates the top three elements of the stack. The top element becomes the bottom, the second becomes the top, and the third becomes the second.DROP: Discards (pops) the top element of the stack.NIP: Removes the second element from the top of the stack.TUCK: Copies the top element and inserts it under the second element.
Arithmetic Operations
ADD: Pops the top two elements from the stack, adds them, and pushes the result back onto the stack.SUB: Pops the top two elements (a, b) and pushesb - aonto the stack. (Order matters!)MUL: Pops the top two elements, multiplies them, and pushes the result.DIV: Pops the top two elements (a, b) and performs integer divisionb // a, pushing the result. (Order matters!)
Input/Output
PRINT <string_literal>: Prints the given<string_literal>to the console.READ: Reads an integer from the user's input and pushes it onto the stack.PRINT.TOP: Prints the value at the top of the stack without removing it.
Control Flow
JUMP.IF.0 <label>: Pops the top element. If it is 0, execution jumps to the line marked by<label>. Otherwise, execution continues to the next instruction.JUMP.IF.POS <label>: Pops the top element. If it is greater than 0, execution jumps to the line marked by<label>. Otherwise, execution continues.LOOP <line_number>: Jumps back to the specifiedline_number. Be careful to avoid infinite loops.
Program Termination
HALT: Terminates the program execution.
Labels
<label>:: A label marks a specific location in the program code. It's used as a target for jump instructions. The label itself isn't an opcode; it's a marker.
📝 Examples
# Example: Adding two numbers
PUSH 5
PUSH 10
ADD
PRINT.TOP # Output: 15
HALT
# Example: Input and output
PRINT "Enter a number:"
READ
PRINT "You entered:"
PRINT.TOP
HALT
💡 Contributing
Contributions are welcome! Please open an issue or submit a pull request.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file simplestackscript-0.2.10.tar.gz.
File metadata
- Download URL: simplestackscript-0.2.10.tar.gz
- Upload date:
- Size: 5.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5ece932167bc1c3529dfb355c1a87b18955988266660962ed88eba3304c972d9
|
|
| MD5 |
395f5a3ad1dd4aef714418572f2a0d09
|
|
| BLAKE2b-256 |
ee122a53aec8f0bc0a9240ae5563a0b983404116c97c08a253bf306b7fcebef2
|
File details
Details for the file simplestackscript-0.2.10-py3-none-any.whl.
File metadata
- Download URL: simplestackscript-0.2.10-py3-none-any.whl
- Upload date:
- Size: 8.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8bce36c54af8103d85467c975268944e813eb09a8b49654dc90e4bf364c25b47
|
|
| MD5 |
2985f4e294e0baf0d057e8fbb2a4719b
|
|
| BLAKE2b-256 |
3eedf04a218d62668f52ef0a409e96b20c9c00a99d8d6585991ebc4f3827ccdf
|