Fun Craft

From Esolang
Jump to navigation Jump to search

Fun Craft is a Stack-Based, semi-original, Esoteric programming language made by User:ManiPM, just because he thought maybe creating a language based off Minecraft's Commands and Cheats system might be fun!

Features

This language's has no ways of declaring variables. But you have access to:

  • The @i and @a Stack (For Saving Integers and Ascii Characters)
  • The JPX Accumulator (Can save one integer, Can be used in loops and conditions)

Also, this language consists of 20 commands that can be used in:

  • Stack Manipulation
  • Arithmetic Operations
  • Input And Output
  • Control Flow

Syntax

List OF Commands

say outputs whatever is in front of it => say [Message]
take takes an input from user and pushes it into one of stacks => take [TargetStack/jpx]
tell outputs the value on top of either of the stacks => tell [TargetStack] [peek/pop]
tell outputs the value of JPX as an either integer or ascii => tell [OutputType] jpx
push pushes a value or JPX value to one of the stacks => push [TargetStack] [Value/jpx]
drop discards the top value of one of the stacks => drop [TargetStack]
turn turns one of the stacks upside down => turn [TargetStack]
swap swaps the two top values of one of the stacks => swap [TargetStack]
dup duplicates the top value of one of the stacks => dup [TargetStack]
add pops the two top value of the stack and pushes the result of addition to the stack => add [TargetStack]
sub pops the two top value of the stack (a, b) and pushes the result of subtraction (b-a) to the stack => sub [TargetStack]
mul pops the two top value of the stack and pushes the result of multiplication to the stack => mul [TargetStack]
div pops the two top value of the stack (a, b) and pushes the result of division (b/a) to the stack => div [TargetStack]
mod pops the two top value of the stack (a, b) and pushes the remainder of division (b%a) to the stack => mod [TargetStack]
equ pops the two top value of the stack (a, b) and if they are equal pushes a 1 to the stack (else, it pushes a 0) => equ [TargetStack]
not pops the top value of the stack and if it was one or bigger than one, it pushes a 0 (else, it pushes a 1) => not [TargetStack]
grt pops the two top value of the stack (a, b) and if the second one is bigger than the first one (b>a) it pushes a 1 to the stack (else, it pushes a 0) => grt [TargetStack]
set sets the value of JPX to either a value of top value of integer stack => set [jpx/@i] [Value/peek/pop]
jump jumps to a specific line in program => jump [Value/@i]
execute run executes the command with no condition => execute run [Command]
execute if executes the command if the top value of integer stack or JPX is not zero => execute if @i [pop/peek] [Command]
execute loop executes the command as many times as specified in JPX (loops infinitely if JPX is set to a negative number) => execute loop jpx [Command]
exit terminates the program => exit

Examples

Hello World

say Hello, World!
exit

Truth Machine

say Truth Machine

take @i

execute if @i pop jump 10

say 0
exit

set jpx -1
execute loop jpx say 1

Infinite loop

set jpx -1
execute loop jpx say Infinite loop!

Interpreter

Interpreter in Java

Source, Release and Manual; All in github