EsoPy Framework

From Esolang
Jump to navigation Jump to search

EsoPy Framework is a language/framework made by User:ce2lo. It provides a Python template for building esoteric programming languages. It includes a lexer and an interpreter, and a runner that ties everything together.

Specification and instructions

There are the instructions of the default language within the framework:

 <VALUE> + <VALUE>       Addition, also works with <VARR>.
 <VALUE> - <VALUE>       Substraction, also works with <VARR>.
 <VALUE> * <VALUE>       Multiplication, also works with <VARR>.
 <VALUE> / <VALUE>       Division, also works with <VARR>.
 <VARR> = <VALUE>        Assignation, also works with <VARR>.
 @ Text                  Comment a line.
 GOTO <LINE>             Jump to a specific line <LINE> in the code.
 GOIF <LINE> <VARR>      Jump based on the value of a variable. If the value of <VARR> is 0, the
                         program jumps to the line <LINE>.
 INPUT <VARR>            Input during runtime and store this input in <VARR>.
 PRINT <VARR>            Print the content of <VARR>.
 END                     Terminate the program.

Since this project provides a Python template for building esoteric programming languages, the user can define its own esoteric programming language, the user can modify the keywords and symbols dictionaries to change the corresponding attributs. But he can also modify the special_characters list to include any special characters that he want to be use as variables names.

 keywords = {"PRINT":"PRINT", "GOTO": "GOTO", "GOIF": "GOIF", "INPUT": "INPUT", "END": "END"}
 symbols = {"=":"=", "+":"+", "-":"-", "*":"*", "/":"/", "(":"(", ")":")", "@":"@"}
 special_characters = ["?", "!", ">", "<", "@", "&", "|", "^", "~", "%", "$", "#", "_", "`", ":", ";", ",", ".", "[", "]", "{", "}", "\\", '"', "'"]

Default examples

Hello World

@ Simple Hello World program
var = "Hello World"
PRINT var
END

Cat Program

@ Simple Cat program
INPUT a
PRINT a
GOTO 1

Different versions of Fibonacci example

In this section, three different versions of the same program have been developed in different syntaxes to show how the framework works.

Example 1 (Default)

@ Fibonacci sequence
i = 0
j = 1
INPUT counter
PRINT j
k = i + j
i = j
j = k
counter = counter - 1
GOIF 12 counter
GOTO 5
END

Example 2 (Confusing)

@@@ Fibonacci sequence
& +-+ 0
$$ +-+ 1
>>> #
<<< $$
: +-+ & --- $$
& +-+ $$
$$ +-+ :
# +-+ # +++ 1
??? 12 #
!!! 5
...

Example 2 (Verbose)

// Fibonacci sequence
firstValue is 0
secondValue is 1
writeIn counter
show secondValue
tempoValue is firstValue plus secondValue
firstValue is secondValue
secondValue is tempoValue
counter is counter minus 1
ifZeroJumpTo 12 counter
jumpTo 5
finish

Framework