(())

From Esolang
Jump to: navigation, search

(()), also known as Empty Nest, is a string re-writing scheme designed by User:DocHerrings to use only properly nested parenthesis, and to be completely impossible to read. The syntax is very simple. Every program consists of a list of productions, with the last item being the data. The interpreter iterates through the productions, testing them in order for a match within the program (all matches are greedy). If a match is found, the match substring is replaced with the productions replacement substring. If the production was non-terminating, then execution starts from the beginning of the productions and data. Otherwise, execution ends and the data is returned. A production of only one object matches the empty string.

A (()) program is made up of the following parts:

((productions) (data))
productions -> (non-terminating) | ((terminating))
non-terminating | terminating -> (match)(replace)

Examples

Binary Increment

Let 0 = (())
Let 1 = (()())
Let A = ((()))
Let B = ((()()))

To increment the binary number 1001, the following productions are used:

A1 -> 1A
A0 -> 0A
A -> B
1B -> B0
0B -| 1
B -| 1
-> A

Written in (()) form:

((((()))(()()))((()())((()))))
((((()))(()))((())((()))))
((((())))(((()()))))
(((()())((()())))(((()()))(())))
((((())((()())))((()()))))
(((((()())))((()()))))
((((()))))

The entire program, without line breaks: ((((((()))(()()))((()())((()))))((((()))(()))((())((()))))((((())))(((()()))))(((()())((()())))(((()()))(())))((((())((()())))((()()))))(((((()())))((()()))))((((())))))((()())(())(())(()())))