EnScript

From Esolang
Jump to: navigation, search

EnScript is an esoteric programming language mainly based on encrypting data. It was created due to the desire of creating a simple language(4 instructions) that will probably result in complex documents. It is created to make writing an implementation very hard, due to the CHS command.

Syntax

The language runs inside an infinite loop. If a "9" appears in the beginning of one of the accumulators, then the execution halts.

There are a infinitely of unbounded accumulators, each represented by a series of alphabets in English. All of the are pre-set to 0.

Commands

They can be written lazily, from 0 to 6, in the order that they are presented.

ENC

ENC means to encrypt the accumulators. Take ENC A, b as an example:

  • Assume that the accumulator A was set to 123, and that the accumulator b was set to 231;
  • Encryption happens on the accumulator A.
  • Both accumulators are saved, and it will act as a lookup table. The values inside the accumulator A will be changed to another number according to the lookup table.
  • (The lookup table acts like this: according to a value in A, find the same value inside the preserved b. Navigate to the value of the preserved A in the same index, and that number in A gets changed to that corresponding number.)
  • For example, 1 will be converted to 3; likewise, A will be changed into 312.
  • All unmapped numbers will map to 0. All repeated numbers in the lookup table will be deleted, and the frontmost one will be recovered.

CHS

CHS means to chase all of the numbers inside an accumulator. This is the hardest command to implement in this language.

  • Chasing a number means to move a number forward inside the accumulator that-number times. Chasing an accumulator means to move all of the numbers inside an accumulator from the lowest number (0) to the highest number (9) sequentially, without repeating.
  • Take A=123 as an example.
  • Value 1 will move forward 1 number. (It will be inserted behind 2.) So, the number will be 213. 1 will be marked as chased.
  • Likewise, 2 will also be moved. It will be moved forward twice, so the number will be 132.
  • 3 will also be chased. It will move forward 1 time (finding that the end of the list is reached), and then it will go to the place before 1. Then, it will go back to where it was.
  • Accumulator A "chased" will be 132.

REV

This one is simpler. I promise.

  • Reverse-cat an accumulator and copy the resulting value to another accumulator. So, REV A, A(where A was set to 123) will be 321.

INC

  • Increment all of the values inside the accumulator by 1, with 10 mapping down to 0, and copy the result to another accumulator. So, the code INC B, A will increment A and put it into B. 129(in A) will be 230(in B).

"Syntactic sugars" (convenience operations not in the documentation)

This is not part of the documentation; this is just syntactic sugar for this language just to make sure that the language is usable for writing programs.

LDA

  • Load a value into the accumulator. LDA A, 12341234

INP

  • Input an accumulator if there is nothing inside the accumulator.

OUT

  • Output an accumulator.

Examples

Hello, world! program

(Fortunately the characters don't contain a "9" in the beginning. Phew!)

LDA A, 72
OUT A
LDA A, 101
OUT A
LDA A, 108
OUT A
OUT A
LDA A, 111
OUT A
LDA A, 44
OUT A
LDA A, 32
OUT A
LDA A, 119
OUT A
LDA A, 111
OUT A
LDA A, 114
OUT A
LDA A, 108
OUT A
LDA A, 100
OUT A
LDA A, 33
OUT A
LDA A, 9

Exchange 2 accumulators

Make sure that all numbers are unique.

//Swap A and B
ENC A, B
ENC B, A
ENC A, B
// Halting code here (if neccecary)

There is another way without limitations:

//Swap A and B
REV C, B
REV C, C
REV B, A
REV B, B
REV A, C
REV A, A

Infinite loop

Looping counter

INC A

Truth-machine

Please make sure that you have a "9" after your one integer of input!

INP A
OUT A//19 or 09
LDA Z, 10
ENC A, Z
OUT A

Lazily:

5A 6A 4Z,10 1A,Z 6A

Cat program

INP A
OUT A

Computational class

It is unknown, but it definitely is more powerful than a FSA.