Operation

From Esolang
Jump to navigation Jump to search

Operation is an esoteric programming language that relies on folder metadata, created by kiken.

Overview

Memory

Memory in Operation consists of a stack. Each item is a single byte.

The memory starts with 00000000 pushed onto the stack. Once the stack is empty, program halts.

Execution

Executing programs in Operation is done in this order:

  • First, the interpreter takes in the file's inode and preforms a split.
  • Then, the interpreter uses the splitted inode and preforms a merge with the file's size (in byte count).
  • With the merged data, a control is then preformed.
  • Finally, with the data, an interpretation is preformed.

Splitting

If the file contents are empty, program halts. Else, the following process is repeated for every digit of the input number:

  • The input is taken.
  • If the input digit is even, then push a 0 onto the stack.
  • If the input digit is odd, then push a 1 onto the stack.

Afterwards, the stack is transformed with the following process:

  • The stack is split into groups of bytes and turned into chars with their corresponding ASCII value. If the group of bits are unable to form a byte, then form a number with the bits and translate into a character.
  • The stack is then merged into one, long string and the end character is cut off.

Merging

After the splitting is completed, then a merge is preformed. The merging process is as so:

  • Two inputs are taken.
  • The two inputs are then merged, with each character from the first input precedes the second. For example, if the first input was abcde and the second input was 12345, then the merged product would be: a1b2c3d4e5. However, if one input is longer than the other, then the input is cut off to match the length of the other.
  • The resulting data is then converted from base-35 into quinary.

Controlling

Controlling is a process which takes in one input.

The first input should be a number in quinary.

If the setgid bit exists, then we use this table to convert the quinary into code:

Quinary Converted code
0 +=
1 =+
2 whitespace
3 =
4 +

Else, use this table to convert into code:

Quinary Converted code
0 ==
1 ++
2 +
3 =
4 whitespace

For examples, if the input was:

01324

then assuming the setgid bit exists, it would translate to:

+==+= +

else, it would translate to:

==++=+

Interpretation

The interpretation is the last process of executing an Operation script. The input consists of two characters, = and +. There is a single factor, the operation, and it is an integer that begins at one, and wraps modulo 3.

Operations are increased using =.

Operation 1

In operation 1, the + command does the following:

  • If the command is at an even position in the code (first character in the code is position 0, next character position 1, etc.), then this character is saved as a jump point with an ID of the amount of spaces preceding the command.
  • If the command is at an odd position in the code, then jump to the jump point with the ID of the amount of spaces (subtract one) preceding it if the byte at the top of the stack is 0 when converted to decimal.

Operation 2

In operation 2, the + command does the following:

  • If the command is at an even position in the code, then add 00000001 to the item at the top of the stack.
  • If the command is at an odd position in the code, then pop the top of the stack.

Operation 3

In operation 3, the + command does the following:

  • If the command is at an even position in the code, then push 00000000 onto the stack.
  • If the command is at an odd position in the code, then output the top of the stack as ASCII.

Once the instruction pointer reaches the end of the code, program halts.

Computational class

I believe Operation to be at least higher than a finite-state machine. This can be proved by making a direct translation from the language brainfuck to Operation's intermediate code:

  • If the program is on operation 1, the following translations can be made:
Operation(ish) brainfuck
any even amount of spaces+ [
any odd amount of spaces+ ]
  • If the program is on operation 2, the following translations can be made:
Operation(ish) brainfuck
+ +

(assuming the character is at an even position in the code)

  • If the program is on operation 3, the following translations can be made:
Operation(ish) brainfuck
+ .

(assuming the character is at an odd position in the code)

However, since Operation uses a stack and not a tape, Operation is likely to be a push-down automaton.

Implementations

There is an unfinished implementation here.