Skip to main content

Simple Malbolge(https://en.wikipedia.org/wiki/Malbolge) interpreter in python with debugger

Project description

pyMalbolge

This is a fork from https://github.com/Avantgarde95/pyMalbolge

Simple Malbolge interpreter in Python with built-in debugger.

Installation

# Basic installation
pip install malbolge

# With TUI debugger support
pip install malbolge[tui]

Usage

Command Line

TUI Debugger Screenshot

# Run a Malbolge program
python3 -m malbolge hello.mal

# Run with input (for programs that read stdin, like cat.mal)
python3 -m malbolge cat.mal -i "Hello World"

# Start CLI debugger
python3 -m malbolge.debug_cli hello.mal

# Start CLI debugger with input
python3 -m malbolge.debug_cli cat.mal -i "Hello World"

# Start TUI debugger (requires textual)
python3 -m malbolge.debug_tui hello.mal

# Start TUI debugger with input
python3 -m malbolge.debug_tui cat.mal -i "Hello World"

Python API

from malbolge import eval

# Hello World
eval('''(=<`#9]~6ZY32Vx/4Rs+0No-&Jk)"Fh}|Bcy?`=*z]Kw%oG4UUS0/@-ejc(:'8dc''')
# Output: Hello World!

# Cat program with input
eval('''(=BA#9"=<;:3y7x54-21q/p-,+*)"!h%B0/.~P<<:(8&66#"!~}|{zyxwvugJ%''', "abc123")
# Output: abc123

Debugger API

from malbolge import MalbolgeDebugger

# Create debugger instance
dbg = MalbolgeDebugger(source_code, input_data)

# Set breakpoints
dbg.add_breakpoint(10)

# Step execution
state = dbg.step()      # Execute one instruction
state = dbg.step_back() # Undo last instruction
state = dbg.run()       # Run until breakpoint

# Inspect state
print(dbg.registers)    # {'a': 0, 'c': 5, 'd': 45}
print(dbg.output)       # Program output so far
print(dbg.disassemble(0, 10))  # Disassemble instructions

Debugger

CLI Debugger

Interactive command-line debugger similar to GDB.

(maldbg) break 10       # Set breakpoint at address 10
(maldbg) run            # Run until breakpoint
(maldbg) step 5         # Step 5 instructions
(maldbg) back 2         # Step back 2 instructions
(maldbg) examine 0 20   # Examine memory at address 0
(maldbg) disassemble    # Show disassembly
(maldbg) registers      # Show register values
(maldbg) output         # Show program output
(maldbg) help           # Show all commands

TUI Debugger

Visual terminal-based debugger with split-screen interface.

TUI Debugger Screenshot

Keybindings:

  • - Step one instruction
  • - Step back
  • r - Run until breakpoint
  • b - Toggle breakpoint at current address
  • / - Scroll memory view left/right
  • 0 - Reset memory scroll to D pointer
  • h / ? - Show help
  • q - Quit

Changes from Original

Fixed

  • Integer division syntax (Python 3 compatibility)

Added

  • eval() function for inline evaluation
  • Full-featured debugger with:
    • Breakpoints and watchpoints
    • Step-by-step execution
    • Step back (execution history)
    • Memory inspection
    • Disassembly view
    • CLI and TUI interfaces

TODO

  • Support Malbolge20 and Malbolge Unshackled
  • A simple Malbolge compiler/generator

License

MIT

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

malbolge-0.1.0.tar.gz (2.9 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

malbolge-0.1.0-py3-none-any.whl (25.9 kB view details)

Uploaded Python 3

File details

Details for the file malbolge-0.1.0.tar.gz.

File metadata

  • Download URL: malbolge-0.1.0.tar.gz
  • Upload date:
  • Size: 2.9 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.11

File hashes

Hashes for malbolge-0.1.0.tar.gz
Algorithm Hash digest
SHA256 b3469225a4cdd805ff09f3f3a46cc52b54e0846d8c5deda9237390ea32c39018
MD5 abaf70ea7d47f8eda7c9b00910c859d0
BLAKE2b-256 624499c8e24c4f12b145cbe7a2a969fa58ea360c3e7343e4f373f794bd047c46

See more details on using hashes here.

File details

Details for the file malbolge-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: malbolge-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 25.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.11

File hashes

Hashes for malbolge-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 bb4f72011a61bd2d1538fcc802aeb56bfec2173a9909d4317f0b6fe9e387b28c
MD5 1d5e8eb2c29548ffd2e313f4dcfe3f7b
BLAKE2b-256 06fd78c1151eeffaae01c65fa2b13b16b64b3fa350538efa3160a47cdd1a8073

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page