Mezzo

From Esolang
Jump to navigation Jump to search

Mezzo is an Esoteric programming language created by User:Stegoratops in 2026. It was inspired by both Forte (thus the name) and Hofstadter.

Each expression evaluated redefines the number of the current line. Though, unlike Forte this doesn't happen deeply, the numbers rather serving as weird variable names.

Syntax

Every line consists of one expression. They are evaluated from top to bottom. If the end is reached the program begins back at the top. If an invalid mathematical operation is performed (i.e. division by zero) the program terminates.

A $ or # can optionally be added to the beginning of line for the result to be outputed. $ outputs the full number from LSB to MSB as ASCII, # outputs the result as a number.

An expression consists of Numbers and Operators. The result is stored to the current linenumber.

Numbers

Numbers can be written in:

  • decimal 1234
  • octal 01234
  • hexadecimal 0x1234
  • ASCII '1', '1234' is also valid, being equivalent (ignoring variable resolution) to '1'|'2'<<8|'3'<<16|'4'<<24

Operators

Operators can either be infix or prefix operators

Infix Operators
Symbol Operation
+ Addition
- Subtraction
* Multiplication
/ Division
% Modulo
Prefix Operators
Symbol Operation
+ Unary Plus (basically a noop)
- Negation
abs Absolute value
sign Sign-Function
in Get n-th character from stdin
nin Get n-th number from stdin

Examples

Hello World

$'Hello '
$'World!\n'
0/(0-0)

Due to 0 being redefined as 'Hello ' or 35662932501832 numerically it cant be simply used in the final line.

Truth-machine

#nin(0-0)
$'\n'*(4-3-0)
0/0

The inputed number read and outputed in the first line. The Second line only prints a newline if the character is 0. In the third line the program terminates if 0 is 0 otherwise it will restart the loop.

Cat

0+1
1
$in(0-1)
1/(2+1)

Calculator

in 0
1
nin(1-1)
nin(1)
1-sign abs(0-'+')
1-sign abs(0-'-')
1-sign abs(0-'*')
(1-sign abs(0-'/')) * sign abs(6)
#2
$0
#3
$'='
#(2+3)*4+(2-3)*5+(2*3)*6+(2/(3-(3+1)*(1-7)))*7
$10010-10000
0/(0-0)

A four operation calculator. First input the operation (+-*/) then two numbers.

Interpreter