SeeLlash

From Esolang
Jump to navigation Jump to search

SeeLlash is an esolang that is created by User:AnotherUser05, which she finally wrote an interpreter for an esolang before making the page for it.

Overview

The language is somewhat inspired by Brainfuck, but only uses 2 values, which one of them cannot be modified directly, which is called the Stored value. The value you can directly modify (like adding or subtracting) is called the Current value.

Caption text
Command Function
+ Increment the Current value by 1
- Decrement the Current value by 1
~ Move the Current value to the Stored, leaving behind a 0
` Move the Stored value to the Current, leaving behind a 0
^ Swap the Current with the Stored value
, Ask for a single character, and set the Current to the Unicode code point of it
. Output the character at the Unicode code point of the Current value
; Ask for a number, and set the Current to it
: Output the Current
[ Jump past the matching ] if the Current is 0
] Jump back to the macthing [ if the Current is nonzero
( Initializes a fixed loop, iterates the amount of times determined by the Stored value
) Jump back to the matching ( if its still iterating


Examples

A+B Problem

;~;(+):

Truth Machine

;[:]:

Fibonacci sequence

+[^:(+)]

Fixed Repeating Output

;~+(:)-:

Hello, World!

++++++++~(+++++++++).~+++++++^(++++)+.+++++++..+++.~+++++++++++^(------)-.~++^(------).~+++++++++^(++++++)+.~++++++^(++++).+++.------.--------.~+++++++++++^(------)-.

Implementation

An interpreter in python that hopefully works

def build_loop_map(code,open,close):
    loop_stack = []
    loop_map = {}
    for i, char in enumerate(code):
        if char == open:
            loop_stack.append(i)
        elif char == close:
            start=loop_stack.pop()
            loop_map[start]=i
            loop_map[i]=start
    return loop_map
def execute(code):
    current = 0
    stored = 0
    index = 0
    code = list(code)
    brackets = build_loop_map(code,'[',']')
    parenthesis = build_loop_map(code,'(',')')
    iterations = {}
    while True:
        if index == len(code):
            break
        elif code[index] == "+":
            current+=1
        elif code[index] == "-":
            current-=1
        elif code[index] == "~":
            stored = current
            current=0
        elif code[index] == "`":
            current = stored
            stored=0
        elif code[index] == "^":
            current,stored=stored,current
        elif code[index] == ",":
            current=ord(input("single character"))
        elif code[index] == ".":
            print(chr(current))
        elif code[index] == ";":
            current=int(input("number"))
        elif code[index] == ":":
            print(current)
        elif code[index] == "[":
            if current == 0: index=brackets[index]
        elif code[index] == "]":
            if current != 0: index=brackets[index]-1
        elif code[index] == "(":
           if index not in iterations: iterations[index]=stored-1
           elif iterations[index]>0: iterations[index]-=1 
           else: 
               del iterations[index]
               index=parenthesis[index]
        elif code[index] == ")":
            if iterations[parenthesis[index]]>0: index=parenthesis[index]-1
            else: del iterations[parenthesis[index]]
        index+=1