A=B

From Esolang
Jump to navigation Jump to search

A=B (pronounced "A to B") is a text replacement-based esolang. Similarly to ///, the only instruction is text replacement, but there are several keywords that add extra functionality that is not present in ///.

This language is the premise of the video game of the same name by Artless Games (the team behind the game Understand) released on 2022 March 29.

Description

The language takes a single line of text as input, and a list of instructions, one per line, as the code. At its very basics, each line of code is in the following format: A=B, where the first occurence of the substring A in the input gets replaced with B.

Comments are notated with the character #. All characters from # to the end of the line is ignored.

Blank lines and comment lines are not counted as lines of code.

A=B can only take ASCII characters as input and code, except for comments.

On each step of execution, the interpreter tries to apply the first substitution rule in order that can be applied. When the input is such that no substitution rules can be applied, the state of the modified input is output.

Below is a simple example program that converts the characters a, b, and c to uppercase:

a=A b=B c=C

When this program is run on the input abacbcab, the input will be mutated in this order:

  • abacbcab
  • Abacbcab
  • AbAcbcab
  • AbAcbcAb
  • ABAcbcAb
  • ABAcBcAb
  • ABAcBcAB
  • ABACBcAB
  • ABACBCAB

Keywords

Keywords are added to the language as the player progresses through the puzzles in the game.

keyword function
A=(return)B (World 2) Halts the program and outputs B instead of the input state.
(start)A=B (World 3) Only matches the start of the input.
(end)A=B (World 3) Only matches the end of the input.
A=(start)B (World 3) Appends the replacement to the start of the input.
A=(end)B (World 3) Appends the replacement to the end of the input.
(once)A=B (World 4) Only executes the rule once per program.

Example

Cat program

A blank A=B program returns the input as its output, so a blank A=B program is already a cat program. Input: anything

Code: nothing

Hello world

Input: anything

Code: =(return)Hello, world!

Truth-machine

Because A=B does not have streamed output, this truth-machine will duplicate the 1 in an endless loop.

Input: 0 or 1

Code: 1=11 0=(return)0