Pysembly

From Esolang
Jump to navigation Jump to search

Pysembly (also styled pysembly, most recent styled pysemblyIV) is a Turing-complete (I think) esoteric programming language made by User: Photostar. The aim of the language is to exist. It is also designed around memory addresses, logical structures, and isolated operations rather than more common object-oriented programming languages. The download also includes the file for a text user interface environment.

Language Overview/Documentation

A Pysembly program is laid out as a set of instructions in a Python list, followed by an instruction to execute the code. The code that prints "Hello, World!", for example, would be:

code = [
    'store Hello, World!'
    'recall 1'
    ]
exec(open('pysembly4/pysembly4.1.py).read())

However, when code is running in the so-called Pysembly Environment, the structure does not require the python wrapper:

store Hello, World!|recall 1

The rest of this page will give code in the basic Pysembly version, but similar transformations can be done to turn any basic Pysembly program into an environment Pysembly program - just make sure to remove all instances of " &", " /", and "|" as those are reserved for the environment's internal processing. A version of Pysembly Environment that can handle these characters is in development.

Starting in 4.1, when running in Terminal/zsh/bash, it is possible for Pysembly to interpret files not in the above format, as:

store Hello, World!
recall 1

as long as the txt-equivalent file has extension .psmb.

Syntax

The syntax of the language can be obtained with the instruction help:

code = [
    'help'
    ]
exec(open('pysembly4/pysembly4.py').open())
help

or preinstalled program 2 in the environment.

Such a program would print out the following:

/pysembly4/: instruction guide 
 store [#] - appends following value to memory 
   store v[#] - appends value at memory address # to memory 
   store inp {text} - appends prompted value to memory, prompt given to user by text 
 recall [#] - recalls value at memory address # 
   see above for variants 
 increment [#] - increments value at memory address # 
   see above for variants 
 decrement [#] - decrements value at memory address # 
   see above for variants 
 add [#1] (newline) [#2] - adds second number to value at first address 
   see above for variants 
   subtract, multiply, and divide are equivalent syntactically 
 showmemory - shows memory 
 showcode - shows code 
 jump [#] - jumps to line # in code 
   see above for variants 
 delete [#] - deletes value at memory address #, shifting all further memory addresses by 1 
 quit - exits program 
 wait [#] - waits # seconds 
   see above for variants 
 if [#1] (newline) {>} (newline [#2] (newline) [#3] - tests if #1 passes operator with regard to #2. #3 is the number of lines to skip if if fails. 
   see above for variants 
   available operators: >, <, =, !, >=, <= 
 repeat [#1] (newline) [#2] - repeats #2 instructions #1 times 
   see above for variants 
 lines [#1] (newline) [#2] - jumps to line #1, runs #2 operations, and jumps back to continue program 
 psmb4 [code] - runs pysembly4 environment formatted code in [code] but with ~ not |
   see above for variants

/pysembly4/: environment commands 
 0 - application editor 
   then filename, then filecode 
 1 - application code viewer 
 -1 - application deleter 
 exit - exit environment 
 2 - first user program 
 3 - second user program 
 etc.

Downloads

Downloads, tutorials, and further documentation for the most recent version of pysembly (pysembly v4 and environment pysembly v1) can be found at: https://sites.google.com/view/pysembly/pysembly-home?authuser=2

The required file structure for execution of pysembly 4 is:

pysembly
   |-README.txt
   |-counter3.py/other pysembly programs
   |-pysembly4
         |-pysembly4.py
         |-pysembly4ui.py

The executed files are counter3.py/other coded files. Alternatively, the pysembly3gui file can be executed to start the environment and code inside of that. All correct structures can be downloaded from the pysembly website. counter3.py is an example file to illustrate correct structure and syntax.

Example Programs

This program prints Hello World in the basic (non-environment) version of Pysembly:

code = [
    'store Hello, World!'
    'recall 1'
    ]
exec(open('pysembly4/pysembly4.py).read())

This code acts as an modified, interactive InterpretMe interpreter:

code = [
    'store inp Enter InterpretMe character',
    'if v1',
    '=',
    '*',
    '2',
    'lines 1',
    '2',
    'jump 1'
    ]
exec(open('pysembly4/pysembly4.1.py').read())

This code acts as a self-interpreter for pysembly:

code = [
    'psmb4 inp Enter Code: '
    ]
exec(open('pysembly4/pysembly4.1.py').read())

This code acts as a single-instruction Subpysembly interpreter:

code = [
       'Store 1',
       'Store inp Enter your code here',
       'Repeat v2',
       '1',
       'Store inp',
       'showmemory',
       'increment 2',
       'store  ',
       'if v3',
       '=',
       '1',
       '1',
       'store v4',
       'if v3',
       '=',
       '2',
       '1',
       'recall v4',
       'if v3',
       '=',
       '3',
       '1',
       'Showmemory',
       'if v3',
       '=',
       '4',
       '1',
       'store inp v4',
       'if v3',
       '=',
       '5',
       '2',
       'increment 4',
       'store v4',
       'if v3',
       '=',
       '6',
       '2',
       'decrement 4',
       'store v4',
       'if v3',
       '=',
       '7',
       '5',
       'if v4',
       '>',
       '0',
       '1',
       'jump 111', 
       'if v3',
       '=',
       '8',
       '1',
       'showmemory',
       'if v3',
       '=',
       '9',
       '1',
       'jump 9'
       ]
exec(open('pysembly4/pysembly4.1.py').read())

It is part of a repeated block that processes Subpysembly.

External Resources