Pseudo language interpreter for Python
Project description
LineUp
LineUp is a pseudo-code interpreter that allows you to write and run a code with a limited action set by the language.
The language is designed to be simple and easy to modify, and add actions to it. But it will be a little complex to write a code with it.
Installation
pip install lineup-lang
from lineup_lang import Language, luexec, lucore
Usage
# Create a new language
# Add here the default actions that your language will have
core_object = [lucore.Variables({"a": 0, "b": -1})]
# You need an executor to run the code, it's the object that will iterate over the code
# Default executor, it will run the code line by line
executor = luexec.DefaultExecutor(core_object)
# Jumper executor, it will run the code line by line, but it will also allow you to jump to a specific line
executor = luexec.JumperExecutor(core_object)
# Create the language object, it's the object that will read the code, split it and send it to the executor
language = Language(executor)
# Run the code
language.run('''
VAR c USE VAR a GET
IF *+2 VAR c GET
ELSE *+2
EXIT VAR a GET
EXIT VAR b GET
''')
Default core objects
-
Variables: It's a object that will store variables and their values. It's a dictionary that will store the variables and their values.Variables({"a": 0, "b": -1}): It will create a new object with the variablesaandbwith the values0and-1respectively.VAR x: Execute an action on a variable.GET: Get the value of a variable.SET y: Set the value "y" of a variable.COPY y: Copy the value of the variable y to the variable.USE ACTION: Execute a core action and store the result in the variable x.EXEC ACTION: Execute an action on a variable. The variable need to be aLanguageObject.ACTION: Execute an action on a variable. The variable need to be aLanguageObject.
-
ConditionsJumpObject: An object that will store the conditions and the lines to jump.IF x CONDITION: If the condition is true, go to the line x, else go to the next line.ELSE JUMP x: Go to the line x.NOTIF x CONDITION: If the condition is false, go to the line x, else go to the next line.- Condition:
ACTIONExecute a core action, if the result is true, the condition is true."ACTION" SIGN "ACTION": Compare two actions with the sign.- SIGN:
- Equal:
EQ,== - Not equal:
NE,!= - Greater:
GT,> - Greater or equal:
GE,>= - Less:
LT,< - Less or equal:
LE,<=
- Equal:
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 lineup_lang-0.2.0.tar.gz.
File metadata
- Download URL: lineup_lang-0.2.0.tar.gz
- Upload date:
- Size: 22.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.9.21
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
03ad5fbfc01a516133f4ebace4ab9865f43d222b7c1efb123f8a090dac35d017
|
|
| MD5 |
1315fc73aa4e61cfe9fad4790e2aabbf
|
|
| BLAKE2b-256 |
ea08609ce63e91358f1d147cddd6c4e4721a5ba0ec1c069d5e59c60db332bca3
|
File details
Details for the file lineup_lang-0.2.0-py3-none-any.whl.
File metadata
- Download URL: lineup_lang-0.2.0-py3-none-any.whl
- Upload date:
- Size: 25.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.9.21
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cfac246639df9739cf0253aebe2583175613c4d5d42b476e0aa54ac7fe325264
|
|
| MD5 |
ce47cd8aaf5d1050deff21a9832cbbc8
|
|
| BLAKE2b-256 |
2b6df864c011dc59e60ffb3764dcb388574f01fcf450d1471cbf4ff05870525c
|