Klon

From Esolang
Jump to navigation Jump to search

Klon is a programming language created by User:KlonMac7.

Commands

left  -Moves the pointer to the left
right -Moves the pointer to the right
in    -Sets cell value
out   -Prints cell value
con   -User input
cls   -Clears cell
copy  -Copies cell value
paste -Pastes cell value
exit  -Exits the program
+     -Adds value to cell
-     -Subtracts value from cell
*     -Multiplies cell value by value
/     -Divided cell value by value

Examples

Hello world

in Hello_world
out

User input

in Whats_your_name_?
out
cls
in Hello_
con
out

Prints: "Hello_<input>".

Cell operations

in 1
right
in 2
right
in 3
out
left
out
left
out

Prints "321".

in Hello
copy
out
right
paste
out

Copies the value from the first cell and paste it into the second cell.

in 5
+ 5
out

Prints the result of "5+5"

in 5
- 5
out

Prints the result of "5-5"

in 5
* 2
out

Prints the result of "5*2"

in 10
/ 2
out

Prints the result of "10/2"

Interpreter in Batch

@echo off
setlocal enabledelayedexpansion
if not exist klon.p exit /b
set p=0
for /f "tokens=1-3" %%i in (klon.p) do call :cmd %%i %%j
exit /b
:cmd
if %1==left if not %p%==0 set /a p-=1
if %1==right if not %p%==32767 set /a p+=1
if %1==in set p%p%=!p%p%!%2
if %1==out echo !p%p%!
if %1==con set /p v=&set p!p!=!p%p%!!v!
if %1==cls set p%p%=
if %1==copy set t=!p%p%!
if %1==paste set p%p%=!p%p%!%t%
if %1==exit exit /b
if %1==+ set /a p!p!+=%2
if %1==- set /a p!p!-=%2
if %1==* set /a p!p!*=%2
if %1==/ set /a p!p!/=%2
goto :Eof