DeathScript

From Esolang
Jump to navigation Jump to search

DeathScript is an esoteric programming language created by YourDeathIsComing. It operates on only 3 variables: A, B and C.

Commands

Command Description
output [text] outputs text
outvar [var] outputs value of the variable
input [var] takes user input and saves it in the variable
set [var] [value|random] sets the value of the variable
math [add|sub|mul|div|mod] performs a math action on B and C and saves the result in A
switch [var] swaps the values of A and [var]
clear clears the screen

Examples

Hello, World!

output Hello, World!

Cat

input A
outvar A

Implementation

Implemention in Windows Batch.

@echo off
setlocal enabledelayedexpansion
for /F "eol=# tokens=1,2* delims= " %%a in (%1) do (
if %%a==output echo %%b %%c
if %%a==outvar (
if %%b==A echo !A!
if %%b==B echo !B!
if %%b==C echo !C!
)
if %%a==input (
if %%b==A set /p A=
if %%b==B set /p B=
if %%b==C set /p C=
)
if %%a==set (
if %%c==random (
if %%b==A set A=%random%
if %%b==B set B=%random%
if %%b==C set C=%random%
) else (
if %%b==A set A=%%c
if %%b==B set B=%%c
if %%b==C set C=%%c
)
)
if %%a==math (
if %%b==add set /a A=!B!+!C!
if %%b==sub set /a A=!B!-!C!
if %%b==mul set /a A=!B!*!C!
if %%b==div set /a A=!B!/!C!
if %%b==mod set /a A=!B! %% !C!
)
if %%a==switch (
if %%b==B (
set A_=!A!
set B_=!B!
set A=!B_!
set B=!A_!
)
if %%b==C (
set A_=!A!
set C_=!C!
set A=!C_!
set C=!A_!
)
)
if %%a==clear cls
)

set A=0
set B=0
set C=0
set A_=0
set B_=0
set C_=0
set skip=0