AEWNN

From Esolang
Jump to navigation Jump to search

AEWNN (or An esolang with no name) is an esolang created by User:ResU in 2021.

Variables

There are two types of variables: letter variables and the VariablesWithNoName. There is only one VariableWithNoName, and numbers get stored in it. Those numbers can have a maximum value of 52. The default letter variable used to store letters is a, but there can be additional letter variables (b, d, e, f, g, h, i, j, k, l, m, n, o, q, s, t, u, v, w, x, y, and z). Those letter variables can be added by simply typing the name of the letter variable.

Letters

Instead of the common ASCII association of codes to characters AEWNN utilizes a specially tailored mapping, restricted to letters only and elucidated in the following tables:

Number 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
Letter A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Number 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
Letter a b c d e f g h i j k l m n o p q r s t u v w x y z

Commands

AEWNN has the following commands:

Command Description
+ Increments the value of VariableWithNoName by 1.
c Converts the value of VariableWithNoName to the corresponding letter variable.
For example, 52 would get stored to A as z, and 26 would get stored to A as Z.
p For example, pEXAMPLE prints the letter stored in EXAMPLE.
r Converts the letter stored in a letter variable to the corresponding number and stores this datum in the VariableWithNoName.
r2 Resets VariableWithNoName to 0.
Prints a space.
[] For example, [3++++cpar2] would print DDD.

Errors

The only error displays when VariableWithNoName is larger than 52. It is Value too big.

Examples

Hello World

[8+]cpar2[5+]cpa[7+]cpacpa+++cpa [8+]cpar2[15+]cpa+++cpar2[12+]cpar2++++cpa

Quine by error

There are an infinite number of quines in this esolang, starting with the following:

[53+]
^
Value too big.

Printing all letters

This program prints all letters available to the language in lexicographic order:

[52+cp]

Interpreters

The following code implements a simple AEWNN interpreter in Common Lisp:

(defun interpret-AEWNN (code)
  "Interprets the AEWNN program CODE and returns ``NIL''."
  (declare (type string code))
  (when (plusp (length code))
    (let ((position  0)
          (character (char code 0)))
      (declare (type fixnum position) (type (or null character) character))
      (let ((variable-with-no-name 0)
            (letter-variables      (make-hash-table :test #'eql))
            (loops                 NIL))
        (declare (type (integer 0 52) variable-with-no-name)
                 (type hash-table letter-variables) (type list loops))
        (labels ((advance ()
                  (the (or null character)
                    (if (< position (1- (length code)))
                      (setf character (char code (incf position)))
                      (setf character NIL))))
                 (read-number ()
                  (let ((start-position position)
                        (end-position   position))
                    (declare (type fixnum start-position end-position))
                    (loop while (and character (digit-char-p character)) do
                      (incf end-position)
                      (advance))
                    (the (integer 0 *)
                      (parse-integer code :start start-position :end end-position))))
                 (get-letter-for (value)
                  (declare (type (integer 1 52) value))
                  (the character
                    (schar "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" (1- value))))
                 (is-letter-variable (character)
                  (declare (type (or null character) character))
                  (the (or null character)
                    (find character "abdefghijklmnoqstuvwxyz" :test #'eql))))
          (loop do
            (case character
              ((NIL)
                (loop-finish))
              (#\Space
                (write-char character)
                (advance))
              (#\+
                (incf variable-with-no-name)
                (when (> variable-with-no-name 52)
                  (error "Value too big."))
                (advance))
              (#\c
                (advance)
                (cond
                  ((is-letter-variable character)
                    (setf (gethash character letter-variables)
                      (get-letter-for variable-with-no-name))
                    (advance))
                  (T
                    (setf (gethash #\a letter-variables)
                      (get-letter-for variable-with-no-name)))))
              (#\p
                (advance)
                (let ((variable-name #\a))
                  (declare (type character variable-name))
                  (when (is-letter-variable character)
                    (setf variable-name character)
                    (advance))
                  (let ((variable-value (gethash variable-name letter-variables)))
                    (declare (type (or null character) variable-value))
                    (when variable-value
                      (write-char variable-value)))))
              (#\r
                (advance)
                (cond
                  ((is-letter-variable character)
                    (let ((variable-name character))
                      (declare (type (or null character) variable-name))
                      (when variable-name
                        (setf variable-with-no-name
                          (gethash variable-name letter-variables 0))))
                    (advance))
                  ((char= character #\2)
                    (setf variable-with-no-name 0)
                    (advance))
                  (T
                    (setf variable-with-no-name 1))))
              (#\[
                (advance)
                (let ((repetitions (read-number)))
                  (declare (type (integer 0 *) repetitions))
                  (if (plusp repetitions)
                    (push (cons repetitions position) loops)
                    (loop with level of-type fixnum = 0 do
                      (case character
                        ((NIL)
                          (error "Unterminated opening bracket."))
                        (#\[
                          (incf level)
                          (advance))
                        (#\]
                          (advance)
                          (if (zerop level)
                            (loop-finish))
                            (decf level))
                        (otherwise
                          (advance)))))))
              (#\]
                (advance)
                (let ((current-loop (first loops)))
                  (declare (type (cons (integer 0 *) fixnum) current-loop))
                  (when (plusp (car current-loop))
                    (decf (car current-loop)))
                  (cond
                    ((plusp (car current-loop))
                      (setf position  (cdr current-loop))
                      (setf character (char code position)))
                    (T
                      (pop loops)))))
              (T
                (error "Invalid character ~s at position ~d." character position)))))))))

External resources

  • Common Lisp implementation of the AEWNN programming language.