We are currently working on new rules for what content should and shouldn't be allowed on this website, and are looking for feedback! See Esolang:2026 topicality proposal to view and give feedback on the current draft.

Machine

From Esolang
Jump to navigation Jump to search

Machine is an esoteric programming language made for creating machines.

not to confused with Machines.

Machines

Machines are usually used to test other esoteric programming languages here are some examples and what they test:

Name What they test
Truth machine
  • input
  • output
  • comparison
  • flow control
  • unbounded repetition
  • termination
False machine
  • input
  • output
  • comparison
  • flow control
  • unbounded repetition
  • termination
Maybe machine
  • input
  • output
  • random number generation
  • comparison
  • flow control
  • repetition
  • termination
Better-machine
  • input
  • output
  • addition
  • subtraction
  • arrays
  • comparison
  • flow control
  • bounded repetition
  • unbounded repetition
  • termination
Unknown machine
  • string input
  • output
  • arrays
  • comparison
  • 3-way flow control
  • unbounded repetition
Denying machine
  • input
  • output
  • flow control
  • labeling
  • goto
  • termination
Numeric machine
  • input
  • comparison
  • flow control
  • bounded repetition
  • unbounded repetition
  • absolute

Syntax

Code Format

this language uses block statements almost exclusively for all its instructions formatted like this:

<instruction> argument
other parameters
<instruction>

Arguments and Parameters

These are mostly the only things that aren't block statements. here's a list of all arguments:

Data types
Type Length (bits) Description
uint 16 An unsigned integer from 0 to 65,535
int 16 A signed integer from −32,768 to 32,767
half float 16 bits A floating‑point from 0.00000005960464477539063 to 0.00006103515625 to 65504
char 8 Just a single character
bool 1 True or False
Truth 1 Truth Flag
Array ? a list
Conditions
Instruction Description
equal is a equal to b or a == b
less is a less than b or a < b
more is a more than b or a > b

Arrays

Arrays are structured like this:

type[length]

For obvious reasons type cannot be Truth or Array if you try to append more than the length, Machine will throw an error:

MACHINE CHRASHED: Cannot append to Array greater than length.

Instructions

As a reminder, almost all instructions are block statements

Input/Output

You should see the Variable Section first.

Output


<display> prints out variable:

<display> type

var/literal
var/literal
...

<display>

for example:

<display> char
    'H'
    'H'
<display>

will print

HH

As for Arrays, it will print out every item in the array

<>

Repetition

Instruction Description
<forever> loops forever
<repeat> int repeat int times
<while> true/false loops while Truth Flag is true/false

Data Manipulation

Variable Definition

Variables are defined using a var and set instructions:

<var> type

<set> name
literal
<set>

<set> name
literal
<set>

...

<var>

Set Instruction

The set instruction is not only for creating variables it can also be used to set a variable:

<set> var
literal
<set>

If you try to set a var to a different type you'll get an error:

MACHINE CRASHED: Cannot set <TypeA> to <TypeB>

You'll get the same error if you do this for the var instruction:

<var> int

<set> character
'a'
<set>

<var>

Will return that error.


Arrays

For arrays this format should be used:

var & set:

<var> char[5]

<set> Hello
'H'
'e'
'l'
'l'
'o'
<set>

<var>

This sets the array Hello to ['H', 'e', 'l', 'l', 'o'].

Numbers


Operators

Operators are formatted like this:

<opp>
a
b
<opp>
Instruction Description
<add> adds a to b and sets a to the result
<sub> subtracts a from b and sets a to the result
<mul> multiplies a with b and sets a to the result
<div> divides a with b and sets a to the result
<mod> finds the modulous of a and b and sets a to the result

If you try to divide or mod by zero you'll get this error:

MACHINE CRASHED: Cannot divide by zero
Rounding/Absolute

Rounding and Absolute are combined due to their similar representation within mathematics

Rounding/Absolute is formatted like this:

<tune> type
var/literal
<tune>

type in this case can be up, down or abs

Examples


<display> int
    <tune> up
    3.5
    <tune>
<display>

Returns

4
<tune> abs
-5
<tune>

Returns

5

Booleans


Booleans only have one instruction: <flip>

 <var> bool
     <set> test
         True
     <set>
 <var>
 
 <display> bool
 test
 <display>
 
 <flip>
 test
 <flip>
 
 <display> bool
 test
 <display>

Interpreter

There is no Interpreter written for this language yet, but if you were to write one please format your interpreter like this:

=== Language/Name ===

code/source of code

for example:

=== PythonMachine ===

Example: source code

this section should be replaced after an implementation is made.